-
Notifications
You must be signed in to change notification settings - Fork 120
/
CMakeLists.txt
86 lines (71 loc) · 2.64 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
cmake_minimum_required(VERSION 3.5)
project(Seasocks VERSION 1.4.6)
if(APPLE)
message(FATAL_ERROR "${PROJECT_NAME} does not support Apple platforms")
endif()
if(MSVC)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
option(SEASOCKS_SHARED "Build seasocks as a shared library" "${BUILD_SHARED_LIBS}")
option(UNITTESTS "Build unittests." ON)
option(COVERAGE "Build with code coverage enabled" OFF)
option(SEASOCKS_EXAMPLE_APP "Build the example applications." ON)
option(DEFLATE_SUPPORT "Include support for deflate (requires zlib)." ON)
if (DEFLATE_SUPPORT)
set(DEFLATE_SUPPORT_BOOL "true")
else ()
set(DEFLATE_SUPPORT_BOOL "false")
endif ()
message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION}")
message(STATUS "Unittests: ${UNITTESTS}")
message(STATUS "Coverage: ${COVERAGE}")
message(STATUS "Building shared: ${SEASOCKS_SHARED}")
set(MEMORYCHECK_SUPPRESSIONS_FILE "${PROJECT_SOURCE_DIR}/src/test/suppressions.txt" CACHE INTERNAL "")
include(CTest)
include(GNUInstallDirs)
include(ClangFormat)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.h.in internal/Config.h @ONLY)
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# anything higher than /W3 results in warnings from Catch2, standard libraries, etc
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Werror -Wextra -pedantic -pedantic-errors)
endif()
if (COVERAGE)
add_compile_options(--coverage -O0)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
set(CMAKE_SHARED_LINKER_FLAGS "${SHARED_EXE_LINKER_FLAGS} --coverage")
endif ()
find_package(Threads REQUIRED)
find_package(PythonInterp)
if (NOT PYTHONINTERP_FOUND)
message(SEND_ERROR "Python not found")
else()
message(STATUS "Using Python: '${PYTHON_EXECUTABLE}'")
endif ()
if (DEFLATE_SUPPORT)
find_package(ZLIB REQUIRED)
endif ()
add_subdirectory(src)
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/SeasocksConfig.cmake.in ${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/"
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/
)
install(FILES
LICENSE
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/${PROJECT_NAME}"
)