Skip to content

Commit 25d0558

Browse files
committed
add dependency support
1 parent 5e8487d commit 25d0558

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set(
88

99
function(packageProject)
1010

11-
cmake_parse_arguments(PROJECT "" "NAME;VERSION;INCLUDE_DIR;INCLUDE_DESTINATION;BINARY_DIR" "" ${ARGN})
11+
cmake_parse_arguments(PROJECT "" "NAME;VERSION;INCLUDE_DIR;INCLUDE_DESTINATION;BINARY_DIR;DEPENDENCIES" "" ${ARGN})
1212

1313
include(CMakePackageConfigHelpers)
1414

Config.cmake.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
@PACKAGE_INIT@
22

33
include(CMakeFindDependencyMacro)
4+
5+
foreach(dependency @PROJECT_DEPENDENCIES@)
6+
find_dependency(${dependency})
7+
endforeach()
8+
49
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
510
check_required_components("@PROJECT_NAME@")

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See [here](https://github.com/TheLartians/ModernCppStarter/blob/master/CMakeList
1414
CPMAddPackage(
1515
NAME PackageProject.cmake
1616
GITHUB_REPOSITORY TheLartians/PackageProject.cmake
17-
VERSION 1.0
17+
VERSION 1.1
1818
)
1919
2020
packageProject(
@@ -28,6 +28,8 @@ packageProject(
2828
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
2929
# should match the target's INSTALL_INTERFACE include directory
3030
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
31+
# comma separated list of all dependencies
32+
DEPENDENCIES ""
3133
)
3234
```
3335

0 commit comments

Comments
 (0)