1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
4 CMAKE_POLICY(SET CMP0048 OLD)
8 #This is for copying the dll's needed by glpk (in lp_test and mip_test)
9 CMAKE_POLICY(SET CMP0026 OLD)
12 SET(PROJECT_NAME "LEMON")
13 PROJECT(${PROJECT_NAME})
15 INCLUDE(FindPythonInterp)
18 IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
19 INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
20 ELSEIF(DEFINED ENV{LEMON_VERSION})
21 SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
25 hg log -r. --template "{latesttag}"
26 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
27 OUTPUT_VARIABLE HG_REVISION_TAG
29 OUTPUT_STRIP_TRAILING_WHITESPACE
33 hg log -r. --template "{latesttagdistance}"
34 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
35 OUTPUT_VARIABLE HG_REVISION_DIST
37 OUTPUT_STRIP_TRAILING_WHITESPACE
41 hg log -r. --template "{node|short}"
42 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
43 OUTPUT_VARIABLE HG_REVISION_ID
45 OUTPUT_STRIP_TRAILING_WHITESPACE
48 IF(HG_REVISION_TAG STREQUAL "")
49 SET(HG_REVISION_ID "hg-tip")
51 IF(HG_REVISION_TAG STREQUAL "null")
52 SET(HG_REVISION_TAG "trunk")
53 ELSEIF(HG_REVISION_TAG MATCHES "^r")
54 STRING(SUBSTRING ${HG_REVISION_TAG} 1 -1 HG_REVISION_TAG)
56 IF(HG_REVISION_DIST STREQUAL "0")
57 SET(HG_REVISION ${HG_REVISION_TAG})
60 "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}")
64 SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.")
67 SET(PROJECT_VERSION ${LEMON_VERSION})
69 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
72 FIND_PACKAGE(Ghostscript)
78 SET(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.")
79 SET(LEMON_ENABLE_ILOG YES CACHE STRING "Enable ILOG (CPLEX) solver backend.")
80 SET(LEMON_ENABLE_COIN YES CACHE STRING "Enable COIN solver backend.")
81 SET(LEMON_ENABLE_SOPLEX YES CACHE STRING "Enable SoPlex solver backend.")
84 FIND_PACKAGE(GLPK 4.33)
85 ENDIF(LEMON_ENABLE_GLPK)
88 ENDIF(LEMON_ENABLE_ILOG)
91 ENDIF(LEMON_ENABLE_COIN)
92 IF(LEMON_ENABLE_SOPLEX)
94 ENDIF(LEMON_ENABLE_SOPLEX)
97 SET(LEMON_HAVE_LP TRUE)
98 SET(LEMON_HAVE_MIP TRUE)
99 SET(LEMON_HAVE_GLPK TRUE)
102 SET(LEMON_HAVE_LP TRUE)
103 SET(LEMON_HAVE_MIP TRUE)
104 SET(LEMON_HAVE_CPLEX TRUE)
107 SET(LEMON_HAVE_LP TRUE)
108 SET(LEMON_HAVE_MIP TRUE)
109 SET(LEMON_HAVE_CLP TRUE)
110 SET(LEMON_HAVE_CBC TRUE)
113 SET(LEMON_HAVE_LP TRUE)
114 SET(LEMON_HAVE_SOPLEX TRUE)
118 SET(DEFAULT_LP "CPLEX")
119 SET(DEFAULT_MIP "CPLEX")
121 SET(DEFAULT_LP "CLP")
122 SET(DEFAULT_MIP "CBC")
124 SET(DEFAULT_LP "GLPK")
125 SET(DEFAULT_MIP "GLPK")
127 SET(DEFAULT_LP "SOPLEX")
130 IF(NOT LEMON_DEFAULT_LP OR
131 (NOT ILOG_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CPLEX")) OR
132 (NOT COIN_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CLP")) OR
133 (NOT GLPK_FOUND AND (LEMON_DEFAULT_LP STREQUAL "GLPK")) OR
134 (NOT SOPLEX_FOUND AND (LEMON_DEFAULT_LP STREQUAL "SOPLEX")))
135 SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
136 "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)" FORCE)
138 SET(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
139 "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)")
141 IF(NOT LEMON_DEFAULT_MIP OR
142 (NOT ILOG_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CPLEX")) OR
143 (NOT COIN_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CBC")) OR
144 (NOT GLPK_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "GLPK")))
145 SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
146 "Default MIP solver backend (GLPK, CPLEX or CBC)" FORCE)
148 SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
149 "Default MIP solver backend (GLPK, CPLEX or CBC)")
153 IF(DEFINED ENV{LEMON_CXX_WARNING})
154 SET(CXX_WARNING $ENV{LEMON_CXX_WARNING})
156 IF(CMAKE_COMPILER_IS_GNUCXX)
157 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")
158 SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
159 SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
161 # This part is unnecessary 'casue the same is set by the lemon/core.h.
162 # Still kept as an example.
164 # SET(CXX_WARNING "/wd4250 /wd4267 /wd4355 /wd4503 /wd4800 /wd4996")
166 # Suppressed warnings:
167 # C4250: 'class1' : inherits 'class2::member' via dominance
168 # C4267: conversion from 'size_t' to 'type', possible loss of data
169 # C4355: 'this' : used in base member initializer list
170 # C4503: 'function' : decorated name length exceeded, name was truncated
171 # C4800: 'type' : forcing value to bool 'true' or 'false'
172 # (performance warning)
173 # C4996: 'function': was declared deprecated
175 SET(CXX_WARNING "-Wall")
178 SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
180 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
183 SET(CMAKE_CXX_FLAGS "/bigobj ${CMAKE_CXX_FLAGS}")
184 SET( CMAKE_CXX_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
185 "Flags used by the C++ compiler during maintainer builds."
187 SET( CMAKE_C_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" 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."
199 SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb -O0" CACHE STRING
200 "Flags used by the C++ compiler during maintainer builds."
202 SET( CMAKE_C_FLAGS_MAINTAINER "-Werror -O0" CACHE STRING
203 "Flags used by the C compiler during maintainer builds."
205 SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
206 "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
207 "Flags used for linking binaries during maintainer builds."
209 SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
210 "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
211 "Flags used by the shared libraries linker during maintainer builds."
216 CMAKE_CXX_FLAGS_MAINTAINER
217 CMAKE_C_FLAGS_MAINTAINER
218 CMAKE_EXE_LINKER_FLAGS_MAINTAINER
219 CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
221 IF(CMAKE_CONFIGURATION_TYPES)
222 LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
223 LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
224 SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
225 "Add the configurations that we need"
229 IF(NOT CMAKE_BUILD_TYPE)
230 SET(CMAKE_BUILD_TYPE "Release")
233 SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
234 "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
238 INCLUDE(CheckTypeSize)
239 CHECK_TYPE_SIZE("long long" LONG_LONG)
240 SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
244 IF(NOT LEMON_THREADING)
245 IF(CMAKE_USE_PTHREADS_INIT)
246 SET(LEMON_THREADING "Pthread")
247 ELSEIF(CMAKE_USE_WIN32_THREADS_INIT)
248 SET(LEMON_THREADING "Win32")
250 SET(LEMON_THREADING "None")
254 SET( LEMON_THREADING "${LEMON_THREADING}" CACHE STRING
255 "Choose the threading library, options are: Pthread Win32 None."
258 IF(LEMON_THREADING STREQUAL "Pthread")
259 SET(LEMON_USE_PTHREAD TRUE)
260 ELSEIF(LEMON_THREADING STREQUAL "Win32")
261 SET(LEMON_USE_WIN32_THREADS TRUE)
266 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
267 ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
269 ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
272 ADD_SUBDIRECTORY(lemon)
273 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
274 ADD_SUBDIRECTORY(contrib)
275 ADD_SUBDIRECTORY(demo)
276 ADD_SUBDIRECTORY(tools)
277 ADD_SUBDIRECTORY(doc)
278 ADD_SUBDIRECTORY(test)
282 ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
283 ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
288 FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
289 DESTINATION share/lemon/cmake
293 FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
299 ${PROJECT_SOURCE_DIR}/cmake/version.cmake.in
300 ${PROJECT_BINARY_DIR}/cmake/version.cmake
304 SET(ARCHIVE_BASE_NAME ${CMAKE_PROJECT_NAME})
305 STRING(TOLOWER ${ARCHIVE_BASE_NAME} ARCHIVE_BASE_NAME)
306 SET(ARCHIVE_NAME ${ARCHIVE_BASE_NAME}-${PROJECT_VERSION})
307 ADD_CUSTOM_TARGET(dist
308 COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
309 COMMAND hg archive ${ARCHIVE_NAME}
310 COMMAND cmake -E copy cmake/version.cmake ${ARCHIVE_NAME}/cmake/version.cmake
311 COMMAND tar -czf ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_NAME}
312 COMMAND zip -r ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.zip ${ARCHIVE_NAME}
313 COMMAND cmake -E copy_directory doc/html ${ARCHIVE_NAME}/doc/html
314 COMMAND tar -czf ${ARCHIVE_NAME}.tar.gz ${ARCHIVE_NAME}
315 COMMAND zip -r ${ARCHIVE_NAME}.zip ${ARCHIVE_NAME}
316 COMMAND cmake -E copy_directory doc/html ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
317 COMMAND tar -czf ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
318 COMMAND zip -r ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.zip ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
319 COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
320 COMMAND cmake -E remove_directory ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
322 WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
324 # CPACK config (Basically for NSIS)
325 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
326 SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
327 SET(CPACK_PACKAGE_VENDOR "EGRES")
328 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
329 "LEMON - Library for Efficient Modeling and Optimization in Networks")
330 SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
332 SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
334 SET(CPACK_PACKAGE_INSTALL_DIRECTORY
335 "${PROJECT_NAME} ${PROJECT_VERSION}")
336 SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
337 "${PROJECT_NAME} ${PROJECT_VERSION}")
339 SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
341 SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
342 SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
343 SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
344 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
346 SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
348 SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
349 "DLL and import library")
350 SET(CPACK_COMPONENT_BIN_DESCRIPTION
351 "Command line utilities")
352 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
353 "Doxygen generated documentation")
355 SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
357 SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
358 SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
359 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
361 SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
362 "Components needed to develop software using LEMON")
363 SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
364 "Documentation of LEMON")
366 SET(CPACK_ALL_INSTALL_TYPES Full Developer)
368 SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
369 SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
370 SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
372 SET(CPACK_GENERATOR "NSIS")
373 SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
374 SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
375 #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
376 SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
377 SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
378 SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
379 SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
380 SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
381 SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
382 CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
384 SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
385 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
386 Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"