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,7 +66,10 @@ endif()
add_subdirectory(lib) add_subdirectory(lib)
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL "Debug") # Code coverage reporting
if(WHOA_STANDALONE AND CMAKE_BUILD_TYPE STREQUAL "Debug")
# GCC coverage configuration
if(CMAKE_COMPILER_IS_GNUCXX)
# Running coverage on linux+gcc: # Running coverage on linux+gcc:
# #
# sudo apt install lcov # sudo apt install lcov
@ -79,6 +88,9 @@ if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL "Debug")
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
if(WHOA_STANDALONE)
# Debug build options
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# GCC debug build options
if(CMAKE_COMPILER_IS_GNUCXX)
# Enable coverage reporting
include(CodeCoverage) 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 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
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# GCC debug build options
if(CMAKE_COMPILER_IS_GNUCXX)
# Enable coverage reporting
include(CodeCoverage) 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 for debug builds on gcc # Enable ASan
target_compile_options(StormTest PRIVATE -fsanitize=address -fno-omit-frame-pointer) target_compile_options(StormTest PRIVATE -fsanitize=address -fno-omit-frame-pointer)
target_link_options(StormTest PRIVATE -fsanitize=address) target_link_options(StormTest PRIVATE -fsanitize=address)
endif()
endif() endif()
install(TARGETS StormTest DESTINATION "bin") install(TARGETS StormTest DESTINATION "bin")