-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
50 lines (40 loc) · 1.48 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
cmake_minimum_required(VERSION 3.25)
project(ZeroRPC CXX)
# 启用C++20标准,这是使用模块所必需的
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
file(GLOB_RECURSE SRC
"${CMAKE_CURRENT_SOURCE_DIR}/Core/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Common/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Common/*.hpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Maintain/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/RPC/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/RPC/*.hpp"
)
file(GLOB_RECURSE INC
"${CMAKE_CURRENT_SOURCE_DIR}/Core/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/Common/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/Maintain/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/RPC/*.h"
)
set(ENABLE_UNIT_TESTS ON CACHE INTERNAL "Enable unit tests")
message(STATUS "Enable testing: ${ENABLE_UNIT_TESTS}")
if(ENABLE_UNIT_TESTS)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.15.2
)
FetchContent_MakeAvailable(googletest)
enable_testing()
file(GLOB_RECURSE SRC_TEST "${CMAKE_CURRENT_SOURCE_DIR}/Test/*.cpp")
add_executable(unitTest ${SRC} ${INC} ${SRC_TEST})
target_link_libraries(unitTest gtest gtest_main brotlienc brotlidec uuid)
include(GoogleTest)
gtest_discover_tests(unitTest)
else()
# 添加可执行文件
add_executable(ZeroRPC ${SRC} ${INC})
target_link_libraries(ZeroRPC brotlienc brotlidec uuid)
endif ()