-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCMakeLists.txt
288 lines (241 loc) · 8.73 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
281
282
283
284
285
286
287
288
project(crave)
cmake_minimum_required(VERSION 2.8.9)
set(${PROJECT_NAME}_CONFIG_DIR "share/${PROJECT_NAME}" CACHE PATH
"where to install CMake and Make Config files")
############################################################
## CRAVE settings ##
############################################################
option(CRAVE_ENABLE_EXPERIMENTAL "enable experimental extensions of CRAVE" on)
option(CRAVE_ENABLE_TESTS "build tests" on)
option(CRAVE_BUILD_EXAMPLES "build and test examples" on)
### C++11 required
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
add_definitions(-std=c++11)
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} does not support -std=c++11. Please use a different C++ compiler.")
endif()
### packages
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(Boost_NO_BOOST_CMAKE true)
set(Boost_NO_SYSTEM_PATHS true)
if (WIN32)
if (MSVC AND (NOT MSVC_VERSION LESS 1900))
find_package(Boost REQUIRED)
else()
message(FATAL_ERROR "CRAVE Windows build only supports Visual Studio C++ 2015 or newer version")
endif()
else()
find_package(Boost REQUIRED COMPONENTS system filesystem)
endif()
find_package(GLOG)
if (GLOG_FOUND)
add_definitions(-DCRAVE_HAVE_GLOG)
endif()
if (WITH_SYSTEMC)
find_package(SystemC REQUIRED)
find_package(Threads REQUIRED)
endif()
add_subdirectory(metaSMT)
list(INSERT CMAKE_PREFIX_PATH 0 "${CMAKE_BINARY_DIR}")
find_package(metaSMT REQUIRED)
string(REPLACE " " ";" metaSMT_DEFINITIONS "${metaSMT_CXXFLAGS}")
add_definitions(${metaSMT_DEFINITIONS})
### FIXME this should not be necessary, reuse variables set by metaSMT instead
if ( WIN32 )
message(STATUS "CRAVE Windows build: explicitly disable all solvers except z3!" )
set(metaSMT_USE_SWORD off)
set(metaSMT_USE_Boolector off)
set(metaSMT_USE_STP off)
set(metaSMT_USE_CVC4 off)
set(metaSMT_USE_YICES2 off)
set(metaSMT_USE_CUDD off)
set(metaSMT_USE_MiniSat off)
set(metaSMT_USE_picosat off)
set(metaSMT_USE_lingeling off)
set(metaSMT_USE_Aiger off)
set(metaSMT_USE_CW off)
endif()
### SMT solvers
if (metaSMT_USE_Boolector)
add_definitions(-DmetaSMT_USE_Boolector)
endif()
if (metaSMT_USE_CVC4)
add_definitions(-DmetaSMT_USE_CVC4)
endif()
if (metaSMT_USE_STP)
add_definitions(-DmetaSMT_USE_STP)
endif()
if (metaSMT_USE_SWORD)
add_definitions(-DmetaSMT_USE_SWORD)
endif()
if (metaSMT_USE_YICES2)
add_definitions(-DmetaSMT_USE_YICES2)
endif()
if (metaSMT_USE_Z3)
add_definitions(-DmetaSMT_USE_Z3)
endif()
### BDD
if (metaSMT_USE_CUDD)
add_definitions(-DmetaSMT_USE_CUDD)
endif()
if (WITH_SYSTEMC)
add_definitions(-DWITH_SYSTEMC)
endif()
### includes
include_directories(${metaSMT_INCLUDE_DIR})
include_directories(${Boost_INCLUDE_DIRS})
if (GLOG_FOUND)
include_directories(${GLOG_INCLUDE_DIRS})
endif()
if(SystemC_FOUND)
include_directories(${SystemC_INCLUDE_DIR})
endif(SystemC_FOUND)
### libs
SET(ALL_EXTERNAL_LIBS "")
if (GLOG_FOUND)
LIST(APPEND ALL_EXTERNAL_LIBS ${GLOG_LIBRARIES})
endif()
if(SystemC_FOUND)
LIST(APPEND ALL_EXTERNAL_LIBS ${SystemC_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
endif(SystemC_FOUND)
if( Boost_FILESYSTEM_FOUND )
list(APPEND ALL_EXTERNAL_LIBS ${Boost_FILESYSTEM_LIBRARY})
endif()
if( Boost_SYSTEM_FOUND )
list(APPEND ALL_EXTERNAL_LIBS ${Boost_SYSTEM_LIBRARY})
endif()
### build
add_subdirectory(src)
### tests
if (CRAVE_ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
if (CRAVE_BUILD_EXAMPLES)
enable_testing()
add_subdirectory(examples)
endif()
### config
set(${PROJECT_NAME}_LIBS ${CMAKE_INSTALL_PREFIX}/lib/lib${PROJECT_NAME}.a ${ALL_EXTERNAL_LIBS} ${metaSMT_LIBRARIES})
GET_DIRECTORY_PROPERTY(ALL_INCLUDES INCLUDE_DIRECTORIES)
set(${PROJECT_NAME}_INCLUDE ${CMAKE_INSTALL_PREFIX}/include ${ALL_INCLUDES})
GET_DIRECTORY_PROPERTY(${PROJECT_NAME}_DEFS COMPILE_DEFINITIONS)
## create CRAVE CMake config file
file(WRITE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
"set(${PROJECT_NAME}_FOUND 1)
set(${PROJECT_NAME}_INCLUDE_DIR ${${PROJECT_NAME}_INCLUDE})
set(${PROJECT_NAME}_LIBRARIES ${${PROJECT_NAME}_LIBS})
set(${PROJECT_NAME}_DEFINITIONS ${${PROJECT_NAME}_DEFS})
")
## create CRAVE py config file
file(WRITE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.py
"${PROJECT_NAME}_INCLUDES = '${${PROJECT_NAME}_INCLUDE}'
${PROJECT_NAME}_LIBRARIES = '${${PROJECT_NAME}_LIBS}'
${PROJECT_NAME}_DEFINITIONS = '${${PROJECT_NAME}_DEFS}'
")
string(REPLACE ";" " " ${PROJECT_NAME}_MLIBS "${${PROJECT_NAME}_LIBS}")
string(REPLACE ";" " -I" ${PROJECT_NAME}_MINCLUDE "${${PROJECT_NAME}_INCLUDE}")
string(REPLACE ";" " -D" ${PROJECT_NAME}_MDEFS "${${PROJECT_NAME}_DEFS}")
set(${PROJECT_NAME}_RPATH "")
foreach(LIBPATH ${${PROJECT_NAME}_LIBS})
get_filename_component(LIBDIR ${LIBPATH} PATH)
LIST(APPEND ${PROJECT_NAME}_RPATH -Wl,-rpath=${LIBDIR})
endforeach()
string(REPLACE ";" " " ${PROJECT_NAME}_RPATH "${${PROJECT_NAME}_RPATH}")
## create CRAVE CMake make config file
file(WRITE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.makefile
"${PROJECT_NAME}_INCLUDES := ${${PROJECT_NAME}_MINCLUDE}
${PROJECT_NAME}_DEFINITIONS := ${${PROJECT_NAME}_MDEFS}
${PROJECT_NAME}_LIBRARIES := ${${PROJECT_NAME}_MLIBS}
${PROJECT_NAME}_RPATH := ${${PROJECT_NAME}_RPATH}
")
## create CRAVE pkgconfig make config file
string(REPLACE ";" " " ${PROJECT_NAME}_MLIBS "${${PROJECT_NAME}_LIBS}")
file(WRITE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc
"Name: ${PROJECT_NAME}
Description: Constraint Solver library
Cflags: -I${${PROJECT_NAME}_MINCLUDE} -D${${PROJECT_NAME}_MDEFS}
Libs: ${${PROJECT_NAME}_MLIBS}
")
## install
INSTALL( FILES
${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.py
${PROJECT_BINARY_DIR}/${PROJECT_NAME}.makefile
DESTINATION ${${PROJECT_NAME}_CONFIG_DIR})
INSTALL( FILES
${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc
DESTINATION lib/pkgconfig/)
############################################################
## CPack settings ##
############################################################
option( CRAVE_BUNDLE_PACKAGE_BY_DATE "use date for package name instead of git description" on)
if( CRAVE_BUNDLE_PACKAGE_BY_DATE )
# CPack version numbers for release tarball name.
if(UNIX)
execute_process(COMMAND date +%Y OUTPUT_VARIABLE CPACK_PACKAGE_VERSION_MAJOR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND date +%m OUTPUT_VARIABLE CPACK_PACKAGE_VERSION_MINOR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND date +%d OUTPUT_VARIABLE CPACK_PACKAGE_VERSION_PATCH ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
set(VERSION "${CPACK_PACKAGE_VERSION_MAJOR}-${CPACK_PACKAGE_VERSION_MINOR}-${CPACK_PACKAGE_VERSION_PATCH}")
else()
include(cmake/get_git_version.cmake)
get_git_version(VERSION crave-bundle-)
endif()
message(STATUS "crave-bundle VERSION: ${VERSION}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CRAVE - Constrained RAndom Verification Environment for SystemC/C++")
set(CPACK_PACKAGE_VENDOR "CRAVE development team")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
set(CPACK_GENERATOR TGZ)
set(
CPACK_SOURCE_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${VERSION}"
CACHE INTERNAL "tarball basename"
)
set(CPACK_SOURCE_GENERATOR TGZ)
set(CPACK_SOURCE_IGNORE_FILES
"/\\\\.git"
"/deps.*/"
"/build.*/"
"/root.*/"
"/crave-doxygen/"
"/logs/"
"crave.cfg"
"jenkins_run_crave_check.sh"
"~$"
"^${PROJECT_SOURCE_DIR}/scripts/"
"^${PROJECT_SOURCE_DIR}/crave.*"
"^${PROJECT_SOURCE_DIR}/.*.user"
)
if (NOT CRAVE_ENABLE_EXPERIMENTAL)
LIST(APPEND CPACK_SOURCE_IGNORE_FILES "crave/experimental/" "lib/experimental")
endif()
include(CPack)
############################################################
## CMAKE flags settings ##
############################################################
SET( CMAKE_CXX_FLAGS_PROFILING "-O0 -g -Wall -Wextra -pedantic --coverage" CACHE STRING
"Flags used by the C++ compiler during maintainer builds."
FORCE )
SET( CMAKE_C_FLAGS_PROFILING "${CMAKE_CXX_FLAGS_PROFILING}" CACHE STRING
"Flags used by the C compiler during maintainer builds."
FORCE )
SET( CMAKE_EXE_LINKER_FLAGS_PROFILING
"--coverage" CACHE STRING
"Flags used for linking binaries during maintainer builds."
FORCE )
SET( CMAKE_SHARED_LINKER_FLAGS_PROFILING
" --coverage" CACHE STRING
"Flags used by the shared libraries linker during maintainer builds."
FORCE )
MARK_AS_ADVANCED(
CMAKE_CXX_FLAGS_PROFILING
CMAKE_C_FLAGS_PROFILING
CMAKE_EXE_LINKER_FLAGS_PROFILING
CMAKE_SHARED_LINKER_FLAGS_PROFILING )
# Update the documentation string of CMAKE_BUILD_TYPE for GUIs
SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Profiling."
FORCE )