Skip to content

Commit

Permalink
full CI/CD correction for CMake.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonymakarewicz committed Jul 15, 2024
1 parent 924705a commit 1e0b56d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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()
22 changes: 18 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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()

0 comments on commit 1e0b56d

Please sign in to comment.