From 2a24bad2183e349d5a4f5da405a4872fd8c4c7ec Mon Sep 17 00:00:00 2001 From: AliceMazzoleni99 Date: Wed, 17 Jun 2026 13:50:07 +0200 Subject: [PATCH] treating warnings as errors during workflows (#1473) * treating warnings as errors during workflows * suppress warnings for moench calibration * no format overflow * revert formatting * bettter conditional branching in cmake --- .github/workflows/cmake.yaml | 3 ++- CMakeLists.txt | 15 ++++++++++++--- .../moenchExecutables/CMakeLists.txt | 8 ++++++++ .../moenchExecutables/moench03Interpolation.cpp | 4 ++-- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cmake.yaml b/.github/workflows/cmake.yaml index 1c4d7b0f6..d3eeee0bd 100644 --- a/.github/workflows/cmake.yaml +++ b/.github/workflows/cmake.yaml @@ -37,7 +37,8 @@ jobs: -DSLS_USE_PYTHON=ON \ -DSLS_USE_HDF5=ON \ -DSLS_USE_GUI=ON \ - -DSLS_USE_MOENCH=ON + -DSLS_USE_MOENCH=ON \ + -DSLS_TREAT_WARNINGS_AS_ERRORS=ON - name: Build # Build your program with the given configuration diff --git a/CMakeLists.txt b/CMakeLists.txt index 8830eb86e..d29e4782b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,6 +236,7 @@ option(SLS_USE_MOENCH "compile zmq and post processing for Moench" OFF) option(SLS_USE_JUNGFRAU "compile post processing for Jungfrau" OFF) option(SLS_USE_MATTERHORN "compile matterhorn server" OFF) option(SLS_INSTALL_VERSIONED_BINARIES "Add version number to binaries on install" OFF) #Needed for multi version RPM +option(SLS_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF) #Convenience option to switch off defaults when building Moench binaries only option(SLS_BUILD_ONLY_MOENCH "compile only Moench" OFF) @@ -347,7 +348,9 @@ if (NOT TARGET slsProjectWarnings) -Wno-missing-field-initializers) endif() - + if(SLS_TREAT_WARNINGS_AS_ERRORS) + target_compile_options(slsProjectWarnings INTERFACE -Werror) + endif() endif() @@ -376,6 +379,10 @@ if (NOT TARGET slsProjectCSettings) target_compile_options(slsProjectCSettings INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer) target_link_libraries(slsProjectCSettings INTERFACE -fsanitize=address,undefined) endif() + + if(SLS_TREAT_WARNINGS_AS_ERRORS) + target_compile_options(slsProjectCSettings INTERFACE -Werror) + endif() endif() @@ -483,13 +490,15 @@ if(SLS_BUILD_DOCS) add_subdirectory(docs) endif(SLS_BUILD_DOCS) -if(SLS_USE_MOENCH) +if(SLS_USE_MOENCH OR SLS_USE_JUNGFRAU) add_subdirectory(slsDetectorCalibration/tiffio) +endif() + +if(SLS_USE_MOENCH) add_subdirectory(slsDetectorCalibration/moenchExecutables) endif(SLS_USE_MOENCH) if(SLS_USE_JUNGFRAU) - add_subdirectory(slsDetectorCalibration/tiffio) add_subdirectory(slsDetectorCalibration/jungfrauExecutables) endif(SLS_USE_JUNGFRAU) diff --git a/slsDetectorCalibration/moenchExecutables/CMakeLists.txt b/slsDetectorCalibration/moenchExecutables/CMakeLists.txt index 44b212df3..55faa558d 100644 --- a/slsDetectorCalibration/moenchExecutables/CMakeLists.txt +++ b/slsDetectorCalibration/moenchExecutables/CMakeLists.txt @@ -76,6 +76,14 @@ foreach(exe ${MOENCH_EXECUTABLES}) slsProjectOptions ) + target_compile_options(${exe} PRIVATE + -Wno-unused-but-set-variable + -Wno-format-nonliteral + -Wno-format-security + -Wno-double-promotion + -Wno-unused-variable + -Wno-format-overflow) + set_target_properties(${exe} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin diff --git a/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp b/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp index cbbe32746..dc3e71583 100644 --- a/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp +++ b/slsDetectorCalibration/moenchExecutables/moench03Interpolation.cpp @@ -204,9 +204,9 @@ int main(int argc, char *argv[]) { */ //#endif - if (totquad > cmin && cl.x >= xmin && cl.x <= xmax && + if (totquad > static_cast(cmin) && cl.x >= xmin && cl.x <= xmax && cl.y >= ymin && cl.y <= ymax && - totquad < cmax) { + totquad < static_cast(cmax)) { // if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 && // sum < cmax) {