forked from microsoft/picologging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
48 lines (40 loc) · 1.81 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
cmake_minimum_required(VERSION 3.4...3.22)
option(COVERAGE "Enable coverage reporting" OFF)
option(CACHE_FILEPATH "Enable cache filepath" ON)
project(picologging)
find_package(PythonExtensions REQUIRED)
add_library(_picologging MODULE src/picologging/_picologging.cxx src/picologging/logrecord.cxx src/picologging/formatstyle.cxx src/picologging/formatter.cxx src/picologging/logger.cxx src/picologging/handler.cxx src/picologging/filterer.cxx src/picologging/streamhandler.cxx)
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest")
else()
set_target_properties(_picologging PROPERTIES CXX_STANDARD 17)
endif (MSVC)
if (CACHE_FILEPATH)
add_definitions(-DPICOLOGGING_CACHE_FILEPATH)
endif (CACHE_FILEPATH)
if(COVERAGE)
message(STATUS "Enabling coverage")
# Add required flags (GCC & LLVM/Clang)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(_picologging PRIVATE
-O0 # no optimization
-g # generate debug info
--coverage # sets all required flags
-fprofile-abs-path
)
target_link_options(_picologging PRIVATE --coverage)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(_picologging PRIVATE
-O0 # no optimization
-g # generate debug info
-fprofile-instr-generate -fcoverage-mapping # coverage flags
)
target_link_options(_picologging PRIVATE --coverage)
endif()
endif(COVERAGE)
if(FUZZING)
target_compile_options(_picologging PRIVATE -fsanitize=address,fuzzer)
target_link_options(_picologging PRIVATE -fsanitize=address,fuzzer)
endif(FUZZING)
python_extension_module(_picologging)
install(TARGETS _picologging LIBRARY DESTINATION src/picologging)