1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
3 CMAKE_POLICY(SET CMP0048 OLD)
5 SET(PROJECT_NAME "LEMON")
6 PROJECT(${PROJECT_NAME})
8 INCLUDE(FindPythonInterp)
11 IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
12 INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
13 ELSEIF(DEFINED ENV{LEMON_VERSION})
14 SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
18 hg log -r. --template "{latesttag}"
19 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
20 OUTPUT_VARIABLE HG_REVISION_TAG
22 OUTPUT_STRIP_TRAILING_WHITESPACE
26 hg log -r. --template "{latesttagdistance}"
27 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
28 OUTPUT_VARIABLE HG_REVISION_DIST
30 OUTPUT_STRIP_TRAILING_WHITESPACE
34 hg log -r. --template "{node|short}"
35 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
36 OUTPUT_VARIABLE HG_REVISION_ID
38 OUTPUT_STRIP_TRAILING_WHITESPACE
41 IF(HG_REVISION_TAG STREQUAL "")
42 SET(HG_REVISION_ID "hg-tip")
44 IF(HG_REVISION_TAG STREQUAL "null")
45 SET(HG_REVISION_TAG "trunk")
46 ELSEIF(HG_REVISION_TAG MATCHES "^r")
47 STRING(SUBSTRING ${HG_REVISION_TAG} 1 -1 HG_REVISION_TAG)
49 IF(HG_REVISION_DIST STREQUAL "0")
50 SET(HG_REVISION ${HG_REVISION_TAG})
53 "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}")
57 SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.")
60 SET(PROJECT_VERSION ${LEMON_VERSION})
62 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
65 FIND_PACKAGE(Ghostscript)
67 SET(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.")
68 SET(LEMON_ENABLE_ILOG YES CACHE STRING "Enable ILOG (CPLEX) solver backend.")
69 SET(LEMON_ENABLE_COIN YES CACHE STRING "Enable COIN solver backend.")
70 SET(LEMON_ENABLE_SOPLEX YES CACHE STRING "Enable SoPlex solver backend.")
73 FIND_PACKAGE(GLPK 4.33)
74 ENDIF(LEMON_ENABLE_GLPK)
77 ENDIF(LEMON_ENABLE_ILOG)
80 ENDIF(LEMON_ENABLE_COIN)
81 IF(LEMON_ENABLE_SOPLEX)
83 ENDIF(LEMON_ENABLE_SOPLEX)
86 SET(LEMON_HAVE_LP TRUE)
87 SET(LEMON_HAVE_MIP TRUE)
88 SET(LEMON_HAVE_GLPK TRUE)
91 SET(LEMON_HAVE_LP TRUE)
92 SET(LEMON_HAVE_MIP TRUE)
93 SET(LEMON_HAVE_CPLEX TRUE)
96 SET(LEMON_HAVE_LP TRUE)
97 SET(LEMON_HAVE_MIP TRUE)
98 SET(LEMON_HAVE_CLP TRUE)
99 SET(LEMON_HAVE_CBC TRUE)
102 SET(LEMON_HAVE_LP TRUE)
103 SET(LEMON_HAVE_SOPLEX TRUE)
107 SET(DEFAULT_LP "CPLEX")
108 SET(DEFAULT_MIP "CPLEX")
110 SET(DEFAULT_LP "CLP")
111 SET(DEFAULT_MIP "CBC")
113 SET(DEFAULT_LP "GLPK")
114 SET(DEFAULT_MIP "GLPK")
116 SET(DEFAULT_LP "SOPLEX")
119 IF(NOT LEMON_DEFAULT_LP OR
120 (NOT ILOG_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CPLEX")) OR
121 (NOT COIN_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CLP")) OR
122 (NOT GLPK_FOUND AND (LEMON_DEFAULT_LP STREQUAL "GLPK")) OR
123 (NOT SOPLEX_FOUND AND (LEMON_DEFAULT_LP STREQUAL "SOPLEX")))
124 SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
125 "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)" FORCE)
127 SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
128 "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)")
130 IF(NOT LEMON_DEFAULT_MIP OR
131 (NOT ILOG_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CPLEX")) OR
132 (NOT COIN_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CBC")) OR
133 (NOT GLPK_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "GLPK")))
134 SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
135 "Default MIP solver backend (GLPK, CPLEX or CBC)" FORCE)
137 SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
138 "Default MIP solver backend (GLPK, CPLEX or CBC)")
142 IF(DEFINED ENV{LEMON_CXX_WARNING})
143 SET(CXX_WARNING $ENV{LEMON_CXX_WARNING})
145 IF(CMAKE_COMPILER_IS_GNUCXX)
146 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")
147 SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
148 SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
150 # This part is unnecessary 'casue the same is set by the lemon/core.h.
151 # Still keep it as an example.
152 SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
153 # Suppressed warnings:
154 # C4250: 'class1' : inherits 'class2::member' via dominance
155 # C4355: 'this' : used in base member initializer list
156 # C4503: 'function' : decorated name length exceeded, name was truncated
157 # C4800: 'type' : forcing value to bool 'true' or 'false'
158 # (performance warning)
159 # C4996: 'function': was declared deprecated
161 SET(CXX_WARNING "-Wall")
164 SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
166 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
169 SET( CMAKE_CXX_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
170 "Flags used by the C++ compiler during maintainer builds."
172 SET( CMAKE_C_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
173 "Flags used by the C compiler during maintainer builds."
175 SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
176 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
177 "Flags used for linking binaries during maintainer builds."
179 SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
180 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
181 "Flags used by the shared libraries linker during maintainer builds."
184 SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb -O0" CACHE STRING
185 "Flags used by the C++ compiler during maintainer builds."
187 SET( CMAKE_C_FLAGS_MAINTAINER "-Werror -O0" CACHE STRING
188 "Flags used by the C compiler during maintainer builds."
190 SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
191 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
192 "Flags used for linking binaries during maintainer builds."
194 SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
195 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
196 "Flags used by the shared libraries linker during maintainer builds."
201 CMAKE_CXX_FLAGS_MAINTAINER
202 CMAKE_C_FLAGS_MAINTAINER
203 CMAKE_EXE_LINKER_FLAGS_MAINTAINER
204 CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
206 IF(CMAKE_CONFIGURATION_TYPES)
207 LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
208 LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
209 SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
210 "Add the configurations that we need"
214 IF(NOT CMAKE_BUILD_TYPE)
215 SET(CMAKE_BUILD_TYPE "Release")
218 SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
219 "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
223 INCLUDE(CheckTypeSize)
224 CHECK_TYPE_SIZE("long long" LONG_LONG)
225 SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
229 IF(NOT LEMON_THREADING)
230 IF(CMAKE_USE_PTHREADS_INIT)
231 SET(LEMON_THREADING "Pthread")
232 ELSEIF(CMAKE_USE_WIN32_THREADS_INIT)
233 SET(LEMON_THREADING "Win32")
235 SET(LEMON_THREADING "None")
239 SET( LEMON_THREADING "${LEMON_THREADING}" CACHE STRING
240 "Choose the threading library, options are: Pthread Win32 None."
243 IF(LEMON_THREADING STREQUAL "Pthread")
244 SET(LEMON_USE_PTHREAD TRUE)
245 ELSEIF(LEMON_THREADING STREQUAL "Win32")
246 SET(LEMON_USE_WIN32_THREADS TRUE)
251 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
252 ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
254 ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
257 ADD_SUBDIRECTORY(lemon)
258 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
259 ADD_SUBDIRECTORY(contrib)
260 ADD_SUBDIRECTORY(demo)
261 ADD_SUBDIRECTORY(tools)
262 ADD_SUBDIRECTORY(doc)
263 ADD_SUBDIRECTORY(test)
267 ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
268 ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
273 FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
274 DESTINATION share/lemon/cmake
278 FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
284 ${PROJECT_SOURCE_DIR}/cmake/version.cmake.in
285 ${PROJECT_BINARY_DIR}/cmake/version.cmake
289 SET(ARCHIVE_BASE_NAME ${CMAKE_PROJECT_NAME})
290 STRING(TOLOWER ${ARCHIVE_BASE_NAME} ARCHIVE_BASE_NAME)
291 SET(ARCHIVE_NAME ${ARCHIVE_BASE_NAME}-${PROJECT_VERSION})
292 ADD_CUSTOM_TARGET(dist
293 COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
294 COMMAND hg archive ${ARCHIVE_NAME}
295 COMMAND cmake -E copy cmake/version.cmake ${ARCHIVE_NAME}/cmake/version.cmake
296 COMMAND tar -czf ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_NAME}
297 COMMAND zip -r ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.zip ${ARCHIVE_NAME}
298 COMMAND cmake -E copy_directory doc/html ${ARCHIVE_NAME}/doc/html
299 COMMAND tar -czf ${ARCHIVE_NAME}.tar.gz ${ARCHIVE_NAME}
300 COMMAND zip -r ${ARCHIVE_NAME}.zip ${ARCHIVE_NAME}
301 COMMAND cmake -E copy_directory doc/html ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
302 COMMAND tar -czf ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
303 COMMAND zip -r ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.zip ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
304 COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
305 COMMAND cmake -E remove_directory ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
307 WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
309 # CPACK config (Basically for NSIS)
310 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
311 SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
312 SET(CPACK_PACKAGE_VENDOR "EGRES")
313 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
314 "LEMON - Library for Efficient Modeling and Optimization in Networks")
315 SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
317 SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
319 SET(CPACK_PACKAGE_INSTALL_DIRECTORY
320 "${PROJECT_NAME} ${PROJECT_VERSION}")
321 SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
322 "${PROJECT_NAME} ${PROJECT_VERSION}")
324 SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
326 SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
327 SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
328 SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
329 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
331 SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
333 SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
334 "DLL and import library")
335 SET(CPACK_COMPONENT_BIN_DESCRIPTION
336 "Command line utilities")
337 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
338 "Doxygen generated documentation")
340 SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
342 SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
343 SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
344 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
346 SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
347 "Components needed to develop software using LEMON")
348 SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
349 "Documentation of LEMON")
351 SET(CPACK_ALL_INSTALL_TYPES Full Developer)
353 SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
354 SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
355 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
357 SET(CPACK_GENERATOR "NSIS")
358 SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
359 SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
360 #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
361 SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
362 SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
363 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
364 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
365 SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
366 SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
367 CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
369 SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
370 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
371 Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"