-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from Goddard-Fortran-Ecosystem/cmake-cache-sou…
…rce-compilation-tests CMake: Don't rerun source-compilation tests if they've already run
- Loading branch information
Showing
3 changed files
with
55 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
function (CHECK_FORTRAN_SOURCE_RUN file var) | ||
if (NOT DEFINED ${var}) | ||
try_run ( | ||
run compile | ||
${CMAKE_BINARY_DIR} | ||
${file} | ||
CMAKE_FLAGS "-DCOMPILE_DEFINITIONS=${CMAKE_REQUIRED_DEFINITIONS}" | ||
RUN_OUTPUT_VARIABLE ${var} | ||
) | ||
|
||
# Successful runs return "0", which is opposite of CMake sense of "if": | ||
if (NOT compile OR run) | ||
if (NOT CMAKE_REQUIRED_QUIET) | ||
message(STATUS "Performing Test ${var}: FAILURE") | ||
endif () | ||
return() | ||
endif() | ||
|
||
string(STRIP "${${var}}" ${var}) | ||
if (NOT CMAKE_REQUIRED_QUIET) | ||
message(STATUS "Performing Test ${var}: SUCCESS (value=${${var}})") | ||
endif () | ||
set(${var} ${${var}} CACHE STRING "" FORCE) | ||
|
||
endif() | ||
add_definitions(-D${var}=${${var}}) | ||
endfunction (CHECK_FORTRAN_SOURCE_RUN) | ||
|
||
|
||
function (CHECK_FORTRAN_SOURCE_COMPILE file var) | ||
if (NOT DEFINED ${var}) | ||
try_compile ( | ||
code_compiles | ||
${CMAKE_BINARY_DIR} | ||
${file} | ||
CMAKE_FLAGS "-DCOMPILE_DEFINITIONS=${CMAKE_REQUIRED_DEFINITIONS}" | ||
) | ||
|
||
if (NOT ${code_compiles}) | ||
if (NOT CMAKE_REQUIRED_QUIET) | ||
message (STATUS "Performing Test ${var}: BUILD FAILURE") | ||
endif () | ||
return() | ||
endif() | ||
|
||
set(${var} SUCCESS) | ||
if (NOT CMAKE_REQUIRED_QUIET) | ||
message (STATUS "Performing Test ${var}: SUCCESS") | ||
endif () | ||
|
||
set(${var} ${${var}} CACHE STRING "" FORCE) | ||
endif() | ||
add_definitions(-D${var}) | ||
endfunction (CHECK_FORTRAN_SOURCE_COMPILE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.