Skip to content

Commit 208d310

Browse files
committed
Handle install
1 parent a3b35d4 commit 208d310

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,45 @@ if(SPARROW_IPC_BUILD_DOCS)
254254
message(STATUS "📚 Create docs targets")
255255
add_subdirectory(docs)
256256
endif()
257+
258+
# Installation
259+
# ============
260+
include(GNUInstallDirs)
261+
include(CMakePackageConfigHelpers)
262+
263+
# Install target
264+
install(TARGETS sparrow-ipc
265+
EXPORT ${PROJECT_NAME}-targets)
266+
267+
# Makes the project importable from the build directory
268+
export(EXPORT ${PROJECT_NAME}-targets
269+
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
270+
NAMESPACE sparrow-ipc::)
271+
272+
# Install headers
273+
install(DIRECTORY ${SPARROW_IPC_INCLUDE_DIR}
274+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
275+
PATTERN ".clang-*" EXCLUDE
276+
PATTERN "README.md" EXCLUDE)
277+
278+
# Install CMake configuration files
279+
set(SPARROW_IPC_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" CACHE
280+
STRING "install path for sparrow-ipcConfig.cmake")
281+
282+
configure_package_config_file(${PROJECT_NAME}Config.cmake.in
283+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
284+
INSTALL_DESTINATION ${SPARROW_IPC_CMAKECONFIG_INSTALL_DIR})
285+
286+
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
287+
VERSION ${CMAKE_PROJECT_VERSION}
288+
COMPATIBILITY AnyNewerVersion)
289+
290+
install(FILES
291+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
292+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
293+
DESTINATION ${SPARROW_IPC_CMAKECONFIG_INSTALL_DIR})
294+
295+
install(EXPORT ${PROJECT_NAME}-targets
296+
FILE ${PROJECT_NAME}Targets.cmake
297+
NAMESPACE sparrow-ipc::
298+
DESTINATION ${SPARROW_IPC_CMAKECONFIG_INSTALL_DIR})

sparrow-ipcConfig.cmake.in

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# sparrow-ipc cmake module
2+
# This module sets the following variables in your project::
3+
#
4+
# sparrow-ipc_FOUND - true if sparrow-ipc found on the system
5+
# sparrow-ipc_INCLUDE_DIRS - the directory containing sparrow-ipc headers
6+
# sparrow-ipc_LIBRARY - the location of the sparrow-ipc library (or empty if not applicable)
7+
8+
@PACKAGE_INIT@
9+
10+
include(CMakeFindDependencyMacro)
11+
12+
find_dependency(sparrow)
13+
find_dependency(flatbuffers)
14+
15+
if(NOT TARGET sparrow-ipc::sparrow-ipc)
16+
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
17+
get_target_property(@PROJECT_NAME@_INCLUDE_DIRS sparrow-ipc::sparrow-ipc INTERFACE_INCLUDE_DIRECTORIES)
18+
get_target_property(@PROJECT_NAME@_LIBRARY sparrow-ipc::sparrow-ipc LOCATION)
19+
endif()

0 commit comments

Comments
 (0)