-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
66 lines (50 loc) · 2.16 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
cmake_minimum_required(VERSION 2.6)
# project settings
project(psac)
#### Options
OPTION(PSAC_BUILD_EXES "Build all psac executables (command line tools & benchmark scripts)" ON)
OPTION(PSAC_BUILD_TESTS "Build unit tests" ON)
OPTION(PSAC_ENABLE_COVERAGE "Enable code coverage reporting" OFF)
##### General Compilation Settings
# Initialize CXXFLAGS.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wuninitialized --std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -march=native")
### Test Coverage
if(PSAC_ENABLE_COVERAGE)
# turn off stack protection for gcov coverage, because the stack protector shows
# up as a never taken branch, and thus turns any last statement in a function
# with a stack procetor into a partially covered statement.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fno-stack-protector")
endif(PSAC_ENABLE_COVERAGE)
###### Executable and Libraries
# Save libs and executables in the same place
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
## psac header library
add_library(psaclib INTERFACE)
target_include_directories(psaclib INTERFACE include)
## psac dependencies
# load mxx and its gtest wrapper
set(MXX_BUILD_TESTS OFF CACHE BOOL "disable building mxx tests" FORCE)
add_subdirectory(ext/mxx)
target_link_libraries(psaclib INTERFACE mxx)
# include libdivsufsort (with 64bit support but without examples)
set(BUILD_DIVSUFSORT64 ON CACHE BOOL "enables divsufsort 64bit functions" FORCE)
set(BUILD_EXAMPLES OFF CACHE BOOL "enables divsufsort examples" FORCE)
add_subdirectory(ext/libdivsufsort)
# prettyprint
target_include_directories(psaclib INTERFACE ext/cxx-prettyprint)
# divsufsort (integrate into psac as `psac-dss-lib`)
add_library(psac-dss-lib INTERFACE)
target_link_libraries(psac-dss-lib INTERFACE psaclib)
target_include_directories(psac-dss-lib INTERFACE ${libdivsufsort_BINARY_DIR}/include)
target_link_libraries(psac-dss-lib INTERFACE divsufsort divsufsort64)
## build executables
if(PSAC_BUILD_EXES)
add_subdirectory(src)
endif()
# build tests
if (PSAC_BUILD_TESTS)
add_subdirectory(test)
endif()