This repository has been archived by the owner on Aug 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
125 lines (108 loc) · 5.73 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
cmake_minimum_required(VERSION 3.15)
project(NginD)
set(CMAKE_CXX_STANDARD 17)
if (0)
set(OUT_PATH build)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
else()
set(OUT_PATH bin)
endif()
option(PLATFORM_LINUX "target platform: linux" ON)
option(PLATFORM_WINDOWS "target platform: windows" OFF)
include(kernel/CMakeLists.txt)
include(extern/CMakeLists.txt)
include(plugin/CMakeLists.txt)
include_directories(.)
include_directories(kernel)
include_directories(include)
include_directories(include/opengl)
include_directories(resources)
include_directories(include/freetype2)
if (PLATFORM_LINUX)
add_definitions(-D PLATFORM_LINUX)
include_directories(/usr/local/include/freetype2)
elseif (PLATFORM_WINDOWS)
add_definitions(-D PLATFORM_WINDOWS)
include_directories(include/freetype2)
endif()
if (PLATFORM_LINUX)
set(PLATFORM_PREFIX "/lib/linux")
elseif (PLATFORM_WINDOWS)
set(PLATFORM_PREFIX "/lib/windows")
endif()
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/${OUT_PATH}")
add_executable(NginD main.cc
${KERNEL_HEADER}
${KERNEL_SRC}
${EXTERN_HEADER}
${EXTERN_SRC}
${PLUGIN_HEADER}
${PLUGIN_SRC})
if (PLATFORM_LINUX)
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/libGLEW.so.2.1")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/libGLEW.so")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/libglfw.so")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/libglfw3.a")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/libglfw.so.3")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/libGL.so")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/libX11.so")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/libXrand.so")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/libXi.so")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/libXi.a")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/soil2/libsoil2.a")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/soloud/libSDL2.a")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/soloud/libSDL2main.a")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/soloud/libsoloud_static_x64.a" "libasound.so" -ldl -lpthread)
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/lua/liblua52.so")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/freetype/libfreetype.so")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/freetype/libfreetype.a")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/snappy/libsnappy.a")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/box2d/libbox2d.a")
elseif (PLATFORM_WINDOWS)
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/glew32.lib")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/glew32s.lib")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/glfw3.lib")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/glfw3_mt.lib")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/opengl/glfw3dll.lib")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/soloud/soloud_static_x64.lib")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/freetype/freetype.lib")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/soil2/soil2.lib")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/box2d/box2d.lib")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/snappy/snappy.lib")
target_link_libraries(NginD "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/lua/lua52.lib")
target_link_libraries(NginD "opengl32.lib")
endif()
if (PLATFORM_LINUX)
add_custom_command(TARGET ${PROJECT_NAME}
PRE_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_directory "${CMAKE_SOURCE_DIR}/resources" "${EXECUTABLE_OUTPUT_PATH}/resources"
COMMENT "COPY RESOURCES FILES")
add_compile_options(-ldl)
add_compile_options(-pthread)
elseif (PLATFORM_WINDOWS)
add_custom_command(TARGET ${PROJECT_NAME}
PRE_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_directory "../resources" "${EXECUTABLE_OUTPUT_PATH}/Debug/resources"
COMMENT "COPY RESOURCES FILES")
add_custom_command(TARGET ${PROJECT_NAME}
PRE_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E copy_directory "../resources" "../win32/resources"
COMMENT "COPY RESOURCES FILES")
file(COPY "${CMAKE_SOURCE_DIR}/${PLATFORM_PREFIX}/freetype/freetype.dll" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/Debug")
file(COPY "${CMAKE_SOURCE_DIR}/${PLATFORM_PREFIX}/lua/lua52.dll" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/Debug")
file(COPY "${CMAKE_SOURCE_DIR}/${PLATFORM_PREFIX}/opengl/glfw3.dll" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/Debug")
file(COPY "${CMAKE_SOURCE_DIR}/${PLATFORM_PREFIX}/opengl/glew32.dll" DESTINATION "${EXECUTABLE_OUTPUT_PATH}/Debug")
endif()
add_compile_options(-finput-charset=GBK -fexec-charset=UTF-8)
add_executable(crypto kernel/crypto/main.cc
kernel/crypto/aes.h kernel/crypto/aes.cc
kernel/math/galois_field.h kernel/math/galois_field.cc)
add_executable(compress kernel/compress/main.cc)
if (PLATFORM_LINUX)
target_link_libraries(compress "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/snappy/libsnappy.a")
elseif (PLATFORM_WINDOWS)
target_link_libraries(compress "${CMAKE_SOURCE_DIR}${PLATFORM_PREFIX}/snappy/snappy.lib")
endif()