-
Notifications
You must be signed in to change notification settings - Fork 21
/
CMakeLists.txt
executable file
·260 lines (230 loc) · 11 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
project(RocketEditor)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_OSX_ARCHITECTURES x86_64)
set(RKT_EXE_NAME "RocketEditor")
set(EXAMPLE_NAME "BasicExample")
set(VERSION_MAJOR "1")
set(VERSION_MINOR "1")
set(VERSION_PATCH "0")
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
if (APPLE)
add_definitions(-DMACOSX -DEMGUI_MACOSX)
add_compile_options(-Wall -Wno-format-security -Wno-deprecated-declarations)
elseif (UNIX)
add_definitions(-DEMGUI_UNIX)
add_compile_options(-Wall -Wno-format-security -Wno-deprecated-declarations)
elseif (MSVC)
add_definitions(-DEMGUI_WINDOWS -DUNICODE -D_UNICODE -DWIN32)
add_compile_options(/W4 /FS /wd4996 /wd4389)
endif ()
##############################################################################
# MXML
file(GLOB RKT_MXML_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/external/mxml/*.c
)
add_library(rkt_mxml ${RKT_MXML_SRCS})
target_include_directories(rkt_mxml PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/external/mxml)
if (APPLE)
target_compile_definitions(rkt_mxml PUBLIC -D_THREAD_SAFE -D_REENTRANT)
target_compile_options(rkt_mxml PUBLIC -Wall)
elseif (UNIX)
target_compile_definitions(rkt_mxml PUBLIC -D_THREAD_SAFE -D_REENTRANT)
target_compile_options(rkt_mxml PUBLIC -Wall)
elseif (MSVC)
set_target_properties(rkt_mxml PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
endif ()
set(RKT_PROJECT_INCLUDES ${RKT_PROJECT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/external/mxml)
set(RKT_PROJECT_LIBS ${RKT_PROJECT_LIBS} rkt_mxml)
##############################################################################
# SYNC
file(GLOB RKT_SYNC_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/external/rocket/lib/*.c
)
add_library(rkt_sync ${RKT_SYNC_SRCS})
target_include_directories(rkt_sync PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/external/rocket/lib)
set(RKT_PROJECT_INCLUDES ${RKT_PROJECT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/external/rocket/lib)
set(RKT_PROJECT_LIBS ${RKT_PROJECT_LIBS} rkt_sync)
##############################################################################
# TINYCTHREAD
file(GLOB RKT_TINYCTHREAD_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/external/tinycthread/*.c
)
add_library(rkt_tinycthread ${RKT_TINYCTHREAD_SRCS})
target_include_directories(rkt_tinycthread PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/external/tinycthread)
if (APPLE)
target_compile_options(rkt_tinycthread PUBLIC -Wall)
elseif (UNIX)
target_compile_options(rkt_tinycthread PUBLIC -Wall)
elseif (MSVC)
set_target_properties(rkt_tinycthread PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
endif ()
set(RKT_PROJECT_INCLUDES ${RKT_PROJECT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/external/tinycthread)
set(RKT_PROJECT_LIBS ${RKT_PROJECT_LIBS} rkt_tinycthread)
##############################################################################
# BASS
set(RKT_PROJECT_INCLUDES ${RKT_PROJECT_INCLUDES} ${CMAKE_SOURCE_DIR}/external/bass)
if (APPLE)
set(RKT_PROJECT_LIBS ${RKT_PROJECT_LIBS} ${CMAKE_SOURCE_DIR}/external/bass/mac/libbass.dylib)
elseif (UNIX)
set(RKT_PROJECT_LIBS ${RKT_PROJECT_LIBS} ${CMAKE_SOURCE_DIR}/external/bass/linux/libbass.so)
elseif (MSVC)
set(RKT_PROJECT_LIBS ${RKT_PROJECT_LIBS} ${CMAKE_SOURCE_DIR}/external/bass/win32/bass.lib)
endif ()
##############################################################################
# EMGUI
file(GLOB_RECURSE RKT_EMGUI_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/emgui/src/*.c
${CMAKE_CURRENT_SOURCE_DIR}/emgui/src/*.h
)
add_library(rkt_emgui ${RKT_EMGUI_SRCS})
target_include_directories(rkt_emgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/emgui/src ${CMAKE_CURRENT_SOURCE_DIR}/emgui/include)
if (APPLE)
target_compile_definitions(rkt_emgui PUBLIC -DEMGUI_MACOSX)
target_compile_options(rkt_emgui PUBLIC -Werror -pedantic-errors -Wall -Wno-format-security)
elseif (UNIX)
target_compile_definitions(rkt_emgui PUBLIC -DEMGUI_UNIX)
target_compile_options(rkt_emgui PUBLIC -Werror -pedantic-errors -Wall -Wno-format-security)
set_source_files_properties(emgui/src/External/stb_image.c PROPERTIES COMPILE_FLAGS "-Wno-misleading-indentation -Wno-unused-but-set-variable")
set_source_files_properties(emgui/src/External/stb_typetype.c PROPERTIES COMPILE_FLAGS -Wno-unused-but-set-variable)
elseif (MSVC)
target_compile_definitions(rkt_emgui PUBLIC -DEMGUI_WINDOWS)
set_target_properties(rkt_emgui PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
endif ()
set(RKT_PROJECT_INCLUDES ${RKT_PROJECT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/emgui/include)
set(RKT_PROJECT_LIBS ${RKT_PROJECT_LIBS} rkt_emgui)
##############################################################################
# ROCKET EDITOR
file(GLOB RKT_PROJECT_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/src/*.c
${CMAKE_CURRENT_SOURCE_DIR}/src/*.m
${CMAKE_CURRENT_SOURCE_DIR}/src/*.h
)
if (APPLE)
file(GLOB RKT_PLATFORM_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/src/macosx/*.c
${CMAKE_CURRENT_SOURCE_DIR}/src/macosx/*.m
${CMAKE_CURRENT_SOURCE_DIR}/src/macosx/*.h
)
file(GLOB RKT_RESOURCES_DATA
${CMAKE_CURRENT_SOURCE_DIR}/data/macosx/icon.icns
)
source_group("Data" FILES ${RKT_RESOURCES_DATA})
elseif (UNIX)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK2 gtk+-2.0 QUIET)
pkg_check_modules(GTK3 gtk+-3.0 QUIET)
# Prefer Gtk+ 3.0 over 2.0. This is a totally arbitrary choice.
# If you have development packages for both installed, but prefer
# the Gtk+ 2.0 dialogs, just comment the "pkg_check_modules(GTK3...)"
# line above.
if(GTK3_FOUND)
message(STATUS "GUI toolkit for dialogs: Gtk+ 3.x")
set(RKT_PROJECT_INCLUDES ${RKT_PROJECT_INCLUDES} ${GTK3_INCLUDE_DIRS})
set(RKT_PROJECT_LIBS ${RKT_PROJECT_LIBS} ${GTK3_LIBRARIES})
elseif(GTK2_FOUND)
message(STATUS "GUI toolkit for dialogs: Gtk+ 2.x")
set(RKT_PROJECT_INCLUDES ${RKT_PROJECT_INCLUDES} ${GTK2_INCLUDE_DIRS})
set(RKT_PROJECT_LIBS ${RKT_PROJECT_LIBS} ${GTK2_LIBRARIES})
else()
message(WARNING "No Gtk+ 2.x or 3.x found. File and Color dialogs will be unavailable.")
endif()
file(GLOB RKT_PLATFORM_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/src/linux/*.c
${CMAKE_CURRENT_SOURCE_DIR}/src/linux/*.h
)
elseif (MSVC)
file(GLOB RKT_PLATFORM_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/src/windows/*.c
${CMAKE_CURRENT_SOURCE_DIR}/src/windows/*.h
)
file(GLOB RKT_RESOURCES_DATA
${CMAKE_CURRENT_SOURCE_DIR}/data/windows/appicon.ico
${CMAKE_CURRENT_SOURCE_DIR}/data/windows/editor.rc
)
source_group("Data" FILES ${RKT_RESOURCES_DATA})
endif ()
set(RKT_PROJECT_SRCS ${RKT_PROJECT_SRCS} ${RKT_PLATFORM_SRCS} ${RKT_RESOURCES_DATA})
set(RKT_PROJECT_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/src ${RKT_PROJECT_INCLUDES})
##############################################################################
#### APPLE BUNDLE, RESSOURCES AND DYNAMIC LIBS
if (APPLE)
set(GUI_TYPE MACOSX_BUNDLE)
# Define some settings for the Bundle
set(MACOSX_BUNDLE_BUNDLE_NAME ${RKT_EXE_NAME})
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.tbl.rocketeditor")
set(MACOSX_BUNDLE_ICON_FILE icon.icns)
set(MACOSX_BUNDLE_INFO_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH},Copyright © 2016 GNU Rocket Contributors")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
set(MACOSX_BUNDLE_BUNDLE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2012-2016 GNU Rocket Contributors. All rights reserved.")
set_source_files_properties(${RKT_RESOURCES_DATA} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(OSX_LIB_FILES ${CMAKE_SOURCE_DIR}/external/bass/mac/libbass.dylib)
set_source_files_properties(${OSX_LIB_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS)
set(RKT_PROJECT_SRCS ${RKT_PROJECT_SRCS} ${OSX_LIB_FILES})
set(RKT_PROJECT_SRCS ${GUI_TYPE} ${RKT_PROJECT_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/data/macosx/appnib.xib)
find_library(COCOA_FRAMEWORK Cocoa)
find_library(OPENGL_FRAMEWORK OpenGL)
find_library(CARBON_FRAMEWORK Carbon)
find_library(COREAUDIO_FRAMEWORK CoreAudio)
mark_as_advanced(COCOA_FRAMEWORK OPENGL_FRAMEWORK CARBON_FRAMEWORK COREAUDIO_FRAMEWORK)
set(PLATFORM_LIBS ${COCOA_FRAMEWORK} ${OPENGL_FRAMEWORK} ${CARBON_FRAMEWORK} ${COREAUDIO_FRAMEWORK})
elseif (UNIX)
find_package(SDL2 REQUIRED)
if (NOT SDL2_FOUND)
message(FATAL_ERROR "SDL2 not found!")
endif ()
set(PLATFORM_LIBS ${SDL2_LIBRARY} GL m)
set(RKT_PROJECT_INCLUDES ${RKT_PROJECT_INCLUDES} ${SDL2_INCLUDE_DIR})
elseif (MSVC)
set(PLATFORM_LIBS ws2_32 opengl32 glu32 kernel32 user32 gdi32 Comdlg32 Advapi32)
endif ()
set(RKT_PROJECT_LIBS ${RKT_PROJECT_LIBS} ${PLATFORM_LIBS})
##############################################################################
add_executable(${RKT_EXE_NAME} ${RKT_PROJECT_SRCS})
if (APPLE)
set_target_properties(${RKT_EXE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/data/macosx/MacOSXBundleInfo.plist.in)
elseif (MSVC)
set_target_properties(${RKT_EXE_NAME} PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
endif ()
if (APPLE)
target_compile_definitions(${RKT_EXE_NAME} PUBLIC -DEMGUI_MACOSX)
target_compile_options(${RKT_EXE_NAME} PUBLIC -Werror -pedantic-errors -Wall -Wno-format-security)
elseif (UNIX)
target_compile_definitions(${RKT_EXE_NAME} PUBLIC -DEMGUI_UNIX)
target_compile_options(${RKT_EXE_NAME} PUBLIC -Werror -pedantic-errors -Wall -Wno-format-security)
if (GTK2_FOUND OR GTK3_FOUND)
target_compile_definitions(${RKT_EXE_NAME} PUBLIC -DHAVE_GTK)
endif()
elseif (MSVC)
target_compile_definitions(${RKT_EXE_NAME} PUBLIC -DEMGUI_WIN32)
endif ()
target_include_directories(${RKT_EXE_NAME} PUBLIC ${RKT_PROJECT_INCLUDES})
target_link_libraries(${RKT_EXE_NAME} ${RKT_PROJECT_LIBS})
# compile the nibs
if (APPLE)
find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND")
message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin")
endif ()
# Make sure the 'Resources' Directory is correctly created before we build
#add_custom_command (TARGET ${RKT_EXE_NAME} PRE_BUILD COMMAND echo ${CMAKE_BINARY_DIR}/\${CONFIGURATION}/${RKT_EXE_NAME}.app/Contents/Resources/appnib.nib)
# Compile the .xib files using the 'ibtool' program with the destination being the app package
add_custom_command (TARGET ${RKT_EXE_NAME} POST_BUILD
COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text
--compile ${CMAKE_CURRENT_BINARY_DIR}/\${CONFIGURATION}/${RKT_EXE_NAME}.app/Contents/Resources/appnib.nib
${CMAKE_CURRENT_SOURCE_DIR}/data/macosx/appnib.xib
COMMENT "Compiling appnib.xib")
endif ()
# move the bass dll close to the executable
if (MSVC)
add_custom_command(TARGET ${RKT_EXE_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/external/bass/win32/bass.dll" $<TARGET_FILE_DIR:${RKT_EXE_NAME}>)
endif ()
##############################################################################
# BASIC EXAMPLE
file(GLOB EXAMPLE_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/basic_example/*.c
${CMAKE_CURRENT_SOURCE_DIR}/basic_example/*.h
)
add_executable(${EXAMPLE_NAME} ${EXAMPLE_SRCS})
target_link_libraries(${EXAMPLE_NAME} ${RKT_PROJECT_LIBS})