1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
3 SET(PROJECT_NAME "LEMON")
4 PROJECT(${PROJECT_NAME})
6 INCLUDE(FindPythonInterp)
9 IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
10 INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
11 ELSEIF(DEFINED ENV{LEMON_VERSION})
12 SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
16 hg log -r. --template "{latesttag}"
17 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
18 OUTPUT_VARIABLE HG_REVISION_TAG
20 OUTPUT_STRIP_TRAILING_WHITESPACE
24 hg log -r. --template "{latesttagdistance}"
25 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
26 OUTPUT_VARIABLE HG_REVISION_DIST
28 OUTPUT_STRIP_TRAILING_WHITESPACE
32 hg log -r. --template "{node|short}"
33 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
34 OUTPUT_VARIABLE HG_REVISION_ID
36 OUTPUT_STRIP_TRAILING_WHITESPACE
39 IF(HG_REVISION_TAG STREQUAL "")
40 SET(HG_REVISION_ID "hg-tip")
42 IF(HG_REVISION_TAG STREQUAL "null")
43 SET(HG_REVISION_TAG "trunk")
44 ELSEIF(HG_REVISION_TAG MATCHES "^r")
45 STRING(SUBSTRING ${HG_REVISION_TAG} 1 -1 HG_REVISION_TAG)
47 IF(HG_REVISION_DIST STREQUAL "0")
48 SET(HG_REVISION ${HG_REVISION_TAG})
51 "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}")
55 SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.")
58 SET(PROJECT_VERSION ${LEMON_VERSION})
60 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
63 FIND_PACKAGE(Ghostscript)
65 SET(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.")
66 SET(LEMON_ENABLE_ILOG YES CACHE STRING "Enable ILOG (CPLEX) solver backend.")
67 SET(LEMON_ENABLE_COIN YES CACHE STRING "Enable COIN solver backend.")
68 SET(LEMON_ENABLE_SOPLEX YES CACHE STRING "Enable SoPlex solver backend.")
71 FIND_PACKAGE(GLPK 4.33)
72 ENDIF(LEMON_ENABLE_GLPK)
75 ENDIF(LEMON_ENABLE_ILOG)
78 ENDIF(LEMON_ENABLE_COIN)
79 IF(LEMON_ENABLE_SOPLEX)
81 ENDIF(LEMON_ENABLE_SOPLEX)
84 SET(LEMON_HAVE_LP TRUE)
85 SET(LEMON_HAVE_MIP TRUE)
86 SET(LEMON_HAVE_GLPK TRUE)
89 SET(LEMON_HAVE_LP TRUE)
90 SET(LEMON_HAVE_MIP TRUE)
91 SET(LEMON_HAVE_CPLEX TRUE)
94 SET(LEMON_HAVE_LP TRUE)
95 SET(LEMON_HAVE_MIP TRUE)
96 SET(LEMON_HAVE_CLP TRUE)
97 SET(LEMON_HAVE_CBC TRUE)
100 SET(LEMON_HAVE_LP TRUE)
101 SET(LEMON_HAVE_SOPLEX TRUE)
105 SET(DEFAULT_LP "CPLEX")
106 SET(DEFAULT_MIP "CPLEX")
108 SET(DEFAULT_LP "CLP")
109 SET(DEFAULT_MIP "CBC")
111 SET(DEFAULT_LP "GLPK")
112 SET(DEFAULT_MIP "GLPK")
114 SET(DEFAULT_LP "SOPLEX")
117 IF(NOT LEMON_DEFAULT_LP OR
118 (NOT ILOG_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CPLEX")) OR
119 (NOT COIN_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CLP")) OR
120 (NOT GLPK_FOUND AND (LEMON_DEFAULT_LP STREQUAL "GLPK")) OR
121 (NOT SOPLEX_FOUND AND (LEMON_DEFAULT_LP STREQUAL "SOPLEX")))
122 SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
123 "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)" FORCE)
125 IF(NOT LEMON_DEFAULT_MIP OR
126 (NOT ILOG_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CPLEX")) OR
127 (NOT COIN_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CBC")) OR
128 (NOT GLPK_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "GLPK")))
129 SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
130 "Default MIP solver backend (GLPK, CPLEX or CBC)" FORCE)
134 IF(DEFINED ENV{LEMON_CXX_WARNING})
135 SET(CXX_WARNING $ENV{LEMON_CXX_WARNING})
137 IF(CMAKE_COMPILER_IS_GNUCXX)
138 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")
139 SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
140 SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
142 # This part is unnecessary 'casue the same is set by the lemon/core.h.
143 # Still keep it as an example.
144 SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
145 # Suppressed warnings:
146 # C4250: 'class1' : inherits 'class2::member' via dominance
147 # C4355: 'this' : used in base member initializer list
148 # C4503: 'function' : decorated name length exceeded, name was truncated
149 # C4800: 'type' : forcing value to bool 'true' or 'false'
150 # (performance warning)
151 # C4996: 'function': was declared deprecated
153 SET(CXX_WARNING "-Wall")
156 SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
158 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
161 SET( CMAKE_CXX_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
162 "Flags used by the C++ compiler during maintainer builds."
164 SET( CMAKE_C_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
165 "Flags used by the C compiler during maintainer builds."
167 SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
168 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
169 "Flags used for linking binaries during maintainer builds."
171 SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
172 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
173 "Flags used by the shared libraries linker during maintainer builds."
176 SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb -O0" CACHE STRING
177 "Flags used by the C++ compiler during maintainer builds."
179 SET( CMAKE_C_FLAGS_MAINTAINER "-Werror -O0" CACHE STRING
180 "Flags used by the C compiler during maintainer builds."
182 SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
183 "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
184 "Flags used for linking binaries during maintainer builds."
186 SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
187 "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
188 "Flags used by the shared libraries linker during maintainer builds."
193 CMAKE_CXX_FLAGS_MAINTAINER
194 CMAKE_C_FLAGS_MAINTAINER
195 CMAKE_EXE_LINKER_FLAGS_MAINTAINER
196 CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
198 IF(CMAKE_CONFIGURATION_TYPES)
199 LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
200 LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
201 SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
202 "Add the configurations that we need"
206 IF(NOT CMAKE_BUILD_TYPE)
207 SET(CMAKE_BUILD_TYPE "Release")
210 SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
211 "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
215 INCLUDE(CheckTypeSize)
216 CHECK_TYPE_SIZE("long long" LONG_LONG)
217 SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
221 IF(NOT LEMON_THREADING)
222 IF(CMAKE_USE_PTHREADS_INIT)
223 SET(LEMON_THREADING "Pthread")
224 ELSEIF(CMAKE_USE_WIN32_THREADS_INIT)
225 SET(LEMON_THREADING "Win32")
227 SET(LEMON_THREADING "None")
231 SET( LEMON_THREADING "${LEMON_THREADING}" CACHE STRING
232 "Choose the threading library, options are: Pthread Win32 None."
235 IF(LEMON_THREADING STREQUAL "Pthread")
236 SET(LEMON_USE_PTHREAD TRUE)
237 ELSEIF(LEMON_THREADING STREQUAL "Win32")
238 SET(LEMON_USE_WIN32_THREADS TRUE)
243 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
244 ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
246 ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
249 ADD_SUBDIRECTORY(lemon)
250 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
251 ADD_SUBDIRECTORY(contrib)
252 ADD_SUBDIRECTORY(demo)
253 ADD_SUBDIRECTORY(tools)
254 ADD_SUBDIRECTORY(doc)
255 ADD_SUBDIRECTORY(test)
259 ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
260 ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
265 FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
266 DESTINATION share/lemon/cmake
270 FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
276 ${PROJECT_SOURCE_DIR}/cmake/version.cmake.in
277 ${PROJECT_BINARY_DIR}/cmake/version.cmake
281 SET(ARCHIVE_BASE_NAME ${CMAKE_PROJECT_NAME})
282 STRING(TOLOWER ${ARCHIVE_BASE_NAME} ARCHIVE_BASE_NAME)
283 SET(ARCHIVE_NAME ${ARCHIVE_BASE_NAME}-${PROJECT_VERSION})
284 ADD_CUSTOM_TARGET(dist
285 COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
286 COMMAND hg archive ${ARCHIVE_NAME}
287 COMMAND cmake -E copy cmake/version.cmake ${ARCHIVE_NAME}/cmake/version.cmake
288 COMMAND tar -czf ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_NAME}
289 COMMAND zip -r ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.zip ${ARCHIVE_NAME}
290 COMMAND cmake -E copy_directory doc/html ${ARCHIVE_NAME}/doc/html
291 COMMAND tar -czf ${ARCHIVE_NAME}.tar.gz ${ARCHIVE_NAME}
292 COMMAND zip -r ${ARCHIVE_NAME}.zip ${ARCHIVE_NAME}
293 COMMAND cmake -E copy_directory doc/html ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
294 COMMAND tar -czf ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
295 COMMAND zip -r ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.zip ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
296 COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
297 COMMAND cmake -E remove_directory ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
299 WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
301 # CPACK config (Basically for NSIS)
302 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
303 SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
304 SET(CPACK_PACKAGE_VENDOR "EGRES")
305 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
306 "LEMON - Library for Efficient Modeling and Optimization in Networks")
307 SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
309 SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
311 SET(CPACK_PACKAGE_INSTALL_DIRECTORY
312 "${PROJECT_NAME} ${PROJECT_VERSION}")
313 SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
314 "${PROJECT_NAME} ${PROJECT_VERSION}")
316 SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
318 SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
319 SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
320 SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
321 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
323 SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
325 SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
326 "DLL and import library")
327 SET(CPACK_COMPONENT_BIN_DESCRIPTION
328 "Command line utilities")
329 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
330 "Doxygen generated documentation")
332 SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
334 SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
335 SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
336 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
338 SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
339 "Components needed to develop software using LEMON")
340 SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
341 "Documentation of LEMON")
343 SET(CPACK_ALL_INSTALL_TYPES Full Developer)
345 SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
346 SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
347 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
349 SET(CPACK_GENERATOR "NSIS")
350 SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
351 SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
352 #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
353 SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
354 SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
355 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
356 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
357 SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
358 SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
359 CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
361 SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
362 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
363 Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"