mirror of
https://github.com/reactos/CMake.git
synced 2025-02-23 13:32:49 +00:00
cmInstallTargetGenerator: Add tests for the RPATH_CHANGE rule
This commit is contained in:
parent
749ce48eb5
commit
4caefbb423
@ -408,7 +408,12 @@ else()
|
||||
set(NO_NAMELINK 0)
|
||||
endif()
|
||||
|
||||
add_RunCMake_test(install -DNO_NAMELINK=${NO_NAMELINK} -DCYGWIN=${CYGWIN} -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
|
||||
add_RunCMake_test(install -DNO_NAMELINK=${NO_NAMELINK} -DCYGWIN=${CYGWIN} -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
|
||||
-DCMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN=${CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN}
|
||||
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
||||
-DCMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG=${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG}
|
||||
-DCMAKE_EXECUTABLE_FORMAT=${CMAKE_EXECUTABLE_FORMAT})
|
||||
|
||||
add_RunCMake_test(CPackCommandLine)
|
||||
add_RunCMake_test(CPackConfig)
|
||||
add_RunCMake_test(CPackInstallProperties)
|
||||
|
@ -48,6 +48,22 @@ in directory:
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Wrapper for run_cmake() that skips platforms that are non-ELF or have no RPATH support
|
||||
function(run_cmake_ELFRPATH_only case)
|
||||
if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
|
||||
run_cmake(${case})
|
||||
else()
|
||||
# Sanity check against a platform known to be ELF-based
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
message(FATAL_ERROR "Expected platform Linux to advertize itself as ELF-based, but it did not.")
|
||||
else()
|
||||
message(STATUS "${case} - SKIPPED (No ELF-based platform found)")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
run_cmake(TARGETS-FILE_RPATH_CHANGE-old_rpath)
|
||||
run_cmake_ELFRPATH_only(TARGETS-FILE_RPATH_CHANGE-new_rpath)
|
||||
run_cmake(DIRECTORY-MESSAGE_NEVER)
|
||||
run_cmake(DIRECTORY-PATTERN-MESSAGE_NEVER)
|
||||
run_cmake(DIRECTORY-message)
|
||||
|
@ -0,0 +1,30 @@
|
||||
file(READ ${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake install_script)
|
||||
#message(STATUS ${install_script})
|
||||
|
||||
set(wsnl " *[\n\r]+ *") # whitespace + single newline + whitespace
|
||||
set(wssl " *[\n\r]+[^\n\r]*[\n\r]+ *") # ws nl skipline nl ws
|
||||
string(CONCAT prefix [[file\(RPATH_CHANGE]])
|
||||
set(_msg "cmake_install.cmake does not match ")
|
||||
|
||||
macro(check)
|
||||
if(NOT install_script MATCHES "${regex}")
|
||||
message(STATUS "${test} - check \"${target}\" - FAILED:")
|
||||
string(CONCAT RunCMake_TEST_FAILED "${_msg}" ">>>${regex}<<<")
|
||||
return()
|
||||
else()
|
||||
message(STATUS "${test} - check \"${target}\" - PASSED")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(skip_without_rpath_change_rule)
|
||||
# Not all platforms generate a file(RPATH_CHANGE) rule
|
||||
if(NOT install_script MATCHES [[file\(RPATH_CHANGE]])
|
||||
# Sanity check against a platform known to generate a file(RPATH_CHANGE) rule
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
message(FATAL_ERROR "Expected generated file(RPATH_CHANGE) rule on platform Linux.")
|
||||
else()
|
||||
message(STATUS "${test} - All checks skipped. No file(RPATH_CHANGE) rule found on this platform.")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
@ -0,0 +1,63 @@
|
||||
include(${RunCMake_SOURCE_DIR}/TARGETS-FILE_RPATH_CHANGE-check-common.cmake)
|
||||
skip_without_rpath_change_rule()
|
||||
string(APPEND prefix "${wsnl}" [[FILE "[^"]*/]])
|
||||
|
||||
set(target "exe1_cmp0095_old")
|
||||
string(CONCAT regex "${prefix}${target}\"${wssl}"
|
||||
[[NEW_RPATH "/foo/bar]])
|
||||
check()
|
||||
|
||||
set(target "exe1_cmp0095_warn")
|
||||
string(CONCAT regex "${prefix}${target}\"${wssl}"
|
||||
[[NEW_RPATH "/foo/bar]])
|
||||
check()
|
||||
|
||||
set(target "exe1_cmp0095_new")
|
||||
string(CONCAT regex "${prefix}${target}\"${wssl}"
|
||||
[[NEW_RPATH "/foo/bar]])
|
||||
check()
|
||||
|
||||
set(target "exe2_cmp0095_old")
|
||||
string(CONCAT regex "${prefix}${target}\"${wssl}"
|
||||
[[NEW_RPATH "\$ORIGIN/../lib]])
|
||||
check()
|
||||
|
||||
set(target "exe2_cmp0095_warn")
|
||||
string(CONCAT regex "${prefix}${target}\"${wssl}"
|
||||
[[NEW_RPATH "\$ORIGIN/../lib]])
|
||||
check()
|
||||
|
||||
set(target "exe2_cmp0095_new")
|
||||
string(CONCAT regex "${prefix}${target}\"${wssl}"
|
||||
[[NEW_RPATH "\\\$ORIGIN/../lib]])
|
||||
check()
|
||||
|
||||
set(target "exe3_cmp0095_old")
|
||||
string(CONCAT regex "${prefix}${target}\"${wssl}"
|
||||
[[NEW_RPATH "\${ORIGIN}/../lib]])
|
||||
check()
|
||||
|
||||
set(target "exe3_cmp0095_warn")
|
||||
string(CONCAT regex "${prefix}${target}\"${wssl}"
|
||||
[[NEW_RPATH "\${ORIGIN}/../lib]])
|
||||
check()
|
||||
|
||||
set(target "exe3_cmp0095_new")
|
||||
string(CONCAT regex "${prefix}${target}\"${wssl}"
|
||||
[[NEW_RPATH "\\\${ORIGIN}/../lib]])
|
||||
check()
|
||||
|
||||
set(target "exe4_cmp0095_old")
|
||||
string(CONCAT regex "${prefix}${target}\"${wssl}"
|
||||
[[NEW_RPATH "/foo/bar/\${PLATFORM}]])
|
||||
check()
|
||||
|
||||
set(target "exe4_cmp0095_warn")
|
||||
string(CONCAT regex "${prefix}${target}\"${wssl}"
|
||||
[[NEW_RPATH "/foo/bar/\${PLATFORM}]])
|
||||
check()
|
||||
|
||||
set(target "exe4_cmp0095_new")
|
||||
string(CONCAT regex "${prefix}${target}\"${wssl}"
|
||||
[[NEW_RPATH "/foo/bar/\\\${PLATFORM}]])
|
||||
check()
|
@ -0,0 +1,23 @@
|
||||
^CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(install\):
|
||||
Policy CMP0095 is not set: RPATH entries are properly escaped in the
|
||||
intermediary CMake install script\. Run "cmake --help-policy CMP0095" for
|
||||
policy details\. Use the cmake_policy command to set the policy and
|
||||
suppress this warning\.
|
||||
|
||||
RPATH entries for target 'exe3_cmp0095_warn' will not be escaped in the
|
||||
intermediary cmake_install\.cmake script\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.
|
||||
|
||||
CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(install\):
|
||||
Policy CMP0095 is not set: RPATH entries are properly escaped in the
|
||||
intermediary CMake install script\. Run "cmake --help-policy CMP0095" for
|
||||
policy details\. Use the cmake_policy command to set the policy and
|
||||
suppress this warning\.
|
||||
|
||||
RPATH entries for target 'exe4_cmp0095_warn' will not be escaped in the
|
||||
intermediary cmake_install\.cmake script\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers\. Use -Wno-dev to suppress it\.$
|
@ -0,0 +1,72 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
enable_language(C)
|
||||
|
||||
# test matrix
|
||||
#
|
||||
# A :=
|
||||
# | no cmake syntax | cmake syntax |
|
||||
# -----------------------+-----------------+--------------+
|
||||
# absolute install RPATH | exe1 | exe4 |
|
||||
# relative install RPATH | exe2 | exe3 |
|
||||
#
|
||||
# all := A * CMP005_OLD + A * CMP0095_WARN + A * CMP0095_NEW
|
||||
|
||||
add_library(utils SHARED obj1.c)
|
||||
set(targets utils)
|
||||
|
||||
set(exe1_install_rpath "/foo/bar")
|
||||
set(exe2_install_rpath "\$ORIGIN/../lib")
|
||||
set(exe3_install_rpath "\${ORIGIN}/../lib")
|
||||
set(exe4_install_rpath "/foo/bar/\${PLATFORM}")
|
||||
|
||||
macro(A_CMP0095 policy_value)
|
||||
cmake_policy(PUSH)
|
||||
if(NOT "x${policy_value}x" STREQUAL "xWARNx")
|
||||
cmake_policy(SET CMP0095 ${policy_value})
|
||||
endif()
|
||||
string(TOLOWER "${policy_value}" p)
|
||||
|
||||
# exe1: absolute install RPATH, no cmake syntax
|
||||
set(case "exe1")
|
||||
set(target "${case}_cmp0095_${p}")
|
||||
list(APPEND targets ${target})
|
||||
add_executable(${target} main.c)
|
||||
target_link_libraries(${target} PRIVATE utils)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
INSTALL_RPATH "${${case}_install_rpath}")
|
||||
|
||||
# exe2: relative install RPATH, no cmake syntax
|
||||
set(case "exe2")
|
||||
set(target "${case}_cmp0095_${p}")
|
||||
list(APPEND targets ${target})
|
||||
add_executable(${target} main.c)
|
||||
target_link_libraries(${target} PRIVATE utils)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
INSTALL_RPATH "${${case}_install_rpath}")
|
||||
|
||||
# exe3: relative install RPATH, cmake syntax
|
||||
set(case "exe3")
|
||||
set(target "${case}_cmp0095_${p}")
|
||||
list(APPEND targets ${target})
|
||||
add_executable(${target} main.c)
|
||||
target_link_libraries(${target} PRIVATE utils)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
INSTALL_RPATH "${${case}_install_rpath}")
|
||||
|
||||
# exe4: absolute install RPATH, cmake syntax
|
||||
set(case "exe4")
|
||||
set(target "${case}_cmp0095_${p}")
|
||||
list(APPEND targets ${target})
|
||||
add_executable(${target} main.c)
|
||||
target_link_libraries(${target} PRIVATE utils)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
INSTALL_RPATH "${${case}_install_rpath}")
|
||||
|
||||
cmake_policy(POP)
|
||||
endmacro()
|
||||
|
||||
A_CMP0095("OLD")
|
||||
A_CMP0095("WARN") # exe3 and exe4 are expected to issue an author warning
|
||||
A_CMP0095("NEW")
|
||||
|
||||
install(TARGETS ${targets})
|
@ -0,0 +1,15 @@
|
||||
include(${RunCMake_SOURCE_DIR}/TARGETS-FILE_RPATH_CHANGE-check-common.cmake)
|
||||
skip_without_rpath_change_rule()
|
||||
string(APPEND prefix "${wsnl}" [[FILE "[^"]*/]])
|
||||
|
||||
set(target "exe1")
|
||||
string(CONCAT regex "${prefix}${target}\"${wsnl}"
|
||||
[[OLD_RPATH "]] "${RunCMake_BINARY_DIR}")
|
||||
check()
|
||||
|
||||
if("x${CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN}" STREQUAL "x\$ORIGIN")
|
||||
set(target "exe2")
|
||||
string(CONCAT regex "${prefix}${target}\"${wsnl}"
|
||||
[[OLD_RPATH "\\\$ORIGIN]])
|
||||
check()
|
||||
endif()
|
@ -0,0 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
enable_language(C)
|
||||
|
||||
add_library(utils SHARED obj1.c)
|
||||
|
||||
# exe1: absolute build RPATH, no cmake syntax
|
||||
set(CMAKE_BUILD_RPATH_USE_ORIGIN OFF)
|
||||
set(CMAKE_INSTALL_RPATH "/foo/bar")
|
||||
add_executable(exe1 main.c)
|
||||
target_link_libraries(exe1 PRIVATE utils)
|
||||
|
||||
# exe2: relative build RPATH, no cmake syntax
|
||||
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
|
||||
set(CMAKE_INSTALL_RPATH "/foo/bar")
|
||||
add_executable(exe2 main.c)
|
||||
target_link_libraries(exe2 PRIVATE utils)
|
||||
|
||||
install(TARGETS utils exe1 exe2)
|
Loading…
x
Reference in New Issue
Block a user