mirror of
https://github.com/reactos/CMake.git
synced 2024-12-14 23:29:57 +00:00
Tests: Add case for RPATH exclusion of symlinks to implicit directories
Issue: #16682
This commit is contained in:
parent
f3102ca884
commit
69528fe65f
@ -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)
|
||||
|
4
Tests/RunCMake/RuntimePath/A.c
Normal file
4
Tests/RunCMake/RuntimePath/A.c
Normal file
@ -0,0 +1,4 @@
|
||||
int libA(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
3
Tests/RunCMake/RuntimePath/CMakeLists.txt
Normal file
3
Tests/RunCMake/RuntimePath/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
18
Tests/RunCMake/RuntimePath/RunCMakeTest.cmake
Normal file
18
Tests/RunCMake/RuntimePath/RunCMakeTest.cmake
Normal 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()
|
17
Tests/RunCMake/RuntimePath/SymlinkImplicit.cmake
Normal file
17
Tests/RunCMake/RuntimePath/SymlinkImplicit.cmake
Normal 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})
|
@ -0,0 +1 @@
|
||||
1
|
22
Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-stderr.txt
Normal file
22
Tests/RunCMake/RuntimePath/SymlinkImplicitCheck-stderr.txt
Normal 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\.$
|
2
Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake
Normal file
2
Tests/RunCMake/RuntimePath/SymlinkImplicitCheck.cmake
Normal 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")
|
4
Tests/RunCMake/RuntimePath/main.c
Normal file
4
Tests/RunCMake/RuntimePath/main.c
Normal file
@ -0,0 +1,4 @@
|
||||
int main(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user