-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
102 lines (86 loc) · 2.31 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
cmake_minimum_required(VERSION 3.21)
project(
LibSinex
VERSION 1.1.0
DESCRIPTION ""
LANGUAGES CXX
)
find_package(Eigen3 3.3 REQUIRED)
find_package(datetime 1 REQUIRED)
find_package(geodesy 1 REQUIRED)
# Enable clang-tidy option
option(ENABLE_CLANG_TIDY "Enable clang-tidy checks" OFF)
# Define an option for building tests (defaults to ON)
option(BUILD_TESTING "Enable building of tests" ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED On)
set(CMAKE_CXX_EXTENSIONS Off)
add_compile_options(-Wall
-Wextra
-Werror
-pedantic
-W
-Wshadow
$<$<CONFIG:Release>:-O2>
$<$<CONFIG:Release>:-march=native>
$<$<CONFIG:Debug>:-g>
$<$<CONFIG:Debug>:-pg>
$<$<CONFIG:Debug>:-Wdisabled-optimization>
)
add_compile_definitions(
$<$<CONFIG:Debug>:DEBUG>
)
# clang-tidy (targets that follow will be checked)
if(ENABLE_CLANG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=bugprone-*,\
clang-analyzer-*,\
cppcoreguidelines-*,\
llvm-*,\
modernize-*,\
performance-*,\
-modernize-use-trailing-return-type,\
-cppcoreguidelines-pro-bounds-pointer-arithmetic,\
-cppcoreguidelines-pro-bounds-constant-array-index,\
-cppcoreguidelines-pro-type-vararg")
message(STATUS "clang-tidy is enabled.")
else()
message(STATUS "clang-tidy is disabled. To enable it, use -DENABLE_CLANG_TIDY=ON.")
endif()
add_library(sinex)
target_include_directories(sinex PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include/sinex>
)
add_subdirectory(src)
# disable clang-tidy (targets that follow will not be checked)
set(CMAKE_CXX_CLANG_TIDY "")
# The tests
if(BUILD_TESTING)
# The tests
include(CTest)
add_subdirectory(test)
enable_testing()
endif()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/
DESTINATION include/sinex
)
install(TARGETS sinex
EXPORT sinexTargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(EXPORT sinexTargets
FILE sinexTargets.cmake
NAMESPACE dso::
DESTINATION lib/cmake
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"sinexConfigVersion.cmake"
VERSION ${sinex_version}
COMPATIBILITY AnyNewerVersion
)
install(FILES "sinexConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/sinexConfigVersion.cmake"
DESTINATION lib/cmake
)