From 41f7b1169a0b3e86506ac9c6d8f2664997cd340c Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Mon, 26 Sep 2022 16:12:57 -0400 Subject: 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. --- Modules/TestBigEndian.cmake | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'Modules/TestBigEndian.cmake') 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() -- cgit v1.2.1