COIN-OR::LEMON - Graph Library

source: glpk-cmake/CMakeLists.txt @ 2:4c8956a7bdf4

tip
Last change on this file since 2:4c8956a7bdf4 was 2:4c8956a7bdf4, checked in by Alpar Juttner <alpar@…>, 9 years ago

Set up CMAKE build environment

File size: 5.8 KB
Line 
1CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2
3SET(PROJECT_NAME "GLPK")
4PROJECT(${PROJECT_NAME})
5
6IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
7  INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
8ELSEIF(DEFINED ENV{GLPK_VERSION})
9  SET(GLPK_VERSION $ENV{GLPK_VERSION} CACHE STRING "GLPK version string.")
10ELSE()
11  EXECUTE_PROCESS(
12    COMMAND ${PYTHON_EXECUTABLE} ./scripts/chg-len.py
13    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
14    OUTPUT_VARIABLE HG_REVISION_PATH
15    ERROR_QUIET
16    OUTPUT_STRIP_TRAILING_WHITESPACE
17  )
18  EXECUTE_PROCESS(
19    COMMAND hg id -i
20    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
21    OUTPUT_VARIABLE HG_REVISION
22    ERROR_QUIET
23    OUTPUT_STRIP_TRAILING_WHITESPACE
24  )
25  IF(HG_REVISION STREQUAL "")
26    SET(HG_REVISION_ID "hg-tip")
27  ELSE()
28    IF(HG_REVISION_PATH STREQUAL "")
29      SET(HG_REVISION_ID ${HG_REVISION})
30    ELSE()
31      SET(HG_REVISION_ID ${HG_REVISION_PATH}.${HG_REVISION})
32    ENDIF()
33  ENDIF()
34  SET(GLPK_VERSION ${HG_REVISION_ID} CACHE STRING "GLPK version string.")
35ENDIF()
36
37SET(PROJECT_VERSION ${GLPK_VERSION})
38
39SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
40
41IF(DEFINED ENV{GLPK_C_WARNING})
42  SET(C_WARNING $ENV{GLPK_C_WARNING})
43ELSE()
44  IF(CMAKE_COMPILER_IS_GNUC)
45    SET(C_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")
46    SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
47    SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
48  ELSEIF(MSVC)
49    # SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
50    # # suppressed warnings:
51    # # C4250: 'class1' : inherits 'class2::member' via dominance
52    # # C4355: 'this' : used in base member initializer list
53    # # C4503: 'function' : decorated name length exceeded, name was truncated
54    # # C4800: 'type' : forcing value to bool 'true' or 'false'
55    # #        (performance warning)
56    # # C4996: 'function': was declared deprecated
57  ELSE()
58    SET(C_WARNING "-Wall -W")
59  ENDIF()
60ENDIF()
61SET(GLPK_C_WARNING_FLAGS ${C_WARNING} CACHE STRING "GLPK warning flags.")
62
63SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GLPK_C_WARNING_FLAGS}")
64
65SET(CMAKE_C_FLAGS_MAINTAINER "-ggdb" CACHE STRING
66    "Flags used by the C compiler during maintainer builds."
67    FORCE )
68SET(CMAKE_EXE_LINKER_FLAGS_MAINTAINER
69    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
70    "Flags used for linking binaries during maintainer builds."
71    FORCE )
72SET(CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
73    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
74    "Flags used by the shared libraries linker during maintainer builds."
75    FORCE )
76MARK_AS_ADVANCED(
77    CMAKE_C_FLAGS_MAINTAINER
78    CMAKE_EXE_LINKER_FLAGS_MAINTAINER
79    CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
80
81IF(CMAKE_CONFIGURATION_TYPES)
82  LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
83  LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
84  SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
85      "Add the configurations that we need"
86      FORCE)
87 endif()
88
89IF(NOT CMAKE_BUILD_TYPE)
90  SET(CMAKE_BUILD_TYPE "Release")
91ENDIF()
92
93SET(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
94  "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
95  FORCE )
96
97
98INCLUDE(CheckTypeSize)
99CHECK_TYPE_SIZE("long long" LONG_LONG)
100SET(GLPK_HAVE_LONG_LONG ${HAVE_LONG_LONG})
101
102ENABLE_TESTING()
103
104IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
105  ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
106ELSE()
107  ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
108ENDIF()
109
110INCLUDE_DIRECTORIES(
111  ${PROJECT_SOURCE_DIR}/include
112  ${PROJECT_SOURCE_DIR}/src
113)
114
115INCLUDE(FindLATEX)
116
117ADD_SUBDIRECTORY(src)
118ADD_SUBDIRECTORY(include)
119IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
120  ADD_SUBDIRECTORY(examples)
121  ADD_SUBDIRECTORY(doc)
122ENDIF()
123
124IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
125  SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
126  SET(CPACK_PACKAGE_VENDOR "GNU")
127  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
128    "GLPK - GNU Linear Programming Kit")
129  SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
130
131  SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
132
133  SET(CPACK_PACKAGE_INSTALL_DIRECTORY
134    "${PROJECT_NAME} ${PROJECT_VERSION}")
135  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
136    "${PROJECT_NAME} ${PROJECT_VERSION}")
137
138  INCLUDE(CPack)
139
140  CPACK_ADD_INSTALL_TYPE(Full)   
141 
142  CPACK_ADD_COMPONENT(headers
143    DISPLAY_NAME "C headers"
144    DESCRIPTION "C header files"
145    DEPENDS library
146    INSTALL_TYPES Full
147    )
148  CPACK_ADD_COMPONENT(library
149    DISPLAY_NAME "Libraries"
150    DESCRIPTION "DLL and import library"
151    INSTALL_TYPES Full
152    )
153
154  CPACK_ADD_COMPONENT(bin
155    DISPLAY_NAME "Command line utilities"
156    DESCRIPTION "Command line utilities"
157    INSTALL_TYPES Full
158    )
159
160  SET(CPACK_GENERATOR "NSIS")
161  # SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/glpk.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\\\\glpk.ico")
165  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
166  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.gnu.org\\\\software\\\\glpk")
167  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.gnu.org\\\\software\\\\glpk")
168  SET(CPACK_NSIS_CONTACT "mao@gnu.org")
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
177ENDIF()
Note: See TracBrowser for help on using the repository browser.