-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
208 lines (180 loc) · 5.99 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#cmake ver req
cmake_minimum_required(VERSION 2.8.3)
if(NOT CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE Release CACHE STRING "Select if you want to build Debug or Release" FORCE )
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake/modules/")
set(SHARED_BUILD TRUE CACHE BOOL "Set this to false if you want a static build")
set(BUILD_TESTS TRUE CACHE BOOL "build the tests")
set(BUILD_EXAMPLES TRUE CACHE BOOL "build the examples - requires SDL2")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) #for shared libs
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) #for static libs
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) #for static libs
SET(CMAKE_DEBUG_POSTFIX "-d")
if(SHARED_BUILD)
set(SHARED_OR_STATIC SHARED)
else(SHARED_BUILD)
set(SHARED_OR_STATIC STATIC)
endif(SHARED_BUILD)
set(project_name gimgui)
project(${project_name})
find_package(Freetype REQUIRED)
include_directories(${FREETYPE_INCLUDE_DIRS})
#Set source files.
set(source_files
src/data/element.cpp
src/data/codepointsize.cpp
src/data/font.cpp
src/data/fontloadexception.cpp
src/data/renderdata.cpp
src/data/texturecoordinates.cpp
src/data/textstyles.cpp
src/data/variant.cpp
src/logic/attributepopulator.cpp
src/logic/fonttexturecache.cpp
src/logic/rectanglepacker.cpp
src/logic/utf8decoder.cpp
src/util/guillotinebinpack.cpp
)
set(header_files
include/gimgui/assert.hpp
include/gimgui/data/bitmap.hpp
include/gimgui/data/codepointsize.hpp
include/gimgui/data/element.hpp
include/gimgui/data/element.inl
include/gimgui/data/font.hpp
include/gimgui/data/fontloadexception.hpp
include/gimgui/data/glyph.hpp
include/gimgui/data/ivec2.hpp
include/gimgui/data/renderdata.hpp
include/gimgui/data/rendermodes.hpp
include/gimgui/data/rectangle.hpp
include/gimgui/data/types.hpp
include/gimgui/data/textalignments.hpp
include/gimgui/data/textstyles.hpp
include/gimgui/data/texturecoordinates.hpp
include/gimgui/data/variant.hpp
include/gimgui/data/variant.inl
include/gimgui/data/wrapmode.hpp
include/gimgui/logic/absolutemap.hpp
include/gimgui/logic/absolutemap.inl
include/gimgui/logic/attributepopulator.hpp
include/gimgui/logic/attributepopulator.inl
include/gimgui/logic/event.hpp
include/gimgui/logic/fonttexturecache.hpp
include/gimgui/logic/fonttexturecache.inl
include/gimgui/logic/foreach.hpp
include/gimgui/logic/foreach.inl
include/gimgui/logic/renderdatagenerator.hpp
include/gimgui/logic/renderdatagenerator.inl
include/gimgui/logic/rectanglepacker.hpp
include/gimgui/logic/utf8decoder.hpp
include/gimgui/util/getorfallback.hpp
include/gimgui/util/getorfallback.inl
include/gimgui/util/guillotinebinpack.hpp
include/gimgui/util/ref.hpp
include/gimgui/util/ref.inl
include/gimgui/util/resolve.hpp
include/gimgui/util/resolve.inl
)
include_directories(include)
#C++11 required
if(NOT MSVC)
set(CPP_11_FLAG -std=c++11)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPP_11_FLAG}")
#build
add_library(${project_name} ${SHARED_OR_STATIC} ${header_files} ${source_files})
target_link_libraries(${project_name} ${FREETYPE_LIBRARIES})
#tests
if(BUILD_TESTS)
include_directories(test)
add_executable(tests "test/main.cpp"
"test/data/elementtest.cpp"
"test/data/fonttest.cpp"
"test/data/rectangletest.cpp"
"test/data/varianttest.cpp"
"test/logic/attributepopulatortest.cpp"
"test/logic/absolutemaptest.cpp"
"test/logic/fonttexturecachetest.cpp"
"test/logic/renderdatageneratortest.cpp"
"test/logic/rectanglepackertest.cpp"
"test/logic/utf8decodertest.cpp"
"test/helpers/helperstest.cpp"
"test/util/getorfallbacktest.cpp"
"test/util/guillotinebinpacktest.cpp"
"test/util/resolvetest.cpp"
"test/util/reftest.cpp"
"test/helpers/color.cpp"
"test/helpers/closeenough.cpp"
"test/helpers/textureinterfacestub.cpp"
"test/helpers/vector2.cpp"
"test/helpers/rectangle.cpp"
)
target_link_libraries(tests ${project_name})
endif(BUILD_TESTS)
#examples
if(BUILD_EXAMPLES)
find_package(OpenGL REQUIRED)
if(${OPENGL_FOUND})
include_directories(${OPENGL_INCLUDE_DIRS})
endif()
find_package(SDL2 REQUIRED)
if(SDL2_FOUND)
include_directories(${SDL2_INCLUDE_DIR})
endif()
set(common "examples/common")
include_directories(${common})
set(common_src
${common}/gl_core_3_3.c
${common}/window.cpp
${common}/lodepng.cpp
${common}/textureadaptor.cpp
${common}/glutils/baseshader.cpp
${common}/glutils/buffer.cpp
${common}/glutils/projection.cpp
${common}/glutils/shader.cpp
${common}/glutils/texture.cpp
${common}/glutils/textureloader.cpp
${common}/glutils/uniform.cpp
${common}/glutils/vao.cpp
${common}/glutils/vertexattribute.cpp
)
set(simple_src "examples/simple_rendering/src")
add_executable(simple_rendering
${common_src}
${simple_src}/main.cpp
${simple_src}/simplerendering.cpp
${simple_src}/events.cpp
test/helpers/vector2.cpp
test/helpers/rectangle.cpp
test/helpers/color.cpp
)
target_link_libraries(simple_rendering ${project_name} ${SDL2_LIBRARY} ${OPENGL_LIBRARIES})
endif()
#testing
if(BUILD_TESTS)
enable_testing()
add_test(tests ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tests)
endif()
#installation
if(WIN32)
set(GIMGUI_MISC_DIR .)
set(WINFIX SYSTEM)
else()
set(GIMGUI_MISC_DIR share/gimgui)
endif()
install(
DIRECTORY include
DESTINATION .
)
install(
TARGETS ${project_name}
RUNTIME DESTINATION bin COMPONENT bin
LIBRARY DESTINATION lib COMPONENT bin
ARCHIVE DESTINATION lib COMPONENT dev
)
install(
FILES README.md LICENSE
DESTINATION ${GIMGUI_MISC_DIR}
)