-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
69 lines (64 loc) · 3.22 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
cmake_minimum_required(VERSION 3.20)
project(ZenUnitAndMetalMock)
include(${CMAKE_SOURCE_DIR}/CMakeMacros.cmake)
if(${CMAKE_SIZEOF_VOID_P} STREQUAL "4")
message("Notice: ZenUnit and MetalMock are not supported on 32-bit Windows")
endif()
if(UNIX)
set(CMAKE_CXX_FLAGS "-std=c++2b -Wall -Wextra -pedantic -Werror -pthread -Wno-unused-variable")
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
append(CMAKE_CXX_FLAGS "-Wno-gnu-zero-variadic-macro-arguments")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
append(CMAKE_CXX_FLAGS "-fuse-ld=lld -Wno-dangling-reference")
endif()
if(FastLinuxDebugBuildMode)
replace(CMAKE_CXX_FLAGS_DEBUG "-g" "")
message("FastLinuxDebugBuildMode enabled: -g removed")
elseif(FastLinuxReleaseBuildMode)
replace(CMAKE_CXX_FLAGS_RELEASE "-O3" "")
message("FastLinuxReleaseBuildMode enabled: -O3 removed")
endif()
if(ClangTidyMode)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
message("ClangTidyMode enabled: CMAKE_EXPORT_COMPILE_COMMANDS set to ON")
elseif(ClangUndefinedBehaviorSanitizerMode)
append(CMAKE_CXX_FLAGS "-fsanitize=undefined")
message("ClangUndefinedBehaviorSanitizerMode enabled: -fsanitize=undefined appended to CMAKE_CXX_FLAGS")
elseif(ClangAddressSanitizerMode)
append(CMAKE_CXX_FLAGS "-fsanitize=address")
message("ClangAddressSanitizerMode enabled: -fsanitize=address appended to CMAKE_CXX_FLAGS")
elseif(ClangThreadSanitizerMode)
append(CMAKE_CXX_FLAGS "-fsanitize=thread")
message("ClangThreadSanitizerMode enabled: -fsanitize=thread appended to CMAKE_CXX_FLAGS")
elseif(ClangCodeCoverageMode)
append(CMAKE_CXX_FLAGS "-fcoverage-mapping -fprofile-instr-generate=coverage.profraw")
message("ClangCodeCoverageMode enabled: -fcoverage-mapping -fprofile-instr-generate=coverage.profraw appended to CMAKE_CXX_FLAGS")
elseif(LCovCodeCoverageMode)
add_library(CodeCovLibraryInterface INTERFACE)
target_compile_options(CodeCovLibraryInterface INTERFACE -O0 -g --coverage)
target_link_libraries(CodeCovLibraryInterface INTERFACE --coverage)
endif()
elseif(MSVC)
set(CMAKE_CXX_FLAGS "/std:c++latest /EHsc /Wall /WX /permissive- /sdl /Zc:rvalueCast /MP")
replace(CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug" "/DEBUG:FASTLINK")
replace(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/debug" "")
replace(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2" "/Od")
replace(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Ob2" "/Ob0")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()
add_subdirectory(ZenUnitAndMetalMock)
add_subdirectory(ZenUnitCompileSpeedTests)
add_subdirectory(ZenUnitExamples)
add_subdirectory(ZenUnitLibraryTests)
add_subdirectory(ZenUnitTestUtils)
add_subdirectory(ZenUnitUtilsAndAssertionTests)
add_subdirectory(MetalMockExamples)
add_subdirectory(MetalMockTests)
set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo")
if(UNIX AND NOT APPLE)
include(ProcessorCount)
ProcessorCount(numberOfThreads)
add_custom_target(clang-tidy COMMAND
find -name "*.cpp" -print0 | xargs -0 -n 1 -P ${numberOfThreads} -t clang-tidy -header-filter=.* -p ${CMAKE_BUILD_TYPE}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} VERBATIM USES_TERMINAL)
endif()