From 13287f70fc3fe23f2bcdcbc57b4ff643f098dbea Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Mon, 15 Apr 2024 18:51:04 +0200 Subject: [PATCH 1/2] 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 From c600f7495cfb3c305ba71aabb31be0861cb97b6b Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Thu, 18 Jul 2024 13:22:09 +0200 Subject: [PATCH 2/2] Add `OCTOPUS_DEBUG_FLAGS` option Signed-off-by: Cristian Le --- CMakeLists.txt | 11 +++++++---- cmake/CMakePresets-buildbot.json | 4 ++++ src/CMakeLists.txt | 19 +++++++++++++------ src/utils/CMakeLists.txt | 2 +- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4859a40ca..114789ac3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,10 +42,7 @@ cmake_dependent_option(OCTOPUS_TESTS_FULL "Octopus: Build with full test-suite" 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) option(OCTOPUS_COMPILER_WARNINGS "Octopus: Show compiler warnings" OFF) -mark_as_advanced( - OCTOPUS_COMPILER_WARNINGS - OCTOPUS_TESTS_RUN_SERIAL -) +option(OCTOPUS_DEBUG_FLAGS "Octopus: Include debug flags" OFF) 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 @@ -65,6 +62,12 @@ add_feature_info(OCTOPUS_OpenCL OCTOPUS_OpenCL "OpenCL graphics driver support") option(OCTOPUS_DOXYGEN "Octopus: Build with Doxygen support for in-source documentation" OFF) add_feature_info(OCTOPUS_DOXYGEN OCTOPUS_DOXYGEN "Doxygen source documentation support") +mark_as_advanced( + OCTOPUS_COMPILER_WARNINGS + OCTOPUS_DEBUG_FLAGS + OCTOPUS_TESTS_RUN_SERIAL +) + if (NOT OCTOPUS_MKL AND NOT OCTOPUS_FFTW) message(FATAL_ERROR "No FFTW vendor enabled. Either MKL or FFTW must be enabled.") endif () diff --git a/cmake/CMakePresets-buildbot.json b/cmake/CMakePresets-buildbot.json index 782e84eada..7bdf109a29 100644 --- a/cmake/CMakePresets-buildbot.json +++ b/cmake/CMakePresets-buildbot.json @@ -40,6 +40,10 @@ "type": "BOOL", "value": "$penv{OCTOPUS_COMPILER_WARNINGS}" }, + "OCTOPUS_DEBUG_FLAGS": { + "type": "BOOL", + "value": "$penv{OCTOPUS_DEBUG_FLAGS}" + }, "OCTOPUS_TESTS": { "type": "BOOL", "value": true diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9f1a0df702..cc3a7f5c0f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,20 +2,27 @@ # Basic objects and interface add_library(fortran_cli OBJECT) target_link_libraries(fortran_cli PRIVATE Octopus_base) -add_library(octopus_compiler_warnings INTERFACE) +add_library(octopus_extra_options INTERFACE) if (OCTOPUS_COMPILER_WARNINGS) - target_compile_options(octopus_compiler_warnings INTERFACE + target_compile_options(octopus_extra_options INTERFACE "$<$:-Wall>" "$<$:-Wall>" "$<$:-Wall>" ) - target_link_options(octopus_compiler_warnings INTERFACE + target_link_options(octopus_extra_options 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) +if (OCTOPUS_DEBUG_FLAGS) + target_compile_options(octopus_extra_options INTERFACE + "$<$:>" + "$<$:>" + "$<$:>" + ) +endif () +target_link_libraries(fortran_cli PRIVATE octopus_extra_options) +target_link_libraries(Octopus_lib PRIVATE octopus_extra_options) +target_link_libraries(Octopus_octopus PRIVATE octopus_extra_options) # Dependent objects set(OctopusDependentObjects "") diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 38bfc8351b..95d03fa13e 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -144,5 +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) + target_link_libraries(${oct_exec} PRIVATE octopus_extra_options) endforeach() \ No newline at end of file -- GitLab