COIN-OR::LEMON - Graph Library

source: lemon/CMakeLists.txt @ 1334:ee96cd1cad8a

Last change on this file since 1334:ee96cd1cad8a was 1334:ee96cd1cad8a, checked in by Alpar Juttner <alpar@…>, 6 years ago

Turn on LEMON_ENABLE_DEBUG in Debug modes (#477)

File size: 12.4 KB
Line 
1CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2
3IF(POLICY CMP0043)
4  CMAKE_POLICY(SET CMP0043 OLD)
5ENDIF(POLICY CMP0043)
6
7SET(PROJECT_NAME "LEMON")
8PROJECT(${PROJECT_NAME})
9
10INCLUDE(FindPythonInterp)
11INCLUDE(FindWget)
12
13IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
14  INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
15ELSEIF(DEFINED ENV{LEMON_VERSION})
16  SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
17ELSE()
18  EXECUTE_PROCESS(
19    COMMAND
20    hg log -r. --template "{latesttag}"
21    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
22    OUTPUT_VARIABLE HG_REVISION_TAG
23    ERROR_QUIET
24    OUTPUT_STRIP_TRAILING_WHITESPACE
25  )
26  EXECUTE_PROCESS(
27    COMMAND
28    hg log -r. --template "{latesttagdistance}"
29    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
30    OUTPUT_VARIABLE HG_REVISION_DIST
31    ERROR_QUIET
32    OUTPUT_STRIP_TRAILING_WHITESPACE
33  )
34  EXECUTE_PROCESS(
35    COMMAND
36    hg log -r. --template "{node|short}"
37    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
38    OUTPUT_VARIABLE HG_REVISION_ID
39    ERROR_QUIET
40    OUTPUT_STRIP_TRAILING_WHITESPACE
41  )
42
43  IF(HG_REVISION_TAG STREQUAL "")
44    SET(HG_REVISION_ID "hg-tip")
45  ELSE()
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)
50    ENDIF()
51    IF(HG_REVISION_DIST STREQUAL "0")
52      SET(HG_REVISION ${HG_REVISION_TAG})
53    ELSE()
54      SET(HG_REVISION
55        "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}")
56    ENDIF()
57  ENDIF()
58
59  SET(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.")
60ENDIF()
61
62SET(PROJECT_VERSION ${LEMON_VERSION})
63
64SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
65
66FIND_PACKAGE(Doxygen)
67FIND_PACKAGE(Ghostscript)
68
69SET(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.")
70SET(LEMON_ENABLE_ILOG YES CACHE STRING "Enable ILOG (CPLEX) solver backend.")
71SET(LEMON_ENABLE_COIN YES CACHE STRING "Enable COIN solver backend.")
72SET(LEMON_ENABLE_SOPLEX YES CACHE STRING "Enable SoPlex solver backend.")
73
74IF(LEMON_ENABLE_GLPK)
75  FIND_PACKAGE(GLPK 4.33)
76ENDIF(LEMON_ENABLE_GLPK)
77IF(LEMON_ENABLE_ILOG)
78  FIND_PACKAGE(ILOG)
79ENDIF(LEMON_ENABLE_ILOG)
80IF(LEMON_ENABLE_COIN)
81  FIND_PACKAGE(COIN)
82ENDIF(LEMON_ENABLE_COIN)
83IF(LEMON_ENABLE_SOPLEX)
84  FIND_PACKAGE(SOPLEX)
85ENDIF(LEMON_ENABLE_SOPLEX)
86
87IF(GLPK_FOUND)
88  SET(LEMON_HAVE_LP TRUE)
89  SET(LEMON_HAVE_MIP TRUE)
90  SET(LEMON_HAVE_GLPK TRUE)
91ENDIF(GLPK_FOUND)
92IF(ILOG_FOUND)
93  SET(LEMON_HAVE_LP TRUE)
94  SET(LEMON_HAVE_MIP TRUE)
95  SET(LEMON_HAVE_CPLEX TRUE)
96ENDIF(ILOG_FOUND)
97IF(COIN_FOUND)
98  SET(LEMON_HAVE_LP TRUE)
99  SET(LEMON_HAVE_MIP TRUE)
100  SET(LEMON_HAVE_CLP TRUE)
101  SET(LEMON_HAVE_CBC TRUE)
102ENDIF(COIN_FOUND)
103IF(SOPLEX_FOUND)
104  SET(LEMON_HAVE_LP TRUE)
105  SET(LEMON_HAVE_SOPLEX TRUE)
106ENDIF(SOPLEX_FOUND)
107
108IF(ILOG_FOUND)
109  SET(DEFAULT_LP "CPLEX")
110  SET(DEFAULT_MIP "CPLEX")
111ELSEIF(COIN_FOUND)
112  SET(DEFAULT_LP "CLP")
113  SET(DEFAULT_MIP "CBC")
114ELSEIF(GLPK_FOUND)
115  SET(DEFAULT_LP "GLPK")
116  SET(DEFAULT_MIP "GLPK")
117ELSEIF(SOPLEX_FOUND)
118  SET(DEFAULT_LP "SOPLEX")
119ENDIF()
120
121IF(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)
128ENDIF()
129IF(NOT LEMON_DEFAULT_MIP OR
130    (NOT ILOG_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CPLEX")) OR
131    (NOT COIN_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CBC")) OR
132    (NOT GLPK_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "GLPK")))
133  SET(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
134    "Default MIP solver backend (GLPK, CPLEX or CBC)" FORCE)
135ENDIF()
136
137
138IF(DEFINED ENV{LEMON_CXX_WARNING})
139  SET(CXX_WARNING $ENV{LEMON_CXX_WARNING})
140ELSE()
141  IF(CMAKE_COMPILER_IS_GNUCXX)
142    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")
143    SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
144    SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
145  ELSEIF(MSVC)
146    # This part is unnecessary 'casue the same is set by the lemon/core.h.
147    # Still keep it as an example.
148    SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
149    # Suppressed warnings:
150    # C4250: 'class1' : inherits 'class2::member' via dominance
151    # C4355: 'this' : used in base member initializer list
152    # C4503: 'function' : decorated name length exceeded, name was truncated
153    # C4800: 'type' : forcing value to bool 'true' or 'false'
154    #        (performance warning)
155    # C4996: 'function': was declared deprecated
156  ELSE()
157    SET(CXX_WARNING "-Wall")
158  ENDIF()
159ENDIF()
160SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
161
162SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
163
164IF(MSVC)
165  SET( CMAKE_CXX_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
166    "Flags used by the C++ compiler during maintainer builds."
167    )
168  SET( CMAKE_C_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
169    "Flags used by the C compiler during maintainer builds."
170    )
171  SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
172    "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
173    "Flags used for linking binaries during maintainer builds."
174    )
175  SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
176    "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
177    "Flags used by the shared libraries linker during maintainer builds."
178    )
179ELSE()
180  SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb -O0" CACHE STRING
181    "Flags used by the C++ compiler during maintainer builds."
182    )
183  SET( CMAKE_C_FLAGS_MAINTAINER "-Werror -O0" CACHE STRING
184    "Flags used by the C compiler during maintainer builds."
185    )
186  SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
187    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
188    "Flags used for linking binaries during maintainer builds."
189    )
190  SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
191    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
192    "Flags used by the shared libraries linker during maintainer builds."
193    )
194ENDIF()
195
196MARK_AS_ADVANCED(
197    CMAKE_CXX_FLAGS_MAINTAINER
198    CMAKE_C_FLAGS_MAINTAINER
199    CMAKE_EXE_LINKER_FLAGS_MAINTAINER
200    CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
201
202IF(CMAKE_CONFIGURATION_TYPES)
203  LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
204  LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
205  SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
206      "Add the configurations that we need"
207      FORCE)
208 endif()
209
210IF(NOT CMAKE_BUILD_TYPE)
211  SET(CMAKE_BUILD_TYPE "Release")
212ENDIF()
213
214SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
215    "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
216    FORCE )
217
218SET_DIRECTORY_PROPERTIES(PROPERTIES
219  COMPILE_DEFINITIONS_DEBUG "LEMON_ENABLE_DEBUG"
220  COMPILE_DEFINITIONS_MAINTAINER "LEMON_ENABLE_DEBUG"
221)
222
223INCLUDE(CheckTypeSize)
224CHECK_TYPE_SIZE("long long" LONG_LONG)
225SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
226
227INCLUDE(FindThreads)
228
229IF(NOT LEMON_THREADING)
230  IF(CMAKE_USE_PTHREADS_INIT)
231    SET(LEMON_THREADING "Pthread")
232  ELSEIF(CMAKE_USE_WIN32_THREADS_INIT)
233    SET(LEMON_THREADING "Win32")
234  ELSE()
235    SET(LEMON_THREADING "None")
236  ENDIF()
237ENDIF()
238
239SET( LEMON_THREADING "${LEMON_THREADING}" CACHE STRING
240  "Choose the threading library, options are: Pthread Win32 None."
241  FORCE )
242
243IF(LEMON_THREADING STREQUAL "Pthread")
244  SET(LEMON_USE_PTHREAD TRUE)
245ELSEIF(LEMON_THREADING STREQUAL "Win32")
246  SET(LEMON_USE_WIN32_THREADS TRUE)
247ENDIF()
248
249ENABLE_TESTING()
250
251IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
252  ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
253ELSE()
254  ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
255ENDIF()
256
257ADD_SUBDIRECTORY(lemon)
258IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
259  ADD_SUBDIRECTORY(contrib)
260  ADD_SUBDIRECTORY(demo)
261  ADD_SUBDIRECTORY(tools)
262  ADD_SUBDIRECTORY(doc)
263  ADD_SUBDIRECTORY(test)
264ENDIF()
265
266CONFIGURE_FILE(
267  ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
268  ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
269  @ONLY
270)
271IF(UNIX)
272  INSTALL(
273    FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
274    DESTINATION share/lemon/cmake
275  )
276ELSEIF(WIN32)
277  INSTALL(
278    FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
279    DESTINATION cmake
280  )
281ENDIF()
282
283CONFIGURE_FILE(
284  ${PROJECT_SOURCE_DIR}/cmake/version.cmake.in
285  ${PROJECT_BINARY_DIR}/cmake/version.cmake
286  @ONLY
287)
288
289SET(ARCHIVE_BASE_NAME ${CMAKE_PROJECT_NAME})
290STRING(TOLOWER ${ARCHIVE_BASE_NAME} ARCHIVE_BASE_NAME)
291SET(ARCHIVE_NAME ${ARCHIVE_BASE_NAME}-${PROJECT_VERSION})
292ADD_CUSTOM_TARGET(dist
293  COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
294  COMMAND hg archive ${ARCHIVE_NAME}
295  COMMAND cmake -E copy cmake/version.cmake ${ARCHIVE_NAME}/cmake/version.cmake
296  COMMAND tar -czf ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_NAME}
297  COMMAND zip -r ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.zip ${ARCHIVE_NAME}
298  COMMAND cmake -E copy_directory doc/html ${ARCHIVE_NAME}/doc/html
299  COMMAND tar -czf ${ARCHIVE_NAME}.tar.gz ${ARCHIVE_NAME}
300  COMMAND zip -r ${ARCHIVE_NAME}.zip ${ARCHIVE_NAME}
301  COMMAND cmake -E copy_directory doc/html ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
302  COMMAND tar -czf ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
303  COMMAND zip -r ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.zip ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
304  COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
305  COMMAND cmake -E remove_directory ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
306  DEPENDS html
307  WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
308
309# CPACK config (Basically for NSIS)
310IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
311  SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
312  SET(CPACK_PACKAGE_VENDOR "EGRES")
313  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
314    "LEMON - Library for Efficient Modeling and Optimization in Networks")
315  SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
316
317  SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
318
319  SET(CPACK_PACKAGE_INSTALL_DIRECTORY
320    "${PROJECT_NAME} ${PROJECT_VERSION}")
321  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
322    "${PROJECT_NAME} ${PROJECT_VERSION}")
323
324  SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
325
326  SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
327  SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
328  SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
329  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
330
331  SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
332    "C++ header files")
333  SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
334    "DLL and import library")
335  SET(CPACK_COMPONENT_BIN_DESCRIPTION
336    "Command line utilities")
337  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
338    "Doxygen generated documentation")
339
340  SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
341
342  SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
343  SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
344  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
345
346  SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
347    "Components needed to develop software using LEMON")
348  SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
349    "Documentation of LEMON")
350
351  SET(CPACK_ALL_INSTALL_TYPES Full Developer)
352
353  SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
354  SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
355  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
356
357  SET(CPACK_GENERATOR "NSIS")
358  SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
359  SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
360  #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
361  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
362  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
363  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
364  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
365  SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
366  SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
367    CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
368    ")
369  SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
370    !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
371    Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
372    ")
373
374  INCLUDE(CPack)
375ENDIF()
Note: See TracBrowser for help on using the repository browser.