/
CMakeLists.txt
277 lines (203 loc) · 7.13 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#/**
# *
# * This file is part of GusGui.
# * Copyright 2011 Andreas Rönnquist
# *
# * GusGame is free software: you can redistribute it and/or modify
# * it under the terms of the GNU Lesser General Public License as published by
# * the Free Software Foundation, either version 3 of the License, or
# * (at your option) any later version.
# *
# * GusGame is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# * GNU Lesser General Public License for more details.
# *
# * You should have received a copy of the GNU Lesser General Public License
# * along with GusGame. If not, see <http://www.gnu.org/licenses/>.
# *
# */
project (GusGui)
# Require CMake 2.6
cmake_minimum_required(VERSION 3.10.2)
# cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
set(GUSGUI_LIBRARY_NAME gusgui)
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
option (DEBUG "Build Debug executable" off)
find_package(Allegro5 REQUIRED)
if (DEBUG)
message(STATUS "Building Debug executable")
set(CMAKE_BUILD_TYPE "Debug")
add_definitions(-D_DEBUG)
#add_definitions(-Wwrite-strings
#-Wextra
#-Wall
#-Winit-self
#-O
#-Wno-uninitialized
#-Wno-unused-parameter
#-Wno-switch
#-w
#-Wreturn-type
#-Weffc++
#)
# Cpp only flags: (Will not be applied to C files.)
# set(CMAKE_CXX_FLAGS -Weffc++)
else (DEBUG)
message(STATUS "Building Release executable")
#add_definitions(-fomit-frame-pointer)
set(CMAKE_BUILD_TYPE "Release")
endif (DEBUG)
set(DLL_FLAGS -DBUILDING_GUSGAME_DLL)
set(BUILD_SHARED_LIBS on)
SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -DBUILDING_GUSGAME_DLL")
# Fix MinGW/MSYS problem-- c:\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe:
# warning: auto-importing has been activated without --enable-auto-import
# specified on the command line.
#
# see
# http://sourceware.org/ml/binutils/2009-02/msg00341.html
# http://wiki.wxwidgets.org/HowTo:_Install_MSYS_and_MinGW_for_use_with_Eclipse_CDT
#
# for some info.
if (MSYS)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-enable-auto-import")
endif (MSYS)
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
# Silence OpenGL cmake policy warnings
# See CMP0072 for more details (cmake --help-policy CMP0072)
if ((NOT ${CMAKE_VERSION} VERSION_LESS 3.11) AND (NOT OpenGL_GL_PREFERENCE))
set(OpenGL_GL_PREFERENCE "GLVND")
endif()
find_package(OpenGL REQUIRED)
find_package(GusGame REQUIRED)
find_package(Allegro5 REQUIRED)
message(STATUS "GusGame Library: ${GUSGAME_LIBRARY}")
include_directories(include ${GUSGAME_INCLUDE_DIR})
include_directories(include ${CMAKE_SOURCE_DIR}/include)
include_directories(include ${CMAKE_SOURCE_DIR}/include/GusGui)
include_directories(include ${ALLEGRO_INCLUDE_DIR})
# -------------------------------------------------------
# Gui Object Source
# -------------------------------------------------------
set(SRC src/GuiObjects)
set(OBJECT_SOURCES
${SRC}/Button.cpp
${SRC}/CheckBox.cpp
${SRC}/DelayButton.cpp
${SRC}/FadeButton.cpp
${SRC}/FileListGui.cpp
${SRC}/GuiObject.cpp
${SRC}/InvisibleGuiObject.cpp
${SRC}/LoaderMeter.cpp
${SRC}/Panel.cpp
# ${SRC}/TextInput.cpp
# ${SRC}/TextMarker.cpp
)
#add_library(logLib STATIC ${LOG_SOURCES})
# -------------------------------------------------------
# "Root"
# -------------------------------------------------------
set(SRC src/)
set(LIB_SOURCES
${SRC}/GuiData.cpp
${SRC}/GuiDraw.cpp
${SRC}/GuiHandler.cpp
${SRC}/GuiEventHandler.cpp
)
#add_library(exceptionLib STATIC ${EXCEPTION_SOURCES})
#add_library(eventLib STATIC ${EVENTLIB_SOURCES})
set(SOURCES
${OBJECT_SOURCES}
${LIB_SOURCES}
)
set(INC include/GusGui)
set(INCLUDE_FILES
${INC}/Button.h
${INC}/DelayButton.h
${INC}/DynamicLink.h
${INC}/FileListGui.h
${INC}/GuiDraw.h
${INC}/GuiLib.h
${INC}/GusGui.h
${INC}/LoaderMeter.h
#${INC}/TextInput.h
${INC}/CheckBox.h
${INC}/FadeButton.h
${INC}/GuiData.h
${INC}/GuiHandler.h
${INC}/GuiObject.h
${INC}/InvisibleGuiObject.h
${INC}/Panel.h
#${INC}/TextMarker.h
${INC}/GuiEventHandler.h
)
if (WIN32)
if (MSYS)
Set (WINGL_LIBS glu32)
else (MSYS)
Set (WINGL_LIBS glu32)
endif (MSYS)
endif(WIN32)
find_package(OpenGL REQUIRED)
find_package(GusGame REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem system)
message(STATUS "GusGame Library: ${GUSGAME_LIBRARY}")
include_directories(include ${CMAKE_SOURCE_DIR}/src)
include_directories(include ${CMAKE_SOURCE_DIR}/src/Objects)
include_directories(include ${GUSGAME_INCLUDE_DIR})
include_directories(include ${Boost_INCLUDE_DIR})
if (MSYS)
message(STATUS "MingDir: $ENV{MINGDIR}")
endif (MSYS)
message(STATUS "Boost INCLUDE_DIR: ${Boost_INCLUDE_DIR}")
message(STATUS "GUSGAME_INCLUDE_DIR: ${GUSGAME_INCLUDE_DIR}")
if (NOT ALLEGRO_FOUND)
message(FATAL_ERROR "Allegro not found!")
endif (NOT ALLEGRO_FOUND)
# And some libs:
message(STATUS "Allegro5 LIBRARY: ${ALLEGRO_LIBRARIES}")
message(STATUS "OPENGL_LIBRARY: ${OPENGL_LIBRARY}")
message(STATUS "OPENGL_LIBRARIES: ${OPENGL_LIBRARIES}")
message(STATUS "GLUT_LIBRARY: ${GLUT_LIBRARY}")
message(STATUS "MY_GLEW_LIB: ${MY_GLEW_LIB}")
if (USE_GLEW)
set (MY_GLEW_LIB ${GLEW_LIBRARY})
else (USE_GLEW)
set (MY_GLEW_LIB )
endif (USE_GLEW)
if (MSYS)
set (GL_LIBS ${OPENGL_LIBRARY} ${OPENGL_LIBRARIES})
else (MSYS)
set (GL_LIBS ${OPENGL_LIBRARY})
endif (MSYS)
set(ALL_LIBS
${LUA_LIBRARIES}
${GL_LIBS}
${GLUT_LIBRARY}
${WINGL_LIBS}
${MY_GLEW_LIB}
${ALLEGRO_LIBRARIES}
)
link_libraries(${ALL_LIBS} ${GUSGAME_LIBRARY})
add_library(${GUSGUI_LIBRARY_NAME} STATIC ${SOURCES})
target_link_libraries(${GUSGUI_LIBRARY_NAME} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY}) #${ALL_LIBS})
set(EX_DIR examples)
# link_libraries(${ALL_LIBS})
#add_dependencies(example1 ${LIBRARY_NAME})
include_directories(include "/usr/local/include")
include_directories(include ${GUSGAME_INCLUDE})
LINK_DIRECTORIES( ${LINK_DIRECTORIES} ${LIBRARY_OUTPUT_PATH} )
add_executable(example1 WIN32 ${EX_DIR}/example1.cpp)
target_link_libraries(example1 ${ALL_LIBS} ${GUSGUI_LIBRARY_NAME} ${GUSGAME_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
add_executable(example2 WIN32 ${EX_DIR}/example2.cpp)
target_link_libraries(example2 ${ALL_LIBS} ${GUSGUI_LIBRARY_NAME} ${GUSGAME_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
#add_executable(example3 WIN32 ${EX_DIR}/example3.cpp)
#target_link_libraries(example3 ${ALL_LIBS} ${LIBRARY_NAME})
#add_executable(example4 WIN32 ${EX_DIR}/example4.cpp)
#target_link_libraries(example4 ${ALL_LIBS} ${MY_LIBS} ${LIBRARY_NAME})
install_targets(/lib ${GUSGUI_LIBRARY_NAME})
install(FILES ${INCLUDE_FILES} DESTINATION include/GusGui)