-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
50 lines (39 loc) · 1.41 KB
/
CMakeLists.txt
File metadata and controls
50 lines (39 loc) · 1.41 KB
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
cmake_minimum_required(VERSION 3.17)
project(cppsafe-tidy VERSION 0.1.0)
include(CTest)
enable_testing()
if(CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
endif()
# cpp options
if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"))
add_compile_options(-Wall)
add_compile_options(-Wextra)
add_compile_options(-Werror)
add_compile_options(-Wno-unused-parameter)
add_compile_options(-Wno-missing-field-initializers)
endif()
if((CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
endif()
# profile cpp options
if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"))
add_compile_options($<$<CONFIG:Debug>:-fsanitize=undefined>)
add_link_options($<$<CONFIG:Debug>:-fsanitize=undefined>)
message(STATUS "Enable ubsan")
endif()
# cpp std
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED On)
set(CMAKE_CXX_EXTENSIONS Off)
# Package finders
if(NOT LOCAL_CLANG)
message(FATAL "LOCAL_CLANG is not defined, please set it to llvm install dir")
endif()
set(Clang_DIR "${LOCAL_CLANG}/lib/cmake/clang/")
find_package(Clang REQUIRED CONFIG)
file(GLOB SRCS src/*.cpp)
add_library(cppsafe-tidy MODULE ${SRCS})
target_compile_options(cppsafe-tidy PRIVATE -fno-rtti)
target_include_directories(cppsafe-tidy PRIVATE
${CLANG_INCLUDE_DIRS})
target_link_libraries(cppsafe-tidy PRIVATE clangTidyUtils)