-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
106 lines (94 loc) · 2.95 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
cmake_minimum_required(VERSION 3.5.1)
project(mammut VERSION 1.2.0)
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_C_STANDARD 11)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules/")
###########
# Options #
###########
option (ENABLE_TESTS "Enables testing" OFF)
option (ENABLE_CPPCHECK "Enables cppcheck checks" OFF)
option (ENABLE_CODECOV "Enables code coverage reports" OFF)
option (ENABLE_CLANGFORMAT "Enables clang-format formatting" OFF)
option (ENABLE_DOCS "Enables documentation generation" OFF)
option (ENABLE_PYTHON "Enables Python binding generation generation" OFF)
option (ENABLE_REMOTE "Enables remote calls support" OFF)
option (ENABLE_PAPI "Enables PAPI support" OFF)
option (ENABLE_RAPLCAP "Enables raplcap support" ON)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
SET(CMAKE_CXX_FLAGS_RELEASE "-Wall -finline-functions -O3")
SET(CMAKE_CXX_FLAGS_DEBUG "-Wall -finline-functions -O0 -g")
# This must be the first thing done, since COVERAGE_COMPILER_FLAGS must be used by all the targets
###########
# codecov #
###########
if (ENABLE_CODECOV)
set (CMAKE_BUILD_TYPE Debug)
if (NOT ENABLE_TESTS)
message (FATAL_ERROR "You need to define -DENABLE_TESTS=ON when you use -DENABLE_CODECOV=ON")
endif()
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
endif (ENABLE_CODECOV)
########
# PAPI #
########
if (ENABLE_PAPI)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITH_PAPI")
endif (ENABLE_PAPI)
###########
# Library #
###########
add_subdirectory(src)
add_subdirectory(demo)
############
# cppcheck #
############
if (ENABLE_CPPCHECK)
include(cmake/cppcheck.cmake)
endif (ENABLE_CPPCHECK)
###########
# Testing #
###########
if (ENABLE_TESTS)
enable_testing()
add_subdirectory(test)
endif (ENABLE_TESTS)
###########
# codecov #
###########
if (ENABLE_CODECOV)
set(COVERAGE_GCOVR_EXCLUDES 'src/external/*' 'test/*' 'demo/*')
SETUP_TARGET_FOR_COVERAGE_GCOVR_XML(
NAME coverage
EXECUTABLE make test
DEPENDENCIES mammut
)
endif (ENABLE_CODECOV)
################
# clang-format #
################
if (ENABLE_CLANGFORMAT)
include(cmake/clang_format.cmake)
endif (ENABLE_CLANGFORMAT)
#######
# Doc #
#######
if (ENABLE_DOCS)
find_package(Doxygen)
if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile)
# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message("Doxygen build started")
add_custom_target(docs
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message(WARNING "Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif (ENABLE_DOCS)