CMakeLists.txt
author Balazs Dezso <deba@inf.elte.hu>
Sun, 14 Nov 2010 09:25:03 +0100
changeset 913 5087694945e4
parent 901 63e4468c680e
child 912 09282720100b
permissions -rw-r--r--
New implementation for Nagamochi-Ibaraki algorithm
alpar@225
     1
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
alpar@225
     2
ladanyi@678
     3
SET(PROJECT_NAME "LEMON")
ladanyi@678
     4
PROJECT(${PROJECT_NAME})
alpar@225
     5
alpar@899
     6
INCLUDE(FindPythonInterp)
alpar@899
     7
ladanyi@678
     8
IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
ladanyi@678
     9
  INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
ladanyi@678
    10
ELSEIF(DEFINED ENV{LEMON_VERSION})
ladanyi@678
    11
  SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
ladanyi@678
    12
ELSE()
ladanyi@678
    13
  EXECUTE_PROCESS(
alpar@899
    14
    COMMAND ${PYTHON_EXECUTABLE} ./scripts/chg-len.py
ladanyi@898
    15
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
ladanyi@898
    16
    OUTPUT_VARIABLE HG_REVISION_PATH
ladanyi@898
    17
    ERROR_QUIET
ladanyi@898
    18
    OUTPUT_STRIP_TRAILING_WHITESPACE
ladanyi@898
    19
  )
ladanyi@898
    20
  EXECUTE_PROCESS(
ladanyi@678
    21
    COMMAND hg id -i
ladanyi@678
    22
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
ladanyi@678
    23
    OUTPUT_VARIABLE HG_REVISION
ladanyi@678
    24
    ERROR_QUIET
ladanyi@678
    25
    OUTPUT_STRIP_TRAILING_WHITESPACE
ladanyi@678
    26
  )
ladanyi@680
    27
  IF(HG_REVISION STREQUAL "")
ladanyi@898
    28
    SET(HG_REVISION_ID "hg-tip")
ladanyi@898
    29
  ELSE()
alpar@899
    30
    IF(HG_REVISION_PATH STREQUAL "")
alpar@899
    31
      SET(HG_REVISION_ID ${HG_REVISION})
alpar@899
    32
    ELSE()
alpar@899
    33
      SET(HG_REVISION_ID ${HG_REVISION_PATH}.${HG_REVISION})
alpar@899
    34
    ENDIF()
ladanyi@680
    35
  ENDIF()
ladanyi@898
    36
  SET(LEMON_VERSION ${HG_REVISION_ID} CACHE STRING "LEMON version string.")
ladanyi@678
    37
ENDIF()
ladanyi@678
    38
ladanyi@678
    39
SET(PROJECT_VERSION ${LEMON_VERSION})
alpar@225
    40
ladanyi@549
    41
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
alpar@225
    42
ladanyi@679
    43
FIND_PACKAGE(Doxygen)
ladanyi@679
    44
FIND_PACKAGE(Ghostscript)
ladanyi@473
    45
FIND_PACKAGE(GLPK 4.33)
ladanyi@620
    46
FIND_PACKAGE(CPLEX)
ladanyi@621
    47
FIND_PACKAGE(COIN)
ladanyi@473
    48
alpar@900
    49
IF(DEFINED ENV{LEMON_CXX_WARNING})
alpar@900
    50
  SET(CXX_WARNING $ENV{LEMON_CXX_WARNING})
alpar@900
    51
ELSE()
alpar@900
    52
  IF(CMAKE_COMPILER_IS_GNUCXX)
alpar@900
    53
    SET(CXX_WARNING "-Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas")
alpar@900
    54
    SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
alpar@900
    55
    SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
alpar@900
    56
  ELSEIF(MSVC)
alpar@900
    57
    # This part is unnecessary 'casue the same is set by the lemon/core.h.
alpar@900
    58
    # Still keep it as an example.
alpar@900
    59
    SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
alpar@900
    60
    # Suppressed warnings:
alpar@900
    61
    # C4250: 'class1' : inherits 'class2::member' via dominance
alpar@900
    62
    # C4355: 'this' : used in base member initializer list
alpar@900
    63
    # C4503: 'function' : decorated name length exceeded, name was truncated
alpar@900
    64
    # C4800: 'type' : forcing value to bool 'true' or 'false'
alpar@900
    65
    #        (performance warning)
alpar@900
    66
    # C4996: 'function': was declared deprecated
alpar@900
    67
  ELSE()
alpar@900
    68
    SET(CXX_WARNING "-Wall -W")
alpar@900
    69
  ENDIF()
alpar@900
    70
ENDIF()
alpar@900
    71
SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
alpar@900
    72
alpar@900
    73
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
alpar@900
    74
alpar@901
    75
SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb" CACHE STRING
alpar@901
    76
    "Flags used by the C++ compiler during maintainer builds."
alpar@901
    77
    FORCE )
alpar@901
    78
SET( CMAKE_C_FLAGS_MAINTAINER "-Werror" CACHE STRING
alpar@901
    79
    "Flags used by the C compiler during maintainer builds."
alpar@901
    80
    FORCE )
alpar@901
    81
SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
alpar@901
    82
    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
alpar@901
    83
    "Flags used for linking binaries during maintainer builds."
alpar@901
    84
    FORCE )
alpar@901
    85
SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
alpar@901
    86
    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
alpar@901
    87
    "Flags used by the shared libraries linker during maintainer builds."
alpar@901
    88
    FORCE )
alpar@901
    89
