-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow components in Config.cmake. (#396)
* Allow components in Config.cmake. * Add macro PROJECT_INSTALL_COMPONENT * Update doc. * Add missing include * Add optional argument NAMESPACE to PROJECT_INSTALL_COMPONENT
- Loading branch information
Showing
4 changed files
with
132 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
@PACKAGE_INIT@ | ||
|
||
if(@PROJECT_NAME@_FOUND) | ||
set(skip_this_file TRUE) | ||
if(NOT @PROJECT_NAME@_FOUND) | ||
set(skip_this_file FALSE) | ||
endif() | ||
if(skip_this_file) | ||
foreach(component ${@PROJECT_NAME@_FIND_COMPONENTS}) | ||
if(NOT "@PROJECT_NAME@_${component}_FOUND") | ||
set(skip_this_file FALSE) | ||
endif() | ||
endforeach() | ||
endif() | ||
if(skip_this_file) | ||
return() | ||
endif() | ||
|
||
|
@@ -82,9 +93,9 @@ set("@PROJECT_NAME_UPPER@_LIBRARIES" ${_PACKAGE_CONFIG_LIBRARIES}) | |
|
||
include(CMakeFindDependencyMacro) | ||
if(${CMAKE_VERSION} VERSION_LESS "3.15.0") | ||
@PACKAGE_DEPENDENCIES_FIND_PACKAGE@ | ||
@PACKAGE_DEPENDENCIES_FIND_PACKAGE@ | ||
else() | ||
@PACKAGE_DEPENDENCIES_FIND_DEPENDENCY@ | ||
@PACKAGE_DEPENDENCIES_FIND_DEPENDENCY@ | ||
endif() | ||
|
||
IF(COMMAND ADD_REQUIRED_DEPENDENCY) | ||
|
@@ -98,6 +109,20 @@ IF(COMMAND ADD_REQUIRED_DEPENDENCY) | |
ENDIF(COMMAND ADD_REQUIRED_DEPENDENCY) | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") | ||
|
||
foreach(component ${@PROJECT_NAME@_FIND_COMPONENTS}) | ||
set(comp_file "${CMAKE_CURRENT_LIST_DIR}/${component}Config.cmake") | ||
if(EXISTS ${comp_file}) | ||
include(${comp_file}) | ||
else() | ||
set("@PROJECT_NAME@_${component}_FOUND" FALSE) | ||
endif() | ||
if("@PROJECT_NAME@_${component}_FOUND") | ||
message(STATUS "@PROJECT_NAME@: ${component} found.") | ||
else() | ||
message(STATUS "@PROJECT_NAME@: ${component} not found.") | ||
endif() | ||
endforeach() | ||
check_required_components("@PROJECT_NAME@") | ||
|
||
@PACKAGE_EXTRA_MACROS@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@PACKAGE_INIT@ | ||
|
||
if(NOT @PROJECT_NAME@_FOUND) | ||
set(@PROJECT_NAME@_@COMPONENT@_FOUND FALSE) | ||
return() | ||
endif() | ||
|
||
# At the moment, components only support targets | ||
#set("@PROJECT_NAME@_@COMPONENT@_INCLUDE_DIRS" "@CMAKE_INSTALL_FULL_INCLUDEDIR@") | ||
#set("@PROJECT_NAME@_@COMPONENT@_LIBRARIES" ${_PACKAGE_CONFIG_LIBRARIES}) | ||
set(@PROJECT_NAME@_@COMPONENT@_DEPENDENCIES "@_PACKAGE_CONFIG_COMPONENT_DEPENDENCIES_PROJECTS@") | ||
|
||
include(CMakeFindDependencyMacro) | ||
if(${CMAKE_VERSION} VERSION_LESS "3.15.0") | ||
@COMPONENT_FIND_PACKAGE@ | ||
else() | ||
@COMPONENT_FIND_DEPENDENCY@ | ||
endif() | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") | ||
set(@PROJECT_NAME@_@COMPONENT@_FOUND TRUE) | ||
|
||
@COMPONENT_EXTRA_MACRO@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters