-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
92 lines (76 loc) · 2.97 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
# See http://www.stablecoder.ca/2018/10/30/full-cmake-helper-suite.html
# See https://cliutils.gitlab.io/modern-cmake/chapters/basics/structure.html
cmake_minimum_required(VERSION 3.16) # Version that comes with Ubuntu 20.04.
project(gslcpp)
# Append ${PROJECT_SOURCE_DIR}/cmake to CMAKE_MODULE_PATH.
# Note that PROJECT_SOURCE_DIR is defined by the most recent project() command.
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(CodeCoverage)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_DEBUG 17)
set(CMAKE_CXX_STANDARD_REQUIRED_DEBUG ON)
set(CMAKE_CXX_EXTENSIONS_DEBUG OFF)
set(CMAKE_CXX_STANDARD_COVERAGE 17)
set(CMAKE_CXX_STANDARD_REQUIRED_COVERAGE ON)
set(CMAKE_CXX_EXTENSIONS_COVERAGE OFF)
set(CMAKE_BUILD_TYPE Coverage)
set(CMAKE_VERBOSE_MAKEFILE ON)
# This generates 'compile_commands.json' that Doxygen can use.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# clang-tidy
find_program (CLANG_TIDY_EXE NAMES "clang-tidy")
if(CLANG_TIDY_EXE)
message(STATUS "clang-tidy found!")
set(CMAKE_CXX_CLANG_TIDY
"${CLANG_TIDY_EXE};-format-style=file;-header-filter='${CMAKE_SOURCE_DIR}/*'"
CACHE STRING "" FORCE)
else()
message(STATUS "clang-tidy NOT found!")
set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # clear it
endif()
# eigen
#
find_package(Eigen3 REQUIRED)
message("-- Found Eigen-${Eigen3_VERSION}")
# TODO: Add this flag to the right declaration (not add_definitions!).
# This is needed in case the installed version of Eigen causes this warning to
# be emitted.
add_definitions(-Wno-deprecated-anon-enum-enum-conversion)
# doxygen
#
# doxygen-1.9.2 is not required here, but version below 1.9.2 will not document
# C++-20 concepts correctly.
find_package(Doxygen REQUIRED dot OPTIONAL_COMPONENTS dia mscgen)
#
# The function that is supposed to add a target for generating docs via
# `doxygen` has failed for me when I use Doxygen-1.9.3. It stubbornly makes
# `doxygen` look for `dot` under `/usr/sbin`!
#doxygen_add_docs(doc)
#
# Instead, manually add the target.
if(DOXYGEN_FOUND)
set(doxyfile ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
# This invokes 'doxygen', which runs at the top of the source-tree and puts
# output under 'html' for github-pages.
add_custom_target(doc
bash -c "\
rm -fr html;\
if ${DOXYGEN_EXECUTABLE} ${doxyfile}; then\
echo disabled: git add html;\
fi"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "generating API-documentation with Doxygen"
VERBATIM)
# This deletes the directory 'build/html' in case the Doxygen-generated files
# were to go there. This will end up doing nothing at the moment, though,
# because the Doxygen-generated files go to 'docs/html' relative to the
# top-level source-directory (for github-pages) according to 'Doxyfile'.
set_directory_properties(PROPERIES ADDITIONAL_MAKE_CLEAN_FILES html)
endif()
# gsl
#
find_package(GSL 2.7 REQUIRED)
add_subdirectory(examples)
add_subdirectory(test)