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