Commit 69528fe6 authored by Brad King's avatar Brad King
Browse files

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

Issue: #16682
parent f3102ca8
......@@ -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)
......
int libA(void)
{
return 0;
}
cmake_minimum_required(VERSION 3.7)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
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()
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})
^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\.$
file(COPY ${dir}/bin/exe DESTINATION ${dir})
file(RPATH_CHANGE FILE "${dir}/exe" OLD_RPATH "${dir}/libLink" NEW_RPATH "old-should-not-exist")
int main(void)
{
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment