1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) |
---|
2 | |
---|
3 | SET(PROJECT_NAME "LEMON") |
---|
4 | PROJECT(${PROJECT_NAME}) |
---|
5 | |
---|
6 | INCLUDE(FindPythonInterp) |
---|
7 | INCLUDE(FindWget) |
---|
8 | |
---|
9 | IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake) |
---|
10 | INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake) |
---|
11 | ELSEIF(DEFINED ENV{LEMON_VERSION}) |
---|
12 | SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.") |
---|
13 | ELSE() |
---|
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.") |
---|
56 | ENDIF() |
---|
57 | |
---|
58 | SET(PROJECT_VERSION ${LEMON_VERSION}) |
---|
59 | |
---|
60 | SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) |
---|
61 | |
---|
62 | FIND_PACKAGE(Doxygen) |
---|
63 | FIND_PACKAGE(Ghostscript) |
---|
64 | FIND_PACKAGE(GLPK 4.33) |
---|
65 | FIND_PACKAGE(CPLEX) |
---|
66 | FIND_PACKAGE(COIN) |
---|
67 | |
---|
68 | IF(DEFINED ENV{LEMON_CXX_WARNING}) |
---|
69 | SET(CXX_WARNING $ENV{LEMON_CXX_WARNING}) |
---|
70 | ELSE() |
---|
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() |
---|
89 | ENDIF() |
---|
90 | SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.") |
---|
91 | |
---|
92 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}") |
---|
93 | |
---|
94 | SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb -O0" CACHE STRING |
---|
95 | "Flags used by the C++ compiler during maintainer builds." |
---|
96 | FORCE ) |
---|
97 | SET( CMAKE_C_FLAGS_MAINTAINER "-Werror -O0" CACHE STRING |
---|
98 | "Flags used by the C compiler during maintainer builds." |
---|
99 | FORCE ) |
---|
100 | SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER |
---|
101 | "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING |
---|
102 | "Flags used for linking binaries during maintainer builds." |
---|
103 | FORCE ) |
---|
104 | SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER |
---|
105 | "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING |
---|
106 | "Flags used by the shared libraries linker during maintainer builds." |
---|
107 | FORCE ) |
---|
108 | MARK_AS_ADVANCED( |
---|
109 | CMAKE_CXX_FLAGS_MAINTAINER |
---|
110 | CMAKE_C_FLAGS_MAINTAINER |
---|
111 | CMAKE_EXE_LINKER_FLAGS_MAINTAINER |
---|
112 | CMAKE_SHARED_LINKER_FLAGS_MAINTAINER ) |
---|
113 | |
---|
114 | IF(CMAKE_CONFIGURATION_TYPES) |
---|
115 | LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer) |
---|
116 | LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES) |
---|
117 | SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING |
---|
118 | "Add the configurations that we need" |
---|
119 | FORCE) |
---|
120 | endif() |
---|
121 | |
---|
122 | IF(NOT CMAKE_BUILD_TYPE) |
---|
123 | SET(CMAKE_BUILD_TYPE "Release") |
---|
124 | ENDIF() |
---|
125 | |
---|
126 | SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING |
---|
127 | "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer." |
---|
128 | FORCE ) |
---|
129 | |
---|
130 | |
---|
131 | INCLUDE(CheckTypeSize) |
---|
132 | CHECK_TYPE_SIZE("long long" LONG_LONG) |
---|
133 | SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG}) |
---|
134 | |
---|
135 | INCLUDE(FindThreads) |
---|
136 | |
---|
137 | IF(NOT LEMON_THREADING) |
---|
138 | IF(CMAKE_USE_PTHREADS_INIT) |
---|
139 | SET(LEMON_THREADING "Pthread") |
---|
140 | ELSEIF(CMAKE_USE_WIN32_THREADS_INIT) |
---|
141 | SET(LEMON_THREADING "Win32") |
---|
142 | ELSE() |
---|
143 | SET(LEMON_THREADING "None") |
---|
144 | ENDIF() |
---|
145 | ENDIF() |
---|
146 | |
---|
147 | SET( LEMON_THREADING "${LEMON_THREADING}" CACHE STRING |
---|
148 | "Choose the threading library, options are: Pthread Win32 None." |
---|
149 | FORCE ) |
---|
150 | |
---|
151 | IF(LEMON_THREADING STREQUAL "Pthread") |
---|
152 | SET(LEMON_USE_PTHREAD TRUE) |
---|
153 | ELSEIF(LEMON_THREADING STREQUAL "Win32") |
---|
154 | SET(LEMON_USE_WIN32_THREADS TRUE) |
---|
155 | ENDIF() |
---|
156 | |
---|
157 | ENABLE_TESTING() |
---|
158 | |
---|
159 | IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") |
---|
160 | ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND}) |
---|
161 | ELSE() |
---|
162 | ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND}) |
---|
163 | ENDIF() |
---|
164 | |
---|
165 | ADD_SUBDIRECTORY(lemon) |
---|
166 | IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) |
---|
167 | ADD_SUBDIRECTORY(contrib) |
---|
168 | ADD_SUBDIRECTORY(demo) |
---|
169 | ADD_SUBDIRECTORY(tools) |
---|
170 | ADD_SUBDIRECTORY(doc) |
---|
171 | ADD_SUBDIRECTORY(test) |
---|
172 | ENDIF() |
---|
173 | |
---|
174 | CONFIGURE_FILE( |
---|
175 | ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in |
---|
176 | ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake |
---|
177 | @ONLY |
---|
178 | ) |
---|
179 | IF(UNIX) |
---|
180 | INSTALL( |
---|
181 | FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake |
---|
182 | DESTINATION share/lemon/cmake |
---|
183 | ) |
---|
184 | ELSEIF(WIN32) |
---|
185 | INSTALL( |
---|
186 | FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake |
---|
187 | DESTINATION cmake |
---|
188 | ) |
---|
189 | ENDIF() |
---|
190 | |
---|
191 | IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) |
---|
192 | SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) |
---|
193 | SET(CPACK_PACKAGE_VENDOR "EGRES") |
---|
194 | SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY |
---|
195 | "LEMON - Library for Efficient Modeling and Optimization in Networks") |
---|
196 | SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") |
---|
197 | |
---|
198 | SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) |
---|
199 | |
---|
200 | SET(CPACK_PACKAGE_INSTALL_DIRECTORY |
---|
201 | "${PROJECT_NAME} ${PROJECT_VERSION}") |
---|
202 | SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY |
---|
203 | "${PROJECT_NAME} ${PROJECT_VERSION}") |
---|
204 | |
---|
205 | SET(CPACK_COMPONENTS_ALL headers library html_documentation bin) |
---|
206 | |
---|
207 | SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers") |
---|
208 | SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library") |
---|
209 | SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities") |
---|
210 | SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation") |
---|
211 | |
---|
212 | SET(CPACK_COMPONENT_HEADERS_DESCRIPTION |
---|
213 | "C++ header files") |
---|
214 | SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION |
---|
215 | "DLL and import library") |
---|
216 | SET(CPACK_COMPONENT_BIN_DESCRIPTION |
---|
217 | "Command line utilities") |
---|
218 | SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION |
---|
219 | "Doxygen generated documentation") |
---|
220 | |
---|
221 | SET(CPACK_COMPONENT_HEADERS_DEPENDS library) |
---|
222 | |
---|
223 | SET(CPACK_COMPONENT_HEADERS_GROUP "Development") |
---|
224 | SET(CPACK_COMPONENT_LIBRARY_GROUP "Development") |
---|
225 | SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation") |
---|
226 | |
---|
227 | SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION |
---|
228 | "Components needed to develop software using LEMON") |
---|
229 | SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION |
---|
230 | "Documentation of LEMON") |
---|
231 | |
---|
232 | SET(CPACK_ALL_INSTALL_TYPES Full Developer) |
---|
233 | |
---|
234 | SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full) |
---|
235 | SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full) |
---|
236 | SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full) |
---|
237 | |
---|
238 | SET(CPACK_GENERATOR "NSIS") |
---|
239 | SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico") |
---|
240 | SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico") |
---|
241 | #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp") |
---|
242 | SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico") |
---|
243 | SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}") |
---|
244 | SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu") |
---|
245 | SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu") |
---|
246 | SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu") |
---|
247 | SET(CPACK_NSIS_CREATE_ICONS_EXTRA " |
---|
248 | CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\" |
---|
249 | ") |
---|
250 | SET(CPACK_NSIS_DELETE_ICONS_EXTRA " |
---|
251 | !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP |
---|
252 | Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\" |
---|
253 | ") |
---|
254 | |
---|
255 | INCLUDE(CPack) |
---|
256 | ENDIF() |
---|