-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
46 lines (35 loc) · 1.06 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
cmake_minimum_required(VERSION 3.10)
# 设置工程名
project(CalculateSqrt VERSION 1.0)
# 设置最大版本号和最小版本号
set(CalculateSqrt_version_major 1)
set(CalculateSqrt_version_minor 0)
#将版本号传递给源文件,.h.in是新建文档,.h文件是自动生成文件
configure_file(
"${CalculateSqrt_SOURCE_DIR}/CalculateSqrtConfig.h.in"
"${CalculateSqrt_BINARY_DIR}/CalculateSqrtConfig.h"
)
# 设置开关项相应操作
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
list(APPEND EXTRA_INCLUDES "${PROJECT_SOURCE_DIR}/MathFunctions")
endif()
# 添加文件
add_executable(CalculateSqrt main.cpp)
#if(USE_MYMATH)
# target_compile_definitions(CalculateSqrt PRIVATE USE_MYMATH)
#endif()
target_link_libraries(CalculateSqrt PUBLIC ${EXTRA_LIBS})
#包含头文件
# target_include_directories(
# CalculateSqrt
# PUBLIC
# "${PROJECT_BINARY_DIR}"
# "${PROJECT_SOURCE_DIR}/MathFunctions")
#包含头文件
target_include_directories(
CalculateSqrt
PUBLIC
"${PROJECT_BINARY_DIR}"
"${EXTRA_INCLUDES}")