summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-10-07 19:42:22 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-10-07 19:42:22 (GMT)
commitd97fa4b4dabce6e2da660d44e004c6416f33567e (patch)
treea76012faad599d2b651d2983d74e3fbd270b11dc /Modules
parent5f9de609dd1d7a8e5063fcfb4ff69d98a8163f3f (diff)
parentbb501a2a648f4c2e2dd008b925b87b575b4e2cf1 (diff)
downloadCMake-d97fa4b4dabce6e2da660d44e004c6416f33567e.zip
CMake-d97fa4b4dabce6e2da660d44e004c6416f33567e.tar.gz
CMake-d97fa4b4dabce6e2da660d44e004c6416f33567e.tar.bz2
Merge topic 'add-find_dependency-macro'
bb501a2 CMakePackageConfigHelpers: Add a find_dependency macro
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakePackageConfigHelpers.cmake39
1 files changed, 37 insertions, 2 deletions
diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake
index d042d5e..3c56b7f 100644
--- a/Modules/CMakePackageConfigHelpers.cmake
+++ b/Modules/CMakePackageConfigHelpers.cmake
@@ -3,7 +3,8 @@
# CONFIGURE_PACKAGE_CONFIG_FILE(<input> <output> INSTALL_DESTINATION <path>
# [PATH_VARS <var1> <var2> ... <varN>]
# [NO_SET_AND_CHECK_MACRO]
-# [NO_CHECK_REQUIRED_COMPONENTS_MACRO])
+# [NO_CHECK_REQUIRED_COMPONENTS_MACRO]
+# [NO_FIND_DEPENDENCY_MACRO])
#
# CONFIGURE_PACKAGE_CONFIG_FILE() should be used instead of the plain
# configure_file() command when creating the <Name>Config.cmake or <Name>-config.cmake
@@ -154,7 +155,7 @@ endmacro()
function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile)
- set(options NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
+ set(options NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO NO_FIND_DEPENDENCY_MACRO)
set(oneValueArgs INSTALL_DESTINATION )
set(multiValueArgs PATH_VARS )
@@ -240,6 +241,40 @@ endmacro()
")
endif()
+ if(NOT CCF_NO_FIND_DEPENDENCY_MACRO)
+ set(PACKAGE_INIT "${PACKAGE_INIT}
+macro(find_dependency dep)
+ if (NOT \${dep}_FOUND)
+ if (\${ARGV1})
+ set(version \${ARGV1})
+ endif()
+ set(exact_arg)
+ if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT)
+ set(exact_arg EXACT)
+ endif()
+ set(quiet_arg)
+ if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
+ set(quiet_arg QUIET)
+ endif()
+ set(required_arg)
+ if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
+ set(required_arg REQUIRED)
+ endif()
+
+ find_package(\${dep} \${version} \${exact_arg} \${quiet_arg} \${required_arg})
+ if (NOT \${dep}_FOUND)
+ set(\${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE \"\${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency \${dep} could not be found.\")
+ set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
+ return()
+ endif()
+ set(required_arg)
+ set(quiet_arg)
+ set(exact_arg)
+ endif()
+endmacro()
+")
+ endif()
+
set(PACKAGE_INIT "${PACKAGE_INIT}
####################################################################################")