-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathCMakeLists.txt
133 lines (112 loc) · 3.87 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
cmake_minimum_required(VERSION 3.6)
# project settings
project(mxx LANGUAGES CXX)
#### options
OPTION(MXX_BUILD_TESTS "Build tests" ON)
OPTION(MXX_BUILD_UTILS "Build utilities and benchmarks" OFF)
OPTION(MXX_ENABLE_COVERAGE "Enable code coverage reporting" OFF)
OPTION(MXX_TRAVIS "Travis build (turns on tests and coverage)" OFF)
OPTION(MXX_FAKE_BIG_MPI "Enable a fake, tiny bigMPI threshold (used during CI testing)" OFF)
#### add mxx as header library
add_library(mxx INTERFACE)
target_compile_features(mxx INTERFACE cxx_std_11)
target_include_directories(mxx INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
#### load MPI
find_package(MPI REQUIRED)
if (MPI_FOUND)
target_link_libraries(mxx INTERFACE ${MPI_CXX_LIBRARIES})
target_include_directories(mxx INTERFACE ${MPI_CXX_INCLUDE_PATH})
else (MPI_FOUND)
message(SEND_ERROR "This application cannot compile without MPI")
endif (MPI_FOUND)
#### cxx-prettyprint
target_include_directories(mxx INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ext>
$<INSTALL_INTERFACE:include/mxx/ext>)
#### Installation
install(DIRECTORY include/mxx/ DESTINATION include/mxx)
install(DIRECTORY ext/ DESTINATION include/mxx FILES_MATCHING PATTERN "*.hpp")
include(CMakePackageConfigHelpers)
install(TARGETS mxx
EXPORT mxxTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
export(EXPORT mxxTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/mxx/mxxTargets.cmake"
NAMESPACE mxx::
)
set(ConfigPackageLocation lib/cmake/mxx)
configure_package_config_file(cmake/mxxConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/mxx/mxxConfig.cmake"
INSTALL_DESTINATION "${ConfigPackageLocation}"
)
install(EXPORT mxxTargets
FILE
mxxTargets.cmake
NAMESPACE
mxx::
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
cmake/mxxConfig.cmake
DESTINATION
${ConfigPackageLocation}
COMPONENT
Devel
)
#### Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
message(STATUS "Found Doxygen")
message(STATUS " use `make doc` to build documentation")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile @ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)
#### Travis
if(MXX_TRAVIS)
# enable coverage
SET(MXX_BUILD_TESTS ON CACHE BOOL "Build tests on travis" FORCE)
SET(MXX_ENABLE_COVERAGE ON CACHE BOOL "Enable code coverage reporting" FORCE)
# set debug build
SET(CMAKE_BUILD_TYPE Debug)
endif(MXX_TRAVIS)
#### Test Coverage
if(MXX_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.
#
# additionally: disable inlining for more precise coverage
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fno-stack-protector -fno-inline -fno-inline-small-functions -fno-default-inline")
endif(MXX_ENABLE_COVERAGE)
#### Fake BIG MPI
# for testing of BigMPI functions on travis or other small RAM build systems
if (MXX_FAKE_BIG_MPI)
add_definitions(-DMXX_MAX_INT=3)
endif(MXX_FAKE_BIG_MPI)
###### 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)
# build mxx enabled gtest module
add_subdirectory(gtest)
# build tests
if(MXX_BUILD_TESTS)
add_subdirectory(test)
endif(MXX_BUILD_TESTS)
# build utils and benchmarks
if (MXX_BUILD_UTILS)
add_subdirectory(src)
endif (MXX_BUILD_UTILS)