CMakeLists.txt
author Balazs Dezso <deba@google.com>
Tue, 12 Feb 2013 07:15:52 +0100
changeset 1030 4936be66d2f5
parent 1000 404b98971e1f
child 1062 caf16813b1e8
permissions -rw-r--r--
Changes in BpGraph lgf reader and writer (#69)
- Add typesade RedNode and BlueNode reading and writing
- RedNodes and BlueNodes don't need to have distinct label set
- Add tests
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@927
     6
INCLUDE(FindPythonInterp)
alpar@927
     7
INCLUDE(FindWget)
alpar@927
     8
ladanyi@678
     9
IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
ladanyi@678
    10
  INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
ladanyi@678
    11
ELSEIF(DEFINED ENV{LEMON_VERSION})
ladanyi@678
    12
  SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
ladanyi@678
    13
ELSE()
ladanyi@678
    14
  EXECUTE_PROCESS(
alpar@982
    15
    COMMAND
alpar@982
    16
    hg log -r. --template "{latesttag}"
alpar@927
    17
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
alpar@982
    18
    OUTPUT_VARIABLE HG_REVISION_TAG
alpar@927
    19
    ERROR_QUIET
alpar@927
    20
    OUTPUT_STRIP_TRAILING_WHITESPACE
alpar@927
    21
  )
alpar@927
    22
  EXECUTE_PROCESS(
alpar@982
    23
    COMMAND
alpar@982
    24
    hg log -r. --template "{latesttagdistance}"
ladanyi@678
    25
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
alpar@982
    26
    OUTPUT_VARIABLE HG_REVISION_DIST
ladanyi@678
    27
    ERROR_QUIET
ladanyi@678
    28
    OUTPUT_STRIP_TRAILING_WHITESPACE
ladanyi@678
    29
  )
alpar@982
    30
  EXECUTE_PROCESS(
alpar@982
    31
    COMMAND
alpar@982
    32
    hg log -r. --template "{node|short}"
alpar@982
    33
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
alpar@982
    34
    OUTPUT_VARIABLE HG_REVISION_ID
alpar@982
    35
    ERROR_QUIET
alpar@982
    36
    OUTPUT_STRIP_TRAILING_WHITESPACE
alpar@982
    37
  )
alpar@982
    38
alpar@982
    39
  IF(HG_REVISION_TAG STREQUAL "")
alpar@927
    40
    SET(HG_REVISION_ID "hg-tip")
alpar@927
    41
  ELSE()
alpar@982
    42
    IF(HG_REVISION_TAG STREQUAL "null")
alpar@982
    43
      SET(HG_REVISION_TAG "trunk")
alpar@982
    44
    ELSEIF(HG_REVISION_TAG MATCHES "^r")
alpar@982
    45
      STRING(SUBSTRING ${HG_REVISION_TAG} 1 -1 HG_REVISION_TAG)
alpar@982
    46
    ENDIF()
alpar@982
    47
    IF(HG_REVISION_DIST STREQUAL "0")
alpar@982
    48
      SET(HG_REVISION ${HG_REVISION_TAG})
alpar@927
    49
    ELSE()
alpar@982
    50
      SET(HG_REVISION
alpar@982
    51
	"${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}")
alpar@927
    52
    ENDIF()
ladanyi@680
    53
  ENDIF()
alpar@982
    54
alpar@982
    55
  SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.")
ladanyi@678
    56
ENDIF()
ladanyi@678
    57
ladanyi@678
    58
SET(PROJECT_VERSION ${LEMON_VERSION})
alpar@225
    59
ladanyi@549
    60
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
alpar@225
    61
ladanyi@679
    62
FIND_PACKAGE(Doxygen)
ladanyi@679
    63
FIND_PACKAGE(Ghostscript)
ladanyi@473
    64
FIND_PACKAGE(GLPK 4.33)
ladanyi@620
    65
FIND_PACKAGE(CPLEX)
ladanyi@621
    66
FIND_PACKAGE(COIN)
ladanyi@473
    67
alpar@927
    68
IF(DEFINED ENV{LEMON_CXX_WARNING})
alpar@927
    69
  SET(CXX_WARNING $ENV{LEMON_CXX_WARNING})
alpar@927
    70
ELSE()
alpar@927
    71
  IF(CMAKE_COMPILER_IS_GNUCXX)
alpar@940
    72
    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 -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas")
alpar@927
    73
    SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
alpar@927
    74
    SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
alpar@927
    75
  ELSEIF(MSVC)
alpar@927
    76
    # This part is unnecessary 'casue the same is set by the lemon/core.h.
alpar@927
    77
    # Still keep it as an example.
alpar@927
    78
    SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
alpar@927
    79
    # Suppressed warnings:
alpar@927
    80
    # C4250: 'class1' : inherits 'class2::member' via dominance
alpar@927
    81
    # C4355: 'this' : used in base member initializer list
alpar@927
    82
    # C4503: 'function' : decorated name length exceeded, name was truncated
alpar@927
    83
    # C4800: 'type' : forcing value to bool 'true' or 'false'
alpar@927
    84
    #        (performance warning)
alpar@927
    85
    # C4996: 'function': was declared deprecated
alpar@927
    86
  ELSE()
alpar@975
    87
    SET(CXX_WARNING "-Wall")
alpar@927
    88
  ENDIF()
alpar@927
    89
ENDIF()
alpar@927
    90
SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
alpar@927
    91
alpar@927
    92
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
alpar@927
    93
alpar@1017
    94
IF(MSVC)
alpar@1017
    95
  SET( CMAKE_CXX_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
alpar@927
    96
    "Flags used by the C++ compiler during maintainer builds."
alpar@1017
    97
    )
alpar@1017
    98
  SET( CMAKE_C_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
alpar@927
    99
    "Flags used by the C compiler during maintainer builds."
alpar@1017
   100
    )
alpar@1017
   101
  SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
alpar@1017
   102
    "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
alpar@1017
   103
    "Flags used for linking binaries during maintainer builds."
alpar@1017
   104
    )
