summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-05-08 13:54:07 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-05-08 13:54:11 (GMT)
commit141b8ccf2cddc6b5d3c3c7258cefb181c09e5ce9 (patch)
treebfa0bbc13e4c34197954b2e0053d836a4b6c9ef6
parent733555020988e7f9362ebb9ef2cca5ec227244d5 (diff)
parent93f119ed251f970ef83496b3a7775130bae835b2 (diff)
downloadCMake-141b8ccf2cddc6b5d3c3c7258cefb181c09e5ce9.zip
CMake-141b8ccf2cddc6b5d3c3c7258cefb181c09e5ce9.tar.gz
CMake-141b8ccf2cddc6b5d3c3c7258cefb181c09e5ce9.tar.bz2
Merge topic 'f2c-int-fix'
93f119ed FortranCInterface: Add support for PGI on Windows 2cfea104 FortranCInt: Pass CONFIG flags to try_compile Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !802
-rw-r--r--Modules/FortranCInterface/CMakeLists.txt11
-rw-r--r--Modules/FortranCInterface/Detect.cmake5
-rw-r--r--Modules/FortranCInterface/MYMODULE.c3
-rw-r--r--Modules/FortranCInterface/MY_MODULE.c3
4 files changed, 16 insertions, 6 deletions
diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt
index 3a66f68..e3b81d7 100644
--- a/Modules/FortranCInterface/CMakeLists.txt
+++ b/Modules/FortranCInterface/CMakeLists.txt
@@ -15,11 +15,11 @@ int main() { return 0; }
# List manglings of global symbol names to try.
set(global_symbols
my_sub # VisualAge
- my_sub_ # GNU, Intel, HP, SunPro, MIPSpro
+ my_sub_ # GNU, Intel, HP, SunPro, MIPSpro, PGI
my_sub__ # GNU g77
MY_SUB # Intel on Windows
mysub # VisualAge
- mysub_ # GNU, Intel, HP, SunPro, MIPSpro
+ mysub_ # GNU, Intel, HP, SunPro, MIPSpro, PGI
MYSUB # Intel on Windows
${FortranCInterface_GLOBAL_SYMBOLS}
)
@@ -71,7 +71,7 @@ if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(PathScale|Cray)$")
# use '.in.' so we cannot provide them anyway.
# - Cray Fortran >= 7.3.2 uses module init symbols but module symbols
# use 'mysub$mymodule_' so we cannot provide them anyway.
- list(APPEND symbol_sources mymodule_.c my_module_.c)
+ list(APPEND symbol_sources mymodule_.c my_module_.c MY_MODULE.c MYMODULE.c)
endif()
foreach(symbol IN LISTS global_symbols module_symbols)
# Skip symbols with '$' if C cannot handle them.
@@ -93,11 +93,12 @@ add_library(myfort STATIC mysub.f my_sub.f ${myfort_modules})
# Provide symbols through C but fall back to Fortran.
add_library(symbols STATIC ${symbol_sources})
-target_link_libraries(symbols myfort)
+target_link_libraries(symbols PUBLIC myfort)
+
# In case the Fortran compiler produces PIC by default make sure
# the C compiler produces PIC even if it is not its default.
set_property(TARGET symbols PROPERTY POSITION_INDEPENDENT_CODE 1)
# Require symbols through Fortran.
add_executable(FortranCInterface main.F call_sub.f ${call_mod})
-target_link_libraries(FortranCInterface symbols)
+target_link_libraries(FortranCInterface PUBLIC symbols)
diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake
index 7612890..7789785 100644
--- a/Modules/FortranCInterface/Detect.cmake
+++ b/Modules/FortranCInterface/Detect.cmake
@@ -27,6 +27,7 @@ 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}
@@ -35,6 +36,8 @@ try_compile(FortranCInterface_COMPILED
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)
@@ -43,7 +46,7 @@ unset(FortranCInterface_COMPILED CACHE)
if(FortranCInterface_COMPILED)
find_program(FortranCInterface_EXE
NAMES FortranCInterface${CMAKE_EXECUTABLE_SUFFIX}
- PATHS ${FortranCInterface_BINARY_DIR} ${FortranCInterface_BINARY_DIR}/Debug
+ PATHS ${FortranCInterface_BINARY_DIR} ${FortranCInterface_BINARY_DIR}/Release
NO_DEFAULT_PATH
)
set(FortranCInterface_EXE ${FortranCInterface_EXE})
diff --git a/Modules/FortranCInterface/MYMODULE.c b/Modules/FortranCInterface/MYMODULE.c
new file mode 100644
index 0000000..19b51fb
--- /dev/null
+++ b/Modules/FortranCInterface/MYMODULE.c
@@ -0,0 +1,3 @@
+void MYMODULE(void)
+{
+}
diff --git a/Modules/FortranCInterface/MY_MODULE.c b/Modules/FortranCInterface/MY_MODULE.c
new file mode 100644
index 0000000..87b3071
--- /dev/null
+++ b/Modules/FortranCInterface/MY_MODULE.c
@@ -0,0 +1,3 @@
+void MY_MODULE(void)
+{
+}