1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
3 SET(CMAKE_C_STANDARD 99)
4 SET(CMAKE_CXX_STANDARD 14)
5 PROJECT(dali-demo C CXX)
7 SET(dali-demo_VERSION_MAJOR 1)
8 SET(dali-demo_VERSION_MINOR 0)
10 SET(GCC_COMPILER_VERSION_REQUIRED "6")
11 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
12 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_COMPILER_VERSION_REQUIRED)
13 message(FATAL_ERROR "The GCC required compiler version is " ${GCC_COMPILER_VERSION_REQUIRED})
17 # Define options to CMake
18 OPTION(ENABLE_EXPORTALL "Enable Export all symbols" OFF)
19 OPTION(ENABLE_DEBUG "Enable Debug" OFF)
20 OPTION(ENABLE_PKG_CONFIGURE "Use pkgconfig" ON)
21 OPTION(INTERNATIONALIZATION "Internationalization demo string names" ON)
23 SET(ROOT_SRC_DIR ${CMAKE_SOURCE_DIR}/../..)
24 SET(DEMO_SHARED ${CMAKE_SOURCE_DIR}/../../shared)
26 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
28 IF(DEFINED DALI_APP_DIR)
29 SET(BINDIR ${DALI_APP_DIR})
31 SET(BINDIR ${PREFIX}/bin)
34 IF(DEFINED DALI_APP_RES_DIR)
35 SET(APP_DATA_RES_DIR ${DALI_APP_RES_DIR})
37 SET(APP_DATA_RES_DIR ${PREFIX}/share/com.samsung.dali-demo/res)
40 MESSAGE( STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} )
42 IF(CMAKE_BUILD_TYPE MATCHES Debug)
43 SET( ENABLE_DEBUG ON )
47 MESSAGE( STATUS "CMAKE_BUILD_TYPE: " Debug )
48 SET( ENABLE_EXPORTALL ON )
50 MESSAGE( STATUS "CMAKE_BUILD_TYPE: " Release )
53 SET(RESOURCE_DIR ${ROOT_SRC_DIR}/resources)
54 SET(LOCAL_IMAGES_DIR ${RESOURCE_DIR}/images)
55 SET(LOCAL_GAME_DIR ${RESOURCE_DIR}/game)
56 SET(LOCAL_VIDEOS_DIR ${RESOURCE_DIR}/videos)
57 SET(LOCAL_MODELS_DIR ${RESOURCE_DIR}/models)
58 SET(LOCAL_SCRIPTS_DIR ${RESOURCE_DIR}/scripts)
59 SET(LOCAL_SHADERS_DIR ${RESOURCE_DIR}/shaders)
60 IF(NOT DEFINED LOCAL_STYLE_DIR)
61 SET(LOCAL_STYLE_DIR ${RESOURCE_DIR}/style)
65 SET(LOCAL_STYLE_ANDROID_DIR ${RESOURCE_DIR}/style/android)
68 SET(IMAGES_DIR ${APP_DATA_RES_DIR}/images/)
69 SET(GAME_DIR ${APP_DATA_RES_DIR}/game/)
70 SET(VIDEOS_DIR ${APP_DATA_RES_DIR}/videos/)
71 SET(MODELS_DIR ${APP_DATA_RES_DIR}/models/)
72 SET(SCRIPTS_DIR ${APP_DATA_RES_DIR}/scripts/)
73 SET(SHADERS_DIR ${APP_DATA_RES_DIR}/shaders/)
74 SET(STYLE_DIR ${APP_DATA_RES_DIR}/style/)
76 IF(NOT DEFINED LOCALE_DIR)
77 SET(LOCALE_DIR ${PREFIX}/share/locale)
80 IF(DEFINED DALI_DEMO_RES_DIR)
81 SET(DEMO_IMAGE_DIR \\"${DALI_DEMO_RES_DIR}/images/\\")
82 SET(DEMO_GAME_DIR \\"${DALI_DEMO_RES_DIR}/game/\\")
83 SET(DEMO_VIDEO_DIR \\"${DALI_DEMO_RES_DIR}/videos/\\")
84 SET(DEMO_MODEL_DIR \\"${DALI_DEMO_RES_DIR}/models/\\")
85 SET(DEMO_SCRIPT_DIR \\"${DALI_DEMO_RES_DIR}/scripts/\\")
86 SET(DEMO_SHADER_DIR \\"${DALI_DEMO_RES_DIR}/shaders/\\")
87 SET(DEMO_STYLE_DIR \\"${DALI_DEMO_RES_DIR}/style/\\")
88 SET(DEMO_THEME_PATH \\"${DALI_DEMO_RES_DIR}/style/demo-theme.json\\")
89 SET(DEMO_LOCALE_DIR \\"${DALI_DEMO_RES_DIR}/locale/\\")
90 SET(DEMO_STYLE_IMAGE_DIR \\"${DALI_DEMO_RES_DIR}/style/images\\")
92 SET(DEMO_GAME_DIR \\"${GAME_DIR}\\")
93 SET(DEMO_IMAGE_DIR \\"${IMAGES_DIR}\\")
94 SET(DEMO_VIDEO_DIR \\"${VIDEOS_DIR}\\")
95 SET(DEMO_MODEL_DIR \\"${MODELS_DIR}\\")
96 SET(DEMO_SCRIPT_DIR \\"${SCRIPTS_DIR}\\")
97 SET(DEMO_SHADER_DIR \\"${SHADERS_DIR}\\")
98 SET(DEMO_STYLE_DIR \\"${STYLE_DIR}\\")
99 SET(DEMO_THEME_PATH \\"${STYLE_DIR}demo-theme.json\\")
100 SET(DEMO_LOCALE_DIR \\"${LOCALE_DIR}\\")
101 SET(DEMO_STYLE_IMAGE_DIR ${STYLE_DIR}/images)
104 SET(DEMO_EXAMPLE_BIN \\"${BINDIR}/\\")
105 SET(DEMO_LANG \\"${LANG}\\")
107 FILE(GLOB LOCAL_IMAGES_PNG RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.png")
108 FILE(GLOB LOCAL_IMAGES_JPG RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.jpg")
109 FILE(GLOB LOCAL_IMAGES_GIF RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.gif")
110 FILE(GLOB LOCAL_IMAGES_WEBP RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.webp")
111 FILE(GLOB LOCAL_IMAGES_BMP RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.bmp")
112 FILE(GLOB LOCAL_IMAGES_ICO RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.ico")
113 FILE(GLOB LOCAL_IMAGES_WBMP RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.wbmp")
114 FILE(GLOB LOCAL_IMAGES_KTX RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.ktx")
115 FILE(GLOB LOCAL_IMAGES_ASTC RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.astc")
116 FILE(GLOB LOCAL_IMAGES_SVG RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.svg")
117 FILE(GLOB LOCAL_IMAGES_JSON RELATIVE "${LOCAL_IMAGES_DIR}" "${LOCAL_IMAGES_DIR}/*.json")
119 SET(LOCAL_IMAGES_LIST ${LOCAL_IMAGES_PNG};${LOCAL_IMAGES_JPG};${LOCAL_IMAGES_GIF};${LOCAL_IMAGES_WEBP};${LOCAL_IMAGES_BMP};${LOCAL_IMAGES_ICO};${LOCAL_IMAGES_WBMP};${LOCAL_IMAGES_KTX};${LOCAL_IMAGES_ASTC};${LOCAL_IMAGES_SVG};${LOCAL_IMAGES_JSON})
120 FOREACH(flag ${LOCAL_IMAGES_LIST})
121 INSTALL(FILES ${LOCAL_IMAGES_DIR}/${flag} DESTINATION ${IMAGES_DIR})
124 FILE(GLOB LOCAL_VIDEOS_LIST RELATIVE "${LOCAL_VIDEOS_DIR}" "${LOCAL_VIDEOS_DIR}/*")
125 FOREACH(flag ${LOCAL_VIDEOS_LIST})
126 INSTALL(FILES ${LOCAL_VIDEOS_DIR}/${flag} DESTINATION ${VIDEOS_DIR})
129 FILE(GLOB LOCAL_MODELS_LIST RELATIVE "${LOCAL_MODELS_DIR}" "${LOCAL_MODELS_DIR}/*")
130 FOREACH(flag ${LOCAL_MODELS_LIST})
131 INSTALL(FILES ${LOCAL_MODELS_DIR}/${flag} DESTINATION ${MODELS_DIR})
134 FILE(GLOB LOCAL_SCRIPTS_LIST RELATIVE "${LOCAL_SCRIPTS_DIR}" "${LOCAL_SCRIPTS_DIR}/*.json")
135 FOREACH(flag ${LOCAL_SCRIPTS_LIST})
136 INSTALL(FILES ${LOCAL_SCRIPTS_DIR}/${flag} DESTINATION ${SCRIPTS_DIR})
139 FILE(GLOB LOCAL_SHADERS_LIST RELATIVE "${LOCAL_SHADERS_DIR}" "${LOCAL_SHADERS_DIR}/*")
140 FOREACH(flag ${LOCAL_SHADERS_LIST})
141 INSTALL(FILES ${LOCAL_SHADERS_DIR}/${flag} DESTINATION ${SHADERS_DIR})
144 FILE(GLOB LOCAL_GAME_LIST RELATIVE "${LOCAL_GAME_DIR}" "${LOCAL_GAME_DIR}/*.*")
145 FOREACH(flag ${LOCAL_GAME_LIST})
146 INSTALL(FILES ${LOCAL_GAME_DIR}/${flag} DESTINATION ${GAME_DIR})
149 #Create resources location file
150 CONFIGURE_FILE( resources-location.in ${DEMO_SHARED}/resources-location.cpp )
152 FILE(GLOB LOCAL_STYLES_LIST "${LOCAL_STYLE_DIR}/*.json")
153 FOREACH(flag ${LOCAL_STYLES_LIST})
154 INSTALL(FILES ${flag} DESTINATION ${STYLE_DIR})
156 MESSAGE("Installed ${LOCAL_STYLES_LIST} to ${STYLE_DIR}")
159 FILE(GLOB LOCAL_STYLES_ANDROID_LIST "${LOCAL_STYLE_ANDROID_DIR}/*.json")
160 FOREACH(flag ${LOCAL_STYLES_ANDROID_LIST})
161 INSTALL(FILES ${flag} DESTINATION ${STYLE_DIR})
163 MESSAGE("Installed ${LOCAL_STYLES_ANDROID_LIST} to ${STYLE_DIR}")
166 FILE(GLOB LOCAL_STYLE_IMAGES_LIST "${LOCAL_STYLE_DIR}/images/*.png")
167 FOREACH(flag ${LOCAL_STYLE_IMAGES_LIST})
168 INSTALL(FILES ${flag} DESTINATION ${STYLE_DIR}/images)
170 MESSAGE("Installed style resources ${LOCAL_STYLE_IMAGES_LIST} to ${STYLE_DIR}/images")
172 IF( ENABLE_PKG_CONFIGURE )
173 SET(PKG_LIST dali2-core
177 INCLUDE(FindPkgConfig)
178 pkg_check_modules(REQUIRED_PKGS REQUIRED ${PKG_LIST})
180 FOREACH(flag ${REQUIRED_PKGS_CFLAGS})
181 SET(REQUIRED_CFLAGS "${REQUIRED_CFLAGS} ${flag}")
185 SET( VCPKG_INCLUDE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
187 IF( WIN32 ) # WIN32 includes x64 as well according to the cmake doc.
188 FIND_PACKAGE( pthreads REQUIRED )
189 FIND_PACKAGE( curl REQUIRED )
190 FIND_LIBRARY( GETOPT_LIBRARY NAMES getopt )
191 FIND_LIBRARY( EXIF_LIBRARY NAMES libexif )
193 FIND_PACKAGE( png REQUIRED )
194 FIND_PACKAGE( gif REQUIRED )
195 FIND_PACKAGE( jpeg REQUIRED )
196 FIND_LIBRARY( TURBO_JPEG_LIBRARY NAMES turbojpeg )
198 FIND_PACKAGE( unofficial-fontconfig REQUIRED )
199 FIND_PACKAGE( freetype REQUIRED )
200 FIND_PACKAGE( harfbuzz REQUIRED )
201 FIND_LIBRARY( FRIBIDI_LIBRARY NAMES fribidi )
203 FIND_PACKAGE( unofficial-angle REQUIRED )
204 FIND_PACKAGE( unofficial-cairo REQUIRED )
206 FIND_PACKAGE( WebP REQUIRED )
208 FIND_PACKAGE( dali-windows-dependencies REQUIRED )
209 FIND_PACKAGE( dali2-core REQUIRED )
210 FIND_PACKAGE( dali2-adaptor REQUIRED )
211 FIND_PACKAGE( dali2-toolkit REQUIRED )
213 # Set up the include dir
214 SET( INCLUDE_DIR $ENV{includedir} )
215 IF( NOT INCLUDE_DIR )
216 SET( INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR} )
218 IF( NOT INCLUDE_DIR )
219 SET( INCLUDE_DIR ${PREFIX}/include )
222 SET( LIB_DIR $ENV{libdir} )
224 SET( LIB_DIR ${CMAKE_INSTALL_LIBDIR} )
227 SET( LIB_DIR ${PREFIX}/lib )
231 PThreads4W::PThreads4W
238 ${TURBO_JPEG_LIBRARY}
239 unofficial::fontconfig::fontconfig
243 unofficial::angle::libEGL
244 unofficial::angle::libGLESv2
245 unofficial::cairo::cairo
248 dali-windows-dependencies::dali-windows-dependencies
249 dali2-core::dali2-core
250 dali2-adaptor::dali2-adaptor
251 dali2-toolkit::dali2-toolkit
255 ${REQUIRED_PKGS_LDFLAGS}
260 SET(DALI_DEMO_CFLAGS "-DDEMO_GAME_DIR=${DEMO_GAME_DIR} -DDEMO_IMAGE_DIR=${DEMO_IMAGE_DIR} -DDEMO_VIDEO_DIR=${DEMO_VIDEO_DIR} -DDEMO_MODEL_DIR=${DEMO_MODEL_DIR} -DDEMO_SCRIPT_DIR=${DEMO_SCRIPT_DIR} -DDEMO_SHADER_DIR=${DEMO_SHADER_DIR} -DDEMO_STYLE_DIR=${DEMO_STYLE_DIR} -DDEMO_THEME_PATH=${DEMO_THEME_PATH} -DDEMO_EXAMPLE_BIN=${DEMO_EXAMPLE_BIN} -DDEMO_LOCALE_DIR=${DEMO_LOCALE_DIR} -DDEMO_LANG=${DEMO_LANG}")
263 SET(DALI_DEMO_CFLAGS "${DALI_DEMO_CFLAGS} -DDEBUG_ENABLED")
267 IF( NOT ${ENABLE_EXPORTALL} )
268 ADD_DEFINITIONS( "-DHIDE_DALI_INTERNALS" )
272 ###########################################################################
273 # Internationalization
276 SET(PO_DIR ${RESOURCE_DIR}/po)
278 FILE(GLOB PO_FILES RELATIVE "${PO_DIR}" "${PO_DIR}/*.po")
280 SET(MSGFMT "/usr/bin/msgfmt")
281 SET(MO_FILES_DIR ${CMAKE_BINARY_DIR}/mo)
282 FILE(MAKE_DIRECTORY ${MO_FILES_DIR})
284 FOREACH(PO_FILE ${PO_FILES})
285 SET(PO_FILE ${PO_DIR}/${PO_FILE})
286 MESSAGE("PO: ${PO_FILE}")
287 GET_FILENAME_COMPONENT(ABS_PO_FILE ${PO_FILE} ABSOLUTE)
288 GET_FILENAME_COMPONENT(lang ${ABS_PO_FILE} NAME_WE)
289 SET(MO_FILE ${MO_FILES_DIR}/${lang}.mo)
290 ADD_CUSTOM_COMMAND(OUTPUT ${MO_FILE}
291 COMMAND ${MSGFMT} -o ${MO_FILE} ${ABS_PO_FILE}
292 DEPENDS ${ABS_PO_FILE})
293 INSTALL(FILES ${MO_FILE} DESTINATION ${LOCALE_DIR}/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo)
294 SET(MO_FILES ${MO_FILES} ${MO_FILE})
297 MESSAGE(".mo files: ${MO_FILES}")
298 ADD_CUSTOM_TARGET(po ALL DEPENDS ${MO_FILES})
301 IF (INTERNATIONALIZATION)
302 SET(DALI_DEMO_CFLAGS "${DALI_DEMO_CFLAGS} -DINTERNATIONALIZATION_ENABLED")
303 ENDIF(INTERNATIONALIZATION)
305 ###########################################################################
308 ADD_COMPILE_OPTIONS( /FIdali-windows-dependencies.h ) # Adds missing definitions.
309 ADD_COMPILE_OPTIONS( /vmg ) # Avoids a 'reinterpret_cast' compile error while compiling signals and callbacks.
310 ADD_COMPILE_OPTIONS( /wd4251 ) # Ignores warning C4251: "'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'"
312 SET(DALI_DEMO_CFLAGS "${DALI_DEMO_CFLAGS} -Werror -Wall -fPIE")
314 IF( NOT ${ENABLE_EXPORTALL} )
315 SET(DALI_DEMO_CFLAGS "${DALI_DEMO_CFLAGS} -fvisibility=hidden")
319 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${REQUIRED_CFLAGS} ${DALI_DEMO_CFLAGS}")
320 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
323 ${SYSTEM_INCLUDE_DIR}
330 INCLUDE_DIRECTORIES( ${ANDROID_NDK}/sources/android/native_app_glue )
331 INCLUDE_DIRECTORIES( ${ANDROID_NDK}/sysroot/usr )
332 INCLUDE_DIRECTORIES( ${ANDROID_NDK}/sysroot/usr/include/android )
333 INCLUDE_DIRECTORIES( ${ROOT_SRC_DIR}/build/android/app/src/main/cpp )
336 LINK_DIRECTORIES(${LIB_DIR})
338 ADD_SUBDIRECTORY(demo)
339 ADD_SUBDIRECTORY(examples)
340 ADD_SUBDIRECTORY(examples-reel)
341 ADD_SUBDIRECTORY(tests-reel)
342 ADD_SUBDIRECTORY(builder)
345 MESSAGE( " Folder DEMO_IMAGE_DIR : [" ${DEMO_IMAGE_DIR} "]" )
346 MESSAGE( " Folder DEMO_STYLE_DIR : [" ${DEMO_STYLE_DIR} "]" )
347 MESSAGE( " Folder DEMO_SHADER_DIR : [" ${DEMO_SHADER_DIR} "]" )
348 MESSAGE( " Folder DEMO_THEME_PATH : [" ${DEMO_THEME_PATH} "]" )
349 MESSAGE( " Folder DEMO_GAME_DIR : [" ${DEMO_GAME_DIR} "]" )
350 MESSAGE( " Folder DEMO_VIDEO_DIR : [" ${DEMO_VIDEO_DIR} "]" )
351 MESSAGE( " Folder DEMO_MODEL_DIR : [" ${DEMO_MODEL_DIR} "]" )
352 MESSAGE( " Folder DEMO_SCRIPT_DIR : [" ${DEMO_SCRIPT_DIR} "]" )
353 MESSAGE( " Folder DEMO_LOCALE_DIR : [" ${DEMO_LOCALE_DIR} "]" )
354 MESSAGE( " Folder DEMO_EXAMPLE_BIN : [" ${DEMO_EXAMPLE_BIN} "]" )
355 MESSAGE( " Folder DEMO_LANG : [" ${DEMO_LANG} "]" )