1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
4 CMAKE_POLICY(SET CMP0048 OLD)
7 SET(PROJECT_NAME "LEMON")
8 PROJECT(${PROJECT_NAME})
10 INCLUDE(FindPythonInterp)
13 IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
14 INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
15 ELSEIF(DEFINED ENV{LEMON_VERSION})
16 SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
20 hg log -r. --template "{latesttag}"
21 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
22 OUTPUT_VARIABLE HG_REVISION_TAG
24 OUTPUT_STRIP_TRAILING_WHITESPACE
28 hg log -r. --template "{latesttagdistance}"
29 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
30 OUTPUT_VARIABLE HG_REVISION_DIST
32 OUTPUT_STRIP_TRAILING_WHITESPACE
36 hg log -r. --template "{node|short}"
37 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
38 OUTPUT_VARIABLE HG_REVISION_ID
40 OUTPUT_STRIP_TRAILING_WHITESPACE
43 IF(HG_REVISION_TAG STREQUAL "")
44 SET(HG_REVISION_ID "hg-tip")
46 IF(HG_REVISION_TAG STREQUAL "null")
47 SET(HG_REVISION_TAG "trunk")
48 ELSEIF(HG_REVISION_TAG MATCHES "^r")
49 STRING(SUBSTRING ${HG_REVISION_TAG} 1 -1 HG_REVISION_TAG)
51 IF(HG_REVISION_DIST STREQUAL "0")
52 SET(HG_REVISION ${HG_REVISION_TAG})
55 "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}")
59 SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.")
62 SET(PROJECT_VERSION ${LEMON_VERSION})
64 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
67 FIND_PACKAGE(Ghostscript)
69 SET(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.")
70 SET(LEMON_ENABLE_ILOG YES CACHE STRING "Enable ILOG (CPLEX) solver backend.")
71 SET(LEMON_ENABLE_COIN YES CACHE STRING "Enable COIN solver backend.")
72 SET(LEMON_ENABLE_SOPLEX YES CACHE STRING "Enable SoPlex solver backend.")
75 FIND_PACKAGE(GLPK 4.33)
76 ENDIF(LEMON_ENABLE_GLPK)
79 ENDIF(LEMON_ENABLE_ILOG)
82 ENDIF(LEMON_ENABLE_COIN)
83 IF(LEMON_ENABLE_SOPLEX)
85 ENDIF(LEMON_ENABLE_SOPLEX)
88 SET(LEMON_HAVE_LP TRUE)
89 SET(LEMON_HAVE_MIP TRUE)
90 SET(LEMON_HAVE_GLPK TRUE)
93 SET(LEMON_HAVE_LP TRUE)
94 SET(LEMON_HAVE_MIP TRUE)
95 SET(LEMON_HAVE_CPLEX TRUE)
98 SET(LEMON_HAVE_LP TRUE)
99 SET(LEMON_HAVE_MIP TRUE)
100 SET(LEMON_HAVE_CLP TRUE)
101 SET(LEMON_HAVE_CBC TRUE)
104 SET(LEMON_HAVE_LP TRUE)
105 SET(LEMON_HAVE_SOPLEX TRUE)
109 SET(DEFAULT_LP "CPLEX")
110 SET(DEFAULT_MIP "CPLEX")
112 SET(DEFAULT_LP "CLP")
113 SET(DEFAULT_MIP "CBC")
115 SET(DEFAULT_LP "GLPK")
116 SET(DEFAULT_MIP "GLPK")
118 SET(DEFAULT_LP "SOPLEX")
121 IF(NOT LEMON_DEFAULT_LP OR
122 (NOT ILOG_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CPLEX")) OR
123 (NOT COIN_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CLP")) OR
124 (NOT GLPK_FOUND AND (LEMON_DEFAULT_LP STREQUAL "GLPK")) OR
125 (NOT SOPLEX_FOUND AND (LEMON_DEFAULT_LP STREQUAL "SOPLEX")))
126 SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
127 "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)" FORCE)
129 SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
130 "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)")
132 IF(NOT LEMON_DEFAULT_MIP OR
133 (NOT ILOG_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CPLEX")) OR
134 (NOT COIN_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CBC")) OR
135 (NOT GLPK_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "GLPK")))
136 SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
137 "Default MIP solver backend (GLPK, CPLEX or CBC)" FORCE)
139 SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
140 "Default MIP solver backend (GLPK, CPLEX or CBC)")
144 IF(DEFINED ENV{LEMON_CXX_WARNING})
145 SET(CXX_WARNING $ENV{LEMON_CXX_WARNING})
147 IF(CMAKE_COMPILER_IS_GNUCXX)
148 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")
149 SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
150 SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
152 # This part is unnecessary 'casue the same is set by the lemon/core.h.
153 # Still keep it as an example.
154 SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
155 # Suppressed warnings:
156 # C4250: 'class1' : inherits 'class2::member' via dominance
157 # C4355: 'this' : used in base member initializer list
158 # C4503: 'function' : decorated name length exceeded, name was truncated
159 # C4800: 'type' : forcing value to bool 'true' or 'false'
160 # (performance warning)
161 # C4996: 'function': was declared deprecated
163 SET(CXX_WARNING "-Wall")
166 SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
168 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
171 SET( CMAKE_CXX_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
172 "Flags used by the C++ compiler during maintainer builds."
174 SET( CMAKE_C_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
175 "Flags used by the C compiler during maintainer builds."
177 SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
178 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
179 "Flags used for linking binaries during maintainer builds."
181 SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
182 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
183 "Flags used by the shared libraries linker during maintainer builds."
186 SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb -O0" CACHE STRING
187 "Flags used by the C++ compiler during maintainer builds."
189 SET( CMAKE_C_FLAGS_MAINTAINER "-Werror -O0" CACHE STRING
190 "Flags used by the C compiler during maintainer builds."
192 SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
193 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
194 "Flags used for linking binaries during maintainer builds."
196 SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
197 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
198 "Flags used by the shared libraries linker during maintainer builds."
203 CMAKE_CXX_FLAGS_MAINTAINER
204 CMAKE_C_FLAGS_MAINTAINER
205 CMAKE_EXE_LINKER_FLAGS_MAINTAINER
206 CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
208 IF(CMAKE_CONFIGURATION_TYPES)
209 LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
210 LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
211 SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
212 "Add the configurations that we need"
216 IF(NOT CMAKE_BUILD_TYPE)
217 SET(CMAKE_BUILD_TYPE "Release")
220 SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
221 "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
225 INCLUDE(CheckTypeSize)
226 CHECK_TYPE_SIZE("long long" LONG_LONG)
227 SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
231 IF(NOT LEMON_THREADING)
232 IF(CMAKE_USE_PTHREADS_INIT)
233 SET(LEMON_THREADING "Pthread")
234 ELSEIF(CMAKE_USE_WIN32_THREADS_INIT)
235 SET(LEMON_THREADING "Win32")
237 SET(LEMON_THREADING "None")
241 SET( LEMON_THREADING "${LEMON_THREADING}" CACHE STRING
242 "Choose the threading library, options are: Pthread Win32 None."
245 IF(LEMON_THREADING STREQUAL "Pthread")
246 SET(LEMON_USE_PTHREAD TRUE)
247 ELSEIF(LEMON_THREADING STREQUAL "Win32")
248 SET(LEMON_USE_WIN32_THREADS TRUE)
253 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
254 ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
256 ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
259 ADD_SUBDIRECTORY(lemon)
260 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
261 ADD_SUBDIRECTORY(contrib)
262 ADD_SUBDIRECTORY(demo)
263 ADD_SUBDIRECTORY(tools)
264 ADD_SUBDIRECTORY(doc)
265 ADD_SUBDIRECTORY(test)
269 ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
270 ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
275 FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
276 DESTINATION share/lemon/cmake
280 FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
286 ${PROJECT_SOURCE_DIR}/cmake/version.cmake.in
287 ${PROJECT_BINARY_DIR}/cmake/version.cmake
291 SET(ARCHIVE_BASE_NAME ${CMAKE_PROJECT_NAME})
292 STRING(TOLOWER ${ARCHIVE_BASE_NAME} ARCHIVE_BASE_NAME)
293 SET(ARCHIVE_NAME ${ARCHIVE_BASE_NAME}-${PROJECT_VERSION})
294 ADD_CUSTOM_TARGET(dist
295 COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
296 COMMAND hg archive ${ARCHIVE_NAME}
297 COMMAND cmake -E copy cmake/version.cmake ${ARCHIVE_NAME}/cmake/version.cmake
298 COMMAND tar -czf ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_NAME}
299 COMMAND zip -r ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.zip ${ARCHIVE_NAME}
300 COMMAND cmake -E copy_directory doc/html ${ARCHIVE_NAME}/doc/html
301 COMMAND tar -czf ${ARCHIVE_NAME}.tar.gz ${ARCHIVE_NAME}
302 COMMAND zip -r ${ARCHIVE_NAME}.zip ${ARCHIVE_NAME}
303 COMMAND cmake -E copy_directory doc/html ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
304 COMMAND tar -czf ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
305 COMMAND zip -r ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.zip ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
306 COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
307 COMMAND cmake -E remove_directory ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
309 WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
311 # CPACK config (Basically for NSIS)
312 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
313 SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
314 SET(CPACK_PACKAGE_VENDOR "EGRES")
315 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
316 "LEMON - Library for Efficient Modeling and Optimization in Networks")
317 SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
319 SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
321 SET(CPACK_PACKAGE_INSTALL_DIRECTORY
322 "${PROJECT_NAME} ${PROJECT_VERSION}")
323 SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
324 "${PROJECT_NAME} ${PROJECT_VERSION}")
326 SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
328 SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
329 SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
330 SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
331 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
333 SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
335 SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
336 "DLL and import library")
337 SET(CPACK_COMPONENT_BIN_DESCRIPTION
338 "Command line utilities")
339 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
340 "Doxygen generated documentation")
342 SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
344 SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
345 SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
346 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
348 SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
349 "Components needed to develop software using LEMON")
350 SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
351 "Documentation of LEMON")
353 SET(CPACK_ALL_INSTALL_TYPES Full Developer)
355 SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
356 SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
357 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
359 SET(CPACK_GENERATOR "NSIS")
360 SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
361 SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
362 #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
363 SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
364 SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
365 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
366 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
367 SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
368 SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
369 CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
371 SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
372 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
373 Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"