1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
4 CMAKE_POLICY(SET CMP0048 OLD)
8 CMAKE_POLICY(SET CMP0043 OLD)
11 SET(PROJECT_NAME "LEMON")
12 PROJECT(${PROJECT_NAME})
14 INCLUDE(FindPythonInterp)
17 IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
18 INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
19 ELSEIF(DEFINED ENV{LEMON_VERSION})
20 SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
24 hg log -r. --template "{latesttag}"
25 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
26 OUTPUT_VARIABLE HG_REVISION_TAG
28 OUTPUT_STRIP_TRAILING_WHITESPACE
32 hg log -r. --template "{latesttagdistance}"
33 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
34 OUTPUT_VARIABLE HG_REVISION_DIST
36 OUTPUT_STRIP_TRAILING_WHITESPACE
40 hg log -r. --template "{node|short}"
41 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
42 OUTPUT_VARIABLE HG_REVISION_ID
44 OUTPUT_STRIP_TRAILING_WHITESPACE
47 IF(HG_REVISION_TAG STREQUAL "")
48 SET(HG_REVISION_ID "hg-tip")
50 IF(HG_REVISION_TAG STREQUAL "null")
51 SET(HG_REVISION_TAG "trunk")
52 ELSEIF(HG_REVISION_TAG MATCHES "^r")
53 STRING(SUBSTRING ${HG_REVISION_TAG} 1 -1 HG_REVISION_TAG)
55 IF(HG_REVISION_DIST STREQUAL "0")
56 SET(HG_REVISION ${HG_REVISION_TAG})
59 "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}")
63 SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.")
66 SET(PROJECT_VERSION ${LEMON_VERSION})
68 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
71 FIND_PACKAGE(Ghostscript)
73 SET(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.")
74 SET(LEMON_ENABLE_ILOG YES CACHE STRING "Enable ILOG (CPLEX) solver backend.")
75 SET(LEMON_ENABLE_COIN YES CACHE STRING "Enable COIN solver backend.")
76 SET(LEMON_ENABLE_SOPLEX YES CACHE STRING "Enable SoPlex solver backend.")
79 FIND_PACKAGE(GLPK 4.33)
80 ENDIF(LEMON_ENABLE_GLPK)
83 ENDIF(LEMON_ENABLE_ILOG)
86 ENDIF(LEMON_ENABLE_COIN)
87 IF(LEMON_ENABLE_SOPLEX)
89 ENDIF(LEMON_ENABLE_SOPLEX)
92 SET(LEMON_HAVE_LP TRUE)
93 SET(LEMON_HAVE_MIP TRUE)
94 SET(LEMON_HAVE_GLPK TRUE)
97 SET(LEMON_HAVE_LP TRUE)
98 SET(LEMON_HAVE_MIP TRUE)
99 SET(LEMON_HAVE_CPLEX TRUE)
102 SET(LEMON_HAVE_LP TRUE)
103 SET(LEMON_HAVE_MIP TRUE)
104 SET(LEMON_HAVE_CLP TRUE)
105 SET(LEMON_HAVE_CBC TRUE)
108 SET(LEMON_HAVE_LP TRUE)
109 SET(LEMON_HAVE_SOPLEX TRUE)
113 SET(DEFAULT_LP "CPLEX")
114 SET(DEFAULT_MIP "CPLEX")
116 SET(DEFAULT_LP "CLP")
117 SET(DEFAULT_MIP "CBC")
119 SET(DEFAULT_LP "GLPK")
120 SET(DEFAULT_MIP "GLPK")
122 SET(DEFAULT_LP "SOPLEX")
125 IF(NOT LEMON_DEFAULT_LP OR
126 (NOT ILOG_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CPLEX")) OR
127 (NOT COIN_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CLP")) OR
128 (NOT GLPK_FOUND AND (LEMON_DEFAULT_LP STREQUAL "GLPK")) OR
129 (NOT SOPLEX_FOUND AND (LEMON_DEFAULT_LP STREQUAL "SOPLEX")))
130 SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
131 "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)" FORCE)
133 SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
134 "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)")
136 IF(NOT LEMON_DEFAULT_MIP OR
137 (NOT ILOG_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CPLEX")) OR
138 (NOT COIN_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CBC")) OR
139 (NOT GLPK_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "GLPK")))
140 SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
141 "Default MIP solver backend (GLPK, CPLEX or CBC)" FORCE)
143 SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
144 "Default MIP solver backend (GLPK, CPLEX or CBC)")
148 IF(DEFINED ENV{LEMON_CXX_WARNING})
149 SET(CXX_WARNING $ENV{LEMON_CXX_WARNING})
151 IF(CMAKE_COMPILER_IS_GNUCXX)
152 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")
153 SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
154 SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
156 # This part is unnecessary 'casue the same is set by the lemon/core.h.
157 # Still kept as an example.
159 # SET(CXX_WARNING "/wd4250 /wd4267 /wd4355 /wd4503 /wd4800 /wd4996")
161 # Suppressed warnings:
162 # C4250: 'class1' : inherits 'class2::member' via dominance
163 # C4267: conversion from 'size_t' to 'type', possible loss of data
164 # C4355: 'this' : used in base member initializer list
165 # C4503: 'function' : decorated name length exceeded, name was truncated
166 # C4800: 'type' : forcing value to bool 'true' or 'false'
167 # (performance warning)
168 # C4996: 'function': was declared deprecated
170 SET(CXX_WARNING "-Wall")
173 SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
175 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
178 SET(CMAKE_CXX_FLAGS "/bigobj ${CMAKE_CXX_FLAGS}")
179 SET( CMAKE_CXX_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
180 "Flags used by the C++ compiler during maintainer builds."
182 SET( CMAKE_C_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
183 "Flags used by the C compiler during maintainer builds."
185 SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
186 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
187 "Flags used for linking binaries during maintainer builds."
189 SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
190 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
191 "Flags used by the shared libraries linker during maintainer builds."
194 SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb -O0" CACHE STRING
195 "Flags used by the C++ compiler during maintainer builds."
197 SET( CMAKE_C_FLAGS_MAINTAINER "-Werror -O0" CACHE STRING
198 "Flags used by the C compiler during maintainer builds."
200 SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
201 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
202 "Flags used for linking binaries during maintainer builds."
204 SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
205 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
206 "Flags used by the shared libraries linker during maintainer builds."
211 CMAKE_CXX_FLAGS_MAINTAINER
212 CMAKE_C_FLAGS_MAINTAINER
213 CMAKE_EXE_LINKER_FLAGS_MAINTAINER
214 CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
216 IF(CMAKE_CONFIGURATION_TYPES)
217 LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
218 LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
219 SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
220 "Add the configurations that we need"
224 IF(NOT CMAKE_BUILD_TYPE)
225 SET(CMAKE_BUILD_TYPE "Release")
228 SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
229 "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
232 SET_DIRECTORY_PROPERTIES(PROPERTIES
233 COMPILE_DEFINITIONS_DEBUG "LEMON_ENABLE_DEBUG"
234 COMPILE_DEFINITIONS_MAINTAINER "LEMON_ENABLE_DEBUG"
237 INCLUDE(CheckTypeSize)
238 CHECK_TYPE_SIZE("long long" LONG_LONG)
239 SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
243 IF(NOT LEMON_THREADING)
244 IF(CMAKE_USE_PTHREADS_INIT)
245 SET(LEMON_THREADING "Pthread")
246 ELSEIF(CMAKE_USE_WIN32_THREADS_INIT)
247 SET(LEMON_THREADING "Win32")
249 SET(LEMON_THREADING "None")
253 SET( LEMON_THREADING "${LEMON_THREADING}" CACHE STRING
254 "Choose the threading library, options are: Pthread Win32 None."
257 IF(LEMON_THREADING STREQUAL "Pthread")
258 SET(LEMON_USE_PTHREAD TRUE)
259 ELSEIF(LEMON_THREADING STREQUAL "Win32")
260 SET(LEMON_USE_WIN32_THREADS TRUE)
266 INCLUDE(CheckCXXCompilerFlag)
267 CHECK_CXX_COMPILER_FLAG("-std=c++11" LEMON_CXX11)
269 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
273 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
274 ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
276 ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
279 ADD_SUBDIRECTORY(lemon)
280 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
281 ADD_SUBDIRECTORY(contrib)
282 ADD_SUBDIRECTORY(demo)
283 ADD_SUBDIRECTORY(tools)
284 ADD_SUBDIRECTORY(doc)
285 ADD_SUBDIRECTORY(test)
289 ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
290 ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
295 FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
296 DESTINATION share/lemon/cmake
300 FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
306 ${PROJECT_SOURCE_DIR}/cmake/version.cmake.in
307 ${PROJECT_BINARY_DIR}/cmake/version.cmake
311 SET(ARCHIVE_BASE_NAME ${CMAKE_PROJECT_NAME})
312 STRING(TOLOWER ${ARCHIVE_BASE_NAME} ARCHIVE_BASE_NAME)
313 SET(ARCHIVE_NAME ${ARCHIVE_BASE_NAME}-${PROJECT_VERSION})
314 ADD_CUSTOM_TARGET(dist
315 COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
316 COMMAND hg archive ${ARCHIVE_NAME}
317 COMMAND cmake -E copy cmake/version.cmake ${ARCHIVE_NAME}/cmake/version.cmake
318 COMMAND tar -czf ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_NAME}
319 COMMAND zip -r ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.zip ${ARCHIVE_NAME}
320 COMMAND cmake -E copy_directory doc/html ${ARCHIVE_NAME}/doc/html
321 COMMAND tar -czf ${ARCHIVE_NAME}.tar.gz ${ARCHIVE_NAME}
322 COMMAND zip -r ${ARCHIVE_NAME}.zip ${ARCHIVE_NAME}
323 COMMAND cmake -E copy_directory doc/html ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
324 COMMAND tar -czf ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
325 COMMAND zip -r ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.zip ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
326 COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
327 COMMAND cmake -E remove_directory ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
329 WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
331 # CPACK config (Basically for NSIS)
332 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
333 SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
334 SET(CPACK_PACKAGE_VENDOR "EGRES")
335 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
336 "LEMON - Library for Efficient Modeling and Optimization in Networks")
337 SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
339 SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
341 SET(CPACK_PACKAGE_INSTALL_DIRECTORY
342 "${PROJECT_NAME} ${PROJECT_VERSION}")
343 SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
344 "${PROJECT_NAME} ${PROJECT_VERSION}")
346 SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
348 SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
349 SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
350 SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
351 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
353 SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
355 SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
356 "DLL and import library")
357 SET(CPACK_COMPONENT_BIN_DESCRIPTION
358 "Command line utilities")
359 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
360 "Doxygen generated documentation")
362 SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
364 SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
365 SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
366 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
368 SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
369 "Components needed to develop software using LEMON")
370 SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
371 "Documentation of LEMON")
373 SET(CPACK_ALL_INSTALL_TYPES Full Developer)
375 SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
376 SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
377 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
379 SET(CPACK_GENERATOR "NSIS")
380 SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
381 SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
382 #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
383 SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
384 SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
385 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
386 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
387 SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
388 SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
389 CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
391 SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
392 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
393 Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"