summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-07-03 11:25:25 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-07-03 11:25:31 (GMT)
commit977f5ed3d101d200baf5e88832b25d2c3edd1475 (patch)
treea2ee9601f6ed37098224dd2f05ec043afdc31b25 /Tests/RunCMake
parentbfa645c5992fa111b2ac90c5b7994c6aac8f7764 (diff)
parent85a945a607d5c417e780afed98868366fcfd8fae (diff)
downloadCMake-977f5ed3d101d200baf5e88832b25d2c3edd1475.zip
CMake-977f5ed3d101d200baf5e88832b25d2c3edd1475.tar.gz
CMake-977f5ed3d101d200baf5e88832b25d2c3edd1475.tar.bz2
Merge topic 'restore-cwd-translation-map'
85a945a607 Restore handling of build directory inside a symlinked path Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4963
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/SymlinkTrees/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/SymlinkTrees/PrintTrees.cmake6
-rw-r--r--Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake34
-rw-r--r--Tests/RunCMake/SymlinkTrees/common_symlinks-stdout.txt4
-rw-r--r--Tests/RunCMake/SymlinkTrees/common_symlinks.cmake1
6 files changed, 52 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index fc337df..871e18f 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -436,6 +436,10 @@ else()
message(STATUS "Could not find ctresalloc")
endif()
+if(NOT WIN32)
+ add_RunCMake_test(SymlinkTrees)
+endif ()
+
find_package(Qt4 QUIET)
find_package(Qt5Core QUIET)
if (QT4_FOUND AND Qt5Core_FOUND AND NOT Qt5Core_VERSION VERSION_LESS 5.1.0)
diff --git a/Tests/RunCMake/SymlinkTrees/CMakeLists.txt b/Tests/RunCMake/SymlinkTrees/CMakeLists.txt
new file mode 100644
index 0000000..d6fea2c
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.12)
+project(${RunCMake_TEST} NONE)
+include("${include_dir}/${RunCMake_TEST}.cmake")
diff --git a/Tests/RunCMake/SymlinkTrees/PrintTrees.cmake b/Tests/RunCMake/SymlinkTrees/PrintTrees.cmake
new file mode 100644
index 0000000..aa99127
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/PrintTrees.cmake
@@ -0,0 +1,6 @@
+message(STATUS "source: '${CMAKE_SOURCE_DIR}'")
+message(STATUS "binary: '${CMAKE_BINARY_DIR}'")
+get_filename_component(real_source "${CMAKE_SOURCE_DIR}" REALPATH)
+get_filename_component(real_binary "${CMAKE_BINARY_DIR}" REALPATH)
+message(STATUS "real source: '${real_source}'")
+message(STATUS "real binary: '${real_binary}'")
diff --git a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake
new file mode 100644
index 0000000..e5f1f7f
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake
@@ -0,0 +1,34 @@
+include(RunCMake)
+
+# This function assumes that ``${RunCMake_BINARY_DIR}/${name}/source`` and
+# ``${RunCMake_BINARY_DIR}/${name}/binary`` are set up properly prior to
+# calling it.
+function (run_symlink_test name)
+ set(RunCMake_TEST_NO_CLEAN TRUE)
+ configure_file(
+ "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt"
+ "${RunCMake_BINARY_DIR}/${name}/source/CMakeLists.txt"
+ COPYONLY)
+ set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}/source")
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}/binary")
+ # Emulate a shell using this directory.
+ set(ENV{PWD} "${RunCMake_TEST_BINARY_DIR}")
+ set(RunCMake_TEST_OPTIONS
+ "-Dinclude_dir:PATH=${CMAKE_CURRENT_LIST_DIR}")
+ run_cmake("${name}_symlinks")
+endfunction ()
+
+# Create the following structure:
+#
+# .../common_real/source
+# .../common_real/binary
+# .../common -> common_real
+#
+# In this case, CMake should act as if .../common *is* .../common_real for all
+# computations except ``REALPATH``. This supports the case where a system has
+# a stable *symlink*, but not a stable target for that symlink.
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/common_real")
+file(REMOVE "${RunCMake_BINARY_DIR}/common")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/source")
+file(CREATE_LINK "common_real" "${RunCMake_BINARY_DIR}/common" SYMBOLIC)
+run_symlink_test(common)
diff --git a/Tests/RunCMake/SymlinkTrees/common_symlinks-stdout.txt b/Tests/RunCMake/SymlinkTrees/common_symlinks-stdout.txt
new file mode 100644
index 0000000..bb04450
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/common_symlinks-stdout.txt
@@ -0,0 +1,4 @@
+-- source: '[^']*/Tests/RunCMake/SymlinkTrees/common/source'
+-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary'
+-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/common_real/source'
+-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/common_real/binary'
diff --git a/Tests/RunCMake/SymlinkTrees/common_symlinks.cmake b/Tests/RunCMake/SymlinkTrees/common_symlinks.cmake
new file mode 100644
index 0000000..5eafe26
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/common_symlinks.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/PrintTrees.cmake")