From 1d3a98456d0191995ebd53f67cc70a5f4bcb680d Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 25 Feb 2022 11:32:04 -0500 Subject: Tests: Fix Qt*Autogen.MocIncludeSymlink test on Windows This test runs the `Tests/QtAutogen/MocInclude` test inside symlinked directories. The `MocInclude` test previously relied on `get_filename_component(... REALPATH)` to get the real source tree location and compute the path to `AutogenCoreTest.cmake` from it. However, this does not work on Windows due to issue #17206. The test has been passing on Windows only on machines where symlinks cannot be created and the main part of the test is skipped. On machines where symlinks can be created, the test failed with that approach. Fix it by explicitly passing the path to the helper script in as a cache entry. Avoid relying on `REALPATH`. --- Tests/QtAutogen/MocInclude/CMakeLists.txt | 6 ++++-- Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Tests/QtAutogen/MocInclude/CMakeLists.txt b/Tests/QtAutogen/MocInclude/CMakeLists.txt index 4224d2f..c62128b 100644 --- a/Tests/QtAutogen/MocInclude/CMakeLists.txt +++ b/Tests/QtAutogen/MocInclude/CMakeLists.txt @@ -1,7 +1,9 @@ cmake_minimum_required(VERSION 3.16) project(MocInclude) -get_filename_component(CS_REAL ${CMAKE_CURRENT_SOURCE_DIR} REALPATH) -include("${CS_REAL}/../AutogenCoreTest.cmake") +if (NOT DEFINED AUTOGEN_CORE_TEST_CMAKE) + get_filename_component(AUTOGEN_CORE_TEST_CMAKE "../AutogenCoreTest.cmake" ABSOLUTE) +endif() +include("${AUTOGEN_CORE_TEST_CMAKE}") # Test moc include patterns diff --git a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt index c28616b..cf60555 100644 --- a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt +++ b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.16) project(MocIncludeSymlink) -include("../AutogenCoreTest.cmake") +get_filename_component(AUTOGEN_CORE_TEST_CMAKE "../AutogenCoreTest.cmake" ABSOLUTE) +include("${AUTOGEN_CORE_TEST_CMAKE}") # # Tests if MocInclude can be build when @@ -65,6 +66,7 @@ macro(buildMocInclude sourceDir binaryDir) "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + "-DAUTOGEN_CORE_TEST_CMAKE:STRING=${AUTOGEN_CORE_TEST_CMAKE}" OUTPUT_VARIABLE output ) if (result) -- cgit v0.12