add PackageProject.cmake as a CPM dependency
This commit is contained in:
parent
7c03ec71ea
commit
5f3c39b657
3 changed files with 15 additions and 51 deletions
|
@ -23,7 +23,7 @@ FILE(GLOB_RECURSE sources "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp")
|
||||||
# ---- Add dependencies via CPM (if required) ----
|
# ---- Add dependencies via CPM (if required) ----
|
||||||
# see https://github.com/TheLartians/CPM.cmake for more info
|
# see https://github.com/TheLartians/CPM.cmake for more info
|
||||||
|
|
||||||
# include(cmake/CPM.cmake)
|
include(cmake/CPM.cmake)
|
||||||
|
|
||||||
# CPMAddPackage(
|
# CPMAddPackage(
|
||||||
# NAME cxxopts
|
# NAME cxxopts
|
||||||
|
@ -56,6 +56,18 @@ target_include_directories(Greeter
|
||||||
)
|
)
|
||||||
|
|
||||||
# ---- Create an installable target ----
|
# ---- Create an installable target ----
|
||||||
# this allows users install and find the library via `find_package(Greeter)`.
|
# this allows users to install and find the library via `find_package()`.
|
||||||
|
|
||||||
include(cmake/packaging.cmake)
|
CPMAddPackage(
|
||||||
|
NAME PackageProject.cmake
|
||||||
|
GITHUB_REPOSITORY TheLartians/PackageProject.cmake
|
||||||
|
VERSION 1.0
|
||||||
|
)
|
||||||
|
|
||||||
|
packageProject(
|
||||||
|
NAME ${PROJECT_NAME}
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
BINARY_DIR ${PROJECT_BINARY_DIR}
|
||||||
|
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
|
||||||
|
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
|
||||||
|
)
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
@PACKAGE_INIT@
|
|
||||||
|
|
||||||
include(CMakeFindDependencyMacro)
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
|
||||||
check_required_components("@PROJECT_NAME@")
|
|
|
@ -1,43 +0,0 @@
|
||||||
include(CMakePackageConfigHelpers)
|
|
||||||
|
|
||||||
write_basic_package_version_file(
|
|
||||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
COMPATIBILITY AnyNewerVersion
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS ${PROJECT_NAME}
|
|
||||||
EXPORT ${PROJECT_NAME}Targets
|
|
||||||
LIBRARY DESTINATION lib/${PROJECT_NAME}-${PROJECT_VERSION} COMPONENT Runtime
|
|
||||||
ARCHIVE DESTINATION lib/${PROJECT_NAME}-${PROJECT_VERSION} COMPONENT Development
|
|
||||||
RUNTIME DESTINATION bin/${PROJECT_NAME}-${PROJECT_VERSION} COMPONENT Runtime
|
|
||||||
PUBLIC_HEADER DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION} COMPONENT Development
|
|
||||||
BUNDLE DESTINATION bin COMPONENT Runtime
|
|
||||||
)
|
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
|
||||||
|
|
||||||
configure_package_config_file(
|
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/Config.cmake.in"
|
|
||||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
|
||||||
INSTALL_DESTINATION lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
EXPORT ${PROJECT_NAME}Targets
|
|
||||||
DESTINATION lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
FILES
|
|
||||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
|
||||||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
|
||||||
DESTINATION
|
|
||||||
lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
DIRECTORY ${PROJECT_SOURCE_DIR}/include/
|
|
||||||
DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
|
|
||||||
)
|
|
Loading…
Add table
Add a link
Reference in a new issue