COIN-OR::LEMON - Graph Library

source: lemon-main/CMakeLists.txt @ 1062:caf16813b1e8

Last change on this file since 1062:caf16813b1e8 was 1062:caf16813b1e8, checked in by Alpar Juttner <alpar@…>, 7 years ago

Better CPLEX discovery (#446)

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