1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
3 SET(PROJECT_NAME "GLPK")
4 PROJECT(${PROJECT_NAME})
6 IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
7 INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
8 ELSEIF(DEFINED ENV{GLPK_VERSION})
9 SET(GLPK_VERSION $ENV{GLPK_VERSION} CACHE STRING "GLPK version string.")
12 COMMAND ${PYTHON_EXECUTABLE} ./scripts/chg-len.py
13 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
14 OUTPUT_VARIABLE HG_REVISION_PATH
16 OUTPUT_STRIP_TRAILING_WHITESPACE
20 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
21 OUTPUT_VARIABLE HG_REVISION
23 OUTPUT_STRIP_TRAILING_WHITESPACE
25 IF(HG_REVISION STREQUAL "")
26 SET(HG_REVISION_ID "hg-tip")
28 IF(HG_REVISION_PATH STREQUAL "")
29 SET(HG_REVISION_ID ${HG_REVISION})
31 SET(HG_REVISION_ID ${HG_REVISION_PATH}.${HG_REVISION})
34 SET(GLPK_VERSION ${HG_REVISION_ID} CACHE STRING "GLPK version string.")
37 SET(PROJECT_VERSION ${GLPK_VERSION})
39 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
41 IF(DEFINED ENV{GLPK_C_WARNING})
42 SET(C_WARNING $ENV{GLPK_C_WARNING})
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")
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
58 SET(C_WARNING "-Wall -W")
61 SET(GLPK_C_WARNING_FLAGS ${C_WARNING} CACHE STRING "GLPK warning flags.")
63 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GLPK_C_WARNING_FLAGS}")
65 SET(CMAKE_C_FLAGS_MAINTAINER "-ggdb" CACHE STRING
66 "Flags used by the C compiler during maintainer builds."
68 SET(CMAKE_EXE_LINKER_FLAGS_MAINTAINER
69 "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
70 "Flags used for linking binaries during maintainer builds."
72 SET(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."
77 CMAKE_C_FLAGS_MAINTAINER
78 CMAKE_EXE_LINKER_FLAGS_MAINTAINER
79 CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
81 IF(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"
89 IF(NOT CMAKE_BUILD_TYPE)
90 SET(CMAKE_BUILD_TYPE "Release")
93 SET(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."
98 INCLUDE(CheckTypeSize)
99 CHECK_TYPE_SIZE("long long" LONG_LONG)
100 SET(GLPK_HAVE_LONG_LONG ${HAVE_LONG_LONG})
104 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
105 ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
107 ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
111 ${PROJECT_SOURCE_DIR}/include
112 ${PROJECT_SOURCE_DIR}/src
117 ADD_SUBDIRECTORY(src)
118 ADD_SUBDIRECTORY(include)
119 IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
120 ADD_SUBDIRECTORY(examples)
121 ADD_SUBDIRECTORY(doc)
124 IF(${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")
131 SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
133 SET(CPACK_PACKAGE_INSTALL_DIRECTORY
134 "${PROJECT_NAME} ${PROJECT_VERSION}")
135 SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
136 "${PROJECT_NAME} ${PROJECT_VERSION}")
140 CPACK_ADD_INSTALL_TYPE(Full)
142 CPACK_ADD_COMPONENT(headers
143 DISPLAY_NAME "C headers"
144 DESCRIPTION "C header files"
148 CPACK_ADD_COMPONENT(library
149 DISPLAY_NAME "Libraries"
150 DESCRIPTION "DLL and import library"
154 CPACK_ADD_COMPONENT(bin
155 DISPLAY_NAME "Command line utilities"
156 DESCRIPTION "Command line utilities"
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\\\"
172 # SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
173 # !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
174 # Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"