Commit cf9b71c6 authored by Sebastian Müller's avatar Sebastian Müller 🐈
Browse files

CMake: try to fix coverage and mpi

parent 2aaf6776
......@@ -27,8 +27,8 @@ target_link_libraries(mhm PRIVATE mhm_lib)
# setup coverage with GNU
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU" AND CMAKE_WITH_COVERAGE)
# compile flags are added with the mhm_lib
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
SETUP_TARGET_FOR_COVERAGE_LCOV(NAME mhm_coverage_CI
EXECUTABLE ../CI-scripts/run_cmake_coverage.sh
DEPENDENCIES mhm mhm_lib
......
......@@ -31,7 +31,7 @@ if (CMAKE_WITH_MPI)
else()
message(STATUS "found MPI_Fortran_COMPILER ${MPI_Fortran_COMPILER}")
endif()
add_compile_definitions(MPI)
# add_compile_definitions(MPI)
endif()
if (CMAKE_WITH_OpenMP)
......
......@@ -36,7 +36,6 @@ target_include_directories(${LIB_NAME} PUBLIC
target_compile_options(${LIB_NAME} PUBLIC ${NETCDF_CFLAGS_OTHER} ${XPP_FLAG})
target_link_libraries(${LIB_NAME} PUBLIC ${NETCDF_LINK_LIBRARIES} ${MPI_Fortran_LIBRARIES})
target_include_directories(${LIB_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
# target_include_directories(${LIB_NAME} PUBLIC ${NETCDF_INCLUDES})
# by setting compile options and definitions PUBLIC, they are also used by
# programms linking agains it (mhm exe in this case)
......@@ -47,6 +46,9 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
$<$<CONFIG:DEBUG>:-pedantic-errors -Wall -W -O -g -Wno-maybe-uninitialized>
$<$<CONFIG:RELEASE>:-O3>
)
if(CMAKE_WITH_COVERAGE)
target_compile_options(${LIB_NAME} PUBLIC -g -fprofile-arcs -ftest-coverage)
endif()
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
# https://discourse.cmake.org/t/preserving-options-with-spaces-in-add-compile-options/1551/2
target_compile_definitions(${LIB_NAME} PUBLIC INTEL)
......@@ -64,6 +66,10 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "NAG")
)
endif()
if (CMAKE_WITH_MPI)
target_compile_definitions(${LIB_NAME} PUBLIC MPI)
endif()
# Show compile options
get_target_property(MAIN_CFLAGS ${LIB_NAME} COMPILE_OPTIONS)
message(STATUS "Target compiler flags are: ${MAIN_CFLAGS}")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment