1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-01 03:41:33 +00:00

Move coverage build out of CMake config

It is too repetitive, redundant and GCC specific.

Configure with CMAKE_CXX_FLAGS_DEBUG and CMAKE_EXE_LINKER_FLAGS instead.
This commit is contained in:
elsid 2025-04-26 10:26:07 +02:00
parent ef68ed1d31
commit 0166b07ad5
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
20 changed files with 5 additions and 112 deletions

View file

@ -20,6 +20,11 @@ declare -a CMAKE_CONF_OPTS=(
-DOPENMW_CXX_FLAGS="${OPENMW_CXX_FLAGS}" # flags specific to OpenMW project
)
if [[ "${BUILD_WITH_CODE_COVERAGE}" ]]; then
CMAKE_CXX_FLAGS_DEBUG="${CMAKE_CXX_FLAGS_DEBUG} --coverage"
CMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS} --coverage"
fi
if [[ "${CMAKE_EXE_LINKER_FLAGS}" ]]; then
CMAKE_CONF_OPTS+=(
-DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS}"
@ -62,12 +67,6 @@ if [[ "${CMAKE_CXX_FLAGS_DEBUG}" ]]; then
)
fi
if [[ "${BUILD_WITH_CODE_COVERAGE}" ]]; then
CMAKE_CONF_OPTS+=(
-DBUILD_WITH_CODE_COVERAGE="${BUILD_WITH_CODE_COVERAGE}"
)
fi
mkdir -p build
cd build

View file

@ -38,7 +38,6 @@ option(BUILD_BSATOOL "Build BSA extractor" ON)
option(BUILD_ESMTOOL "Build ESM inspector" ON)
option(BUILD_NIFTEST "Build nif file tester" ON)
option(BUILD_DOCS "Build documentation." OFF )
option(BUILD_WITH_CODE_COVERAGE "Enable code coverage with gconv" OFF)
option(BUILD_COMPONENTS_TESTS "Build components library tests" OFF)
option(BUILD_BENCHMARKS "Build benchmarks with Google Benchmark" OFF)
option(BUILD_NAVMESHTOOL "Build navmesh tool" ON)

View file

@ -8,8 +8,3 @@ endif()
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
target_precompile_headers(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE <algorithm>)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE --coverage)
target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark gcov)
endif()

View file

@ -8,8 +8,3 @@ endif()
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
target_precompile_headers(openmw_esm_refid_benchmark PRIVATE <algorithm>)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw_esm_refid_benchmark PRIVATE --coverage)
target_link_libraries(openmw_esm_refid_benchmark gcov)
endif()

View file

@ -11,8 +11,3 @@ endif()
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
target_precompile_headers(openmw_settings_access_benchmark PRIVATE <algorithm>)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw_settings_access_benchmark PRIVATE --coverage)
target_link_libraries(openmw_settings_access_benchmark gcov)
endif()

View file

@ -13,11 +13,6 @@ target_link_libraries(bsatool
components
)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(bsatool PRIVATE --coverage)
target_link_libraries(bsatool gcov)
endif()
if (WIN32)
install(TARGETS bsatool RUNTIME DESTINATION ".")
endif()

View file

@ -10,11 +10,6 @@ target_link_libraries(openmw-bulletobjecttool
components
)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-bulletobjecttool PRIVATE --coverage)
target_link_libraries(openmw-bulletobjecttool gcov)
endif()
if (WIN32)
install(TARGETS openmw-bulletobjecttool RUNTIME DESTINATION ".")
endif()

View file

@ -106,11 +106,6 @@ if (UNIX AND NOT APPLE)
target_link_libraries(components-tests ${CMAKE_THREAD_LIBS_INIT})
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(components-tests PRIVATE --coverage)
target_link_libraries(components-tests gcov)
endif()
file(DOWNLOAD
https://gitlab.com/OpenMW/example-suite/-/raw/8966dab24692555eec720c854fb0f73d108070cd/data/template.omwgame
${CMAKE_CURRENT_BINARY_DIR}/data/template.omwgame

View file

@ -20,11 +20,6 @@ target_link_libraries(esmtool
components
)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(esmtool PRIVATE --coverage)
target_link_libraries(esmtool gcov)
endif()
if (WIN32)
install(TARGETS esmtool RUNTIME DESTINATION ".")
endif()

View file

@ -38,11 +38,6 @@ target_link_libraries(openmw-essimporter
components
)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-essimporter PRIVATE --coverage)
target_link_libraries(openmw-essimporter gcov)
endif()
if (WIN32)
INSTALL(TARGETS openmw-essimporter RUNTIME DESTINATION ".")
endif(WIN32)

View file

