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