91de67202d68488514d2836192f9bd2fbd5e2cae
[platform/core/uifw/dali-adaptor.git] / build / emscripten / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 if( ${EMSCRIPTEN} )
4   message("EMSCRIPTEN BUILD")
5   set(CMAKE_C_COMPILER "emcc")
6   set(CMAKE_CXX_COMPILER "em++")
7 else( ${EMSCRIPTEN} )
8   message( FATAL_ERROR "Native Build not supported via cmake." )
9 endif( ${EMSCRIPTEN} )
10
11 if(NOT DEFINED ENV{DESKTOP_PREFIX})
12   message( FATAL_ERROR "DESKTOP_PREFIX is required to build adaptor against dali-core. Please make sure you have sourced your setenv script (created by dali_env)." )
13 endif()
14
15 project(dali-emscripten CXX)
16
17 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
18
19 set(SRCS
20   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/actor-wrapper.cpp
21   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/animation-wrapper.cpp
22   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/dali-wrapper.cpp
23   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/emscripten-utils.cpp
24   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/handle-wrapper.cpp
25   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/image-wrapper.cpp
26   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/property-buffer-wrapper.cpp
27   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/property-value-wrapper.cpp
28   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/render-task-wrapper.cpp
29   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/type-info-wrapper.cpp
30   ${CMAKE_SOURCE_DIR}/../../adaptors/base/separate-update-render/frame-time.cpp
31   ${CMAKE_SOURCE_DIR}/../../adaptors/base/time-service.cpp
32   ${CMAKE_SOURCE_DIR}/../../adaptors/common/gl/egl-image-extensions.cpp
33   ${CMAKE_SOURCE_DIR}/../../adaptors/common/gl/gl-extensions.cpp
34   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/egl-implementation-emscripten.cpp
35   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/main.cpp
36   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/sdl-application.cpp
37   ${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/sdl-gl-sync-abstraction.cpp
38   ${CMAKE_SOURCE_DIR}/../../platform-abstractions/emscripten/emscripten-callbacks.cpp
39   ${CMAKE_SOURCE_DIR}/../../platform-abstractions/emscripten/emscripten-platform-abstraction.cpp
40 )
41
42 include_directories(${CMAKE_SOURCE_DIR}/../../)
43 include_directories(${CMAKE_SOURCE_DIR}/../../adaptors/)
44 include_directories(${CMAKE_SOURCE_DIR}/../../adaptors/common)
45 include_directories(${CMAKE_SOURCE_DIR}/../../adaptors/tizen)
46 include_directories(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten)
47 include_directories(${CMAKE_SOURCE_DIR}/../../platform-abstractions/slp)
48
49 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/all.html all.html COPYONLY)
50 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/dali-page.html dali-page.html COPYONLY)
51 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/dali-tests.css dali-tests.css COPYONLY)
52 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/dali-tests.html dali-tests.html COPYONLY)
53 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/geometry.js geometry.js COPYONLY)
54 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/properties.js properties.js COPYONLY)
55 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/signals.js signals.js COPYONLY)
56 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/math.js math.js COPYONLY)
57 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/animation.js animation.js COPYONLY)
58 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/utilities.js utilities.js COPYONLY)
59 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/shaders.js shaders.js COPYONLY)
60 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/views.js views.js COPYONLY)
61
62 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/qunit/qunit-1.21.0.css qunit-1.21.0.css COPYONLY)
63 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/qunit/qunit-1.21.0.js qunit-1.21.0.js COPYONLY)
64
65 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/dali-wrapper.js dali-wrapper.js COPYONLY)
66
67 set(VENDOR "samsung")
68 set(PACKAGE ${PROJECT_NAME})
69 set(DESKTOP_PREFIX $ENV{DESKTOP_PREFIX})
70 set(CPP_DEFINES -DDALI_GLES_VERSION=2)
71
72 set(EMSCRIPTEN_ENV_DIR ${DESKTOP_PREFIX}/share/emscripten)
73
74 set(DEBUG_FLAGS "-Wall -g -O2")
75 set(RELEASE_FLAGS "-Wall -g -O2")
76
77 if( ${EMSCRIPTEN} )
78  set(DEBUG_FLAGS "${DEBUG_FLAGS} -std=c++11 -DBOOST_ERROR_CODE_HEADER_ONLY")
79  set(RELEASE_FLAGS "${RELEASE_FLAGS} -std=c++11 -DBOOST_ERROR_CODE_HEADER_ONLY")
80 endif( ${EMSCRIPTEN} )
81
82
83 include(FindPkgConfig)
84
85 pkg_check_modules(pkgs REQUIRED
86   dali-core
87   # sdl from emscripten
88   )
89
90 if( ${EMSCRIPTEN} )
91
92 pkg_check_modules(pkgs REQUIRED
93   dali-core
94   # sdl from emscripten
95   )
96
97 else( ${EMSCRIPTEN} )
98
99 find_library(SDL VERSION "1.2" REQUIRED HINTS $DESKTOP_PREFIX/lib)
100 find_library(SDL REQUIRED)
101 find_library(SDL_image REQUIRED)
102
103 find_library(jpeg REQUIRED)
104 find_library(ft2build REQUIRED)
105 find_library(turbojpeg REQUIRED)
106
107 pkg_check_modules(pkgs REQUIRED
108   dali-core
109   # sdl from emscripten
110   sdl
111   egl
112   )
113
114 include_directories(/usr/local/include/SDL/)
115 set(LIBS ${LIBS} -lSDL -lSDL_image -lEGL -lGLESv2)
116
117 endif( ${EMSCRIPTEN} )
118
119 # non pkg config
120 include_directories(${DESKTOP_PREFIX}/include/)
121
122 add_definitions( ${CPP_DEFINES} ) # see configure_file() for *.in to *.h style
123
124 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_FLAGS}")
125 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_FLAGS}")
126
127 add_executable(${PROJECT_NAME} ${SRCS})
128
129 target_link_libraries(${PROJECT_NAME} ${pkgs_LDFLAGS} ${LIBS}) # "-lm"
130
131 # Copy dali-wrapper.js to dali-env
132 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/dali-wrapper.js ${EMSCRIPTEN_ENV_DIR}/dali-wrapper.js COPYONLY)
133
134 # tests
135 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/all.html ${EMSCRIPTEN_ENV_DIR}/all.html COPYONLY)
136 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/dali-page.html ${EMSCRIPTEN_ENV_DIR}/dali-page.html COPYONLY)
137 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/dali-tests.css ${EMSCRIPTEN_ENV_DIR}/dali-tests.css COPYONLY)
138 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/dali-tests.html ${EMSCRIPTEN_ENV_DIR}/dali-tests.html COPYONLY)
139 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/geometry.js ${EMSCRIPTEN_ENV_DIR}/geometry.js COPYONLY)
140 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/properties.js ${EMSCRIPTEN_ENV_DIR}/properties.js COPYONLY)
141 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/signals.js ${EMSCRIPTEN_ENV_DIR}/signals.js COPYONLY)
142 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/math.js ${EMSCRIPTEN_ENV_DIR}/math.js COPYONLY)
143 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/animation.js ${EMSCRIPTEN_ENV_DIR}/animation.js COPYONLY)
144 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/utilities.js ${EMSCRIPTEN_ENV_DIR}/utilities.js COPYONLY)
145 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/shaders.js ${EMSCRIPTEN_ENV_DIR}/shaders.js COPYONLY)
146 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/views.js ${EMSCRIPTEN_ENV_DIR}/views.js COPYONLY)
147
148 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/qunit/qunit-1.21.0.css ${EMSCRIPTEN_ENV_DIR}/qunit-1.21.0.css COPYONLY)
149 configure_file(${CMAKE_SOURCE_DIR}/../../adaptors/emscripten/wrappers/tests/qunit/qunit-1.21.0.js ${EMSCRIPTEN_ENV_DIR}/qunit-1.21.0.js COPYONLY)