summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-23 12:40:13 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-09-23 12:40:13 (GMT)
commit961536dc85b41f77db3d2d220cbf720d0056369a (patch)
treec4533f8f355961a07cc16a1d8cd5299a23fc5583 /Modules
parentc60fe3307591a76d498b4eae7ab8d801c65a709d (diff)
parent4d3874d5ad25d1907a56a92aba7ae94768726c72 (diff)
downloadCMake-961536dc85b41f77db3d2d220cbf720d0056369a.zip
CMake-961536dc85b41f77db3d2d220cbf720d0056369a.tar.gz
CMake-961536dc85b41f77db3d2d220cbf720d0056369a.tar.bz2
Merge topic 'CheckFortranSourceCompiles-custom-ext'
4d3874d5 CheckFortranSourceCompiles: Add support for custom source extension 86d2e427 CheckFortranSourceCompiles: Fix FAIL_REGEX documentation typo
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CheckFortranSourceCompiles.cmake17
1 files changed, 12 insertions, 5 deletions
diff --git a/Modules/CheckFortranSourceCompiles.cmake b/Modules/CheckFortranSourceCompiles.cmake
index 0bdcffa..967b830 100644
--- a/Modules/CheckFortranSourceCompiles.cmake
+++ b/Modules/CheckFortranSourceCompiles.cmake
@@ -4,7 +4,8 @@
#
# Check if given Fortran source compiles and links into an executable::
#
-# CHECK_Fortran_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>])
+# CHECK_Fortran_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>]
+# [SRC_EXT <ext>])
#
# The arguments are:
#
@@ -13,8 +14,10 @@
# ``<var>``
# Variable to store whether the source code compiled.
# Will be created as an internal cache variable.
-# ``<fail-regex>``
+# ``FAIL_REGEX <fail-regex>``
# Fail if test output matches this regex.
+# ``SRC_EXT <ext>``
+# Use source extension ``.<ext>`` instead of the default ``.F``.
#
# The following variables may be set before calling this macro to modify
# the way the check is run::
@@ -43,9 +46,10 @@
macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR)
if(NOT DEFINED "${VAR}")
set(_FAIL_REGEX)
+ set(_SRC_EXT)
set(_key)
foreach(arg ${ARGN})
- if("${arg}" MATCHES "^(FAIL_REGEX)$")
+ if("${arg}" MATCHES "^(FAIL_REGEX|SRC_EXT)$")
set(_key "${arg}")
elseif(_key)
list(APPEND _${_key} "${arg}")
@@ -53,6 +57,9 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR)
message(FATAL_ERROR "Unknown argument:\n ${arg}\n")
endif()
endforeach()
+ if(NOT _SRC_EXT)
+ set(_SRC_EXT F)
+ endif()
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
if(CMAKE_REQUIRED_LIBRARIES)
@@ -67,7 +74,7 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR)
else()
set(CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES)
endif()
- file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.F"
+ file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}"
"${SOURCE}\n")
if(NOT CMAKE_REQUIRED_QUIET)
@@ -75,7 +82,7 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR)
endif()
try_compile(${VAR}
${CMAKE_BINARY_DIR}
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.F
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}