-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
68 lines (52 loc) · 1.7 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
cmake_minimum_required(VERSION 3.13)
project(light_pcapng C)
# Configuration
file(GLOB LIGHT_SOURCES "src/*.c")
file(GLOB LIGHT_HEADERS "include/*.h")
add_library(light_pcapng ${LIGHT_SOURCES})
set_target_properties(light_pcapng PROPERTIES PUBLIC_HEADER
"${LIGHT_HEADERS}")
target_include_directories(light_pcapng PUBLIC "include")
# Export API symbols when the library is created
if(BUILD_SHARED_LIBS)
target_compile_definitions(light_pcapng PRIVATE LIGHT_EXPORTS=1)
target_compile_definitions(light_pcapng PUBLIC LIGHT_IMPORTS=1)
endif()
# ZSTD
option(LIGHT_USE_ZSTD "Compile with ZSTD support" ON)
if(LIGHT_USE_ZSTD)
include(cmake/zstd.cmake)
add_definitions(-DLIGHT_USE_ZSTD)
target_link_libraries(light_pcapng light_zstd)
endif()
# ZLIB
option(LIGHT_USE_ZLIB "Compile with ZLIB support" ON)
if(LIGHT_USE_ZLIB)
include(cmake/zlib.cmake)
add_definitions(-DLIGHT_USE_ZLIB)
target_link_libraries(light_pcapng light_zlib)
endif()
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
# Testing
include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
if(BUILD_COVERAGE)
target_compile_options(light_pcapng PUBLIC
-O0 # no optimization
-g # generate debug info
--coverage # sets all required flags
)
target_link_options(light_pcapng PUBLIC --coverage)
endif()
# We compile with warnings as error on non Windows, We will make it even more
# strict in the future
if(MSVC)
target_compile_options(light_pcapng PRIVATE /W4)
else()
target_compile_options(light_pcapng PRIVATE -Werror)
endif()
endif()
include(GNUInstallDirs)
install(TARGETS light_pcapng PUBLIC_HEADER DESTINATION include)