Skip to content

Commit acbb988

Browse files
committed
CMAKE: use PNAME_LANG_FLAGS
1 parent e062e51 commit acbb988

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ if( NOT ECWAM_PROJECT_NAME )
1919
set( ECWAM_PROJECT_NAME ecwam )
2020
endif()
2121

22+
string( TOUPPER ${ECWAM_PROJECT_NAME} PNAME )
23+
set( ${PNAME}_ECBUILD_COMPILE_FLAGS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ecwam_init_flags.cmake CACHE FILEPATH "")
2224
project( ${ECWAM_PROJECT_NAME} LANGUAGES Fortran C CXX )
2325

2426
include( ecwam_macros )

cmake/ecwam_compile_flags.cmake

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
# granted to it by virtue of its status as an intergovernmental organisation
77
# nor does it submit to any jurisdiction.
88

9+
# Capture ecbuild defaults and/or flags set by a toolchain
10+
set( ${PNAME}_Fortran_FLAGS ${ECBUILD_Fortran_FLAGS} )
11+
set( ${PNAME}_Fortran_FLAGS_BIT ${ECBUILD_Fortran_FLAGS_BIT} )
12+
set( ${PNAME}_Fortran_FLAGS_DEBUG ${ECBUILD_Fortran_FLAGS_DEBUG} )
13+
914
if(CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
1015
set(autopromote_flags "-sreal64")
1116
set(checkbounds_flags "-Rb")
@@ -44,7 +49,8 @@ if( NOT HAVE_SINGLE_PRECISION )
4449
ecbuild_add_fortran_flags( "${autopromote_flags}" NAME autopromote )
4550
endif()
4651
if( DEFINED vectorization_flags )
47-
ecbuild_add_fortran_flags( "${vectorization_flags}" NAME vectorization )
52+
# vectorization flags must be per-sourcefile overrideable, so are set via ${PNAME}_Fortran_FLAGS
53+
set( ${PNAME}_Fortran_FLAGS_BIT "${${PNAME}_Fortran_FLAGS_BIT} ${vectorization_flags}" )
4854
endif()
4955
if( DEFINED fpmodel_flags )
5056
ecbuild_add_fortran_flags( "${fpmodel_flags}" NAME fpmodel )

cmake/ecwam_init_flags.cmake

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# (C) Copyright 2022- ECMWF.
2+
#
3+
# This software is licensed under the terms of the Apache Licence Version 2.0
4+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
# In applying this licence, ECMWF does not waive the privileges and immunities
6+
# granted to it by virtue of its status as an intergovernmental organisation
7+
# nor does it submit to any jurisdiction.
8+
9+
# Empty file to trigger ecbuild to use ${PNAME}_<LANG>_FLAGS

0 commit comments

Comments
 (0)