MARK_AS_ADVANCED(
alpar@901
    90
    CMAKE_CXX_FLAGS_MAINTAINER
alpar@901
    91
    CMAKE_C_FLAGS_MAINTAINER
alpar@901
    92
    CMAKE_EXE_LINKER_FLAGS_MAINTAINER
alpar@901
    93
    CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
alpar@901
    94
alpar@901
    95
IF(CMAKE_CONFIGURATION_TYPES)
alpar@901
    96
  LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
alpar@901
    97
  LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
alpar@901
    98
  SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
alpar@901
    99
      "Add the configurations that we need"
alpar@901
   100
      FORCE)
alpar@901
   101
 endif()
alpar@901
   102
alpar@900
   103
IF(NOT CMAKE_BUILD_TYPE)
alpar@901
   104
  SET(CMAKE_BUILD_TYPE "Release")
alpar@900
   105
ENDIF()
alpar@900
   106
alpar@901
   107
SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
alpar@901
   108
    "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
alpar@901
   109
    FORCE )
alpar@901
   110
alpar@900
   111
alpar@496
   112
INCLUDE(CheckTypeSize)
ladanyi@677
   113
CHECK_TYPE_SIZE("long long" LONG_LONG)
ladanyi@677
   114
SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
alpar@496
   115
alpar@225
   116
ENABLE_TESTING()
alpar@225
   117
alpar@901
   118
IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
alpar@901
   119
  ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
alpar@901
   120
ELSE()
alpar@901
   121
  ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
alpar@901
   122
ENDIF()
ladanyi@897
   123
alpar@225
   124
ADD_SUBDIRECTORY(lemon)
ladanyi@549
   125
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
ladanyi@549
   126
  ADD_SUBDIRECTORY(demo)
ladanyi@549
   127
  ADD_SUBDIRECTORY(tools)
ladanyi@549
   128
  ADD_SUBDIRECTORY(doc)
ladanyi@549
   129
  ADD_SUBDIRECTORY(test)
ladanyi@679
   130
ENDIF()
alpar@225
   131
ladanyi@675
   132
CONFIGURE_FILE(
ladanyi@675
   133
  ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
ladanyi@675
   134
  ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
ladanyi@675
   135
  @ONLY
ladanyi@675
   136
)
ladanyi@675
   137
IF(UNIX)
ladanyi@675
   138
  INSTALL(
ladanyi@675
   139
    FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
ladanyi@675
   140
    DESTINATION share/lemon/cmake
ladanyi@675
   141
  )
ladanyi@675
   142
ELSEIF(WIN32)
ladanyi@675
   143
  INSTALL(
ladanyi@675
   144
    FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
ladanyi@675
   145
    DESTINATION cmake
ladanyi@675
   146
  )
ladanyi@679
   147
ENDIF()
ladanyi@675
   148
alpar@902
   149
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
ladanyi@679
   150
  SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
ladanyi@679
   151
  SET(CPACK_PACKAGE_VENDOR "EGRES")
ladanyi@679
   152
  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
ladanyi@679
   153
    "LEMON - Library for Efficient Modeling and Optimization in Networks")
ladanyi@679
   154
  SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
alpar@225
   155
ladanyi@679
   156
  SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
alpar@225
   157
ladanyi@679
   158
  SET(CPACK_PACKAGE_INSTALL_DIRECTORY
ladanyi@679
   159
    "${PROJECT_NAME} ${PROJECT_VERSION}")
ladanyi@679
   160
  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
ladanyi@679
   161
    "${PROJECT_NAME} ${PROJECT_VERSION}")
alpar@225
   162
ladanyi@679
   163
  SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
alpar@225
   164
ladanyi@679
   165
  SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
ladanyi@679
   166
  SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
ladanyi@679
   167
  SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
ladanyi@679
   168
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
alpar@225
   169
ladanyi@679
   170
  SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
ladanyi@679
   171
    "C++ header files")
ladanyi@679
   172
  SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
ladanyi@679
   173
    "DLL and import library")
ladanyi@679
   174
  SET(CPACK_COMPONENT_BIN_DESCRIPTION
ladanyi@679
   175
    "Command line utilities")
ladanyi@679
   176
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
ladanyi@679
   177
    "Doxygen generated documentation")
alpar@225
   178
ladanyi@679
   179
  SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
alpar@225
   180
ladanyi@679
   181
  SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
ladanyi@679
   182
  SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
ladanyi@679
   183
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
alpar@225
   184
ladanyi@679
   185
  SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
ladanyi@679
   186
    "Components needed to develop software using LEMON")
ladanyi@679
   187
  SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
ladanyi@679
   188
    "Documentation of LEMON")
alpar@225
   189
ladanyi@679
   190
  SET(CPACK_ALL_INSTALL_TYPES Full Developer)
alpar@225
   191
ladanyi@679
   192
  SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
ladanyi@679
   193
  SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
ladanyi@679
   194
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
alpar@225
   195
ladanyi@679
   196
  SET(CPACK_GENERATOR "NSIS")
ladanyi@679
   197
  SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
ladanyi@679
   198
  SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
ladanyi@679
   199
  #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
ladanyi@679
   200
  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
ladanyi@679
   201
  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
ladanyi@679
   202
  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
ladanyi@679
   203
  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
ladanyi@679
   204
  SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
ladanyi@679
   205
  SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
ladanyi@679
   206
    CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
ladanyi@679
   207
    ")
ladanyi@679
   208
  SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
ladanyi@679
   209
    !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
ladanyi@679
   210
    Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
ladanyi@679
   211
    ")
alpar@225
   212
ladanyi@679
   213
  INCLUDE(CPack)
ladanyi@679
   214
ENDIF()