diff options
author | Brad King <brad.king@kitware.com> | 2021-12-01 17:36:07 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-12-01 17:58:11 (GMT) |
commit | 643fc46bdc13dd57584d5d77eee30a99308ba896 (patch) | |
tree | 184ab10c031666afa8249a64662b8fa699b72ffe /Tests | |
parent | 5596cba7dcb06b0641d4a5499fc046cf0959464e (diff) | |
download | CMake-643fc46bdc13dd57584d5d77eee30a99308ba896.zip CMake-643fc46bdc13dd57584d5d77eee30a99308ba896.tar.gz CMake-643fc46bdc13dd57584d5d77eee30a99308ba896.tar.bz2 |
file(RPATH): Restore tolerance of unknown formats if new RPATH is empty
Since commit 2e1149874d (cmSystemTools: Support multiple binary formats,
2021-06-14, v3.22.0-rc1~575^2) the `file(RPATH_...)` operations fail on
files that are not ELF or XCOFF format. Previously the RPATH operations
tolerated files of unknown format if the goal was to produce a file with
an empty RPATH. Restore this tolerance in order to support setting an
empty RPATH on GNU ld scripts.
Fixes: #22963
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/file-RPATH/RunCMakeTest.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/file-RPATH/TextChange-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/file-RPATH/TextChange-stderr.txt | 12 | ||||
-rw-r--r-- | Tests/RunCMake/file-RPATH/TextChange.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/file-RPATH/TextChangeEmpty.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/file-RPATH/TextCheck.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/file-RPATH/TextCheckEmpty.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/file-RPATH/TextRemove.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/file-RPATH/TextSet-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/file-RPATH/TextSet-stderr.txt | 12 | ||||
-rw-r--r-- | Tests/RunCMake/file-RPATH/TextSet.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/file-RPATH/TextSetEmpty.cmake | 3 |
12 files changed, 64 insertions, 0 deletions
diff --git a/Tests/RunCMake/file-RPATH/RunCMakeTest.cmake b/Tests/RunCMake/file-RPATH/RunCMakeTest.cmake index 1ca2e75..525df09 100644 --- a/Tests/RunCMake/file-RPATH/RunCMakeTest.cmake +++ b/Tests/RunCMake/file-RPATH/RunCMakeTest.cmake @@ -5,3 +5,14 @@ run_cmake_command(ELF ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/ELF.cmake) if(CMAKE_SYSTEM_NAME STREQUAL "AIX") run_cmake_command(XCOFF ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/XCOFF.cmake) endif() + +run_cmake_command(TextCheck ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TextCheck.cmake) +run_cmake_command(TextCheckEmpty ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TextCheckEmpty.cmake) + +run_cmake_command(TextChange ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TextChange.cmake) +run_cmake_command(TextChangeEmpty ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TextChangeEmpty.cmake) + +run_cmake_command(TextSet ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TextSet.cmake) +run_cmake_command(TextSetEmpty ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TextSetEmpty.cmake) + +run_cmake_command(TextRemove ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TextRemove.cmake) diff --git a/Tests/RunCMake/file-RPATH/TextChange-result.txt b/Tests/RunCMake/file-RPATH/TextChange-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-RPATH/TextChange-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-RPATH/TextChange-stderr.txt b/Tests/RunCMake/file-RPATH/TextChange-stderr.txt new file mode 100644 index 0000000..48a1bf5 --- /dev/null +++ b/Tests/RunCMake/file-RPATH/TextChange-stderr.txt @@ -0,0 +1,12 @@ +^CMake Error at [^ +]*/Tests/RunCMake/file-RPATH/TextChange.cmake:[0-9]+ \(file\): + file RPATH_CHANGE could not write new RPATH: + + /new/rpath + + to the file: + + [^ +]*/Tests/RunCMake/file-RPATH/TextChange-build/not_a_binary.txt + + The file format is not recognized\.$ diff --git a/Tests/RunCMake/file-RPATH/TextChange.cmake b/Tests/RunCMake/file-RPATH/TextChange.cmake new file mode 100644 index 0000000..5c599ec --- /dev/null +++ b/Tests/RunCMake/file-RPATH/TextChange.cmake @@ -0,0 +1,3 @@ +set(f "${CMAKE_CURRENT_BINARY_DIR}/not_a_binary.txt") +file(WRITE "${f}" "Not a binary.\n") +file(RPATH_CHANGE FILE "${f}" OLD_RPATH "/old/rpath" NEW_RPATH "/new/rpath") diff --git a/Tests/RunCMake/file-RPATH/TextChangeEmpty.cmake b/Tests/RunCMake/file-RPATH/TextChangeEmpty.cmake new file mode 100644 index 0000000..8f855d9 --- /dev/null +++ b/Tests/RunCMake/file-RPATH/TextChangeEmpty.cmake @@ -0,0 +1,3 @@ +set(f "${CMAKE_CURRENT_BINARY_DIR}/not_a_binary.txt") +file(WRITE "${f}" "Not a binary.\n") +file(RPATH_CHANGE FILE "${f}" OLD_RPATH "/old/rpath" NEW_RPATH "") diff --git a/Tests/RunCMake/file-RPATH/TextCheck.cmake b/Tests/RunCMake/file-RPATH/TextCheck.cmake new file mode 100644 index 0000000..1f21ba7 --- /dev/null +++ b/Tests/RunCMake/file-RPATH/TextCheck.cmake @@ -0,0 +1,6 @@ +set(f "${CMAKE_CURRENT_BINARY_DIR}/not_a_binary.txt") +file(WRITE "${f}" "Not a binary.\n") +file(RPATH_CHECK FILE "${f}" RPATH "/some/rpath") +if(EXISTS "${f}") + message(FATAL_ERROR "RPATH_CHECK did not remove\n ${f}\nfor non-empty RPATH") +endif() diff --git a/Tests/RunCMake/file-RPATH/TextCheckEmpty.cmake b/Tests/RunCMake/file-RPATH/TextCheckEmpty.cmake new file mode 100644 index 0000000..806c73d --- /dev/null +++ b/Tests/RunCMake/file-RPATH/TextCheckEmpty.cmake @@ -0,0 +1,6 @@ +set(f "${CMAKE_CURRENT_BINARY_DIR}/not_a_binary.txt") +file(WRITE "${f}" "Not a binary.\n") +file(RPATH_CHECK FILE "${f}" RPATH "") +if(NOT EXISTS "${f}") + message(FATAL_ERROR "RPATH_CHECK removed\n ${f}\nfor empty RPATH") +endif() diff --git a/Tests/RunCMake/file-RPATH/TextRemove.cmake b/Tests/RunCMake/file-RPATH/TextRemove.cmake new file mode 100644 index 0000000..aecaf6f --- /dev/null +++ b/Tests/RunCMake/file-RPATH/TextRemove.cmake @@ -0,0 +1,3 @@ +set(f "${CMAKE_CURRENT_BINARY_DIR}/not_a_binary.txt") +file(WRITE "${f}" "Not a binary.\n") +file(RPATH_REMOVE FILE "${f}") diff --git a/Tests/RunCMake/file-RPATH/TextSet-result.txt b/Tests/RunCMake/file-RPATH/TextSet-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-RPATH/TextSet-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-RPATH/TextSet-stderr.txt b/Tests/RunCMake/file-RPATH/TextSet-stderr.txt new file mode 100644 index 0000000..811c9a5 --- /dev/null +++ b/Tests/RunCMake/file-RPATH/TextSet-stderr.txt @@ -0,0 +1,12 @@ +^CMake Error at [^ +]*/Tests/RunCMake/file-RPATH/TextSet.cmake:[0-9]+ \(file\): + file RPATH_SET could not write new RPATH: + + /new/rpath + + to the file: + + [^ +]*/Tests/RunCMake/file-RPATH/TextSet-build/not_a_binary.txt + + The file format is not recognized\.$ diff --git a/Tests/RunCMake/file-RPATH/TextSet.cmake b/Tests/RunCMake/file-RPATH/TextSet.cmake new file mode 100644 index 0000000..f4b09d2 --- /dev/null +++ b/Tests/RunCMake/file-RPATH/TextSet.cmake @@ -0,0 +1,3 @@ +set(f "${CMAKE_CURRENT_BINARY_DIR}/not_a_binary.txt") +file(WRITE "${f}" "Not a binary.\n") +file(RPATH_SET FILE "${f}" NEW_RPATH "/new/rpath") diff --git a/Tests/RunCMake/file-RPATH/TextSetEmpty.cmake b/Tests/RunCMake/file-RPATH/TextSetEmpty.cmake new file mode 100644 index 0000000..d9517e0 --- /dev/null +++ b/Tests/RunCMake/file-RPATH/TextSetEmpty.cmake @@ -0,0 +1,3 @@ +set(f "${CMAKE_CURRENT_BINARY_DIR}/not_a_binary.txt") +file(WRITE "${f}" "Not a binary.\n") +file(RPATH_SET FILE "${f}" NEW_RPATH "") |