From 13287f70fc3fe23f2bcdcbc57b4ff643f098dbea Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Mon, 15 Apr 2024 18:51:04 +0200 Subject: [PATCH] Add `OCTOPUS_COMPILER_WARNINGS` option Signed-off-by: Cristian Le --- CMakeLists.txt | 6 +++++- cmake/CMakePresets-buildbot.json | 4 ++++ src/CMakeLists.txt | 14 ++++++++++++++ src/utils/CMakeLists.txt | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d20071cc5b..b4859a40ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,11 @@ option(OCTOPUS_TESTS "Octopus: Build with unit-tests" ${PROJECT_IS_TOP_LEVEL}) cmake_dependent_option(OCTOPUS_TESTS_FULL "Octopus: Build with full test-suite" ON "OCTOPUS_TESTS" OFF) cmake_dependent_option(OCTOPUS_TESTS_REPORT "Octopus: Export test report" OFF "OCTOPUS_TESTS" OFF) cmake_dependent_option(OCTOPUS_TESTS_RUN_SERIAL "Octopus: Run all tests as serial" OFF "OCTOPUS_TESTS;OCTOPUS_MPI" ON) -mark_as_advanced(OCTOPUS_TESTS_RUN_SERIAL) +option(OCTOPUS_COMPILER_WARNINGS "Octopus: Show compiler warnings" OFF) +mark_as_advanced( + OCTOPUS_COMPILER_WARNINGS + OCTOPUS_TESTS_RUN_SERIAL +) option(OCTOPUS_MKL "Octopus: Build with MKL support" OFF) add_feature_info(OCTOPUS_MKL OCTOPUS_MKL "Intel MKL backend (BLAS/LAPACK/FFTW)") # Disable FFTW if MKL is enabled, otherwise fallback to FFTW diff --git a/cmake/CMakePresets-buildbot.json b/cmake/CMakePresets-buildbot.json index a45a2d3e35..782e84eada 100644 --- a/cmake/CMakePresets-buildbot.json +++ b/cmake/CMakePresets-buildbot.json @@ -36,6 +36,10 @@ "type": "STRING", "value": "-O3" }, + "OCTOPUS_COMPILER_WARNINGS": { + "type": "BOOL", + "value": "$penv{OCTOPUS_COMPILER_WARNINGS}" + }, "OCTOPUS_TESTS": { "type": "BOOL", "value": true diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9f69596b30..9f1a0df702 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,20 @@ # Basic objects and interface add_library(fortran_cli OBJECT) target_link_libraries(fortran_cli PRIVATE Octopus_base) +add_library(octopus_compiler_warnings INTERFACE) +if (OCTOPUS_COMPILER_WARNINGS) + target_compile_options(octopus_compiler_warnings INTERFACE + "$<$:-Wall>" + "$<$:-Wall>" + "$<$:-Wall>" + ) + target_link_options(octopus_compiler_warnings INTERFACE + -Wall + ) +endif () +target_link_libraries(fortran_cli PRIVATE octopus_compiler_warnings) +target_link_libraries(Octopus_lib PRIVATE octopus_compiler_warnings) +target_link_libraries(Octopus_octopus PRIVATE octopus_compiler_warnings) # Dependent objects set(OctopusDependentObjects "") diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 6a16c5447a..38bfc8351b 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -144,4 +144,5 @@ foreach(oct_exec IN ITEMS ${UtilTargets}) COMMAND mkdir -p ${PROJECT_BINARY_DIR} COMMAND ln -f -s $ ${PROJECT_BINARY_DIR}/$ COMMENT "Generate default symbolic link to ${oct_exec} to default build directory") + target_link_libraries(${oct_exec} PRIVATE octopus_compiler_warnings) endforeach() \ No newline at end of file -- GitLab