diff --git a/CMakeLists.txt b/CMakeLists.txt index d20071cc5b74b55375588e74891457a6cdb42030..b4859a40ca5dc13434f649b3ab56c5629b3e0cf5 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 a45a2d3e353abc84bdce4ab5da7f17456233da44..782e84eada13fb5fe0785cb53d301856844a5224 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 9f69596b307640c08ddd3878741430b9cd2bccaa..9f1a0df702b92447f808adf66e1d36a2733692ac 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 6a16c5447a2fb00e1a4a2c89d575348d33af1bd6..38bfc8351b8ff06d6ddb92ea576a8eb82a54394c 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