From 222fec65b199de8004e5664edd03ced4f29cdb94 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Mon, 30 Oct 2023 21:54:05 +0100 Subject: cmake: move test build into own file test/CMakeLists.txt --- test/CMakeLists.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/CMakeLists.txt (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..b67735a --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,22 @@ +# Fetch googletest. +# https://google.github.io/googletest/quickstart-cmake.html#set-up-a-project +include(FetchContent) +FetchContent_Declare( + googletest URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip +) +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) + +# Generate CTestTestfile.cmake. +enable_testing() +# Include gtest_discover_tests macro. +include(GoogleTest) + +foreach(T IN ITEMS lt_bus) + set(TGT test-${T}) + add_executable(${TGT} ${T}.cc) + target_include_directories(${TGT} PRIVATE ${SRC}) + target_compile_options(${TGT} PRIVATE -Wall -Wextra) + target_link_libraries(${TGT} GTest::gmock_main SystemC::systemc) + gtest_discover_tests(${TGT}) +endforeach() -- cgit v1.2.3