Tests: Add case for RPATH exclusion of symlinks to implicit directories

Issue: #16682
This commit is contained in:
Brad King 2017-03-01 12:38:10 -05:00
parent f3102ca884
commit 69528fe65f
9 changed files with 74 additions and 0 deletions

View File

@ -153,6 +153,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)

View File

@ -0,0 +1,4 @@
int libA(void)
{
return 0;
}

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.7)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -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()

View File

@ -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})

View File

@ -0,0 +1 @@
1

View File

@ -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\.$

View File

@ -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")

View File

@ -0,0 +1,4 @@
int main(void)
{
return 0;
}