forked from quixdb/squash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
191 lines (158 loc) · 6.65 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
####
## Version information
####
# Library version
#
# This should be incremented with every release. See semver.org.
set (SQUASH_VERSION_MAJOR 0)
set (SQUASH_VERSION_MINOR 8)
set (SQUASH_VERSION_REVISION 0)
# API version.
#
# This will go in the pkg-config and shared library names. Should
# only be changed if the API breaks backwards compatibility.
set (SQUASH_VERSION_API "0.8")
# ABI version
#
# Rules from § 11.4: Library Versioning of the autobook
# https://www.sourceware.org/autobook/autobook/autobook_61.html
#
# 1) If you have changed any of the sources for this library, the
# revision number must be incremented. This is a new revision of
# the current interface.
# 2) If the interface has changed, then current must be incremented,
# and revision reset to ‘0’. This is the first revision of a new
# interface.
# 3) If the new interface is a superset of the previous interface
# (that is, if the previous interface has not been broken by the
# changes in this new release), then age must be incremented. This
# release is backwards compatible with the previous release.
# 4) If the new interface has removed elements with respect to the
# previous interface, then you have broken backward compatibility
# and age must be reset to ‘0’. This release has a new, but
# backwards incompatible interface.
#
# Conveniently, this also matches semantic versioning for the most
# part (API changes are a bit more complicated since we change the
# library and pkg-config names and can reset these to whatever we
# want, but we don't *have* to.
set (SQUASH_SOVERSION_CURRENT ${SQUASH_VERSION_MAJOR})
set (SQUASH_SOVERSION_REVISION ${SQUASH_VERSION_MINOR})
set (SQUASH_SOVERSION_AGE ${SQUASH_VERSION_REVISION})
cmake_minimum_required (VERSION 2.8.7)
if (CMAKE_VERSION VERSION_GREATER 3.1.2)
cmake_policy (SET CMP0054 NEW)
endif ()
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
project (squash)
include (CTest)
include (GNUInstallDirs)
include (ExtraWarningFlags)
include (CheckFunctionExists)
include (CheckIncludeFile)
include (AddCompilerFlags)
enable_testing ()
if (ENABLE_COVERAGE STREQUAL "yes")
include (CodeCoverage)
endif ()
if (MSVC)
global_add_compiler_flags (
/wd4996)
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
endif (MSVC)
set (PACKAGE_NAME Squash)
set (SQUASH_TOP_SRCDIR "${PROJECT_SOURCE_DIR}")
set (SQUASH_TOP_BUILDDIR "${PROJECT_BINARY_DIR}")
set (SQUASH_VERSION_MAJOR 0)
set (SQUASH_VERSION_MINOR 8)
set (SQUASH_VERSION_REVISION 0)
set (SQUASH_VERSION_API "0.8")
set (PACKAGE_VERSION ${SQUASH_VERSION_MAJOR}.${SQUASH_VERSION_MINOR}.${SQUASH_VERSION_REVISION})
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/squash/tinycthread/source/tinycthread.c")
message (FATAL_ERROR "It looks like you don't have submodules checked out.
If you are compiling from git, make sure to run `git submodule update --init --recursive' or call autogen.sh, which will invoke that command for you.
If you are compiling from a tarball, make sure you don't use the ones automatically generated by GitHub—they don't include submodules and are, therefore, completely broken. Official releases are on https://github.com/quixdb/squash/releases and are the ones labeled \"squash-x.y.z.tar.bz2\", not \"Source code\". GitHub is aware of the issue.")
endif ()
set(CPACK_PACKAGE_VERSION_MAJOR ${SQUASH_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${SQUASH_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${SQUASH_VERSION_REVISION})
set(CPACK_SOURCE_GENERATOR "TBZ2")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_SOURCE_IGNORE_FILES
"/autogen.sh;/build/;.git;.gitmodules;.gitignore;~$;${CPACK_SOURCE_IGNORE_FILES}")
include (CPack)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
include_directories ("${PROJECT_BINARY_DIR}")
include_directories ("${PROJECT_SOURCE_DIR}")
if ("${PLUGIN_DIRECTORY}" STREQUAL "")
set (PLUGIN_DIRECTORY ${CMAKE_INSTALL_FULL_LIBDIR}/squash/${SQUASH_VERSION_API}/plugins)
endif ()
if ("${SEARCH_PATH}" STREQUAL "")
set (SEARCH_PATH "${PLUGIN_DIRECTORY}")
endif ()
set (SQUASH_PLUGIN_DIRECTORY "${PLUGIN_DIRECTORY}")
set (SQUASH_SEARCH_PATH "${SEARCH_PATH}")
configure_file (
"${PROJECT_SOURCE_DIR}/squash.pc.in"
"${PROJECT_BINARY_DIR}/squash-${SQUASH_VERSION_API}.pc"
@ONLY)
set (squash_enabled_plugins "" CACHE INTERNAL "enabled plugins" FORCE)
# This only works with gcc/clang at the moment.
function (squash_set_target_visibility target visibility)
set (flag "-fvisibility=${visibility}")
string (REGEX REPLACE "[-=]+" "_" abbrev_test_name "${flag}")
CHECK_C_COMPILER_FLAG ("-fvisibility=${visibility}" "CFLAG_${abbrev_test_name}")
CHECK_CXX_COMPILER_FLAG ("-fvisibility=${visibility}" "CXXFLAG_${abbrev_test_name}")
if (CFLAG_${abbrev_test_name})
target_add_compiler_flags (${target} ${flag})
set_property (TARGET ${target} APPEND PROPERTY LINKER_FLAGS "${flag}")
endif ()
unset (flag)
unset (abbrev_test_name)
endfunction (squash_set_target_visibility)
if (CMAKE_BUILD_TYPE MATCHES "Release")
global_add_compiler_flags (-O3 -flto -DNDEBUG)
elseif (NOT ENABLE_COVERAGE STREQUAL "yes")
global_add_compiler_flags (-g -O2)
endif ()
####
## Compatibility with older CMake
##
## This will probably be removed when Ubuntu bumps their LTS server
## release (and Travis upgrades).
####
if (${CMAKE_VERSION} VERSION_LESS 2.8.11)
function (target_include_directories)
foreach (argn RANGE 2 ${ARGC})
if (${argn} LESS ${ARGC})
include_directories (${ARGV${argn}})
endif ()
endforeach ()
endfunction ()
endif ()
if (ENABLE_COVERAGE STREQUAL "yes")
if (CMAKE_BUILD_TYPE MATCHES "Release")
message (WARNING "Coverage anaysis requires a debugging build")
endif ()
endif ()
function (squash_target_add_coverage target)
if (ENABLE_COVERAGE STREQUAL "yes")
set_property (TARGET ${target} APPEND_STRING PROPERTY COMPILE_FLAGS " -fprofile-arcs")
set_property (TARGET ${target} APPEND_STRING PROPERTY COMPILE_FLAGS " -ftest-coverage")
set_property (TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS " -fprofile-arcs")
set_property (TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS " -ftest-coverage")
endif ()
endfunction (squash_target_add_coverage)
add_subdirectory (squash)
add_subdirectory (plugins)
add_subdirectory (utils)
add_subdirectory (docs)
add_subdirectory (examples)
add_subdirectory (bindings)
add_subdirectory (tests)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squash-${SQUASH_VERSION_API}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
if (ENABLE_COVERAGE STREQUAL "yes")
SETUP_TARGET_FOR_COVERAGE(coverage ctest coverage)
endif ()