-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
129 lines (103 loc) · 3.99 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
cmake_minimum_required( VERSION 3.16)
project(cop LANGUAGES CXX VERSION 0.0.1 )
add_library(${PROJECT_NAME})
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
add_library(project_options INTERFACE)
add_library(project_warnings INTERFACE)
if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
#target_compile_options(project_options
#PUBLIC
#-stdlib=libc++
#)
option(ENABLE_BUILD_WITH_TIME_TRACE "Enable -ftime-trace to generate time tracing .json files on clang" OFF)
if(ENABLE_BUILD_WITH_TIME_TRACE)
add_compile_definitions(project_options INTERFACE -ftime-trace)
endif()
endif()
target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
$<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
#enable cache system
include(cmake/Cache.cmake)
# standard compiler warnings
include(cmake/CompilerWarnings.cmake)
set_project_warnings(project_warnings)
target_sources(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/BinaryCoder.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/BinaryFramer.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/Channel.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/Command.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/Crc.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/DataLinkLayer.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/Error.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/Event.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/Field.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/Framer.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/Header.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/Id.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/Interpreter.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/TransportLinkLayer.hpp
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/Error.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/detail/ChannelImpl.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/detail/DynamicMemoryPolicy.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/detail/Empty.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/detail/HandlerWrapper.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/detail/InPlaceAllocationPolicy.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/cop/detail/Utilities.hpp
)
target_link_libraries(${PROJECT_NAME}
PUBLIC
CONAN_PKG::tl-expected
PRIVATE
project_options
project_warnings
)
# testing code
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
target_compile_features(${PROJECT_NAME}
PRIVATE
cxx_std_20
)
include(cmake/StandardProjectSettings.cmake)
include(cmake/PreventInSourceBuilds.cmake)
# sanitizer options if supported by compiler
include(cmake/Sanitizers.cmake)
enable_sanitizers(project_options)
#enable doxygen
include(cmake/Doxygen.cmake)
enable_doxygen()
# allow for static analysis options
include(cmake/StaticAnalyzers.cmake)
#Set up some extra Conan dependencies
set(CONAN_EXTRA_REQUIRES "")
set(CONAN_EXTRA_OPTIONS "")
include(cmake/Conan.cmake)
run_conan()
option(ENABLE_TESTING "Enable Test Builds" ON)
option(ENABLE_SHARED_LIBS "Enable compilation of shared libraries" ON)
option(ENABLE_FUZZING "Enable Fuzzing Buids" OFF)
enable_testing()
if(CONAN_CATCH2_ROOT_DEBUG)
include(${CONAN_CATCH2_ROOT_DEBUG}/lib/cmake/Catch2/Catch.cmake)
else()
include(${CONAN_CATCH2_ROOT}/lib/cmake/Catch2/Catch.cmake)
endif()
add_subdirectory( tests )
add_library(catch_main STATIC ${CMAKE_CURRENT_SOURCE_DIR}/tests/catch_main.cpp)
add_library(catch_main::catch_main ALIAS catch_main)
target_compile_features(catch_main PUBLIC cxx_std_20)
target_link_libraries(catch_main
PRIVATE
project_options
project_warnings
PUBLIC
CONAN_PKG::catch2
CONAN_PKG::trompeloeil
)
include(CTest)
endif()