diff options
author | Brad King <brad.king@kitware.com> | 2019-04-18 20:01:33 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-04-18 20:01:33 (GMT) |
commit | a9428fc473ca6eff749bd9868e2caabf7f84cc39 (patch) | |
tree | c81e2438a2e016fd34211cd1d12d80f0bce6525f /Tests/FindPackageTest | |
parent | e27437d0e0180fc03c44621b0918b559ee393efb (diff) | |
download | CMake-a9428fc473ca6eff749bd9868e2caabf7f84cc39.zip CMake-a9428fc473ca6eff749bd9868e2caabf7f84cc39.tar.gz CMake-a9428fc473ca6eff749bd9868e2caabf7f84cc39.tar.bz2 |
Tests: Fix FindPackageTest when path to source has a symlink
Exclude a portion of the test that does not work in this case.
Diffstat (limited to 'Tests/FindPackageTest')
-rw-r--r-- | Tests/FindPackageTest/CMakeLists.txt | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 972580c..6c876a7 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -205,15 +205,20 @@ if(UNIX) message(SEND_ERROR "SetFoundResolved_DIR set by find_package() is set to \"${SetFoundResolved_DIR}\" (expected \"${SetFoundResolved_EXPECTED}\")") endif() - # Resolve symlinks when finding the package. - set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS TRUE) - set(SetFoundResolved_DIR "") - find_package(SetFoundResolved) - # ./symlink points back here so it should be gone when resolved. - set(SetFoundResolved_EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - if(NOT "${SetFoundResolved_DIR}" STREQUAL "${SetFoundResolved_EXPECTED}") - message(SEND_ERROR "SetFoundResolved_DIR set by find_package() is set to \"${SetFoundResolved_DIR}\" (expected \"${SetFoundResolved_EXPECTED}\")") + # This part of the test only works if there are no symlinks in our path. + get_filename_component(real_src_dir "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH) + if(real_src_dir STREQUAL CMAKE_CURRENT_SOURCE_DIR) + # Resolve symlinks when finding the package. + set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS TRUE) + set(SetFoundResolved_DIR "") + find_package(SetFoundResolved) + # ./symlink points back here so it should be gone when resolved. + set(SetFoundResolved_EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + if(NOT "${SetFoundResolved_DIR}" STREQUAL "${SetFoundResolved_EXPECTED}") + message(SEND_ERROR "SetFoundResolved_DIR set by find_package() is set to \"${SetFoundResolved_DIR}\" (expected \"${SetFoundResolved_EXPECTED}\")") + endif() endif() + # Cleanup. unset(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS) file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/symlink") |