With different test

This commit is contained in:
2025-08-03 21:22:03 +08:00
parent 4f277b00d5
commit 3bc78b34dd

View File

@@ -82,20 +82,26 @@ else()
)
endif()
foreach(test_file ${TEST_FILES})
get_filename_component(test_name ${test_file} NAME_WE) # utFoo
add_executable(${test_name}
${SRC_FILES}
${INCLUDE_FILES}
${test_file}
)
target_link_libraries(${test_name} PRIVATE GTest::gtest_main)
target_include_directories(${test_name} PRIVATE ${INCLUDE_DIR})
target_compile_options(${test_name} PRIVATE ${TARGET_COMPILER_OPTIONS})
add_executable(ut_test_1
include/Package.hpp
src/Package.cpp
test/ut_Package.cpp
)
include(GoogleTest)
gtest_discover_tests(${test_name})
endforeach()
add_executable(ut_test_2
include/Package.hpp
include/MainDish.hpp
include/SideDish.hpp
include/Drink.hpp
include/Food.hpp
src/Package.cpp
src/MainDish.cpp
src/SideDish.cpp
src/Drink.cpp
src/Food.cpp
test/ut_Package.cpp
test/ut_Food.cpp
)
add_executable(ut_all
${SRC_FILES}
@@ -103,6 +109,25 @@ add_executable(ut_all
${TEST_FILES}
)
target_link_libraries(ut_test_1
GTest::gtest_main
)
target_include_directories(ut_test_1 PRIVATE
${INCLUDE_DIR}
)
target_compile_options(ut_test_1 PRIVATE
${TARGET_COMPILER_OPTIONS}
)
target_link_libraries(ut_test_2
GTest::gtest_main
)
target_include_directories(ut_test_2 PRIVATE
${INCLUDE_DIR}
)
target_compile_options(ut_test_2 PRIVATE
${TARGET_COMPILER_OPTIONS}
)
target_link_libraries(ut_all
GTest::gtest_main