alpar@1017
   105
  SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
alpar@1017
   106
    "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
alpar@1017
   107
    "Flags used by the shared libraries linker during maintainer builds."
alpar@1017
   108
    )
alpar@1017
   109
ELSE()
alpar@1017
   110
  SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb -O0" CACHE STRING
alpar@1017
   111
    "Flags used by the C++ compiler during maintainer builds."
alpar@1017
   112
    )
alpar@1017
   113
  SET( CMAKE_C_FLAGS_MAINTAINER "-Werror -O0" CACHE STRING
alpar@1017
   114
    "Flags used by the C compiler during maintainer builds."
alpar@1017
   115
    )
alpar@1017
   116
  SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
alpar@927
   117
    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
alpar@927
   118
    "Flags used for linking binaries during maintainer builds."
alpar@1017
   119
    )
alpar@1017
   120
  SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
alpar@927
   121
    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
alpar@927
   122
    "Flags used by the shared libraries linker during maintainer builds."
alpar@1017
   123
    )
alpar@1017
   124
ENDIF()
alpar@1017
   125
alpar@927
   126
MARK_AS_ADVANCED(
alpar@927
   127
    CMAKE_CXX_FLAGS_MAINTAINER
alpar@927
   128
    CMAKE_C_FLAGS_MAINTAINER
alpar@927
   129
    CMAKE_EXE_LINKER_FLAGS_MAINTAINER
alpar@927
   130
    CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
alpar@927
   131
alpar@927
   132
IF(CMAKE_CONFIGURATION_TYPES)
alpar@927
   133
  LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
alpar@927
   134
  LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
alpar@927
   135
  SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
alpar@927
   136
      "Add the configurations that we need"
alpar@927
   137
      FORCE)
alpar@927
   138
 endif()
alpar@927
   139
alpar@927
   140
IF(NOT CMAKE_BUILD_TYPE)
alpar@927
   141
  SET(CMAKE_BUILD_TYPE "Release")
alpar@927
   142
ENDIF()
alpar@927
   143
alpar@927
   144
SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
alpar@927
   145
    "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
alpar@927
   146
    FORCE )
alpar@927
   147
