From c87410c1c89cf38bc8d3c2df5e5d5477d617bcc6 Mon Sep 17 00:00:00 2001 From: "David J. Gardner" Date: Thu, 16 May 2024 09:40:58 -0700 Subject: [PATCH] make some flags conditional, add conversion flags from Jeknins tests --- cmake/SundialsSetupCompilers.cmake | 14 ++++++++++++-- test/env/default.sh | 5 ----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cmake/SundialsSetupCompilers.cmake b/cmake/SundialsSetupCompilers.cmake index a3810541d0..041760b311 100644 --- a/cmake/SundialsSetupCompilers.cmake +++ b/cmake/SundialsSetupCompilers.cmake @@ -76,8 +76,18 @@ endif() if(ENABLE_ALL_WARNINGS) message(STATUS "Enabling all compiler warnings") - set(CMAKE_C_FLAGS "-Wall -Wpedantic -Wextra -Wshadow -Wmissing-declarations -Wcast-qual -Wdouble-promotion -Wno-unused-parameter -Wno-unused-function ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-Wall -Wpedantic -Wextra -Wshadow -Wmissing-declarations -Wcast-qual -Wdouble-promotion -Wno-unused-parameter -Wno-unused-function ${CMAKE_CXX_FLAGS}") + if(SUNDIALS_PRECISION MATCHES "EXTENDED") + set(CMAKE_C_FLAGS "-Wdouble-promotion ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wdouble-promotion ${CMAKE_CXX_FLAGS}") + endif() + + if((SUNDIALS_PRECISION MATCHES "DOUBLE") AND (SUNDIALS_INDEX_SIZE MATCHES "32")) + set(CMAKE_C_FLAGS "-Wconversion -Wno-sign-conversion ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wconversion -Wno-sign-conversion ${CMAKE_CXX_FLAGS}") + endif() + + set(CMAKE_C_FLAGS "-Wall -Wpedantic -Wextra -Wshadow -Wmissing-declarations -Wcast-qual -Wno-unused-parameter -Wno-unused-function ${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wall -Wpedantic -Wextra -Wshadow -Wmissing-declarations -Wcast-qual -Wno-unused-parameter -Wno-unused-function ${CMAKE_CXX_FLAGS}") set(CMAKE_Fortran_FLAGS "-Wall -Wpedantic -Wno-unused-dummy-argument -Wno-c-binding-type -ffpe-summary=none ${CMAKE_Fortran_FLAGS}") endif() diff --git a/test/env/default.sh b/test/env/default.sh index fb6ed34802..3085490055 100644 --- a/test/env/default.sh +++ b/test/env/default.sh @@ -139,11 +139,6 @@ if [ "$compilername" == "gcc" ]; then export CUDAFLAGS="-g -O3" fi - # append additional warning flags - if [[ "$SUNDIALS_PRECISION" == "double" && "$SUNDIALS_INDEX_SIZE" == "32" ]]; then - export CFLAGS="${CFLAGS} -Wconversion -Wno-sign-conversion" - export CXXFLAGS="${CXXFLAGS} -Wconversion -Wno-sign-conversion" - fi # TODO(CJB): add this back after we upgrade the GNU compiler stack on the Jenkins box # Currently this causes the compiler to segfault on many of the Fortran example codes. # export FFLAGS="${FFLAGS} -fbounds-check"