@ -74,11 +74,6 @@ target_link_libraries(openmw-launcher
target_link_libraries(openmw-launcher Qt::Widgets Qt::Core Qt::Svg)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-launcher PRIVATE --coverage)
target_link_libraries(openmw-launcher gcov)
endif()
if(USE_QT)
set_property(TARGET openmw-launcher PROPERTY AUTOMOC ON)
set_property(TARGET openmw-launcher PROPERTY AUTOUIC ON)

View file

@ -26,11 +26,6 @@ if (MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode")
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-iniimporter PRIVATE --coverage)
target_link_libraries(openmw-iniimporter gcov)
endif()
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
target_precompile_headers(openmw-iniimporter PRIVATE
<string>

View file

@ -20,11 +20,6 @@ target_link_libraries(openmw-navmeshtool-lib
components
)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-navmeshtool PRIVATE --coverage)
target_link_libraries(openmw-navmeshtool gcov)
endif()
if (WIN32)
install(TARGETS openmw-navmeshtool RUNTIME DESTINATION ".")
endif()

View file

@ -12,11 +12,6 @@ target_link_libraries(niftest
components
)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(niftest PRIVATE --coverage)
target_link_libraries(niftest gcov)
endif()
if (WIN32)
install(TARGETS niftest RUNTIME DESTINATION ".")
endif()

View file

@ -184,11 +184,6 @@ if(BUILD_OPENCS)
set_property(TARGET openmw-cs PROPERTY AUTOMOC ON)
set_property(TARGET openmw-cs PROPERTY AUTOUIC_SEARCH_PATHS ui)
set_property(TARGET openmw-cs PROPERTY AUTOUIC ON)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-cs PRIVATE --coverage)
target_link_libraries(openmw-cs gcov)
endif()
endif()
if(APPLE AND BUILD_OPENCS)
@ -280,11 +275,6 @@ if(USE_QT)
set_property(TARGET openmw-cs-lib PROPERTY AUTOUIC ON)
endif(USE_QT)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-cs-lib PRIVATE --coverage)
target_link_libraries(openmw-cs-lib gcov)
endif()
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
target_precompile_headers(openmw-cs-lib PRIVATE
<boost/program_options/options_description.hpp>

View file

@ -21,11 +21,6 @@ if (UNIX AND NOT APPLE)
target_link_libraries(openmw-cs-tests PRIVATE ${CMAKE_THREAD_LIBS_INIT})
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-cs-tests PRIVATE --coverage)
target_link_libraries(openmw-cs-tests PRIVATE gcov)
endif()
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
target_precompile_headers(openmw-cs-tests PRIVATE
<gtest/gtest.h>

View file

@ -242,15 +242,6 @@ if(APPLE AND BUILD_OPENMW)
endif()
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-lib PRIVATE --coverage)
target_link_libraries(openmw-lib gcov)
if (NOT ANDROID AND BUILD_OPENMW)
target_compile_options(openmw PRIVATE --coverage)
target_link_libraries(openmw gcov)
endif()
endif()
if (WIN32 AND BUILD_OPENMW)
INSTALL(TARGETS openmw RUNTIME DESTINATION ".")
endif()

View file

@ -31,11 +31,6 @@ if (UNIX AND NOT APPLE)
target_link_libraries(openmw-tests ${CMAKE_THREAD_LIBS_INIT})
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-tests PRIVATE --coverage)
target_link_libraries(openmw-tests gcov)
endif()
target_compile_definitions(openmw-tests
PRIVATE OPENMW_DATA_DIR=u8"${CMAKE_CURRENT_BINARY_DIR}/data"
OPENMW_PROJECT_SOURCE_DIR=u8"${PROJECT_SOURCE_DIR}")

View file

@ -82,11 +82,6 @@ if(DPKG_PROGRAM)
INSTALL(TARGETS openmw-wizard RUNTIME DESTINATION games COMPONENT openmw-wizard)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-wizard PRIVATE --coverage)
target_link_libraries(openmw-wizard gcov)
endif()
if (WIN32)
INSTALL(TARGETS openmw-wizard RUNTIME DESTINATION ".")
endif(WIN32)

View file

@ -621,11 +621,6 @@ if (USE_QT)
if (BUILD_LAUNCHER OR BUILD_WIZARD)
add_dependencies(components_qt qm-files)
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(components_qt PRIVATE --coverage)
target_link_libraries(components_qt gcov)
endif()
endif()
if (OSG_STATIC AND CMAKE_SYSTEM_NAME MATCHES "Linux")
@ -646,12 +641,6 @@ if (UNIX AND NOT APPLE)
target_link_libraries(components ${CMAKE_THREAD_LIBS_INIT})
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(components PRIVATE --coverage)
target_link_libraries(components gcov)
endif()
# Make the variable accessible for other subdirectories
set(COMPONENT_FILES ${COMPONENT_FILES} PARENT_SCOPE)