alpar@927
   148
alpar@496
   149
INCLUDE(CheckTypeSize)
ladanyi@677
   150
CHECK_TYPE_SIZE("long long" LONG_LONG)
ladanyi@677
   151
SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
alpar@496
   152
deba@979
   153
INCLUDE(FindThreads)
alpar@980
   154
alpar@980
   155
IF(NOT LEMON_THREADING)
alpar@980
   156
  IF(CMAKE_USE_PTHREADS_INIT)
alpar@980
   157
    SET(LEMON_THREADING "Pthread")
alpar@980
   158
  ELSEIF(CMAKE_USE_WIN32_THREADS_INIT)
alpar@980
   159
    SET(LEMON_THREADING "Win32")
alpar@980
   160
  ELSE()
alpar@980
   161
    SET(LEMON_THREADING "None")
alpar@980
   162
  ENDIF()
alpar@980
   163
ENDIF()
alpar@980
   164
alpar@980
   165
SET( LEMON_THREADING "${LEMON_THREADING}" CACHE STRING
alpar@980
   166
  "Choose the threading library, options are: Pthread Win32 None."
alpar@980
   167
  FORCE )
alpar@980
   168
alpar@980
   169
IF(LEMON_THREADING STREQUAL "Pthread")
alpar@980
   170
  SET(LEMON_USE_PTHREAD TRUE)
alpar@980
   171
ELSEIF(LEMON_THREADING STREQUAL "Win32")
alpar@980
   172
  SET(LEMON_USE_WIN32_THREADS TRUE)
alpar@980
   173
ENDIF()
alpar@744
   174
alpar@225
   175
ENABLE_TESTING()
alpar@225
   176
alpar@927
   177
IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
alpar@927
   178
  ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
alpar@927
   179
ELSE()
alpar@927
   180
  ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
alpar@927
   181
ENDIF()
alpar@927
   182
alpar@225
   183
ADD_SUBDIRECTORY(lemon)
ladanyi@549
   184
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
alpar@925
   185
  ADD_SUBDIRECTORY(contrib)
ladanyi@549
   186
  ADD_SUBDIRECTORY(demo)
ladanyi@549
   187
  ADD_SUBDIRECTORY(tools)
ladanyi@549
   188
  ADD_SUBDIRECTORY(doc)
ladanyi@549
   189
  ADD_SUBDIRECTORY(test)
ladanyi@679
   190
ENDIF()
alpar@225
   191
ladanyi@675
   192
CONFIGURE_FILE(
ladanyi@675
   193
  ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
ladanyi@675
   194
  ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
ladanyi@675
   195
  @ONLY
ladanyi@675
   196
)
ladanyi@675
   197
IF(UNIX)
ladanyi@675
   198
  INSTALL(
ladanyi@675
   199
    FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
ladanyi@675
   200
    DESTINATION share/lemon/cmake
ladanyi@675
   201
  )
ladanyi@675
   202
ELSEIF(WIN32)
ladanyi@675
   203
  INSTALL(
ladanyi@675
   204
    FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
ladanyi@675
   205
    DESTINATION cmake
ladanyi@675
   206
  )
ladanyi@679
   207
ENDIF()
ladanyi@675
   208
alpar@983
   209
CONFIGURE_FILE(
alpar@983
   210
  ${PROJECT_SOURCE_DIR}/cmake/version.cmake.in
alpar@983
   211
  ${PROJECT_BINARY_DIR}/cmake/version.cmake
alpar@983
   212
  @ONLY
alpar@983
   213
)
alpar@983
   214
alpar@983
   215
SET(ARCHIVE_BASE_NAME ${CMAKE_PROJECT_NAME})
alpar@983
   216
STRING(TOLOWER ${ARCHIVE_BASE_NAME} ARCHIVE_BASE_NAME)
alpar@983
   217
SET(ARCHIVE_NAME ${ARCHIVE_BASE_NAME}-${PROJECT_VERSION})
alpar@983
   218
