From 3bb3c68e9530a24995fade45ce763298aaaf6292 Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Tue, 17 Jun 2025 17:18:17 +0200 Subject: [PATCH] Moved unit test cmake commands to test --- CMakeLists.txt | 27 +-------------------------- Testing/Temporary/LastTest.log | 3 +++ test/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 Testing/Temporary/LastTest.log create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index bcec558..63a3359 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,33 +35,8 @@ else() option(BUILD_EXAMPLE_BB2A "Build BB2A Example" OFF) add_subdirectory(examples) - add_compile_definitions(GTEST) - include(FetchContent) - FetchContent_Declare( - googletest - DOWNLOAD_EXTRACT_TIMESTAMP ON - URL https://github.com/google/googletest/archive/refs/heads/main.zip - ) - - # For Windows: Prevent overriding the parent project's compiler/linker settings - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - FetchContent_MakeAvailable(googletest) - enable_testing() + add_subdirectory(test) - file(GLOB_RECURSE test_srcs test/*_test.cc) - add_executable( - RoboidControlTest - ${test_srcs} - ) - target_link_libraries( - RoboidControlTest - gtest_main - RoboidControl - LinearAlgebra - ) - - include(GoogleTest) - gtest_discover_tests(RoboidControlTest) endif() diff --git a/Testing/Temporary/LastTest.log b/Testing/Temporary/LastTest.log new file mode 100644 index 0000000..3ab3dd5 --- /dev/null +++ b/Testing/Temporary/LastTest.log @@ -0,0 +1,3 @@ +Start testing: Jun 17 17:17 W. Europe Summer Time +---------------------------------------------------------- +End testing: Jun 17 17:17 W. Europe Summer Time diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..99ee89c --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,30 @@ +# Unit test configuration + +add_compile_definitions(GTEST) +include(FetchContent) +FetchContent_Declare( + googletest + DOWNLOAD_EXTRACT_TIMESTAMP ON + URL https://github.com/google/googletest/archive/refs/heads/main.zip +) + +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) + +file(GLOB_RECURSE test_srcs *.cc) +message(STATUS "Test sources: ${test_srcs}") +add_executable( + RoboidControlTest + ${test_srcs} +) +message(STATUS "RoboidControlTest target created") +target_link_libraries( + RoboidControlTest + gtest_main + RoboidControl + LinearAlgebra +) + +include(GoogleTest) +gtest_discover_tests(RoboidControlTest) \ No newline at end of file