-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
164 lines (149 loc) · 3.68 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
cmake_minimum_required (VERSION 3.3)
project(glTemplate)
include(CMakeOptions.txt)
find_package(OpenGL REQUIRED)
add_custom_target(rscembedding
DEPENDS ${PROJECT_BINARY_DIR}/bin2c)
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/bin2c
COMMAND gcc -o ${PROJECT_BINARY_DIR}/bin2c external/bin2c/bin2c.c
DEPENDS external/bin2c/bin2c.c
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Building bin2c"
VERBATIM
)
set(CMAKE_CXX_STANDARD 14)
macro(get_WIN32_WINNT version)
if (WIN32 AND CMAKE_SYSTEM_VERSION)
set(ver ${CMAKE_SYSTEM_VERSION})
string(REPLACE "." "" ver ${ver})
string(REGEX REPLACE "([0-9])" "0\\1" ver ${ver})
set(${version} "0x${ver}")
endif()
endmacro()
get_WIN32_WINNT(ver)
if(NOT MSVC)
add_definitions(-D_WIN32_WINNT=${ver})
endif(NOT MSVC)
add_subdirectory(external)
if(NOT TIDE_EXCLUDE)
include_directories(
tide/
)
endif()
include_directories(
external/glfw/include/
external/glew/include/
external/glm
external/assimp/include/
external/mango/include/
external/imgui/
external/imgui/examples
)
if(APPLE)
set(ALL_LIBS
${OPENGL_LIBRARY}
glfw
glew
mango-opengl
)
if(TIDE_MANGO)
set(ALL_LIBS
${ALL_LIBS}
mango-opengl
)
endif()
if(TIDE_ASSIMP)
set(ALL_LIBS
${ALL_LIBS}
assimp
)
endif()
if(TIDE_IMGUI)
set(ALL_LIBS
${ALL_LIBS}
imgui
)
endif()
else()
set(ALL_LIBS
${OPENGL_LIBRARY}
glfw
glew
-static-libgcc
-static-libstdc++
)
if(TIDE_MANGO)
set(ALL_LIBS
${ALL_LIBS}
mango-opengl
)
endif()
if(TIDE_ASSIMP)
set(ALL_LIBS
${ALL_LIBS}
assimp
)
endif()
if(TIDE_IMGUI)
set(ALL_LIBS
${ALL_LIBS}
imgui
)
endif()
endif(APPLE)
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CMAKE_EXE_LINKER_FLAGS " -static")
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_definitions(
-DTW_STATIC
-DTW_NO_LIB_PRAGMA
-DTW_NO_DIRECT3D
-DGLEW_STATIC
-D_CRT_SECURE_NO_WARNINGS
)
# Compilation step for static resources
FUNCTION(ADD_RESOURCES out_var)
SET(result)
FOREACH(in_f ${ARGN})
FILE(RELATIVE_PATH src_f ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${in_f})
if(NOT APPLE)
SET(out_f "${PROJECT_BINARY_DIR}/${in_f}.o")
ADD_CUSTOM_COMMAND(OUTPUT ${out_f}
COMMAND ld -r -b binary -o ${out_f} ${src_f}
DEPENDS ${in_f}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Building object ${out_f}"
VERBATIM
)
else()
SET(out_f "${PROJECT_BINARY_DIR}/${in_f}.o")
SET(c_f "${PROJECT_BINARY_DIR}/${in_f}.c")
string(REPLACE "/" "_" tmp ${in_f})
string(REPLACE "." "_" out_name ${tmp})
ADD_CUSTOM_COMMAND(OUTPUT ${c_f}
COMMAND ${PROJECT_BINARY_DIR}/bin2c ${src_f} ${c_f} ${out_name}
DEPENDS ${in_f}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Building object ${c_f}"
VERBATIM
)
ADD_CUSTOM_COMMAND(OUTPUT ${out_f}
COMMAND gcc -c ${c_f} -o ${out_f}
DEPENDS ${c_f}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Building object ${out_f}"
VERBATIM
)
endif()
LIST(APPEND result ${out_f})
ENDFOREACH()
SET(${out_var} "${result}" PARENT_SCOPE)
ENDFUNCTION()
FILE(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/shaders)
FILE(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/misc)
find_package(Threads)
set(CPP_FILES
${imgui_cpp}
)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
include(CMakeExecutables.txt)