From 1e0b56d5365a2f3404b3e117a6c3c8df326cc140 Mon Sep 17 00:00:00 2001 From: anthonymakarewicz Date: Mon, 15 Jul 2024 15:22:30 +0200 Subject: [PATCH] full CI/CD correction for CMake.txt --- CMakeLists.txt | 16 +++++++++++++++- tests/CMakeLists.txt | 22 ++++++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1dfac29..506af83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,4 +15,18 @@ add_executable(Option_pricer main.cpp src/option.cpp src/payoff.cpp src/market_d # Enable testing enable_testing() -add_subdirectory(tests) \ No newline at end of file +add_subdirectory(tests) + +# clang-tidy integration +set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=*,-clang-analyzer-alpha.*") + +# clang-format integration (target to check formatting) +#add_custom_target(clang-format-check +# COMMAND find ${CMAKE_SOURCE_DIR} -name '*.cpp' -o -name '*.h' | xargs clang-format -i +#) + +# Code coverage integration (optional) +if (CMAKE_BUILD_TYPE STREQUAL "Coverage") + target_compile_options(Option_pricer PRIVATE --coverage) + target_link_libraries(Option_pricer PRIVATE --coverage) +endif() \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4df50d6..4ccd6cc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,16 +6,30 @@ add_executable(Option_tester test_main.cpp test_market_data.cpp test_payoff.cpp - #test_option.cpp + mock_classes.h + test_support.h ../src/payoff.cpp ../src/market_data.cpp ../src/option.cpp #test_option.cpp - test_support.h - mock_classes.h) +) # Link Google Test and Google Mock to the test executable target_link_libraries(Option_tester GTest::GTest GTest::Main GTest::gmock_main) # Optionally, register tests with CMake's testing system -add_test(NAME OptionTester COMMAND Option_tester) \ No newline at end of file +add_test(NAME OptionTester COMMAND Option_tester) + +# clang-tidy integration +set_target_properties(Option_tester PROPERTIES CXX_CLANG_TIDY "clang-tidy;-checks=*,-clang-analyzer-alpha.*") + +# clang-format integration (target to check formatting) +add_custom_target(clang-format-check + COMMAND find ${CMAKE_SOURCE_DIR} -name '*.cpp' -o -name '*.h' | xargs clang-format -i +) + +# Code coverage integration (optional) +if (CMAKE_BUILD_TYPE STREQUAL "Coverage") + target_compile_options(Option_tester PRIVATE --coverage) + target_link_libraries(Option_tester PRIVATE --coverage) +endif() \ No newline at end of file