-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
66 lines (57 loc) · 2.02 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
cmake_minimum_required(VERSION 3.21)
project(virtual_collections VERSION 0.1.0 LANGUAGES CXX)
set(namespace virtual_collections)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
find_package(collections CONFIG REQUIRED)
find_package(void_pointer CONFIG REQUIRED)
find_package(function_pointer CONFIG REQUIRED)
target_link_libraries(
${PROJECT_NAME} INTERFACE
collections::collections
void_pointer::void_pointer
function_pointer::function_pointer
)
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endif()
install(EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${namespace}::
DESTINATION share/${PROJECT_NAME}
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${PROJECT_NAME}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
string(CONCAT config_cmake_in
"@PACKAGE_INIT@\n"
"include(CMakeFindDependencyMacro)\n"
"find_dependency(collections CONFIG)\n"
"find_dependency(void_pointer CONFIG)\n"
"find_dependency(function_pointer CONFIG)\n"
"include(\"\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake\")\n"
)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake.in" "${config_cmake_in}")
configure_package_config_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION share/${PROJECT_NAME}
PATH_VARS CMAKE_INSTALL_PREFIX
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION share/${PROJECT_NAME}
)