-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
74 lines (64 loc) · 1.95 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
cmake_minimum_required(VERSION 3.22)
# 设定项目名称
project(dots_and_boxes)
# 设定语言标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
IF(WIN32)
# 定义第三方库路径
set(SFML_DIR 3rdparty/SFML/lib/cmake/SFML)
ENDIF()
set(nowide_DIR 3rdparty/nowide/lib/cmake/nowide)
# 如需静态链接SFML请取消下句注释
#set(SFML_STATIC_LIBRARIES TRUE)
# 查找第三方库
find_package(SFML 2.5 COMPONENTS
system window graphics REQUIRED)
find_package(nowide)
# 声明 SOURCES
file(GLOB_RECURSE SOURCES
src/main.cpp
src/AI/assess.cpp
src/AI/assess.h
src/AI/board.cpp
src/AI/board.h
src/AI/define.h
src/AI/Node.cpp
src/AI/Node.h
src/AI/UCT.cpp
src/AI/UCT.h
src/element/Time.cpp
src/element/Time.h
src/CJSON/cJSON.c
src/CJSON/cJSON.h
src/CJSON/datarecorder.cpp
src/CJSON/datarecorder.h
)
# 如果想要编译出来的程序不带控制台,使用这个
#add_executable(dots_and_boxes WIN32 ${SOURCES})
# 如果想要编译出来的程序带控制台,使用这个
add_executable(dots_and_boxes ${SOURCES})
# 链接头文件查找目录
IF(WIN32)
target_include_directories(dots_and_boxes PUBLIC 3rdparty/SFML/include)
ENDIF()
target_include_directories(dots_and_boxes PUBLIC 3rdparty/nowide/include)
#如需静态链接
#set(CMAKE_EXE_LINKER_FLAGS "-static")
# 链接库
target_link_libraries(dots_and_boxes PRIVATE sfml-system sfml-window sfml-graphics)
IF (WIN32)
# 复制dll
file(GLOB_RECURSE PROJECT_DLL 3rdparty/*.dll)
add_custom_command(TARGET dots_and_boxes POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_DLL}
$<TARGET_FILE_DIR:dots_and_boxes>
)
ENDIF ()
# 复制资源文件
add_custom_command(TARGET dots_and_boxes POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/res
$<TARGET_FILE_DIR:dots_and_boxes>/res
)