Skip to content

Commit dab06c2

Browse files
Add Project Interface Library + PackageProject install configuration
1 parent 457b27d commit dab06c2

3 files changed

Lines changed: 43 additions & 12 deletions

File tree

CMakeLists.txt

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ cmake_minimum_required(VERSION 3.9)
22

33
# set the project name and version
44
project(CXXGraph VERSION 4.1.0)
5-
6-
configure_file(CXXGraphConfig.h.in ${PROJECT_SOURCE_DIR}/include/CXXGraph/CXXGraphConfig.h)
7-
5+
set(PROJECT_NAMESPACE ${PROJECT_NAME})
86
# specify the C++ standard
97
set(CMAKE_CXX_STANDARD 17)
108
set(CMAKE_CXX_STANDARD_REQUIRED True)
@@ -56,4 +54,45 @@ add_subdirectory(test)
5654
add_subdirectory(benchmark)
5755
add_subdirectory(examples)
5856

59-
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include)
57+
include(${CPM_DOWNLOAD_LOCATION})
58+
add_library(${PROJECT_NAME} INTERFACE)
59+
target_include_directories(${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>)
60+
CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.6.0")
61+
62+
packageProject(
63+
# the name of the target to export
64+
NAME ${PROJECT_NAME}
65+
# the version of the target to export
66+
VERSION ${PROJECT_VERSION}
67+
# a temporary directory to create the config files
68+
BINARY_DIR ${PROJECT_BINARY_DIR}
69+
# location of the target's public headers
70+
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
71+
# should match the target's INSTALL_INTERFACE include directory
72+
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
73+
# (optional) option to install only header files with matching pattern
74+
INCLUDE_HEADER_PATTERN "*.h *.hpp"
75+
# semicolon separated list of the project's dependencies
76+
DEPENDENCIES ""
77+
# (optional) create a header containing the version info
78+
# Note: that the path to headers should be lowercase
79+
VERSION_HEADER "${PROJECT_NAME}/version.h"
80+
# (optional) create a export header using GenerateExportHeader module
81+
EXPORT_HEADER "${PROJECT_NAME}/export.h"
82+
# (optional) install your library with a namespace (Note: do NOT add extra '::')
83+
NAMESPACE ${PROJECT_NAMESPACE}
84+
# (optional) define the project's version compatibility, defaults to `AnyNewerVersion`
85+
# supported values: `AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion`
86+
COMPATIBILITY AnyNewerVersion
87+
# (optional) option to disable the versioning of install destinations
88+
DISABLE_VERSION_SUFFIX YES
89+
# (optional) option to ignore target architecture for package resolution
90+
# defaults to YES for header only (i.e. INTERFACE) libraries
91+
ARCH_INDEPENDENT YES
92+
# (optional) option to generate CPack variables
93+
CPACK YES
94+
# (optional) relative install directory for runtimes: bins, libs, archives
95+
# by default libs will be installed to <...>/lib/<packagename-version>/
96+
# / - means relative to <...>/lib, i.e. install libs to <...>/lib/, bins to <...>/bin/, etc
97+
RUNTIME_DESTINATION /
98+
)

CXXGraphConfig.h.in

Lines changed: 0 additions & 4 deletions
This file was deleted.

include/CXXGraph/CXXGraphConfig.h

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)