diff options
author | David Cole <david.cole@kitware.com> | 2012-03-21 17:26:46 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-03-21 17:26:46 (GMT) |
commit | 349ea3f6e6db59a4c1d3a1a8ea6a25e3f55ab713 (patch) | |
tree | ad7851b6dc3b60d4e17c34b06730df7caf3f7ab6 /Tests | |
parent | 45b27021e56845934e996f44739b87e330346dc5 (diff) | |
parent | 6d100f9f469b48ad25a3958e2b4865a9d9d37523 (diff) | |
download | CMake-349ea3f6e6db59a4c1d3a1a8ea6a25e3f55ab713.zip CMake-349ea3f6e6db59a4c1d3a1a8ea6a25e3f55ab713.tar.gz CMake-349ea3f6e6db59a4c1d3a1a8ea6a25e3f55ab713.tar.bz2 |
Merge topic 'ImprovedCOMPONENTSSupportInFindPackage2'
6d100f9 find_package: Test rejection of required+optional components
d81d83c add macro check_required_components() to configure_package_config_file()
b15c0b4 FPHSA(): add HANDLE_COMPONENTS option
34108cd find_package: add documentation for OPTIONAL_COMPONENTS
cdabde8 FPHSA(): add missing "]" to documentation
f2e0a18 find_package: add OPTIONAL_COMPONENTS keyword
Diffstat (limited to 'Tests')
7 files changed, 43 insertions, 0 deletions
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index eba9db9..5862094 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -37,6 +37,12 @@ FIND_PACKAGE(VersionTestB 1.2) FIND_PACKAGE(VersionTestC 1.2.3) FIND_PACKAGE(VersionTestD 1.2.3.4) + +FIND_PACKAGE(LotsOfComponents COMPONENTS AComp OPTIONAL_COMPONENTS BComp CComp) +IF(NOT LOTSOFCOMPONENTS_FOUND) + MESSAGE(SEND_ERROR "LotsOfComponents not found !") +ENDIF() + #----------------------------------------------------------------------------- # Test system package registry if possible. SET(CMakeTestSystemPackage "") @@ -330,6 +336,8 @@ configure_package_config_file(RelocatableConfig.cmake.in "${CMAKE_CURRENT_BINARY PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR ) +set(Relocatable_FIND_COMPONENTS AComp BComp CComp) +set(Relocatable_FIND_REQUIRED_BComp 1) include("${CMAKE_CURRENT_BINARY_DIR}/RelocatableConfig.cmake") if(NOT "${RELOC_INCLUDE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/include") @@ -344,6 +352,14 @@ if(NOT "${RELOC_BUILD_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") message(SEND_ERROR "RELOC_BUILD_DIR set by configure_package_config_file() is set to \"${RELOC_BUILD_DIR}\" (expected \"${CMAKE_CURRENT_BINARY_DIR}\")") endif() +if(NOT DEFINED Relocatable_FOUND) + message(SEND_ERROR "Relocatable_FOUND not defined !") +endif() + +if(Relocatable_FOUND) + message(SEND_ERROR "Relocatable_FOUND set to TRUE !") +endif() + #----------------------------------------------------------------------------- # Test write_basic_config_version_file(). diff --git a/Tests/FindPackageTest/FindLotsOfComponents.cmake b/Tests/FindPackageTest/FindLotsOfComponents.cmake new file mode 100644 index 0000000..9076d86 --- /dev/null +++ b/Tests/FindPackageTest/FindLotsOfComponents.cmake @@ -0,0 +1,10 @@ +set(LOC_FOO TRUE) + +set(LotsOfComponents_AComp_FOUND TRUE) +set(LotsOfComponents_BComp_FOUND FALSE) +set(LotsOfComponents_CComp_FOUND TRUE) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(LotsOfComponents REQUIRED_VARS LOC_FOO + HANDLE_COMPONENTS) diff --git a/Tests/FindPackageTest/RelocatableConfig.cmake.in b/Tests/FindPackageTest/RelocatableConfig.cmake.in index 7a34b2f..4a4b4e9 100644 --- a/Tests/FindPackageTest/RelocatableConfig.cmake.in +++ b/Tests/FindPackageTest/RelocatableConfig.cmake.in @@ -3,3 +3,9 @@ set(RELOC_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") set(RELOC_SHARE_DIR "@PACKAGE_SHARE_INSTALL_DIR@") set_and_check(RELOC_BUILD_DIR "@PACKAGE_CURRENT_BUILD_DIR@") + +set(Relocatable_AComp_FOUND TRUE) +set(Relocatable_BComp_FOUND FALSE) +set(Relocatable_CComp_FOUND FALSE) + +check_required_components(Relocatable) diff --git a/Tests/RunCMake/find_package/ComponentRequiredAndOptional-result.txt b/Tests/RunCMake/find_package/ComponentRequiredAndOptional-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_package/ComponentRequiredAndOptional-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/ComponentRequiredAndOptional-stderr.txt b/Tests/RunCMake/find_package/ComponentRequiredAndOptional-stderr.txt new file mode 100644 index 0000000..db8f512 --- /dev/null +++ b/Tests/RunCMake/find_package/ComponentRequiredAndOptional-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at ComponentRequiredAndOptional.cmake:1 \(find_package\): + find_package called with components that are both required and optional: + + CompA + CompB + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/find_package/ComponentRequiredAndOptional.cmake b/Tests/RunCMake/find_package/ComponentRequiredAndOptional.cmake new file mode 100644 index 0000000..0355f5a --- /dev/null +++ b/Tests/RunCMake/find_package/ComponentRequiredAndOptional.cmake @@ -0,0 +1 @@ +find_package(NotHere REQUIRED CompA CompB CompC OPTIONAL_COMPONENTS CompA CompB CompD) diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 34fa733..42705b7 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -1,5 +1,6 @@ include(RunCMake) +run_cmake(ComponentRequiredAndOptional) run_cmake(MissingNormal) run_cmake(MissingNormalRequired) run_cmake(MissingNormalVersion) |