Skip to content

Commit

Permalink
Fix logic around EXTRA_FCFLAGS
Browse files Browse the repository at this point in the history
The extra flags should be added regardless of the current value of the
compiler flags.

Signed-off-by: Nicolas Bock <nicolasbock@gmail.com>
  • Loading branch information
nicolasbock committed Jun 15, 2021
1 parent b81d149 commit b46cf3e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
32 changes: 16 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,25 @@ set(Intel_Fortran_FLAGS_RELEASE -O2 -g -assume realloc_lhs -qopt-report=5)

set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-none")
option(DONT_TOUCH_MY_FLAGS "Don't touch compiler flags" OFF)
if(NOT DONT_TOUCH_MY_FLAGS)
if(DEFINED EXTRA_FCFLAGS)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${EXTRA_FCFLAGS}")
endif()
endif()
message(STATUS "Setting Fortran compiler flags to ${CMAKE_Fortran_FLAGS}")

if(CMAKE_BUILD_TYPE AND NOT DONT_TOUCH_MY_FLAGS)
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
if(BUILD_TYPE STREQUAL "DEBUG" OR BUILD_TYPE STREQUAL "RELEASE")
if(CMAKE_Fortran_FLAGS STREQUAL "")
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU"
OR CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
set(CMAKE_Fortran_FLAGS_${BUILD_TYPE}
${${CMAKE_Fortran_COMPILER_ID}_Fortran_FLAGS_${BUILD_TYPE}})
string(REPLACE ";" " "
CMAKE_Fortran_FLAGS_${BUILD_TYPE}
"${CMAKE_Fortran_FLAGS_${BUILD_TYPE}}")
if(DEFINED EXTRA_FCFLAGS)
set(CMAKE_Fortran_FLAGS_${BUILD_TYPE} "${CMAKE_Fortran_FLAGS_${BUILD_TYPE}} ${EXTRA_FCFLAGS}")
endif()
message(STATUS "Setting Fortran compiler flags to "
"${CMAKE_Fortran_FLAGS_${BUILD_TYPE}}")
else()
message(STATUS "Unknown Fortran compiler ${CMAKE_Fortran_COMPILER_ID}")
endif()
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU"
OR CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
set(CMAKE_Fortran_FLAGS_${BUILD_TYPE}
${${CMAKE_Fortran_COMPILER_ID}_Fortran_FLAGS_${BUILD_TYPE}})
string(REPLACE ";" " "
CMAKE_Fortran_FLAGS_${BUILD_TYPE}
"${CMAKE_Fortran_FLAGS_${BUILD_TYPE}}")
else()
message(STATUS "Unknown Fortran compiler ${CMAKE_Fortran_COMPILER_ID}")
endif()
endif()
endif()
Expand Down
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ EOF
set_defaults() {
: ${CMAKE_BUILD_TYPE:=Release}
: ${CMAKE_PREFIX_PATH:=""}
: "${CC:=gcc}"
: "${CXX:=g++}"
: "${FC:=gfortran}"
: ${CC:=gcc}
: ${CXX:=g++}
: ${FC:=gfortran}
: ${BML_OPENMP:=yes}
: ${PROGRESS_OPENMP:=yes}
: ${PROGRESS_MPI:=no}
: ${PROGRESS_TESTING:=no}
: ${PROGRESS_EXAMPLES:=no}
: ${PROGRESS_GRAPHLIB:=no}
: "${EXTRA_FCFLAGS:=}"
: ${EXTRA_FCFLAGS:=}
: ${EXTRA_LINK_FLAGS:=""}
: ${SANITY_CHECK:=no}
}
Expand Down

0 comments on commit b46cf3e

Please sign in to comment.