diff options
Diffstat (limited to 'Modules/FortranCInterface/Detect.cmake')
-rw-r--r-- | Modules/FortranCInterface/Detect.cmake | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake index 798c44caa..778978533 100644 --- a/Modules/FortranCInterface/Detect.cmake +++ b/Modules/FortranCInterface/Detect.cmake @@ -1,13 +1,5 @@ -#============================================================================= -# Copyright 2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. configure_file(${FortranCInterface_SOURCE_DIR}/Input.cmake.in ${FortranCInterface_BINARY_DIR}/Input.cmake @ONLY) @@ -35,13 +27,17 @@ unset(FortranCInterface_VERIFIED_CXX CACHE) set(_result) # Build a sample project which reports symbols. +set(CMAKE_TRY_COMPILE_CONFIGURATION Release) try_compile(FortranCInterface_COMPILED ${FortranCInterface_BINARY_DIR} ${FortranCInterface_SOURCE_DIR} - FortranCInterface + FortranCInterface # project name + FortranCInterface # target name CMAKE_FLAGS "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}" "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" + "-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}" + "-DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE}" OUTPUT_VARIABLE FortranCInterface_OUTPUT) set(FortranCInterface_COMPILED ${FortranCInterface_COMPILED}) unset(FortranCInterface_COMPILED CACHE) @@ -49,8 +45,8 @@ unset(FortranCInterface_COMPILED CACHE) # Locate the sample project executable. if(FortranCInterface_COMPILED) find_program(FortranCInterface_EXE - NAMES FortranCInterface - PATHS ${FortranCInterface_BINARY_DIR} ${FortranCInterface_BINARY_DIR}/Debug + NAMES FortranCInterface${CMAKE_EXECUTABLE_SUFFIX} + PATHS ${FortranCInterface_BINARY_DIR} ${FortranCInterface_BINARY_DIR}/Release NO_DEFAULT_PATH ) set(FortranCInterface_EXE ${FortranCInterface_EXE}) @@ -67,11 +63,10 @@ endif() set(FortranCInterface_SYMBOLS) if(FortranCInterface_EXE) file(STRINGS "${FortranCInterface_EXE}" _info_strings - LIMIT_COUNT 8 REGEX "INFO:[^[]*\\[") + LIMIT_COUNT 8 REGEX "INFO:[A-Za-z0-9_]+\\[[^]]*\\]") foreach(info ${_info_strings}) - if("${info}" MATCHES ".*INFO:symbol\\[([^]]*)\\].*") - string(REGEX REPLACE ".*INFO:symbol\\[([^]]*)\\].*" "\\1" symbol "${info}") - list(APPEND FortranCInterface_SYMBOLS ${symbol}) + if("${info}" MATCHES "INFO:symbol\\[([^]]*)\\]") + list(APPEND FortranCInterface_SYMBOLS ${CMAKE_MATCH_1}) endif() endforeach() elseif(NOT _result) |