-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
116 lines (98 loc) · 4.09 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
cmake_minimum_required(VERSION 3.18...3.23)
# Not ideal to use this global variable, but necessary to make sure
# that tooling and projects use the same version
set(CMAKE_CXX_STANDARD 17) # TODO might change
# strongly encouraged to enable this globally to avoid conflicts between
# -Wpedantic being enabled and -std=c++20 and -std=gnu++20 for example
# when compiling with PCH enabled
set(CMAKE_CXX_EXTENSIONS OFF)
# Note: by default ENABLE_DEVELOPER_MODE is True
# This means that all analysis (sanitizers, static analysis)
# is enabled and all warnings are treated as errors
# if you want to switch this behavior, change TRUE to FALSE
set(ENABLE_DEVELOPER_MODE
TRUE
CACHE BOOL "Enable 'developer mode'")
# Change this to false if you want to disable warnings_as_errors in developer mode
set(OPT_WARNINGS_AS_ERRORS_DEVELOPER_DEFAULT TRUE)
# Add project_options v0.20.0
# https://github.com/cpp-best-practices/project_options
include(FetchContent)
FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.20.0.zip)
FetchContent_MakeAvailable(_project_options)
include(${_project_options_SOURCE_DIR}/Index.cmake)
# Set the project name and language
project(
pentadsolver
VERSION 0.0.1
DESCRIPTION ""
LANGUAGES CXX)
# This variable is set by project() in CMake 3.21+
string(
COMPARE EQUAL
"${CMAKE_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}"
PROJECT_IS_TOP_LEVEL)
get_property(BUILDING_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(BUILDING_MULTI_CONFIG)
if(NOT CMAKE_BUILD_TYPE)
# Make sure that all supported configuration types have their
# associated conan packages available. You can reduce this
# list to only the configuration types you use, but only if one
# is not forced-set on the command line for VS
message(TRACE "Setting up multi-config build types")
set(CMAKE_CONFIGURATION_TYPES
Debug
Release
RelWithDebInfo
MinSizeRel
CACHE STRING "Enabled build types" FORCE)
else()
message(TRACE "User chose a specific build type, so we are using that")
set(CMAKE_CONFIGURATION_TYPES
${CMAKE_BUILD_TYPE}
CACHE STRING "Enabled build types" FORCE)
endif()
endif()
include(${_project_options_SOURCE_DIR}/src/DynamicProjectOptions.cmake)
# defaulted_project_options sets recommended defaults and provides user and developer
# modes and full GUI support for choosing options at configure time
# for more flexibility, look into project_options() macro
# Any default can be overridden
# set(<feature_name>_DEFAULT <value>) - set default for both user and developer modes
# set(<feature_name>_DEVELOPER_DEFAULT <value>) - set default for developer mode
# set(<feature_name>_USER_DEFAULT <value>) - set default for user mode
# Initialize project_options variable related to this project
# This overwrites `project_options` and sets `project_warnings`
# uncomment the options to enable them:
dynamic_project_options(
ENABLE_CONAN
# CONAN_OPTIONS # Extra options to pass to conan
# MSVC_WARNINGS # Override the defaults for the MSVC warnings
# CLANG_WARNINGS # Override the defaults for the CLANG warnings
# GCC_WARNINGS # Override the defaults for the GCC warnings
CPPCHECK_OPTIONS
--enable=style,performance,warning,portability
--inline-suppr
# We cannot act on a bug/missing feature of cppcheck
--suppress=cppcheckError
--suppress=internalAstError
# if a file does not have an internalAstError, we get an unmatchedSuppression error
--suppress=unmatchedSuppression
--suppress=passedByValue
--suppress=syntaxError
--inconclusive)
target_compile_features(project_options INTERFACE cxx_std_${CMAKE_CXX_STANDARD})
add_library(${PROJECT_NAME}::project_options INTERFACE IMPORTED)
add_library(${PROJECT_NAME}::project_warnings INTERFACE IMPORTED)
find_package(OpenMP REQUIRED)
# Adding the src:
add_subdirectory(src)
add_subdirectory(benchmarks)
# Adding the tests:
option(ENABLE_TESTING "Enable the tests" ${PROJECT_IS_TOP_LEVEL})
if(ENABLE_TESTING)
enable_testing()
message(AUTHOR_WARNING "Building Tests.")
add_subdirectory(test)
endif()