From f8604e3f55b137b0cee1d0884f374d101561f3aa Mon Sep 17 00:00:00 2001 From: Chris Dalke Date: Thu, 7 Nov 2024 12:23:56 -0500 Subject: [PATCH 1/5] Allow disabling building tests from cmake --- CMakeLists.txt | 136 ++++++++++++++++++++++++++----------------------- 1 file changed, 73 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e678da..56886e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,70 +21,80 @@ include_directories(${Boost_INCLUDE_DIR}) # Include modules add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) -# Add fmt -include_directories(lib/fmt/include/) -add_subdirectory(lib/fmt/) +message("Building tests: ${PING_CPP_BUILD_TESTS}") +if(NOT DEFINED PING_CPP_BUILD_TESTS) + set(PING_CPP_BUILD_TESTS true) +endif() + +if (PING_CPP_BUILD_TESTS MATCHES "true") + # Add fmt subdirectory + add_subdirectory(lib/fmt/) -# test-device -add_executable(test-device) -target_sources( - test-device -PRIVATE - test/test-device.cpp -) -target_link_libraries( - test-device -PRIVATE - DEVICE - HAL - PING_MESSAGES - ${Boost_LIBRARIES} - fmt::fmt -) + # test-device + add_executable(test-device) + target_include_directories(test-device PRIVATE lib/fmt/include/) + target_sources( + test-device + PRIVATE + test/test-device.cpp + ) + target_link_libraries( + test-device + PRIVATE + DEVICE + HAL + PING_MESSAGES + ${Boost_LIBRARIES} + fmt::fmt + ) -# test-device-ping1d -add_executable(test-device-ping1d) -target_sources( - test-device-ping1d -PRIVATE - test/test-device-ping1d.cpp -) -target_link_libraries( - test-device-ping1d -PRIVATE - DEVICE - HAL - PING_MESSAGES - ${Boost_LIBRARIES} - fmt::fmt -) + # test-device-ping1d + add_executable(test-device-ping1d) + target_include_directories(test-device-ping1d PRIVATE lib/fmt/include/) + target_sources( + test-device-ping1d + PRIVATE + test/test-device-ping1d.cpp + ) + target_link_libraries( + test-device-ping1d + PRIVATE + DEVICE + HAL + PING_MESSAGES + ${Boost_LIBRARIES} + fmt::fmt + ) -# test-device-ping1d -add_executable(test-device-ping360) -target_sources( - test-device-ping360 -PRIVATE - test/test-device-ping360.cpp -) -target_link_libraries( - test-device-ping360 -PRIVATE - DEVICE - HAL - PING_MESSAGES - ${Boost_LIBRARIES} - fmt::fmt -) + # test-device-ping360 + add_executable(test-device-ping360) + target_include_directories(test-device-ping360 PRIVATE lib/fmt/include/) + target_sources( + test-device-ping360 + PRIVATE + test/test-device-ping360.cpp + ) + target_link_libraries( + test-device-ping360 + PRIVATE + DEVICE + HAL + PING_MESSAGES + ${Boost_LIBRARIES} + fmt::fmt + ) -# test-message -add_executable(test-message) -target_sources( - test-message -PRIVATE - test/test-message.cpp -) -target_link_libraries( - test-message -PRIVATE - PING_MESSAGES -) + # test-message + add_executable(test-message) + target_include_directories(test-message PRIVATE lib/fmt/include/) + target_sources( + test-message + PRIVATE + test/test-message.cpp + ) + target_link_libraries( + test-message + PRIVATE + PING_MESSAGES + ) +endif() From 7bb878ead76963e69ee9c94d15dae15291a84a69 Mon Sep 17 00:00:00 2001 From: Chris Dalke Date: Thu, 7 Nov 2024 12:30:04 -0500 Subject: [PATCH 2/5] Temporarily disable tests completely --- CMakeLists.txt | 136 ++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56886e8..0887fa5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,75 +26,75 @@ if(NOT DEFINED PING_CPP_BUILD_TESTS) set(PING_CPP_BUILD_TESTS true) endif() -if (PING_CPP_BUILD_TESTS MATCHES "true") - # Add fmt subdirectory - add_subdirectory(lib/fmt/) +# if (PING_CPP_BUILD_TESTS MATCHES "true") +# # Add fmt subdirectory +# add_subdirectory(lib/fmt/) - # test-device - add_executable(test-device) - target_include_directories(test-device PRIVATE lib/fmt/include/) - target_sources( - test-device - PRIVATE - test/test-device.cpp - ) - target_link_libraries( - test-device - PRIVATE - DEVICE - HAL - PING_MESSAGES - ${Boost_LIBRARIES} - fmt::fmt - ) +# # test-device +# add_executable(test-device) +# target_include_directories(test-device PRIVATE lib/fmt/include/) +# target_sources( +# test-device +# PRIVATE +# test/test-device.cpp +# ) +# target_link_libraries( +# test-device +# PRIVATE +# DEVICE +# HAL +# PING_MESSAGES +# ${Boost_LIBRARIES} +# fmt::fmt +# ) - # test-device-ping1d - add_executable(test-device-ping1d) - target_include_directories(test-device-ping1d PRIVATE lib/fmt/include/) - target_sources( - test-device-ping1d - PRIVATE - test/test-device-ping1d.cpp - ) - target_link_libraries( - test-device-ping1d - PRIVATE - DEVICE - HAL - PING_MESSAGES - ${Boost_LIBRARIES} - fmt::fmt - ) +# # test-device-ping1d +# add_executable(test-device-ping1d) +# target_include_directories(test-device-ping1d PRIVATE lib/fmt/include/) +# target_sources( +# test-device-ping1d +# PRIVATE +# test/test-device-ping1d.cpp +# ) +# target_link_libraries( +# test-device-ping1d +# PRIVATE +# DEVICE +# HAL +# PING_MESSAGES +# ${Boost_LIBRARIES} +# fmt::fmt +# ) - # test-device-ping360 - add_executable(test-device-ping360) - target_include_directories(test-device-ping360 PRIVATE lib/fmt/include/) - target_sources( - test-device-ping360 - PRIVATE - test/test-device-ping360.cpp - ) - target_link_libraries( - test-device-ping360 - PRIVATE - DEVICE - HAL - PING_MESSAGES - ${Boost_LIBRARIES} - fmt::fmt - ) +# # test-device-ping360 +# add_executable(test-device-ping360) +# target_include_directories(test-device-ping360 PRIVATE lib/fmt/include/) +# target_sources( +# test-device-ping360 +# PRIVATE +# test/test-device-ping360.cpp +# ) +# target_link_libraries( +# test-device-ping360 +# PRIVATE +# DEVICE +# HAL +# PING_MESSAGES +# ${Boost_LIBRARIES} +# fmt::fmt +# ) - # test-message - add_executable(test-message) - target_include_directories(test-message PRIVATE lib/fmt/include/) - target_sources( - test-message - PRIVATE - test/test-message.cpp - ) - target_link_libraries( - test-message - PRIVATE - PING_MESSAGES - ) -endif() +# # test-message +# add_executable(test-message) +# target_include_directories(test-message PRIVATE lib/fmt/include/) +# target_sources( +# test-message +# PRIVATE +# test/test-message.cpp +# ) +# target_link_libraries( +# test-message +# PRIVATE +# PING_MESSAGES +# ) +# endif() From 4debeb7b9a27058b0e46557dcc9ee9e5b06f3eb6 Mon Sep 17 00:00:00 2001 From: Chris Dalke Date: Thu, 7 Nov 2024 18:17:37 -0500 Subject: [PATCH 3/5] Use cmake option instead of set --- CMakeLists.txt | 140 ++++++++++++++++++++++++------------------------- 1 file changed, 69 insertions(+), 71 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0887fa5..8fb8e66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,80 +21,78 @@ include_directories(${Boost_INCLUDE_DIR}) # Include modules add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) +option(PING_CPP_BUILD_TESTS "" ON) message("Building tests: ${PING_CPP_BUILD_TESTS}") -if(NOT DEFINED PING_CPP_BUILD_TESTS) - set(PING_CPP_BUILD_TESTS true) -endif() -# if (PING_CPP_BUILD_TESTS MATCHES "true") -# # Add fmt subdirectory -# add_subdirectory(lib/fmt/) +if (PING_CPP_BUILD_TESTS) + # Add fmt subdirectory + add_subdirectory(lib/fmt/) -# # test-device -# add_executable(test-device) -# target_include_directories(test-device PRIVATE lib/fmt/include/) -# target_sources( -# test-device -# PRIVATE -# test/test-device.cpp -# ) -# target_link_libraries( -# test-device -# PRIVATE -# DEVICE -# HAL -# PING_MESSAGES -# ${Boost_LIBRARIES} -# fmt::fmt -# ) + # test-device + add_executable(test-device) + target_include_directories(test-device PRIVATE lib/fmt/include/) + target_sources( + test-device + PRIVATE + test/test-device.cpp + ) + target_link_libraries( + test-device + PRIVATE + DEVICE + HAL + PING_MESSAGES + ${Boost_LIBRARIES} + fmt::fmt + ) -# # test-device-ping1d -# add_executable(test-device-ping1d) -# target_include_directories(test-device-ping1d PRIVATE lib/fmt/include/) -# target_sources( -# test-device-ping1d -# PRIVATE -# test/test-device-ping1d.cpp -# ) -# target_link_libraries( -# test-device-ping1d -# PRIVATE -# DEVICE -# HAL -# PING_MESSAGES -# ${Boost_LIBRARIES} -# fmt::fmt -# ) + # test-device-ping1d + add_executable(test-device-ping1d) + target_include_directories(test-device-ping1d PRIVATE lib/fmt/include/) + target_sources( + test-device-ping1d + PRIVATE + test/test-device-ping1d.cpp + ) + target_link_libraries( + test-device-ping1d + PRIVATE + DEVICE + HAL + PING_MESSAGES + ${Boost_LIBRARIES} + fmt::fmt + ) -# # test-device-ping360 -# add_executable(test-device-ping360) -# target_include_directories(test-device-ping360 PRIVATE lib/fmt/include/) -# target_sources( -# test-device-ping360 -# PRIVATE -# test/test-device-ping360.cpp -# ) -# target_link_libraries( -# test-device-ping360 -# PRIVATE -# DEVICE -# HAL -# PING_MESSAGES -# ${Boost_LIBRARIES} -# fmt::fmt -# ) + # test-device-ping360 + add_executable(test-device-ping360) + target_include_directories(test-device-ping360 PRIVATE lib/fmt/include/) + target_sources( + test-device-ping360 + PRIVATE + test/test-device-ping360.cpp + ) + target_link_libraries( + test-device-ping360 + PRIVATE + DEVICE + HAL + PING_MESSAGES + ${Boost_LIBRARIES} + fmt::fmt + ) -# # test-message -# add_executable(test-message) -# target_include_directories(test-message PRIVATE lib/fmt/include/) -# target_sources( -# test-message -# PRIVATE -# test/test-message.cpp -# ) -# target_link_libraries( -# test-message -# PRIVATE -# PING_MESSAGES -# ) -# endif() + # test-message + add_executable(test-message) + target_include_directories(test-message PRIVATE lib/fmt/include/) + target_sources( + test-message + PRIVATE + test/test-message.cpp + ) + target_link_libraries( + test-message + PRIVATE + PING_MESSAGES + ) +endif() From ac90d82b4d086efef448af1425784d5b92b16daf Mon Sep 17 00:00:00 2001 From: Chris Dalke Date: Thu, 7 Nov 2024 18:23:51 -0500 Subject: [PATCH 4/5] Conditional build tests --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fb8e66..1e98af5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ include_directories(${Boost_INCLUDE_DIR}) # Include modules add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) -option(PING_CPP_BUILD_TESTS "" ON) +option(PING_CPP_BUILD_TESTS "Build the test cases when PING_CPP_BUILD_TESTS is enabled." ON) message("Building tests: ${PING_CPP_BUILD_TESTS}") if (PING_CPP_BUILD_TESTS) From 855b34a288fe011b2eb3546dcc2e1fed8a2f1205 Mon Sep 17 00:00:00 2001 From: Chris Dalke Date: Tue, 12 Nov 2024 08:36:34 -0500 Subject: [PATCH 5/5] Remove log message --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e98af5..8498a9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,6 @@ include_directories(${Boost_INCLUDE_DIR}) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) option(PING_CPP_BUILD_TESTS "Build the test cases when PING_CPP_BUILD_TESTS is enabled." ON) -message("Building tests: ${PING_CPP_BUILD_TESTS}") if (PING_CPP_BUILD_TESTS) # Add fmt subdirectory