diff --git a/CMakeLists.txt b/CMakeLists.txt index d20071cc5b74b55375588e74891457a6cdb42030..114789ac3ddd98873c20f78c8af7f8db89f2acc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,8 @@ 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) +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 @@ -61,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 a45a2d3e353abc84bdce4ab5da7f17456233da44..7bdf109a2979853d6a62f7c76f5a33eb0dd52b08 100644 --- a/cmake/CMakePresets-buildbot.json +++ b/cmake/CMakePresets-buildbot.json @@ -36,6 +36,14 @@ "type": "STRING", "value": "-O3" }, + "OCTOPUS_COMPILER_WARNINGS": { + "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 9f69596b307640c08ddd3878741430b9cd2bccaa..cc3a7f5c0f2cba38bd3dba1353fbfeb28c22f74f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,27 @@ # Basic objects and interface add_library(fortran_cli OBJECT) target_link_libraries(fortran_cli PRIVATE Octopus_base) +add_library(octopus_extra_options INTERFACE) +if (OCTOPUS_COMPILER_WARNINGS) + target_compile_options(octopus_extra_options INTERFACE + "$<$:-Wall>" + "$<$:-Wall>" + "$<$:-Wall>" + ) + target_link_options(octopus_extra_options INTERFACE + -Wall + ) +endif () +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 6a16c5447a2fb00e1a4a2c89d575348d33af1bd6..95d03fa13e59dabecd630a2caaa478c00049cc68 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_extra_options) endforeach() \ No newline at end of file