-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
136 lines (116 loc) · 4.19 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
cmake_minimum_required(VERSION 2.8)
project (minisatid)
# The version number.
set (MinisatID_VERSION_MAJOR 3)
set (MinisatID_VERSION_MINOR 12)
set (MinisatID_VERSION_PATCH 0)
set (MinisatID_VERSION "${MinisatID_VERSION_MAJOR}.${MinisatID_VERSION_MINOR}.${MinisatID_VERSION_PATCH}")
execute_process (COMMAND "git" "rev-parse" "HEAD"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE minisatid_git_result
ERROR_VARIABLE minisatid_git_error
OUTPUT_VARIABLE minisatid_git_hash)
if (minisatid_git_result OR minisatid_git_error)
set (minisatid_git_hash "\"Source not version controlled.\"")
endif (minisatid_git_result OR minisatid_git_error)
string(STRIP ${minisatid_git_hash} minisatid_git_hash)
ENABLE_TESTING()
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
### Rpath handling
include(cmake/rpathhandling.cmake)
### Target properties helper
include(cmake/settargetproperties.cmake)
macro(addToCXX ARGUMENT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGUMENT}")
endmacro()
option(GPERF "Enable profiling support with google-perftools" OFF)
if(GPERF)
addToCXX("-fno-omit-frame-pointer")
endif()
OPTION(BUILDTESTS "Run the gtest tests" ON)
OPTION(GMP "Enable gmp support" OFF)
if(GMP)
addToCXX("-D GMP")
find_package(GMP)
if(GMP_FOUND)
include_directories(${GMP_INCLUDE_DIR})
set(LIBS ${LIBS} ${GMP_LIBRARIES})
set(LIBS ${LIBS} ${GMPXX_LIBRARIES})
else()
message(FATAL_ERROR "GMP library not found")
endif()
else()
addToCXX("-D NO_GMP")
message("WARNING: this IntegerType may not be suitable for some input file. Consider using GMP")
endif()
addToCXX("-static-libstdc++")
### 32 bits
option(32BITS "Compile for 32 bit architectures" OFF)
if(32BITS)
addToCXX("-m32")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
endif()
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build.")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "StaticRelease" "StaticDebug" "Profile" "DebugProfile")
if(${CMAKE_BUILD_TYPE} MATCHES "^Profile$")
addToCXX("-DNDEBUG -O3 -pg ")
endif()
if(${CMAKE_BUILD_TYPE} MATCHES "^DebugProfile$")
addToCXX("-O0 -ggdb -DDEBUG -pg ")
endif()
if(${CMAKE_BUILD_TYPE} MATCHES "^StaticRelease$")
addToCXX("-DNDEBUG -O3 ")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNDEBUG ")
set(BUILD_SHARED_LIBS OFF)
set(BUILD_MINISATID_STATIC ON)
endif()
if(${CMAKE_BUILD_TYPE} MATCHES "^Release$")
addToCXX("-O3 -DNDEBUG ")
set(BUILD_SHARED_LIBS ON)
handleRPATHUnix()
endif()
if(${CMAKE_BUILD_TYPE} MATCHES "^StaticDebug$")
addToCXX("-O0 -ggdb -DDEBUG -D_GLIBCXX_DEBUG ")
set(BUILD_SHARED_LIBS OFF) # to allow stepping
set(BUILD_IDP_STATIC ON) # to allow stepping
endif()
if(${CMAKE_BUILD_TYPE} MATCHES "^Debug$")
addToCXX("-O0 -ggdb -DDEBUG -D_GLIBCXX_DEBUG ")
set(BUILD_SHARED_LIBS ON)
handleRPATHUnix()
endif()
MESSAGE(STATUS "build minisatid shared ${BUILD_SHARED_LIBS}")
if(BUILD_MINISATID_STATIC)
MESSAGE(STATUS "build minisatid allstatic")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D MINISATIDGITHASH=\\\"${minisatid_git_hash}\\\" ")
MESSAGE(STATUS "MinisatID CXX flags: ")
MESSAGE(STATUS "${CMAKE_CXX_FLAGS}")
add_subdirectory(lib/pbsolver)
if(BUILDTESTS)
add_subdirectory(lib/gtest-1.6.0)
endif()
add_subdirectory(src)
add_subdirectory(tests)
#Allow packing
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING.LESSER")
set(CPACK_PACKAGE_VERSION_MAJOR ${MinisatID_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${MinisatID_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${MinisatID_VERSION_PATCH})
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_SOURCE_GENERATOR TGZ)
# The following components are regex's to match anywhere (unless anchored)
# in absolute path + filename to find files or directories to be excluded
# from source tarball.
# note: escape char is \\\\
set(CPACK_SOURCE_IGNORE_FILES
"^${PROJECT_SOURCE_DIR}/\\\\..*"
".*/.git/"
"^${PROJECT_SOURCE_DIR}/builds/"
"^${PROJECT_SOURCE_DIR}/build/"
)
message(STATUS "minisatid project source dir: ${PROJECT_SOURCE_DIR}")
message(STATUS "source package name: ${CPACK_SOURCE_PACKAGE_FILE_NAME}")
message(STATUS "source package ignores: ${CPACK_SOURCE_IGNORE_FILES}")
include(CPack)