添加 tests/CMakeLists.txt

This commit is contained in:
root 2026-04-28 08:59:41 +00:00
parent 1d069f92a2
commit e8ecd9f2bc
1 changed files with 29 additions and 0 deletions

29
tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.10.0)
project(auto_plan_test)
include(FetchContent)
if (MSVC)
add_compile_options(/utf-8)
endif()
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
#include_directories(D:/workspace/googletest-demo/test_main)
#add_executable(demo max.cpp main.cpp)
# find_package使
find_package(GTest REQUIRED)
include(CTest)
enable_testing()
file(GLOB TEST_SOURCES "../*.cpp")
add_executable(auto_plan_test test_codegen.cpp ${TEST_SOURCES})
target_link_libraries(auto_plan_test gtest gmock gtest_main)
include(GoogleTest)
gtest_discover_tests(auto_plan_test)