summaryrefslogtreecommitdiff
path: root/Modules/TestBigEndian.cmake
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2022-09-26 16:12:57 -0400
committerMatthew Woehlke <matthew.woehlke@kitware.com>2022-09-27 13:29:52 -0400
commit41f7b1169a0b3e86506ac9c6d8f2664997cd340c (patch)
tree437327cc528d41c1a69c08600c629d720cf78e7e /Modules/TestBigEndian.cmake
parentdb76876db5c16d610efd08f6deb0e4c9cd0e5603 (diff)
downloadcmake-41f7b1169a0b3e86506ac9c6d8f2664997cd340c.tar.gz
Modules: Use new SOURCES_FROM_* try_compile (2/2)
Modify some additional modules that ship with CMake to use the new SOURCES_FROM_* arguments to try_compile / try_run as added by commits cb14ae2b87 (try_compile: Add SOURCE_FROM_{ARG,VAR}, 2022-09-21) and 611d801790 (try_compile: Add SOURCE_FROM_FILE, 2022-09-22). This covers modules that need to read and alter a template source file, which were not addressed in the previous commit. Note that FindOpenACC.cmake does not actually need configure_file functionality; it appears to have inherited the (gratuitous) use thereof from FindOpenMP.cmake, with which its code bears significant similarity.
Diffstat (limited to 'Modules/TestBigEndian.cmake')
-rw-r--r--Modules/TestBigEndian.cmake17
1 files changed, 7 insertions, 10 deletions
diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake
index e738d3259b..096c90c3c5 100644
--- a/Modules/TestBigEndian.cmake
+++ b/Modules/TestBigEndian.cmake
@@ -77,19 +77,16 @@ macro(__TEST_BIG_ENDIAN_LEGACY_IMPL VARIABLE)
endif()
if(_test_language STREQUAL "CXX")
- set(_test_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.cpp")
+ set(_test_file TestEndianess.cpp)
else()
- set(_test_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c")
+ set(_test_file TestEndianess.c)
endif()
- configure_file("${CMAKE_ROOT}/Modules/TestEndianess.c.in"
- ${_test_file}
- @ONLY)
-
- file(READ ${_test_file} TEST_ENDIANESS_FILE_CONTENT)
+ file(READ "${CMAKE_ROOT}/Modules/TestEndianess.c.in" TEST_ENDIANESS_FILE_CONTENT)
+ string(CONFIGURE "${TEST_ENDIANESS_FILE_CONTENT}" TEST_ENDIANESS_FILE_CONTENT @ONLY)
try_compile(HAVE_${VARIABLE}
- SOURCES ${_test_file}
+ SOURCE_FROM_VAR "${_test_file}" TEST_ENDIANESS_FILE_CONTENT
OUTPUT_VARIABLE OUTPUT
COPY_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestEndianess.bin" )
@@ -130,12 +127,12 @@ macro(__TEST_BIG_ENDIAN_LEGACY_IMPL VARIABLE)
endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "Determining if the system is big endian passed with the following output:\n${OUTPUT}\nTestEndianess.c:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n")
+ "Determining if the system is big endian passed with the following output:\n${OUTPUT}\n${_test_file}:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n")
else()
message(CHECK_FAIL "failed")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining if the system is big endian failed with the following output:\n${OUTPUT}\nTestEndianess.c:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n")
+ "Determining if the system is big endian failed with the following output:\n${OUTPUT}\n${_test_file}:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n")
set(${VARIABLE})
endif()
endif()