1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
4 CMAKE_POLICY(SET CMP0048 OLD)
8 CMAKE_POLICY(SET CMP0043 OLD)
12 #This is for copying the dll's needed by glpk (in lp_test and mip_test)
13 CMAKE_POLICY(SET CMP0026 OLD)
16 SET(PROJECT_NAME "LEMON")
17 PROJECT(${PROJECT_NAME})
19 INCLUDE(FindPythonInterp)
22 IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
23 INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
24 ELSEIF(DEFINED ENV{LEMON_VERSION})
25 SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
29 hg log -r. --template "{latesttag}"
30 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
31 OUTPUT_VARIABLE HG_REVISION_TAG
33 OUTPUT_STRIP_TRAILING_WHITESPACE
37 hg log -r. --template "{latesttagdistance}"
38 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
39 OUTPUT_VARIABLE HG_REVISION_DIST
41 OUTPUT_STRIP_TRAILING_WHITESPACE
45 hg log -r. --template "{node|short}"
46 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
47 OUTPUT_VARIABLE HG_REVISION_ID
49 OUTPUT_STRIP_TRAILING_WHITESPACE
52 IF(HG_REVISION_TAG STREQUAL "")
53 SET(HG_REVISION_ID "hg-tip")
55 IF(HG_REVISION_TAG STREQUAL "null")
56 SET(HG_REVISION_TAG "trunk")
57 ELSEIF(HG_REVISION_TAG MATCHES "^r")
58 STRING(SUBSTRING ${HG_REVISION_TAG} 1 -1 HG_REVISION_TAG)
60 IF(HG_REVISION_DIST STREQUAL "0")
61 SET(HG_REVISION ${HG_REVISION_TAG})
64 "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}")
68 SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.")
71 SET(PROJECT_VERSION ${LEMON_VERSION})
73 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
76 FIND_PACKAGE(Ghostscript)
82 SET(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.")
83 SET(LEMON_ENABLE_ILOG YES CACHE STRING "Enable ILOG (CPLEX) solver backend.")
84 SET(LEMON_ENABLE_COIN YES CACHE STRING "Enable COIN solver backend.")
85 SET(LEMON_ENABLE_SOPLEX YES CACHE STRING "Enable SoPlex solver backend.")
88 FIND_PACKAGE(GLPK 4.33)
89 ENDIF(LEMON_ENABLE_GLPK)
92 ENDIF(LEMON_ENABLE_ILOG)
95 ENDIF(LEMON_ENABLE_COIN)
96 IF(LEMON_ENABLE_SOPLEX)
98 ENDIF(LEMON_ENABLE_SOPLEX)
101 SET(LEMON_HAVE_LP TRUE)
102 SET(LEMON_HAVE_MIP TRUE)
103 SET(LEMON_HAVE_GLPK TRUE)
106 SET(LEMON_HAVE_LP TRUE)
107 SET(LEMON_HAVE_MIP TRUE)
108 SET(LEMON_HAVE_CPLEX TRUE)
111 SET(LEMON_HAVE_LP TRUE)
112 SET(LEMON_HAVE_MIP TRUE)
113 SET(LEMON_HAVE_CLP TRUE)
114 SET(LEMON_HAVE_CBC TRUE)
117 SET(LEMON_HAVE_LP TRUE)
118 SET(LEMON_HAVE_SOPLEX TRUE)
122 SET(DEFAULT_LP "CPLEX")
123 SET(DEFAULT_MIP "CPLEX")
125 SET(DEFAULT_LP "CLP")
126 SET(DEFAULT_MIP "CBC")
128 SET(DEFAULT_LP "GLPK")
129 SET(DEFAULT_MIP "GLPK")
131 SET(DEFAULT_LP "SOPLEX")
134 IF(NOT LEMON_DEFAULT_LP OR
135 (NOT ILOG_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CPLEX")) OR
136 (NOT COIN_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CLP")) OR
137 (NOT GLPK_FOUND AND (LEMON_DEFAULT_LP STREQUAL "GLPK")) OR
138 (NOT SOPLEX_FOUND AND (LEMON_DEFAULT_LP STREQUAL "SOPLEX")))
139 SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
140 "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)" FORCE)
142 SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
143 "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)")
145 IF(NOT LEMON_DEFAULT_MIP OR
146 (NOT ILOG_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CPLEX")) OR
147 (NOT COIN_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CBC")) OR
148 (NOT GLPK_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "GLPK")))
149 SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
150 "Default MIP solver backend (GLPK, CPLEX or CBC)" FORCE)
152 SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
153 "Default MIP solver backend (GLPK, CPLEX or CBC)")
157 IF(DEFINED ENV{LEMON_CXX_WARNING})
158 SET(CXX_WARNING $ENV{LEMON_CXX_WARNING})
160 IF(CMAKE_COMPILER_IS_GNUCXX)
161 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")
162 SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
163 SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
165 # This part is unnecessary 'casue the same is set by the lemon/core.h.
166 # Still kept as an example.
168 # SET(CXX_WARNING "/wd4250 /wd4267 /wd4355 /wd4503 /wd4800 /wd4996")
170 # Suppressed warnings:
171 # C4250: 'class1' : inherits 'class2::member' via dominance
172 # C4267: conversion from 'size_t' to 'type', possible loss of data
173 # C4355: 'this' : used in base member initializer list
174 # C4503: 'function' : decorated name length exceeded, name was truncated
175 # C4800: 'type' : forcing value to bool 'true' or 'false'
176 # (performance warning)
177 # C4996: 'function': was declared deprecated
179 SET(CXX_WARNING "-Wall")
182 SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
184 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
187 SET(CMAKE_CXX_FLAGS "/bigobj ${CMAKE_CXX_FLAGS}")
188 SET( CMAKE_CXX_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
189 "Flags used by the C++ compiler during maintainer builds."
191 SET( CMAKE_C_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
192 "Flags used by the C compiler during maintainer builds."
194 SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
195 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
196 "Flags used for linking binaries during maintainer builds."
198 SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
199 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
200 "Flags used by the shared libraries linker during maintainer builds."
203 SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb -O0" CACHE STRING
204 "Flags used by the C++ compiler during maintainer builds."
206 SET( CMAKE_C_FLAGS_MAINTAINER "-Werror -O0" CACHE STRING
207 "Flags used by the C compiler during maintainer builds."
209 SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
210 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
211 "Flags used for linking binaries during maintainer builds."
213 SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
214 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
215 "Flags used by the shared libraries linker during maintainer builds."
220 CMAKE_CXX_FLAGS_MAINTAINER
221 CMAKE_C_FLAGS_MAINTAINER
222 CMAKE_EXE_LINKER_FLAGS_MAINTAINER
223 CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
225 IF(CMAKE_CONFIGURATION_TYPES)
226 LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
227 LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
228 SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
229 "Add the configurations that we need"
233 IF(NOT CMAKE_BUILD_TYPE)
234 SET(CMAKE_BUILD_TYPE "Release")
237 SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
238 "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
241 SET_DIRECTORY_PROPERTIES(PROPERTIES
242 COMPILE_DEFINITIONS_DEBUG "LEMON_ENABLE_DEBUG"
243 COMPILE_DEFINITIONS_MAINTAINER "LEMON_ENABLE_DEBUG"
246 INCLUDE(CheckTypeSize)
247 CHECK_TYPE_SIZE("long long" LONG_LONG)
248 SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
252 IF(NOT LEMON_THREADING)
253 IF(CMAKE_USE_PTHREADS_INIT)
254 SET(LEMON_THREADING "Pthread")
255 ELSEIF(CMAKE_USE_WIN32_THREADS_INIT)
256 SET(LEMON_THREADING "Win32")
258 SET(LEMON_THREADING "None")
262 SET( LEMON_THREADING "${LEMON_THREADING}" CACHE STRING
263 "Choose the threading library, options are: Pthread Win32 None."
266 IF(LEMON_THREADING STREQUAL "Pthread")
267 SET(LEMON_USE_PTHREAD TRUE)
268 ELSEIF(LEMON_THREADING STREQUAL "Win32")
269 SET(LEMON_USE_WIN32_THREADS TRUE)
275 INCLUDE(CheckCXXCompilerFlag)
276 CHECK_CXX_COMPILER_FLAG("-std=c++11" LEMON_CXX11)
278 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
282 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
283 ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
285 ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
288 ADD_SUBDIRECTORY(lemon)
289 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
290 ADD_SUBDIRECTORY(contrib)
291 ADD_SUBDIRECTORY(demo)
292 ADD_SUBDIRECTORY(tools)
293 ADD_SUBDIRECTORY(doc)
294 ADD_SUBDIRECTORY(test)
298 ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
299 ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
304 FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
305 DESTINATION share/lemon/cmake
309 FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
315 ${PROJECT_SOURCE_DIR}/cmake/version.cmake.in
316 ${PROJECT_BINARY_DIR}/cmake/version.cmake
320 SET(ARCHIVE_BASE_NAME ${CMAKE_PROJECT_NAME})
321 STRING(TOLOWER ${ARCHIVE_BASE_NAME} ARCHIVE_BASE_NAME)
322 SET(ARCHIVE_NAME ${ARCHIVE_BASE_NAME}-${PROJECT_VERSION})
323 ADD_CUSTOM_TARGET(dist
324 COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
325 COMMAND hg archive ${ARCHIVE_NAME}
326 COMMAND cmake -E copy cmake/version.cmake ${ARCHIVE_NAME}/cmake/version.cmake
327 COMMAND tar -czf ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_NAME}
328 COMMAND zip -r ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.zip ${ARCHIVE_NAME}
329 COMMAND cmake -E copy_directory doc/html ${ARCHIVE_NAME}/doc/html
330 COMMAND tar -czf ${ARCHIVE_NAME}.tar.gz ${ARCHIVE_NAME}
331 COMMAND zip -r ${ARCHIVE_NAME}.zip ${ARCHIVE_NAME}
332 COMMAND cmake -E copy_directory doc/html ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
333 COMMAND tar -czf ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
334 COMMAND zip -r ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.zip ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
335 COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
336 COMMAND cmake -E remove_directory ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
338 WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
340 # CPACK config (Basically for NSIS)
341 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
342 SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
343 SET(CPACK_PACKAGE_VENDOR "EGRES")
344 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
345 "LEMON - Library for Efficient Modeling and Optimization in Networks")
346 SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
348 SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
350 SET(CPACK_PACKAGE_INSTALL_DIRECTORY
351 "${PROJECT_NAME} ${PROJECT_VERSION}")
352 SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
353 "${PROJECT_NAME} ${PROJECT_VERSION}")
355 SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
357 SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
358 SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
359 SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
360 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
362 SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
364 SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
365 "DLL and import library")
366 SET(CPACK_COMPONENT_BIN_DESCRIPTION
367 "Command line utilities")
368 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
369 "Doxygen generated documentation")
371 SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
373 SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
374 SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
375 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
377 SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
378 "Components needed to develop software using LEMON")
379 SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
380 "Documentation of LEMON")
382 SET(CPACK_ALL_INSTALL_TYPES Full Developer)
384 SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
385 SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
386 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
388 SET(CPACK_GENERATOR "NSIS")
389 SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
390 SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
391 #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
392 SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
393 SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
394 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
395 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
396 SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
397 SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
398 CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
400 SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
401 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
402 Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"