From 0693bda9702bffafd29b3926e3ab96e623939faf Mon Sep 17 00:00:00 2001 From: kradchen Date: Fri, 5 May 2023 16:48:34 +0800 Subject: [PATCH] Add gtest support. --- CMakeLists.txt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f752cd..9ccb48f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,24 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) find_package(Aurora REQUIRED) file(GLOB_RECURSE cpp_files ./src/*.cpp) file(GLOB_RECURSE cxx_files ./src/*.cxx) -add_executable(UR ${cpp_files} ${cxx_files} ${Aurora_Source}) +file(GLOB_RECURSE header_files ./src/*.h) +add_executable(UR ${cpp_files} ${cxx_files} ${header_files} ${Aurora_Source}) target_compile_options(UR PUBLIC ${Aurora_Complie_Options}) target_include_directories(UR PUBLIC ${Aurora_INCLUDE_DIRS}) target_link_libraries(UR PUBLIC ${Aurora_Libraries}) -target_link_libraries(UR PUBLIC matio) \ No newline at end of file +target_link_libraries(UR PUBLIC matio) + +find_package(GTest REQUIRED) +INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS}) +file(GLOB_RECURSE test_cpp ./test/*.cpp) + +enable_testing() + +add_executable(UR_Test ${cpp_files} ${header_files} ${Aurora_Source} ${test_cpp} ) +target_include_directories(UR_Test PUBLIC ./test/ ./src/) +target_compile_options(UR_Test PUBLIC ${Aurora_Complie_Options}) +target_include_directories(UR_Test PUBLIC ${Aurora_INCLUDE_DIRS}) +target_link_libraries(UR_Test PUBLIC ${Aurora_Libraries}) +target_link_libraries(UR_Test PUBLIC matio) +target_link_libraries(UR_Test PUBLIC ${GTEST_BOTH_LIBRARIES}) +gtest_discover_tests(UR_Test ) \ No newline at end of file