-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
54 lines (45 loc) · 1.92 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
cmake_minimum_required(VERSION 3.12)
project(image-transformer LANGUAGES C)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(CMAKE_C_COMPILER_ID STREQUAL GNU)
set(CMAKE_CONFIGURATION_TYPES Debug Release ASan LSan UBSan)
elseif(CMAKE_C_COMPILER_ID MATCHES Clang)
set(CMAKE_CONFIGURATION_TYPES Debug Release ASan LSan MSan UBSan)
elseif(MSVC)
set(CMAKE_CONFIGURATION_TYPES Debug Release ASan)
endif()
if(CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE IN_LIST CMAKE_CONFIGURATION_TYPES)
message(FATAL_ERROR "Unexpected build type ${CMAKE_BUILD_TYPE}, possible values: ${CMAKE_CONFIGURATION_TYPES}")
endif()
if(CMAKE_C_COMPILER_ID STREQUAL GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)
set(CMAKE_C_FLAGS "-std=c17 -pedantic -Wall -Werror -ggdb")
set(CMAKE_C_FLAGS_ASAN "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -fno-optimize-sibling-calls -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS_LSAN "${CMAKE_C_FLAGS_DEBUG} -fsanitize=leak")
set(CMAKE_C_FLAGS_MSAN "${CMAKE_C_FLAGS_DEBUG} -fsanitize=memory -fno-optimize-sibling-calls -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS_UBSAN "${CMAKE_C_FLAGS_DEBUG} -fsanitize=undefined")
elseif(MSVC)
set(CMAKE_C_FLAGS "/std:c17 /W4 /WX")
set(CMAKE_C_FLAGS_ASAN "${CMAKE_C_FLAGS_DEBUG} /fsanitize=address")
set(CMAKE_EXE_LINKER_FLAGS_ASAN "/debug /INCREMENTAL:NO")
endif()
if(WIN32)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif()
find_program(CLANG_TIDY clang-tidy)
message(STATUS "Clang-tidy: ${CLANG_TIDY}")
if(CLANG_TIDY)
file(STRINGS clang-tidy-checks.txt clang_tidy_checks)
list(JOIN clang_tidy_checks "," clang_tidy_checks_str)
set(CMAKE_C_CLANG_TIDY
${CLANG_TIDY}
-header-filter=${CMAKE_SOURCE_DIR}
-checks=${clang_tidy_checks_str}
-warnings-as-errors=*
)
endif()
add_subdirectory(solution)
option(BUILD_TESTING "Enable tests" ON)
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tester)
endif()