-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
53 lines (39 loc) · 1.1 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
cmake_minimum_required(VERSION 3.10)
project(DianCubes)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
add_compile_options(/wd4819)
endif()
# 添加资源目录
set(RESOURCES_DIR ${PROJECT_SOURCE_DIR}/res)
file(GLOB_RECURSE RESOURCES ${RESOURCES_DIR}/*)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/out/)
# 将资源复制到输出目录
foreach(RESOURCE ${RESOURCES})
file(RELATIVE_PATH RESOURCE_PATH ${RESOURCES_DIR} ${RESOURCE})
configure_file(${RESOURCE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${RESOURCE_PATH}
COPYONLY)
endforeach()
# 依靠fetchcontent 属性安装第三方库
include(FetchContent)
FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG 1.0.1
GIT_SHALLOW 1
)
FetchContent_MakeAvailable(glm)
link_directories(lib)
# 添加 GLAD 和链接 OpenGL 库
include_directories(include)
# 添加源文件
set(SOURCE_FILES
src/main.cpp
src/glad.c
src/stb_image.cpp
# 这里列出你的其他源文件
)
# 创建可执行文件
add_executable(DianCubes ${SOURCE_FILES})
# 链接 GLFW 和 GLAD 库
target_link_libraries(DianCubes PRIVATE glfw3 glm)