COIN-OR::LEMON - Graph Library

source: lemon/CMakeLists.txt @ 995:659ba4805a48

Last change on this file since 995:659ba4805a48 was 995:659ba4805a48, checked in by Alpar Juttner <alpar@…>, 14 years ago

Make CMAKE config more consistent with configure.ac (#390)

  • CMAKE_BUILD_TYPE is Release by deafult
  • The same set of warnings are used when compiling with gcc
File size: 6.1 KB
Line 
1CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2
3SET(PROJECT_NAME "LEMON")
4PROJECT(${PROJECT_NAME})
5
6INCLUDE(FindPythonInterp)
7
8IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
9  INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
10ELSEIF(DEFINED ENV{LEMON_VERSION})
11  SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
12ELSE()
13  EXECUTE_PROCESS(
14    COMMAND ${PYTHON_EXECUTABLE} ./scripts/chg-len.py
15    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
16    OUTPUT_VARIABLE HG_REVISION_PATH
17    ERROR_QUIET
18    OUTPUT_STRIP_TRAILING_WHITESPACE
19  )
20  EXECUTE_PROCESS(
21    COMMAND hg id -i
22    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
23    OUTPUT_VARIABLE HG_REVISION
24    ERROR_QUIET
25    OUTPUT_STRIP_TRAILING_WHITESPACE
26  )
27  IF(HG_REVISION STREQUAL "")
28    SET(HG_REVISION_ID "hg-tip")
29  ELSE()
30    IF(HG_REVISION_PATH STREQUAL "")
31      SET(HG_REVISION_ID ${HG_REVISION})
32    ELSE()
33      SET(HG_REVISION_ID ${HG_REVISION_PATH}.${HG_REVISION})
34    ENDIF()
35  ENDIF()
36  SET(LEMON_VERSION ${HG_REVISION_ID} CACHE STRING "LEMON version string.")
37ENDIF()
38
39SET(PROJECT_VERSION ${LEMON_VERSION})
40
41SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
42
43FIND_PACKAGE(Doxygen)
44FIND_PACKAGE(Ghostscript)
45FIND_PACKAGE(GLPK 4.33)
46FIND_PACKAGE(CPLEX)
47FIND_PACKAGE(COIN)
48
49IF(DEFINED ENV{LEMON_CXX_WARNING})
50  SET(CXX_WARNING $ENV{LEMON_CXX_WARNING})
51ELSE()
52  IF(CMAKE_COMPILER_IS_GNUCXX)
53    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 -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas")
54    SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
55    SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
56  ELSEIF(MSVC)
57    # This part is unnecessary 'casue the same is set by the lemon/core.h.
58    # Still keep it as an example.
59    SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
60    # Suppressed warnings:
61    # C4250: 'class1' : inherits 'class2::member' via dominance
62    # C4355: 'this' : used in base member initializer list
63    # C4503: 'function' : decorated name length exceeded, name was truncated
64    # C4800: 'type' : forcing value to bool 'true' or 'false'
65    #        (performance warning)
66    # C4996: 'function': was declared deprecated
67  ELSE()
68    SET(CXX_WARNING "-Wall -W")
69  ENDIF()
70ENDIF()
71SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
72
73SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
74
75IF(NOT CMAKE_BUILD_TYPE)
76  SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
77ENDIF()
78
79
80INCLUDE(CheckTypeSize)
81CHECK_TYPE_SIZE("long long" LONG_LONG)
82SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
83
84ENABLE_TESTING()
85
86ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
87
88ADD_SUBDIRECTORY(lemon)
89IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
90  ADD_SUBDIRECTORY(demo)
91  ADD_SUBDIRECTORY(tools)
92  ADD_SUBDIRECTORY(doc)
93  ADD_SUBDIRECTORY(test)
94ENDIF()
95
96CONFIGURE_FILE(
97  ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
98  ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
99  @ONLY
100)
101IF(UNIX)
102  INSTALL(
103    FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
104    DESTINATION share/lemon/cmake
105  )
106ELSEIF(WIN32)
107  INSTALL(
108    FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
109    DESTINATION cmake
110  )
111ENDIF()
112
113IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR} AND WIN32)
114  SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
115  SET(CPACK_PACKAGE_VENDOR "EGRES")
116  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
117    "LEMON - Library for Efficient Modeling and Optimization in Networks")
118  SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
119
120  SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
121
122  SET(CPACK_PACKAGE_INSTALL_DIRECTORY
123    "${PROJECT_NAME} ${PROJECT_VERSION}")
124  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
125    "${PROJECT_NAME} ${PROJECT_VERSION}")
126
127  SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
128
129  SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
130  SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
131  SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
132  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
133
134  SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
135    "C++ header files")
136  SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
137    "DLL and import library")
138  SET(CPACK_COMPONENT_BIN_DESCRIPTION
139    "Command line utilities")
140  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
141    "Doxygen generated documentation")
142
143  SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
144
145  SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
146  SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
147  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
148
149  SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
150    "Components needed to develop software using LEMON")
151  SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
152    "Documentation of LEMON")
153
154  SET(CPACK_ALL_INSTALL_TYPES Full Developer)
155
156  SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
157  SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
158  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
159
160  SET(CPACK_GENERATOR "NSIS")
161  SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
162  SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
163  #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
164  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
165  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
166  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
167  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
168  SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
169  SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
170    CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
171    ")
172  SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
173    !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
174    Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
175    ")
176
177  INCLUDE(CPack)
178ENDIF()
Note: See TracBrowser for help on using the repository browser.