chore(build): clean up debug build options

This commit is contained in:
fallenoak 2025-12-26 19:30:35 -06:00
parent e16ccdb1e7
commit 511c40aaa4
3 changed files with 56 additions and 32 deletions

View file

@ -25,6 +25,12 @@ list(APPEND CMAKE_MODULE_PATH
include(system) include(system)
# Standalone builds
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(WHOA_STANDALONE 1)
message(STATUS "Building Storm as a standalone project")
endif()
if(WHOA_ASSERTIONS_ENABLED) if(WHOA_ASSERTIONS_ENABLED)
add_definitions(-DWHOA_ASSERTIONS_ENABLED) add_definitions(-DWHOA_ASSERTIONS_ENABLED)
endif() endif()
@ -60,25 +66,31 @@ endif()
add_subdirectory(lib) add_subdirectory(lib)
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL "Debug") # Code coverage reporting
# Running coverage on linux+gcc: if(WHOA_STANDALONE AND CMAKE_BUILD_TYPE STREQUAL "Debug")
# # GCC coverage configuration
# sudo apt install lcov if(CMAKE_COMPILER_IS_GNUCXX)
# cmake -DCMAKE_BUILD_TYPE=Debug .. # Running coverage on linux+gcc:
# make #
# make StormCoverage # sudo apt install lcov
# # cmake -DCMAKE_BUILD_TYPE=Debug ..
# Results in `StormCoverage/index.html` # make
include(CodeCoverage) # make StormCoverage
#
# Results in `StormCoverage/index.html`
include(CodeCoverage)
setup_target_for_coverage_lcov( setup_target_for_coverage_lcov(
NAME StormCoverage NAME StormCoverage
EXECUTABLE StormTest EXECUTABLE StormTest
DEPENDENCIES StormTest storm DEPENDENCIES StormTest storm
BASE_DIRECTORY "${PROJECT_SOURCE_DIR}/storm" BASE_DIRECTORY "${PROJECT_SOURCE_DIR}/storm"
LCOV_ARGS --rc branch_coverage=1 LCOV_ARGS --rc branch_coverage=1
GENHTML_ARGS --rc genhtml_branch_coverage=1 GENHTML_ARGS --rc genhtml_branch_coverage=1
) )
message(STATUS "Code coverage reporting enabled")
endif()
endif() endif()
if(WHOA_TEST_STORMDLL) if(WHOA_TEST_STORMDLL)
@ -94,7 +106,7 @@ else()
add_subdirectory(storm) add_subdirectory(storm)
endif() endif()
# Only build tests when standalone if(WHOA_STANDALONE)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) # Add tests when standalone
add_subdirectory(test) add_subdirectory(test)
endif() endif()

View file

@ -62,10 +62,18 @@ if(HAS_NO_INVALID_OFFSETOF)
) )
endif() endif()
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL "Debug") # Standalone builds
include(CodeCoverage) if(WHOA_STANDALONE)
target_compile_options(${PROJECT_NAME} PRIVATE -g -fprofile-arcs -ftest-coverage -O0) # Debug build options
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# GCC debug build options
if(CMAKE_COMPILER_IS_GNUCXX)
# Enable coverage reporting
include(CodeCoverage)
target_compile_options(${PROJECT_NAME} PRIVATE -g -fprofile-arcs -ftest-coverage -O0)
# Enable ASan for debug builds on gcc # Enable ASan
target_compile_options(storm PRIVATE -fsanitize=address -fno-omit-frame-pointer) target_compile_options(storm PRIVATE -fsanitize=address -fno-omit-frame-pointer)
endif()
endif()
endif() endif()

View file

@ -51,14 +51,18 @@ target_include_directories(StormTest
${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}
) )
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL "Debug") # Debug build options
include(CodeCoverage) if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# GCC debug build options
if(CMAKE_COMPILER_IS_GNUCXX)
# Enable coverage reporting
include(CodeCoverage)
target_compile_options(${PROJECT_NAME} PRIVATE -g -fprofile-arcs -ftest-coverage -O0)
target_compile_options(${PROJECT_NAME} PRIVATE -g -fprofile-arcs -ftest-coverage -O0) # Enable ASan
target_compile_options(StormTest PRIVATE -fsanitize=address -fno-omit-frame-pointer)
# Enable ASan for debug builds on gcc target_link_options(StormTest PRIVATE -fsanitize=address)
target_compile_options(StormTest PRIVATE -fsanitize=address -fno-omit-frame-pointer) endif()
target_link_options(StormTest PRIVATE -fsanitize=address)
endif() endif()
install(TARGETS StormTest DESTINATION "bin") install(TARGETS StormTest DESTINATION "bin")