Skip to content

Commit 6b04383

Browse files
committed
Embed Fortran standard in target library options to ensure downstream compatibility
1 parent e1e3de3 commit 6b04383

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ endif()
3434

3535
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
3636

37+
set(FLIBCPP_FORTRAN_STD "f2003" CACHE STRING
38+
"Fortran standard for compiling generated code")
39+
3740
#---------------------------------------------------------------------------#
3841
# SWIG setup
3942
#---------------------------------------------------------------------------#
@@ -152,12 +155,19 @@ function(swig_fortran_add_module name)
152155
)
153156
endif()
154157

155-
# Enable C++11
158+
# Compile C++ code with C++11
156159
target_compile_features(${name}
157160
PRIVATE
158161
cxx_std_11
159162
)
160163

164+
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
165+
# Compile Fortran code with given standard
166+
target_compile_options(${name}
167+
PUBLIC $<$<COMPILE_LANGUAGE:Fortran>:-std=${FLIBCPP_FORTRAN_STD}>
168+
)
169+
endif()
170+
161171
target_include_directories(${name}
162172
PUBLIC
163173
# Fortran modules

scripts/cmake_vostok

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
BUILD=/rnsdhpc/code/build/flibcpp
33
SOURCE=/rnsdhpc/code/src/flibcpp
44

5-
test -d "$BUILD" || mkdir "$BUILD"
5+
test -d "$BUILD" || mkdir -p "$BUILD"
66
cd $BUILD
77

88
cmake \
@@ -11,8 +11,8 @@ cmake \
1111
-D SWIG_EXECUTABLE="/rnsdhpc/code/build/swig-debug/swig" \
1212
-D SWIG_DIR="/rnsdhpc/code/src/swig/Lib" \
1313
-D BUILD_SHARED_LIBS=ON \
14-
-D CMAKE_Fortran_FLAGS="-Wall -Wextra -Wimplicit-procedure -Wimplicit-interface -Wno-compare-reals -std=f2003" \
14+
-D CMAKE_Fortran_FLAGS="-Wall -Wextra -Wimplicit-procedure -Wimplicit-interface -Wno-compare-reals" \
1515
-D CMAKE_CXX_FLAGS="-Wall -Wextra" \
16-
-D CMAKE_INSTALL_PREFIX="/rnsdhpc/code/install/flibcpp"
16+
-D CMAKE_INSTALL_PREFIX="/rnsdhpc/code/install/flibcpp" \
1717
$SOURCE
1818
ninja

0 commit comments

Comments
 (0)