COIN-OR::LEMON - Graph Library

source: lemon/CMakeLists.txt

Last change on this file was 1416:f179aa1045a4, checked in by Peter Kovacs <kpeter@…>, 7 months ago

Suppress unused typdef warnings (#615)

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