diff options
author | Raul Tambre <raul@tambre.ee> | 2021-02-14 10:07:50 (GMT) |
---|---|---|
committer | Raul Tambre <raul@tambre.ee> | 2021-02-15 17:31:32 (GMT) |
commit | 905d663961074c44201a99476933cf30f6778bcf (patch) | |
tree | ac543eed14b9cd3af0faea78245c808ff010d720 /Tests/CMakeLists.txt | |
parent | e8f178a0016a545d33777d7e0b3717ef0ba718e3 (diff) | |
download | CMake-905d663961074c44201a99476933cf30f6778bcf.zip CMake-905d663961074c44201a99476933cf30f6778bcf.tar.gz CMake-905d663961074c44201a99476933cf30f6778bcf.tar.bz2 |
Tests: Fake home directory even if not set
In some cases ENV{HOME} might not be set, e.g. when run through a systemd
service without User set.
We should still to fake HOME in such cases as some tests (e.g. FindPackageTest)
rely on it. We need only avoid setting ENV{CTEST_REAL_HOME} in such cases. Its
possible absence seems to already be handled by tests.
Diffstat (limited to 'Tests/CMakeLists.txt')
-rw-r--r-- | Tests/CMakeLists.txt | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 4ed902c..5cb59af 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -25,14 +25,14 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/CheckSwift.cmake) # Fake a user home directory to avoid polluting the real one. -if(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) +if(NOT CTEST_NO_TEST_HOME AND (NOT WIN32 OR DEFINED ENV{HOME})) set(TEST_HOME "${CMake_BINARY_DIR}/Tests/CMakeFiles/TestHome") file(MAKE_DIRECTORY "${TEST_HOME}") file(WRITE "${TEST_HOME}/.cvspass" ":pserver:anoncvs@www.cmake.org:/cvsroot/KWSys A\n") set(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one. # But provide original ENV{HOME} value in ENV{CTEST_REAL_HOME} for tests that # need access to the real HOME directory. -if(NOT DEFINED ENV{CTEST_REAL_HOME}) +if(DEFINED ENV{HOME} AND NOT DEFINED ENV{CTEST_REAL_HOME}) set(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\") endif() set(ENV{HOME} \"${TEST_HOME}\") |