This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
84 lines (63 loc) · 2.52 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
75
76
77
78
79
80
81
82
83
84
cmake_minimum_required(VERSION 3.0)
project(test)
# set the C++ standard to C++ 11
set(CMAKE_CXX_STANDARD 20)
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/source-charset:utf-8>")
# Check platforms
if (CMAKE_HOST_WIN32)
set(third_party_lib_dir ${PROJECT_SOURCE_DIR}/third_party/lib/win)
aux_source_directory(src SRC)
aux_source_directory(util UTILS)
find_package(glfw3 CONFIG REQUIRED)
find_package(glm CONFIG REQUIRED)
find_package(GLEW REQUIRED)
find_package(glew REQUIRED)
find_package(Stb REQUIRED)
find_package(Freetype REQUIRED)
add_executable(${PROJECT_NAME} main.cpp ${SRC} ${UTILS})
target_link_directories(${PROJECT_NAME}
PRIVATE ${Stb_INCLUDE_DIR}
PRIVATE ${third_party_lib_dir}
)
target_link_libraries(${PROJECT_NAME}
# PRIVATE OpenGL
# PRIVATE GL
PRIVATE glfw
PRIVATE glm::glm
PRIVATE GLEW::GLEW
PRIVATE Freetype::Freetype
PRIVATE IrrKlang
)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD # Adds a post-build event to MyTest
COMMAND ${CMAKE_COMMAND} -E copy_directory # which executes "cmake - E copy_if_different..."
${third_party_lib_dir} # <--this is in-file
$<TARGET_FILE_DIR:${PROJECT_NAME}>) # <--this is out-file path
elseif(CMAKE_HOST_UNIX)
# 添加对gdb的支持
SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
set(third_party_lib_dir ${PROJECT_SOURCE_DIR}/third_party/lib/linux)
aux_source_directory(src SRC)
aux_source_directory(util UTILS)
add_executable(${PROJECT_NAME} main.cpp ${SRC} ${UTILS})
target_include_directories(${PROJECT_NAME}
PRIVATE "/usr/include"
PRIVATE "/usr/include/freetype2"
PRIVATE "/usr/include/stb"
)
target_link_directories(${PROJECT_NAME}
PRIVATE ${third_party_lib_dir}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE GL
PRIVATE glfw
PRIVATE GLEW
PRIVATE freetype
PRIVATE IrrKlang
)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD # Adds a post-build event to MyTest
COMMAND ${CMAKE_COMMAND} -E copy_directory # which executes "cmake - E copy_if_different..."
${third_party_lib_dir} # <--this is in-file
$<TARGET_FILE_DIR:${PROJECT_NAME}>) # <--this is out-file path
endif()