-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
162 lines (138 loc) · 5.47 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
cmake_minimum_required(VERSION 2.6)
project(cutsat CXX)
enable_testing()
# Default is release with debug info
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF()
# If not in debug build add NDEBUG by default
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
message(STATUS "Enabling tracing.")
set(CMAKE_CXX_FLAGS "-DCUTSAT_TRACING_ENABLED")
set(cutsat_TRACING ON)
endif()
# Add the target for the check
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
# If building a static binary
if(BUILD_STATIC_EXECUTABLES)
message(STATUS "Building static binaries.")
set(CMAKE_EXE_LINKER_FLAGS -static)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
set(CMAKE_SHARED_LIBRARY_C_FLAGS) # remove -fPIC
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS)
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # remove -rdynamic
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
# Maybe this works as well, haven't tried yet.
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
set(Boost_USE_STATIC_LIBS ON)
else()
message(STATUS "Building dynamic binaries.")
set(Boost_USE_STATIC_LIBS OFF)
set(ENABLE_UNIT_TESTS ON)
endif()
# Find the Google-perf tools libraries
set(ADDITIONAL_LIBRARIES "")
if(GOOGLE_PERFTOOLS)
find_library(TCMALLOC_LIBRARY tcmalloc)
if (TCMALLOC_LIBRARY)
message(STATUS "Adding additional: "${TCMALLOC_LIBRARY})
set(ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} ${TCMALLOC_LIBRARY})
endif()
find_library(PROFILER_LIBRARY profiler)
if (PROFILER_LIBRARY)
message(STATUS "Adding additional: "${PROFILER_LIBRARY})
set(ADDITIONAL_LIBRARIES ${ADDITIONAL_LIBRARIES} ${PROFILER_LIBRARY})
endif()
endif()
# Find the Boost libraries
set(Boost_USE_MULTITHREADED OFF)
if (cutsat_TRACING)
find_package(Boost 1.36.0 COMPONENTS program_options regex REQUIRED)
else()
find_package(Boost 1.36.0 COMPONENTS program_options REQUIRED)
endif()
include_directories(${Boost_INCLUDE_DIRS})
# For some reason we need to add these when building statically
if(BUILD_STATIC_EXECUTABLES)
# Find the zip libraries
find_library(Z_LIBRARY z)
if (Z_LIBRARY)
message(STATUS "libz: "${Z_LIBRARY})
else()
MESSAGE(FATAL_ERROR "Could not the z library")
endif()
find_library(BZ2_LIBRARY bz2)
if (BZ2_LIBRARY)
message(STATUS "libbz2: "${BZ2_LIBRARY})
else()
MESSAGE(FATAL_ERROR "Could not the bz2 library (sudo apt-get install libbz2-dev)")
endif()
# Find the pthreads library (for some reason boost needs it)
find_library(PTHREADS_LIBRARY pthread)
if (PTHREADS_LIBRARY)
message(STATUS "libpthread: "${PTHREADS_LIBRARY})
else()
MESSAGE(FATAL_ERROR "Could not the pthreads library")
endif()
# Find the GMP number library
find_library(GMP_LIBRARY gmp)
if (GMP_LIBRARY)
message(STATUS "GMP library: "${GMP_LIBRARY})
else()
MESSAGE(FATAL_ERROR "Could not the GMP number library (sudo apt-get libgmp3c2)")
endif()
else()
set(Z_LIBRARY "")
set(BZ2_LIBRARY "")
set(PTHREADS_LIBRARY "")
set(GMP_LIBRARY "")
endif()
# Find the CLN number library
find_path(CLN_INCLUDE_DIR cln/integer.h)
find_library(CLN_LIBRARY cln)
if (CLN_INCLUDE_DIR AND CLN_LIBRARY)
message(STATUS "CLN headers: "${CLN_INCLUDE_DIR})
message(STATUS "CLN library: "${CLN_LIBRARY})
include_directories(${CLN_INCLUDE_DIR})
else()
MESSAGE(FATAL_ERROR "Could not the CLN number library (sudo apt-get libcln-dev)")
endif()
# Find the CoinUtils library
find_path(COIN_INCLUDE_DIR coin/CoinMpsIO.hpp)
find_library(COIN_LIBRARY CoinUtils)
if (COIN_INCLUDE_DIR AND COIN_LIBRARY)
message(STATUS "CoinUtils headers: "${COIN_INCLUDE_DIR})
message(STATUS "CoinUtils library: "${COIN_LIBRARY})
include_directories(${COIN_INCLUDE_DIR})
else()
MESSAGE(FATAL_ERROR "Could not find the CoinUtils library (sudo apt-get coinor-libcoinutils-dev)")
endif()
# Add our sources to the include
include_directories(${cutsat_SOURCE_DIR}/src)
# Add all the tests
file(STRINGS test/regress/regression_tests.txt REGRESSION_TESTS)
# Configure the subdirectories
add_subdirectory(src)
# Add the documentation
add_subdirectory(doc)
# Configure the packaging
execute_process(COMMAND svn info COMMAND grep Revision COMMAND sed s/Revision:\ // OUTPUT_VARIABLE SVN_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE)
SET(CPACK_PACKAGE_NAME "cutsat")
set(CPACK_PACKAGE_CONTACT "Dejan Jovanovic <[email protected]>")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Cutsat is a feasibility solver for problems in linear integer arithmetic.")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
SET(CPACK_PACKAGE_VERSION_MAJOR "0")
SET(CPACK_PACKAGE_VERSION_MINOR "1")
SET(CPACK_PACKAGE_VERSION_PATCH "${SVN_REVISION}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "cutsat-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
SET(CPACK_SOURCE_GENERATOR "TGZ")
SET(CPACK_SOURCE_IGNORE_FILES "/build/;/CVS/;/\\\\.svn/;/\\\\.bzr/;/\\\\.hg/;/\\\\.git/;\\\\.swp$;\\\\.#;/#;.*~;cscope.*;.*tmp")
INCLUDE(CPack)
# Add the test project
if (NOT BUILD_STATIC_EXECUTABLES)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_TEST_DYN_LINK")
endif()
add_subdirectory(test)