forked from amarullz/libaroma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
269 lines (232 loc) · 9.21 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
cmake_minimum_required(VERSION 2.8)
# Project Config
project(libaroma)
set(CMAKE_BUILD_TYPE Release)
execute_process( COMMAND ${CMAKE_C_COMPILER} -dumpmachine OUTPUT_VARIABLE DUMP_MACHINE OUTPUT_STRIP_TRAILING_WHITESPACE)
message("Dump Machine : ${DUMP_MACHINE}")
# Check Architecture
if(NOT DEFINED ARCHITECTURE)
string(FIND ${DUMP_MACHINE} "-" DUMP_MACHINE_STRIP)
string(SUBSTRING ${DUMP_MACHINE} 0 ${DUMP_MACHINE_STRIP} ARCHITECTURE)
endif()
message("Architecture : ${ARCHITECTURE}")
# Check Platform
if(NOT DEFINED LIBAROMA_PLATFORM_NAME)
set(LIBAROMA_PLATFORM_NAME "linux")
endif()
# Platform list
set( LIBAROMA_PLATFORM_NAME "${LIBAROMA_PLATFORM_NAME}" CACHE STRING "Libaroma target platform" FORCE )
set_property( CACHE LIBAROMA_PLATFORM_NAME PROPERTY STRINGS "linux;qnx;sdl;rpi" )
message("Platform : ${LIBAROMA_PLATFORM_NAME}")
# OpenMP List
if(NOT DEFINED LIBAROMA_WITH_OPENMP)
set(LIBAROMA_WITH_OPENMP "DISABLE")
endif()
set( LIBAROMA_WITH_OPENMP "${LIBAROMA_WITH_OPENMP}" CACHE STRING "Force Compile Libaroma with OpenMP" FORCE )
set_property( CACHE LIBAROMA_WITH_OPENMP PROPERTY STRINGS "DISABLE;ENABLE" )
# Libaroma Debug
if(NOT DEFINED LIBAROMA_CONFIG_DEBUG)
set(LIBAROMA_CONFIG_DEBUG "3")
endif()
set( LIBAROMA_CONFIG_DEBUG "${LIBAROMA_CONFIG_DEBUG}" CACHE STRING "Libaroma Debugging Level" FORCE )
set_property( CACHE LIBAROMA_CONFIG_DEBUG PROPERTY STRINGS "1;2;3;4;5" )
# Libaroma Debug File
if(NOT DEFINED LIBAROMA_CONFIG_DEBUG_FILE)
set(LIBAROMA_CONFIG_DEBUG_FILE "0")
endif()
set( LIBAROMA_CONFIG_DEBUG_FILE "${LIBAROMA_CONFIG_DEBUG_FILE}" CACHE STRING "Libaroma Debug with filename for warning/error (1=with filename, 2=with line number)" FORCE )
set_property( CACHE LIBAROMA_CONFIG_DEBUG_FILE PROPERTY STRINGS "0;1;2" )
# Libaroma Debug Memory
if(NOT DEFINED LIBAROMA_CONFIG_DEBUG_MEMORY)
set(LIBAROMA_CONFIG_DEBUG_MEMORY "0")
endif()
set( LIBAROMA_CONFIG_DEBUG_MEMORY "${LIBAROMA_CONFIG_DEBUG_MEMORY}" CACHE STRING "Track memory leaks for libaroma" FORCE )
set_property( CACHE LIBAROMA_CONFIG_DEBUG_MEMORY PROPERTY STRINGS "0;1" )
# Libaroma SHMEMFB
if(NOT DEFINED LIBAROMA_CONFIG_SHMEMFB)
set(LIBAROMA_CONFIG_SHMEMFB "0")
endif()
set( LIBAROMA_CONFIG_SHMEMFB "${LIBAROMA_CONFIG_SHMEMFB}" CACHE STRING "Main canvas in shmem" FORCE )
set_property( CACHE LIBAROMA_CONFIG_SHMEMFB PROPERTY STRINGS "0;1" )
# Libaroma COMPILER MESSAGE
if(NOT DEFINED LIBAROMA_CONFIG_COMPILER_MESSAGE)
set(LIBAROMA_CONFIG_COMPILER_MESSAGE "1")
endif()
set( LIBAROMA_CONFIG_COMPILER_MESSAGE "${LIBAROMA_CONFIG_COMPILER_MESSAGE}" CACHE STRING "Show compiler message" FORCE )
set_property( CACHE LIBAROMA_CONFIG_COMPILER_MESSAGE PROPERTY STRINGS "0;1" )
# Freetype rendering
if(NOT DEFINED LIBAROMA_FONT_RENDERING)
set(LIBAROMA_FONT_RENDERING "ANTIALIAS")
endif()
set( LIBAROMA_FONT_RENDERING "${LIBAROMA_FONT_RENDERING}" CACHE STRING "Set freetype font rendering" FORCE )
set_property( CACHE LIBAROMA_FONT_RENDERING PROPERTY STRINGS "SUBPIXEL ANTIALIAS;ANTIALIAS" )
# SHMEM Default prefix
set(LIBAROMA_CONFIG_SHMEM_PREFIX "/libaromashm-")
# Default link values
if(NOT DEFINED CMAKE_LINK_TYPE)
set(CMAKE_LINK_TYPE STATIC)
endif()
set( CMAKE_LINK_TYPE "${CMAKE_LINK_TYPE}" CACHE STRING "Link Type" FORCE )
set_property( CACHE CMAKE_LINK_TYPE PROPERTY STRINGS "STATIC;SHARED" )
if("${ARCHITECTURE}" STREQUAL "arm")
if(NOT DEFINED NEON)
set(NEON true)
endif()
if(NOT DEFINED VFPV3)
set(VFPV3 true)
endif()
message("NEON : ${NEON}")
message("VFPV3 : ${VFPV3}")
endif()
# linkage
if("${CMAKE_LINK_TYPE}" STREQUAL "STATIC")
message("Linkage : STATIC")
set(CMAKE_SKIP_RPATH YES)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
else()
message("Linkage : SHARED")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
# release&debug flags
set(CMAKE_C_FLAGS_RELEASE "-O3 -ftree-vectorize -fprefetch-loop-arrays -funsafe-math-optimizations")
set(CMAKE_C_FLAGS_DEBUG "-ggdb")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
# detect NDK
if(ANDROID_NDK)
message("Toolchain : ${ANDROID_NDK}")
else()
message("Toolchain : ${CMAKE_C_COMPILER}")
endif()
# common cflags
set(AROMA_CFLAGS "${AROMA_CFLAGS} -save-temps")
set(AROMA_CFLAGS "${AROMA_CFLAGS} -fdata-sections -ffunction-sections -Wl,--gc-sections")
set(AROMA_CFLAGS "${AROMA_CFLAGS} -D_GLIBCXX_DEBUG_PEDANTIC -D_GLIBCXX_DEBUG")
set(AROMA_CFLAGS "${AROMA_CFLAGS} -fPIC -DPIC -Wl,-s -Wall -Wextra -Wshadow -Wno-unused-parameter")
#set(AROMA_CFLAGS "${AROMA_CFLAGS} -Werror")
# forced aroma cflags
set(AROMA_CFLAGS "${AROMA_CFLAGS} -DLIBAROMA_CONFIG_DEBUG_TRACE=0")
# openmp cflags
# TODO: use custom NDK with (static) openmp support
if (((NOT DEFINED ANDROID_NDK) AND ("${CMAKE_LINK_TYPE}" STREQUAL SHARED)) OR (LIBAROMA_WITH_OPENMP STREQUAL ENABLE))
message("OpenMP Support : ENABLED")
set(AROMA_CFLAGS "${AROMA_CFLAGS} -DLIBAROMA_CONFIG_OPENMP=1")
if("${ARCHITECTURE}" STREQUAL "arm")
set(AROMA_CFLAGS "${AROMA_CFLAGS} -fopenmp")
elseif("${ARCHITECTURE}" STREQUAL "x86_64")
set(AROMA_CFLAGS "${AROMA_CFLAGS} -openmp")
endif()
set(AROMA_OPENMP true)
else()
message("OpenMP Support : DISABLED")
set(AROMA_OPENMP false)
endif()
# AROMA config
set(AROMA_CFLAGS "${AROMA_CFLAGS} -DLIBAROMA_CONFIG_DEBUG=${LIBAROMA_CONFIG_DEBUG}")
set(AROMA_CFLAGS "${AROMA_CFLAGS} -DLIBAROMA_CONFIG_DEBUG_FILE=${LIBAROMA_CONFIG_DEBUG_FILE}")
set(AROMA_CFLAGS "${AROMA_CFLAGS} -DLIBAROMA_CONFIG_DEBUG_MEMORY=${LIBAROMA_CONFIG_DEBUG_MEMORY}")
set(AROMA_CFLAGS "${AROMA_CFLAGS} -DLIBAROMA_CONFIG_COMPILER_MESSAGE=${LIBAROMA_CONFIG_COMPILER_MESSAGE}")
set(AROMA_CFLAGS "${AROMA_CFLAGS} -DLIBAROMA_CONFIG_SHMEMFB=${LIBAROMA_CONFIG_SHMEMFB}")
set(AROMA_CFLAGS "${AROMA_CFLAGS} -DLIBAROMA_CONFIG_SHMEM_PREFIX=\\\"${LIBAROMA_CONFIG_SHMEM_PREFIX}\\\"")
if(LIBAROMA_FONT_RENDERING STREQUAL "ANTIALIAS")
set(AROMA_CFLAGS "${AROMA_CFLAGS} -DLIBAROMA_CONFIG_NOFONT_SUBPIXEL=1")
endif()
# android
if(DEFINED ANDROID)
message("Android Target : ENABLED")
# if we don't use the NDK these flags are not defined by default
set(AROMA_CFLAGS "${AROMA_CFLAGS} -DANDROID=1 -D__ANDROID__")
else()
message("Android Target : DISABLED")
endif()
# ARM cflags
if("${ARCHITECTURE}" STREQUAL "arm")
if(NEON OR VFPV3)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mvectorize-with-neon-quad")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mvectorize-with-neon-quad")
endif()
# NDK has set these flags already
if(NOT DEFINED ANDROID_NDK)
# TODO: check if Toolchain ABI is hard or soft
if(NEON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard -mfpu=neon")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=hard -mfpu=neon")
elseif(VFPV3)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard -mfpu=vfpv3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfloat-abi=hard -mfpu=vfpv3")
endif()
endif()
endif()
# sources
file(GLOB AROMA_SRCS
${PROJECT_SOURCE_DIR}/src/contrib/platform/${LIBAROMA_PLATFORM_NAME}/*.c
src/aroma/aroma.c
src/aroma/version.c
src/aroma/utils/*.c
src/aroma/debug/*.c
src/aroma/graph/*.c
src/aroma/graph/draw/*.c
src/aroma/graph/engine/*.c
src/aroma/hid/*.c
src/aroma/ui/*.c
src/aroma/controls/*.c
src/aroma/controls/listitem/*.c
)
# includes
include_directories(
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/contrib/platform/${LIBAROMA_PLATFORM_NAME}/include
${PROJECT_SOURCE_DIR}/libs/zlib/src
${PROJECT_SOURCE_DIR}/libs/freetype/builds
${PROJECT_SOURCE_DIR}/libs/freetype/include
${PROJECT_SOURCE_DIR}/libs/minzip
${PROJECT_SOURCE_DIR}/libs/png
${PROJECT_SOURCE_DIR}/libs/jpeg
${PROJECT_SOURCE_DIR}/libs/harfbuzz-ng/src
${PROJECT_SOURCE_DIR}/libs/harfbuzz-ng/src/hb-ucdn
${PROJECT_SOURCE_DIR}/libs/squirrel/include
${PROJECT_SOURCE_DIR}/libs/squirrel/squirrel
${PROJECT_SOURCE_DIR}/libs/squirrel/sqstdlib
)
# aroma
add_library(aroma ${CMAKE_LINK_TYPE} ${AROMA_SRCS})
set_target_properties(aroma PROPERTIES COMPILE_FLAGS ${AROMA_CFLAGS})
add_dependencies(aroma z freetype harfbuzz hbucdn minzip png jpeg squirrel)
target_link_libraries(aroma z freetype harfbuzz hbucdn minzip png jpeg squirrel)
# SDL
# TODO: move to platform module
if("${LIBAROMA_PLATFORM_NAME}" STREQUAL "sdl")
find_package(SDL REQUIRED)
include_directories(${SDL_INCLUDE_DIR})
target_link_libraries(aroma ${SDL_LIBRARY})
endif()
if(AROMA_OPENMP)
target_link_libraries(aroma gomp)
endif()
if(NOT DEFINED ANDROID_NDK)
# NDK uses a integrated pthreads API
target_link_libraries(aroma pthread)
target_link_libraries(aroma rt)
endif()
# subdirs
add_subdirectory(libs/zlib)
add_subdirectory(libs/freetype)
add_subdirectory(libs/harfbuzz-ng)
add_subdirectory(libs/harfbuzz-ng/src/hb-ucdn)
add_subdirectory(libs/minzip)
add_subdirectory(libs/png)
add_subdirectory(libs/jpeg)
add_subdirectory(libs/squirrel)
# aromart
file(GLOB AROMART_SRCS src/aromart/*.c)
add_library(aromart ${CMAKE_LINK_TYPE} ${AROMART_SRCS})
target_link_libraries(aromart aroma)
# aromart_test
file(GLOB AROMART_TEST_SRCS examples/rt_test/*.c)
add_executable(aromart_test ${AROMART_TEST_SRCS})
target_link_libraries(aromart_test aromart)
message("CFLAGS : ${CMAKE_C_FLAGS}")
message("CXXFLAGS : ${CMAKE_CXX_FLAGS}")