-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
69 lines (60 loc) · 2.38 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
cmake_minimum_required(VERSION 3.10)
project(reflection-cpp VERSION 0.0.1 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(reflection_cpp_HEADERS
${PROJECT_SOURCE_DIR}/include/reflection-cpp/reflection.hpp
)
add_library(reflection-cpp INTERFACE)
add_library(reflection-cpp::reflection-cpp ALIAS reflection-cpp)
target_compile_features(reflection-cpp INTERFACE cxx_std_20)
target_include_directories(reflection-cpp INTERFACE
$<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
# Generate the version, config and target files
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/reflection-cpp-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file(reflection-cpp-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/reflection-cpp-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/reflection-cpp
)
install(FILES ${reflection_cpp_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/reflection-cpp
)
install(TARGETS reflection-cpp
EXPORT reflection-cpp-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/reflection-cpp-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/reflection-cpp-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/reflection-cpp
)
install(EXPORT reflection-cpp-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/reflection-cpp
NAMESPACE reflection-cpp::
)
# ---------------------------------------------------------------------------
# unit tests
option(REFLECTION_TESTING "Enables building of unittests for reflection-cpp [default: OFF]" OFF)
if(REFLECTION_TESTING)
find_package(Catch2 3.4.0 QUIET)
if(NOT Catch2_FOUND)
ThirdPartiesAdd_Catch2()
endif()
enable_testing()
add_executable(test-reflection-cpp
test-reflection-cpp.cpp
)
target_compile_features(test-reflection-cpp INTERFACE cxx_std_20)
target_link_libraries(test-reflection-cpp reflection-cpp Catch2::Catch2 Catch2::Catch2WithMain)
add_test(test-reflection-cpp ./test-reflection-cpp)
endif()
message(STATUS "[reflection-cpp] Compile unit tests: ${REFLECTION_TESTING}")