Files
CMake/Tests/RunCMake/export/FindDependencyExport-check.cmake
Brad King b1c4806914 install(EXPORT): Drop REQUIRED from exported find_dependency calls
In commit c6e6861e63 (install(EXPORT): Export find_dependency() calls,
2023-11-07, v3.29.0-rc1~439^2~1) we made the calls `REQUIRED`.  However,
a dependency is only required if the dependent package is required.
`find_dependency` already forwards the `REQUIRED` mark, and also already
marks the dependent package as not found if the dependency is missing.

Fixes: #25756
2024-03-11 12:07:32 -04:00

36 lines
1.4 KiB
CMake

file(READ "${RunCMake_TEST_BINARY_DIR}/mytargets.cmake" mytargets)
if("${mytargets}" MATCHES "find_dependency\\(P1")
string(APPEND RunCMake_TEST_FAILED "P1 dependency should not be exported but it is\n")
endif()
if(NOT "${mytargets}" MATCHES "find_dependency\\(P2 \"VERSION\" \"1\\.0\"\\)")
string(APPEND RunCMake_TEST_FAILED "P2 dependency should be exported but it is not\n")
endif()
if(NOT "${mytargets}" MATCHES "find_dependency\\(P3\\)")
string(APPEND RunCMake_TEST_FAILED "P3 dependency should be exported but it is not\n")
endif()
if(NOT "${mytargets}" MATCHES "find_dependency\\(P4\\)")
string(APPEND RunCMake_TEST_FAILED "P4 dependency should be exported but it is not\n")
endif()
if("${mytargets}" MATCHES "find_dependency\\(P5")
string(APPEND RunCMake_TEST_FAILED "P5 dependency should not be exported but it is\n")
endif()
if(NOT "${mytargets}" MATCHES "find_dependency\\(P6\\)")
string(APPEND RunCMake_TEST_FAILED "P6 dependency should be exported but it is not\n")
endif()
if("${mytargets}" MATCHES "find_dependency\\(P7")
string(APPEND RunCMake_TEST_FAILED "P7 dependency should not be exported but it is\n")
endif()
if(NOT "${mytargets}" MATCHES "find_dependency\\(P3[^
]*\\)
find_dependency\\(P2[^
]*\\)
find_dependency\\(P8[^
]*\\)
find_dependency\\(P6[^
]*\\)
find_dependency\\(P9[^
]*\\)
find_dependency\\(P4")
string(APPEND RunCMake_TEST_FAILED "Dependencies are not in the correct order\n")
endif()