-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
281 lines (263 loc) · 11.1 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-support")
set(PROJECT_NAME "CP(Rel+Tuple)")
set(PROJECT_VERSION "0.9.0")
project(${PROJECT_NAME})
##########################################################################
# Command line options
##########################################################################
option(UNIT_TEST "Build unit tests (requires boost unit_test)" NO)
option(BUILD_EXAMPLES "Build examples " NO)
##########################################################################
# Compiler information
##########################################################################
if(CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)
message(STATUS "GCC version ${GCC_VERSION}")
else()
message(FATAL_ERROR "GCC version 4.6 or greater is required")
endif()
else()
message(WARNING "Compiler: ${CMAKE_CXX_COMPILER_ID}")
message(WARNING "${CMAKE_COMPILER_IS_CLANGCXX}")
endif()
##########################################################################
# System information
##########################################################################
message(STATUS "Building for architecture: ${CMAKE_SYSTEM}")
if(CMAKE_SYSTEM MATCHES Darwin-10.6.0)
message(STATUS " Not fully tested platform")
endif()
message(STATUS "Void pointer size ${CMAKE_SIZEOF_VOID_P}")
include(CheckTypeSize)
check_type_size("void*" SIZEOF_VOID_P)
if(SIZEOF_VOID_P STREQUAL "")
message(SEND_ERROR "Failed to determine sizeof(void*)")
endif()
message(STATUS "Size of pointer to void (compiler): ${SIZEOF_VOID_P}")
if(SIZEOF_VOID_P MATCHES "8")
add_definitions(-fPIC)
endif()
##########################################################################
# Additional compiler flags
##########################################################################
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++0x" C0X_SUPPORT)
if(C0X_SUPPORT)
message(STATUS "CXX has c++0x support")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++0x")
else()
message(FATAL_ERROR "c++0x capable compiler is needed to build this project at this time")
endif()
check_cxx_compiler_flag(-Wall FLAG_WALL)
if(FLAG_WALL)
add_definitions(-Wall)
endif()
check_cxx_compiler_flag(-Wextra FLAG_WEXTRA)
if(FLAG_WEXTRA)
add_definitions(-Wextra)
endif()
check_cxx_compiler_flag(-fdiagnostics-show-option FLAG_DIAGNOSTIC)
if(FLAG_DIAGNOSTIC)
add_definitions(-fdiagnostics-show-option)
endif()
##########################################################################
# Cudd library
##########################################################################
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cudd-2.4.2/mtr")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cudd-2.4.2/epd")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cudd-2.4.2/st")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cudd-2.4.2/util")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cudd-2.4.2/cudd")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cudd-2.4.2/obj")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/cudd-2.4.2")
add_subdirectory(cudd-2.4.2)
##########################################################################
# Boost
##########################################################################
set(BOOST_COMPONENTS)
if(UNIT_TEST)
message(STATUS "Building unit tests")
list(APPEND BOOST_COMPONENTS unit_test_framework)
endif()
#add_definitions("-DBOOST_CHRONO_HEADER_ONLY")
list(APPEND BOOST_COMPONENTS system)
list(APPEND BOOST_COMPONENTS chrono)
find_package(Boost 1.47.0 COMPONENTS ${BOOST_COMPONENTS})
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
if(UNIT_TEST)
set(TEST_SOURCES tests/test-main.cpp)
set(TEST_LIBRARIES ${Boost_LIBRARIES})
endif()
else()
message(STATUS "Boost is needed to build this application")
message(STATUS "No compatible version of Boost was found.")
message(STATUS " To build this library you need at least version ${MIN_BOOST_REQUIRED}")
message(STATUS " please execute make BOOST_INSTALL.")
message(STATUS " and reconfigure with option -DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}")
include(ExternalProject)
## configure options used to build boost
set(BOOST_CONFIGURE_OPTIONS)
list(APPEND BOOST_CONFIGURE_OPTIONS "--prefix=${CMAKE_INSTALL_PREFIX}")
ExternalProject_Add(BOOST_INSTALL
SVN_REPOSITORY http://svn.boost.org/svn/boost/tags/release/Boost_1_47_0
SVN_USERNAME anonymous
SVN_PASSWORD [email protected]
CONFIGURE_COMMAND ./bootstrap.sh ${BOOST_CONFIGURE_OPTIONS}
BUILD_IN_SOURCE Yes
BUILD_COMMAND ./b2 -j${JOBS} INSTALL_COMMAND ./b2 -j${JOBS} install
)
endif()
##########################################################################
# Domain representation using BDDs
##########################################################################
include_directories(${CMAKE_SOURCE_DIR})
add_subdirectory(bdddomain)
##########################################################################
# JINC
##########################################################################
#if (BUILD_JINC)
# include(ExternalProject)
# ExternalProject_Add(JINC_INSTALL
# URL http://www.jossowski.de/projects/jinc/download/assets/jinc_2010-05-29_114104.tgz
# BUILD_IN_SOURCE Yes
# PATCH_COMMAND patch < ${CMAKE_SOURCE_DIR}/jinc.patch
# CONFIGURE_COMMAND ""
# BUILD_COMMAND make lib
# INSTALL_COMMAND ""
# )
#endif()
##########################################################################
# Gecode
##########################################################################
set(GECODE_BREL_SUPPORT NO)
find_package(Gecode)
if(GECODE_FOUND)
message(STATUS "Found Gecode version: ${GECODE_VERSION}")
message(STATUS "Using gecode version: ${GECODE_VERSION}")
set(MIN_GECODE_REQUIRED 3.6.0)
if((${GECODE_VERSION} VERSION_EQUAL ${MIN_GECODE_REQUIRED}) OR
(${GECODE_VERSION} VERSION_GREATER ${MIN_GECODE_REQUIRED}))
message(STATUS " Gecode library version is OK")
endif()
if(GECODE_CPREL_SUPPORT)
message(STATUS " Gecode was built with support for the CPRel type of variable.")
endif()
if(GECODE_CPTUPLE_SUPPORT)
message(STATUS " Gecode was built with support for the CPTuple type of variable.")
endif()
endif()
if(NOT GECODE_CPREL_SUPPORT OR NOT GECODE_CPTUPLE_SUPPORT)
message(STATUS "No compatible version of gecode was found.")
message(STATUS " To build the gecode you need please execute make GECODE_INSTALL.")
message(STATUS " and reconfigure with option -DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}")
include(ExternalProject)
## configure options used to build gecode
set(CONFIGURE_OPTIONS)
list(APPEND CONFIGURE_OPTIONS "CXXFLAGS=-DGECODE_HAS_VAR_DISPOSE")
list(APPEND CONFIGURE_OPTIONS "CFLAGS=-DGECODE_HAS_VAR_DISPOSE")
set(VIS_INPUTS "${CMAKE_SOURCE_DIR}/cprel/cprel.vis")
set(VIS_INPUTS "${VIS_INPUTS} ${CMAKE_SOURCE_DIR}/cptuple/cptuple.vis")
list(APPEND VIS_INPUTS ${EXTRA_VIS})
#list(APPEND CONFIGURE_OPTIONS "--with-vis=${CMAKE_SOURCE_DIR}/cprel/cprel.vis")
message(STATUS "VIS sources: ${VIS_INPUTS}")
list(APPEND CONFIGURE_OPTIONS "--with-vis=${VIS_INPUTS}")
list(APPEND CONFIGURE_OPTIONS "--with-architectures=${CMAKE_OSX_ARCHITECTURES}")
list(APPEND CONFIGURE_OPTIONS "--disable-examples")
list(APPEND CONFIGURE_OPTIONS "--prefix=${CMAKE_INSTALL_PREFIX}")
ExternalProject_Add(GECODE_INSTALL
SVN_REPOSITORY https://svn.gecode.org/svn/gecode/tags/release-3.6.0
SVN_USERNAME anonymous
SVN_PASSWORD [email protected]
CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} ${CONFIGURE_OPTIONS}
BUILD_IN_SOURCE Yes
BUILD_COMMAND make -j${JOBS} INSTALL_COMMAND make install
)
endif()
##########################################################################
# Gecode includes
##########################################################################
include_directories(${Gecode_INCLUDE_DIRS})
##########################################################################
# Relation constraint system
##########################################################################
add_subdirectory(cprel)
##########################################################################
# Tuple constraint system
##########################################################################
set(CPTUPLE_SRCS
cptuple/cptuple.hh
cptuple/var.hh
cptuple/varimp.cpp
cptuple/varimp.hh
cptuple/view.hh
# branchers
cptuple/branch/branch.cpp
)
#add_library(gecodecptuple ${CPTUPLE_SRCS})
#target_link_libraries(gecodecptuple bdddomain ${Gecode_LIBRARIES})
##########################################################################
# Uninstall
##########################################################################
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
##########################################################################
# Documentation
##########################################################################
find_package(Doxygen)
if(DOXYGEN_FOUND)
message(STATUS "Doxygen was found, to build the documentation run:
make html")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
set(DOC_SOURCE_CODE doc/declground-ex.cpp)
file(COPY ${DOC_SOURCE_CODE} DESTINATION ${CMAKE_BINARY_DIR})
add_custom_target(html
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif()
##########################################################################
# Unit test
##########################################################################
if(UNIT_TEST)
add_executable(unit-test ${TEST_SOURCES})
target_link_libraries(unit-test ${TEST_LIBRARIES})
message(STATUS "Test libraries ${TEST_LIBRARIES}")
endif()
##########################################################################
# Source distribution
##########################################################################
MACRO(TODAY RESULT)
if(WIN32)
execute_process(COMMAND "date" "/T" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" ${RESULT} ${${RESULT}})
elseif(UNIX)
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" ${RESULT} ${${RESULT}})
else()
message(SEND_ERROR "date not implemented")
set(${RESULT} 000000)
endif()
ENDMACRO()
TODAY(TIME_SUFFIX)
set(FILE_SUFFIX "${PROJECT_VERSION}-${TIME_SUFFIX}")
set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${FILE_SUFFIX})
add_custom_target(dist
git archive --format zip --output ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.zip --prefix=${ARCHIVE_NAME}/ master
COMMAND tar zcvf "${CMAKE_BINARY_DIR}/doc-${FILE_SUFFIX}.tgz" ${CMAKE_BINARY_DIR}/html
DEPENDS html
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
##########################################################################
# Executables
##########################################################################
if(BUILD_EXAMPLES)
add_subdirectory(tests EXCLUDE_FROM_ALL)
endif()