ADD_CUSTOM_TARGET(dist
alpar@983
   219
  COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
alpar@983
   220
  COMMAND hg archive ${ARCHIVE_NAME}
alpar@983
   221
  COMMAND cmake -E copy cmake/version.cmake ${ARCHIVE_NAME}/cmake/version.cmake
alpar@983
   222
  COMMAND tar -czf ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_NAME}
alpar@983
   223
  COMMAND zip -r ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.zip ${ARCHIVE_NAME}
alpar@983
   224
  COMMAND cmake -E copy_directory doc/html ${ARCHIVE_NAME}/doc/html
alpar@983
   225
  COMMAND tar -czf ${ARCHIVE_NAME}.tar.gz ${ARCHIVE_NAME}
alpar@983
   226
  COMMAND zip -r ${ARCHIVE_NAME}.zip ${ARCHIVE_NAME}
alpar@983
   227
  COMMAND cmake -E copy_directory doc/html ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
alpar@983
   228
  COMMAND tar -czf ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
alpar@983
   229
  COMMAND zip -r ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.zip ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
alpar@983
   230
  COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
alpar@983
   231
  COMMAND cmake -E remove_directory ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
alpar@983
   232
  DEPENDS html
alpar@983
   233
  WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
alpar@983
   234
alpar@983
   235
# CPACK config (Basically for NSIS)
alpar@927
   236
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
ladanyi@679
   237
  SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
ladanyi@679
   238
  SET(CPACK_PACKAGE_VENDOR "EGRES")
ladanyi@679
   239
  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
ladanyi@679
   240
    "LEMON - Library for Efficient Modeling and Optimization in Networks")
ladanyi@679
   241
  SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
alpar@225
   242
ladanyi@679
   243
  SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
alpar@225
   244
ladanyi@679
   245
  SET(CPACK_PACKAGE_INSTALL_DIRECTORY
ladanyi@679
   246
    "${PROJECT_NAME} ${PROJECT_VERSION}")
ladanyi@679
   247
  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
ladanyi@679
   248
    "${PROJECT_NAME} ${PROJECT_VERSION}")
alpar@225
   249
ladanyi@679
   250
  SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
alpar@225
   251
ladanyi@679
   252
  SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
ladanyi@679
   253
  SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
ladanyi@679
   254
  SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
ladanyi@679
   255
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
alpar@225
   256
ladanyi@679
   257
  SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
ladanyi@679
   258
    "C++ header files")
ladanyi@679
   259
  SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
ladanyi@679
   260
    "DLL and import library")
ladanyi@679
   261
  SET(CPACK_COMPONENT_BIN_DESCRIPTION
ladanyi@679
   262
    "Command line utilities")
ladanyi@679
   263
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
ladanyi@679
   264
    "Doxygen generated documentation")
alpar@225
   265
ladanyi@679
   266
  SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
alpar@225
   267
ladanyi@679
   268
  SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
ladanyi@679
   269
  SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
ladanyi@679
   270
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
alpar@225
   271
ladanyi@679
   272
  SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
ladanyi@679
   273
    "Components needed to develop software using LEMON")
ladanyi@679
   274
  SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
ladanyi@679
   275
    "Documentation of LEMON")
alpar@225
   276
ladanyi@679
   277
  SET(CPACK_ALL_INSTALL_TYPES Full Developer)
alpar@225
   278
ladanyi@679
   279
  SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
ladanyi@679
   280
  SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
ladanyi@679
   281
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
alpar@225
   282
ladanyi@679
   283
  SET(CPACK_GENERATOR "NSIS")
ladanyi@679
   284
  SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
ladanyi@679
   285
  SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
ladanyi@679
   286
  #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
ladanyi@679
   287
  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
ladanyi@679
   288
  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
ladanyi@679
   289
  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
ladanyi@679
   290
  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
ladanyi@679
   291
  SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
ladanyi@679
   292
  SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
ladanyi@679
   293
    CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
ladanyi@679
   294
    ")
ladanyi@679
   295
  SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
ladanyi@679
   296
    !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
ladanyi@679
   297
    Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
ladanyi@679
   298
    ")
alpar@225
   299
ladanyi@679
   300
  INCLUDE(CPack)
ladanyi@679
   301
ENDIF()