From ec77b9dce54029f74353d4f8a2466cf83f56efe8 Mon Sep 17 00:00:00 2001 From: Jonah Miller Date: Fri, 29 Nov 2024 12:46:15 -0700 Subject: [PATCH] add ability to build fortran backend code without fortran. Useful for clang-sanitize builds, since flang is not super well supported yet --- CMakeLists.txt | 13 +++++++++++++ singularity-eos/CMakeLists.txt | 4 ++-- test/CMakeLists.txt | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56178b2fba..8b09b1868c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,14 @@ cmake_dependent_option( "SINGULARITY_USE_SPINER" OFF) option(SINGULARITY_USE_FORTRAN "Enable fortran bindings" ON) +# Optionally build these if you want to build/test the fortran +# infrastructure without invoking a fortran compiler If fortran is +# off, you can set this. If fortran is on, it's forced to ON and is +# not set-able. +cmake_dependent_option(SINGULARITY_BUILD_FORTRAN_BACKEND + "Build the C++ code to which the fortran bindings bind" + OFF "NOT SINGULARITY_USE_FORTRAN" ON) + option(SINGULARITY_USE_KOKKOS "Use Kokkos for portability" OFF) option(SINGULARITY_USE_EOSPAC "Enable eospac backend" OFF) option(SINGULARITY_EOSPAC_ENABLE_SHMEM @@ -95,6 +103,7 @@ cmake_dependent_option( # modify flags options option(SINGULARITY_BETTER_DEBUG_FLAGS "Better debug flags for singularity" ON) option(SINGULARITY_HIDE_MORE_WARNINGS "hide more warnings" OFF) +option(SINGULARITY_STRICT_WARNINGS "Make warnings strict" OFF) # toggle code options option(SINGULARITY_USE_TRUE_LOG_GRIDDING @@ -552,6 +561,10 @@ target_compile_options( > # release > # cuda ) +if (SINGULARITY_STRICT_WARNINGS) + target_compile_options(singularity-eos_Interface INTERFACE + -Wall -Werror) +endif() if(TARGET singularity-eos_Library) target_compile_options(singularity-eos_Library PRIVATE ${xlfix}) diff --git a/singularity-eos/CMakeLists.txt b/singularity-eos/CMakeLists.txt index 87b2614717..4f0c5e3220 100644 --- a/singularity-eos/CMakeLists.txt +++ b/singularity-eos/CMakeLists.txt @@ -73,13 +73,13 @@ if (SINGULARITY_BUILD_CLOSURE) closure/kinetic_phasetransition_utils.hpp closure/kinetic_phasetransition_methods.hpp ) - if (SINGULARITY_USE_FORTRAN OR SINGULARITY_BUILD_TESTS) + if (SINGULARITY_BUILD_FORTRAN_BACKEND OR SINGULARITY_BUILD_TESTS) # while these are C++ files, they # are only needed for the fortran backend or unit testing register_srcs(eos/singularity_eos.cpp) register_headers(eos/singularity_eos.hpp) endif() - if (SINGULARITY_USE_FORTRAN) + if (SINGULARITY_BUILD_FORTRAN_BACKEND) register_srcs(eos/get_sg_eos.cpp) if (SINGULARITY_USE_KOKKOS) register_srcs( diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e01d0a01e1..318f469387 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -134,7 +134,7 @@ if(SINGULARITY_BUILD_CLOSURE) endif() endif() # disable fortran tests when using OpenMP due to segfaults - if(SINGULARITY_USE_KOKKOS AND SINGULARITY_USE_FORTRAN AND NOT Kokkos_ENABLE_OPENMP) + if(SINGULARITY_USE_KOKKOS AND SINGULARITY_BUILD_FORTRAN_BACKEND AND NOT Kokkos_ENABLE_OPENMP) add_executable(test_get_sg_eos test_get_sg_eos.cpp) target_link_libraries(test_get_sg_eos PRIVATE Catch2::Catch2 singularity-eos::singularity-eos)