-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
62 lines (50 loc) · 2.05 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
cmake_minimum_required(VERSION 3.22)
# Set up project name
set(PROJECT_NAME prefix_tree)
project(${PROJECT_NAME})
# Set up C++ version to be used, globally
set(CMAKE_CXX_STANDARD 17)
# Set compiler warnings
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF)
# I use GCC, on Linux
set(GCC_WARNINGS " \
-Wall -Wextra -Wshadow -Wnon-virtual-dtor \
-pedantic -Wold-style-cast -Wcast-align \
-Woverloaded-virtual -Wpedantic -Wconversion \
-Wsign-conversion -Wmisleading-indentation \
-Wduplicated-cond -Wduplicated-branches \
-Wlogical-op -Wnull-dereference \
-Wuseless-cast -Wdouble-promotion \
-Wformat=2 -std=c++17") # for some reason CMake global flag is not working
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_WARNINGS}")
if (WARNINGS_AS_ERRORS)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Werror ") # Append to previous warnings
endif ()
# Static Analyzers (Thanks to https://github.com/euripedesrocha/ctdsp/blob/master/cmake/StaticAnalyzers.cmake)
option(ENABLE_CPPCHECK "Enable static analysis with cppcheck" ON)
option(ENABLE_CLANG_TIDY "Enable static analysis with clang-tidy" ON)
if (ENABLE_CPPCHECK)
find_program(CPPCHECK cppcheck)
if (CPPCHECK)
set(CMAKE_CXX_CPPCHECK ${CPPCHECK} --suppress=missingInclude --enable=all
--inline-suppr --inconclusive -i ${CMAKE_SOURCE_DIR}/imgui/lib)
else ()
message(SEND_ERROR "cppcheck requested but executable not found")
endif ()
endif ()
if (ENABLE_CLANG_TIDY)
find_program(CLANGTIDY clang-tidy)
if (CLANGTIDY)
set(CMAKE_CXX_CLANG_TIDY ${CLANGTIDY} -extra-arg=-Wno-unknown-warning-option)
else ()
message(SEND_ERROR "clang-tidy requested but executable not found")
endif ()
endif ()
# Address and UB sanitizers
option(ENABLE_SANITIZERS "Enable address and undefined behavior sanitizers" ON)
if (ENABLE_SANITIZERS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined")
endif ()
add_executable(${PROJECT_NAME}
usage_example.cpp)
add_subdirectory(tests)