diff options
author | Matthew Woehlke <matthew.woehlke@kitware.com> | 2022-09-26 16:12:57 -0400 |
---|---|---|
committer | Matthew Woehlke <matthew.woehlke@kitware.com> | 2022-09-27 13:29:52 -0400 |
commit | 41f7b1169a0b3e86506ac9c6d8f2664997cd340c (patch) | |
tree | 437327cc528d41c1a69c08600c629d720cf78e7e /Modules/FindMPI.cmake | |
parent | db76876db5c16d610efd08f6deb0e4c9cd0e5603 (diff) | |
download | cmake-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/FindMPI.cmake')
-rw-r--r-- | Modules/FindMPI.cmake | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 2faab0e9ae..e15be916f9 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -1246,20 +1246,22 @@ function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY SUPPRE else() # F77 header set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'") endif() - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90") + file(READ "${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" MPI_TEST_SOURCE_CONTENT) + string(CONFIGURE "${MPI_TEST_SOURCE_CONTENT}" MPI_TEST_SOURCE_CONTENT) + set(MPI_TEST_SOURCE_FILE "${MPI_TEST_FILE_NAME}.f90") elseif(LANG STREQUAL "CXX") - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp") + file(READ "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" MPI_TEST_SOURCE_CONTENT) + set(MPI_TEST_SOURCE_FILE "${MPI_TEST_FILE_NAME}.cpp") if(MODE STREQUAL "TEST_MPICXX") set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX) endif() else() # C - set(MPI_TEST_SOURCE_FILE "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c") + file(READ "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" MPI_TEST_SOURCE_CONTENT) + set(MPI_TEST_SOURCE_FILE "${MPI_TEST_FILE_NAME}.c") endif() if(RUN_BINARY) try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - SOURCES "${MPI_TEST_SOURCE_FILE}" + SOURCE_FROM_VAR "${MPI_TEST_SOURCE_FILE}" MPI_TEST_SOURCE_CONTENT COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} LINK_LIBRARIES MPI::MPI_${LANG} RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} @@ -1267,7 +1269,7 @@ function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY SUPPRE set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE) else() try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - SOURCES "${MPI_TEST_SOURCE_FILE}" + SOURCE_FROM_VAR "${MPI_TEST_SOURCE_FILE}" MPI_TEST_SOURCE_CONTENT COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} LINK_LIBRARIES MPI::MPI_${LANG} COPY_FILE "${BIN_FILE}" |