summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-03-03 12:57:29 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2017-03-03 12:57:29 (GMT)
commit24c0e229efd92392a877ba5c7c52d74fb9fdf689 (patch)
tree4f6720f87ee7314d1b71da5942c12a8c22704653 /Tests/RunCMake
parent1e0841c67244c70641a18c348cd8a274f4789010 (diff)
parent69528fe65f0c4402c6560917d6cb118d2c103445 (diff)
downloadCMake-24c0e229efd92392a877ba5c7c52d74fb9fdf689.zip
CMake-24c0e229efd92392a877ba5c7c52d74fb9fdf689.tar.gz
CMake-24c0e229efd92392a877ba5c7c52d74fb9fdf689.tar.bz2
Merge topic 'implicit-dir-symlinks'
69528fe6 Tests: Add case for RPATH exclusion of symlinks to implicit directories f3102ca8 Merge branch 'backport-implicit-dir-symlinks' into implicit-dir-symlinks c3fb650c cmOrderDirectories: Consider symlinks when checking implicit directories b1a37362 cmOrderDirectories: Factor out implicit directory check
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/RuntimePath/A.c4
-rw-r--r--Tests/RunCMake/RuntimePath/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/RuntimePath/RunCMakeTest.cmake18
-rw-r--r--Tests/RunCMake/RuntimePath/SymlinkImplicit.cmake17
-rw-r--r--Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-result.txt1
-rw-r--r--Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-stderr.txt22
-rw-r--r--Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake2
-rw-r--r--Tests/RunCMake/RuntimePath/main.c4
9 files changed, 74 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 6423bfd..5157b9f 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -156,6 +156,9 @@ add_RunCMake_test(TargetPropertyGeneratorExpressions)
add_RunCMake_test(Languages)
add_RunCMake_test(LinkStatic)
add_RunCMake_test(ObjectLibrary)
+if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
+ add_RunCMake_test(RuntimePath)
+endif()
add_RunCMake_test(Swift)
add_RunCMake_test(TargetObjects)
add_RunCMake_test(TargetSources)
diff --git a/Tests/RunCMake/RuntimePath/A.c b/Tests/RunCMake/RuntimePath/A.c
new file mode 100644
index 0000000..e9d4195
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/A.c
@@ -0,0 +1,4 @@
+int libA(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/RuntimePath/CMakeLists.txt b/Tests/RunCMake/RuntimePath/CMakeLists.txt
new file mode 100644
index 0000000..a640c56
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.7)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake
new file mode 100644
index 0000000..a9a7f05
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake
@@ -0,0 +1,18 @@
+include(RunCMake)
+
+
+function(run_SymlinkImplicit)
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SymlinkImplicit-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ if(RunCMake_GENERATOR MATCHES "Make|Ninja")
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ endif()
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(SymlinkImplicit)
+ run_cmake_command(SymlinkImplicit-build ${CMAKE_COMMAND} --build . --config Debug)
+ run_cmake_command(SymlinkImplicitCheck
+ ${CMAKE_COMMAND} -Ddir=${RunCMake_TEST_BINARY_DIR} -P ${RunCMake_SOURCE_DIR}/SymlinkImplicitCheck.cmake)
+endfunction()
+run_SymlinkImplicit()
diff --git a/Tests/RunCMake/RuntimePath/SymlinkImplicit.cmake b/Tests/RunCMake/RuntimePath/SymlinkImplicit.cmake
new file mode 100644
index 0000000..6578f8f
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/SymlinkImplicit.cmake
@@ -0,0 +1,17 @@
+enable_language(C)
+
+set(lib_dir ${CMAKE_CURRENT_BINARY_DIR}/lib)
+set(lib_link ${CMAKE_CURRENT_BINARY_DIR}/libLink)
+set(lib_always ${CMAKE_CURRENT_BINARY_DIR}/libAlways)
+file(MAKE_DIRECTORY ${lib_dir})
+execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink lib ${lib_link})
+execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink lib ${lib_always})
+
+add_library(A SHARED A.c)
+list(APPEND CMAKE_C_IMPLICIT_LINK_DIRECTORIES ${lib_dir})
+set_property(TARGET A PROPERTY LIBRARY_OUTPUT_DIRECTORY ${lib_link})
+
+add_executable(exe main.c)
+target_link_libraries(exe A)
+set_property(TARGET exe PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
+set_property(TARGET exe PROPERTY BUILD_RPATH ${lib_always})
diff --git a/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-result.txt b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-stderr.txt b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-stderr.txt
new file mode 100644
index 0000000..b0ede70
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-stderr.txt
@@ -0,0 +1,22 @@
+^CMake Error at .*/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake:[0-9]+ \(file\):
+ file RPATH_CHANGE could not write new RPATH:
+
+ old-should-not-exist
+
+ to the file:
+
+ [^
+]*/Tests/RunCMake/RuntimePath/SymlinkImplicit-build/exe
+
+ The current (RPATH|RUNPATH) is:
+
+ [^
+]*/Tests/RunCMake/RuntimePath/SymlinkImplicit-build/libAlways(:[^
+]*)?
+
+ which does not contain:
+
+ [^
+]*/Tests/RunCMake/RuntimePath/SymlinkImplicit-build/libLink
+
+ as was expected\.$
diff --git a/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake
new file mode 100644
index 0000000..d34742e
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake
@@ -0,0 +1,2 @@
+file(COPY ${dir}/bin/exe DESTINATION ${dir})
+file(RPATH_CHANGE FILE "${dir}/exe" OLD_RPATH "${dir}/libLink" NEW_RPATH "old-should-not-exist")
diff --git a/Tests/RunCMake/RuntimePath/main.c b/Tests/RunCMake/RuntimePath/main.c
new file mode 100644
index 0000000..8488f4e
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}