-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
72 lines (63 loc) · 2.29 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
cmake_minimum_required(VERSION 3.10)
project(boxed-cpp VERSION 1.4.3 LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(GNUInstallDirs)
include(ThirdParties)
include(ClangTidy)
include(PedanticCompiler)
set(boxed_cpp_HEADERS
${PROJECT_SOURCE_DIR}/include/boxed-cpp/boxed.hpp
)
add_library(boxed-cpp INTERFACE)
add_library(boxed-cpp::boxed-cpp ALIAS boxed-cpp)
target_compile_features(boxed-cpp INTERFACE cxx_std_20)
target_include_directories(boxed-cpp INTERFACE
$<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(boxed-cpp INTERFACE BOXED_DEBUG)
endif()
# Generate the version, config and target files
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/boxed-cpp-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file(boxed-cpp-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/boxed-cpp-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/boxed-cpp
)
install(FILES ${boxed_cpp_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/boxed-cpp
)
install(TARGETS boxed-cpp
EXPORT boxed-cpp-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/boxed-cpp-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/boxed-cpp-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/boxed-cpp
)
install(EXPORT boxed-cpp-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/boxed-cpp
NAMESPACE boxed-cpp::
)
# ---------------------------------------------------------------------------
# unit tests
option(BOXED_TESTING "Enables building of unittests for boxed-cpp [default: OFF]" OFF)
if(BOXED_TESTING)
find_package(Catch2 3.4.0 QUIET)
if(NOT Catch2_FOUND)
ThirdPartiesAdd_Catch2()
endif()
enable_testing()
add_executable(test-boxed-cpp
test-boxed-cpp.cpp
)
target_compile_features(test-boxed-cpp INTERFACE cxx_std_20)
target_link_libraries(test-boxed-cpp boxed-cpp Catch2::Catch2WithMain)
add_test(test-boxed-cpp ./test-boxed-cpp)
endif()
message(STATUS "[boxed-cpp] Compile unit tests: ${BOXED_TESTING}")