Skip to content

Commit

Permalink
Refactor CMake configuration to use setup_sanitizers for improved cod…
Browse files Browse the repository at this point in the history
…e safety and update submodule references
  • Loading branch information
riccardodebenedictis committed Jan 15, 2025
1 parent d83dd01 commit 176f4aa
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 49 deletions.
25 changes: 2 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,7 @@ if(BUILD_GUI_SERVER)
target_link_libraries(oRatioServer PRIVATE oRatioLib ratioNet)
target_include_directories(oRatioServer PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/server>)

if(MSVC)
target_compile_options(oRatioServer PRIVATE /W4)
else()
target_compile_options(oRatioServer PRIVATE -Wall -Wextra -Wpedantic -fsanitize=undefined)
target_link_options(oRatioServer PRIVATE -fsanitize=undefined)
if (ENABLE_COVERAGE)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(oRatioServer PRIVATE --coverage)
target_link_libraries(oRatioServer PUBLIC gcov)
endif()
endif()
endif()
setup_sanitizers(oRatioServer)
endif()

message(STATUS "Build oRatio listeners: ${BUILD_LISTENERS}")
Expand All @@ -100,17 +89,7 @@ if(BUILD_TESTING)
add_subdirectory(tests)
endif()

if(MSVC)
target_compile_options(oRatioLib PRIVATE /W4)
else()
target_compile_options(oRatioLib PRIVATE -Wall -Wextra -Wpedantic -fsanitize=undefined)
if (ENABLE_COVERAGE)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(oRatioLib PRIVATE --coverage)
target_link_libraries(oRatioLib PUBLIC gcov)
endif()
endif()
endif()
setup_sanitizers(oRatioLib)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
Expand Down
2 changes: 1 addition & 1 deletion extern/rationet
2 changes: 1 addition & 1 deletion extern/riddle
26 changes: 2 additions & 24 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
add_executable(core_tests test_core.cpp)
add_dependencies(core_tests oRatioLib)
target_link_libraries(core_tests PRIVATE oRatioLib)
if(MSVC)
target_compile_options(core_tests PRIVATE /W4)
else()
target_compile_options(core_tests PRIVATE -Wall -Wextra -Wpedantic -fsanitize=undefined)
target_link_options(core_tests PRIVATE -fsanitize=undefined)
if (ENABLE_COVERAGE)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(core_tests PRIVATE --coverage)
target_link_libraries(core_tests PUBLIC gcov)
endif()
endif()
endif()
setup_sanitizers(core_tests)

add_executable(solver_tests test_solver.cpp)
add_dependencies(solver_tests oRatioLib)
target_compile_definitions(solver_tests PRIVATE NUM_TESTS=1)
target_link_libraries(solver_tests PRIVATE oRatioLib)
if(MSVC)
target_compile_options(solver_tests PRIVATE /W4)
else()
target_compile_options(solver_tests PRIVATE -Wall -Wextra -Wpedantic -fsanitize=undefined)
target_link_options(solver_tests PRIVATE -fsanitize=undefined)
if (ENABLE_COVERAGE)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(solver_tests PRIVATE --coverage)
target_link_libraries(solver_tests PUBLIC gcov)
endif()
endif()
endif()
setup_sanitizers(solver_tests)

add_test(NAME oRatio_CoreTest COMMAND core_tests WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

Expand Down

0 comments on commit 176f4aa

Please sign in to comment.