添加googletest
This commit is contained in:
@@ -1,11 +1,13 @@
|
|||||||
cmake_minimum_required(VERSION 3.30)
|
cmake_minimum_required(VERSION 3.30)
|
||||||
project(leetcode C)
|
project(leetcode C CXX)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
-Wall
|
-Wall
|
||||||
-Wextra
|
-Wextra
|
||||||
@@ -21,6 +23,14 @@ add_link_options(
|
|||||||
-fsanitize=undefined
|
-fsanitize=undefined
|
||||||
)
|
)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
googletest
|
||||||
|
URL https://github.com/google/googletest/releases/download/v1.15.2/googletest-1.15.2.tar.gz
|
||||||
|
URL_HASH MD5=7e11f6cfcf6498324ac82d567dcb891e
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(googletest)
|
||||||
|
|
||||||
file(GLOB SRC_FILES "src/*.c")
|
file(GLOB SRC_FILES "src/*.c")
|
||||||
|
|
||||||
foreach (SRC_FILE ${SRC_FILES})
|
foreach (SRC_FILE ${SRC_FILES})
|
||||||
@@ -28,3 +38,4 @@ foreach(SRC_FILE ${SRC_FILES})
|
|||||||
add_executable(${EXE_NAME} ${SRC_FILE})
|
add_executable(${EXE_NAME} ${SRC_FILE})
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
|
add_subdirectory(tests)
|
||||||
|
|||||||
Reference in New Issue
Block a user