move function prototype to animation.h
[platform/core/uifw/lottie-player.git] / CMakeLists.txt
1 cmake_minimum_required( VERSION 3.3 )
2
3 #declare project
4 project( rlottie VERSION 0.2 LANGUAGES C CXX ASM)
5
6 if (NOT CMAKE_BUILD_TYPE)
7     set(CMAKE_BUILD_TYPE MinSizeRel)
8 endif()
9
10 if (NOT DEFINED BUILD_SHARED_LIBS)
11     # Keep the previous behavior of the build system, consistent with Meson.
12     set(BUILD_SHARED_LIBS ON)
13 endif()
14
15 #declare target
16 add_library( rlottie )
17 set_target_properties( rlottie PROPERTIES DEFINE_SYMBOL RLOTTIE_BUILD )
18
19 #declare version of the target
20 set(player_version_major 0)
21 set(player_version_minor 2)
22 set(player_version ${player_version_major}.${player_version_minor})
23 set_target_properties(rlottie PROPERTIES
24                         VERSION    ${player_version}
25                         SOVERSION  ${player_version_major}
26                       )
27
28 #declare alias so that library can be used inside the build tree, e.g. when testing
29 add_library(rlottie::rlottie ALIAS rlottie)
30
31 option(LOTTIE_MODULE "Enable LOTTIE MODULE SUPPORT" ON)
32 option(LOTTIE_THREAD "Enable LOTTIE THREAD SUPPORT" ON)
33 option(LOTTIE_CACHE "Enable LOTTIE CACHE SUPPORT" ON)
34 option(LOTTIE_TEST "Build LOTTIE AUTOTESTS" OFF)
35 option(LOTTIE_CCACHE "Enable LOTTIE ccache SUPPORT" OFF)
36 option(LOTTIE_ASAN "Compile with asan" OFF)
37
38 set(LOTTIE_MODULE_PATH "${CMAKE_SHARED_LIBRARY_PREFIX}rlottie-image-loader${CMAKE_SHARED_LIBRARY_SUFFIX}"
39     CACHE STRING "Absolute or relative path to dynamic loader plugin.")
40
41 configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/config.h.in config.h)
42
43 target_include_directories(rlottie
44     PRIVATE
45         "${CMAKE_CURRENT_BINARY_DIR}"
46     )
47
48 #declare common target compilation options
49 target_compile_options(rlottie
50                     PUBLIC
51                     PRIVATE
52                         -std=c++14
53                         -fno-exceptions
54                         -fno-unwind-tables
55                         -fno-asynchronous-unwind-tables
56                         -fno-rtti
57                         -Wall
58                         -fvisibility=hidden
59                     )
60
61 #MSVC does not recognize these parameters
62 if (NOT WIN32)
63     target_compile_options(rlottie
64                         PUBLIC
65                         PRIVATE
66                             -Wnon-virtual-dtor
67                             -Woverloaded-virtual
68                             -Wno-unused-parameter
69                         )
70 endif()
71
72 if (WIN32 AND NOT BUILD_SHARED_LIBS)
73     target_compile_definitions(rlottie PUBLIC -DRLOTTIE_BUILD=0)
74 endif()
75
76 #declare dependancy
77 set( CMAKE_THREAD_PREFER_PTHREAD TRUE )
78 find_package( Threads )
79
80 target_link_libraries(rlottie
81                     PUBLIC
82                         "${CMAKE_THREAD_LIBS_INIT}"
83                      )
84
85 if (NOT APPLE AND NOT WIN32)
86     target_link_libraries(rlottie
87                         PRIVATE
88                             "-Wl,--version-script=${CMAKE_SOURCE_DIR}/rlottie.expmap"
89                           )
90 endif()
91
92 if (LOTTIE_MODULE)
93     # for dlopen, dlsym and dlclose dependancy
94     target_link_libraries(rlottie PRIVATE ${CMAKE_DL_LIBS})
95 endif()
96
97 if (NOT LOTTIE_ASAN)
98     if(APPLE)
99         target_link_libraries(rlottie
100                             PUBLIC
101                                  "-Wl, -undefined error"
102                               )
103     else()
104         target_link_libraries(rlottie
105                             PUBLIC
106                                  "-Wl,--no-undefined"
107                               )
108     endif()
109 endif()
110
111 if (LOTTIE_CCACHE)
112     find_program(CCACHE_FOUND ccache)
113     if (CCACHE_FOUND)
114         message(STATUS "Found ccache")
115         set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
116         set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
117     else()
118         message(STATUS "Could NOT find ccache (this is NOT an error)")
119     endif()
120 endif()
121
122 if (LOTTIE_ASAN)
123     target_compile_options(rlottie PUBLIC -fsanitize=address)
124     target_link_options(rlottie PUBLIC  -fsanitize=address)
125 endif()
126
127 if (NOT LIB_INSTALL_DIR)
128     set (LIB_INSTALL_DIR "/usr/lib")
129 endif (NOT LIB_INSTALL_DIR)
130
131 #declare source and include files
132 add_subdirectory(inc)
133 add_subdirectory(src)
134 add_subdirectory(example)
135
136 if (LOTTIE_TEST)
137     enable_testing()
138     add_subdirectory(test)
139 endif()
140
141 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
142 SET(EXEC_DIR ${PREFIX})
143 SET(LIBDIR ${LIB_INSTALL_DIR})
144 SET(INCDIR ${PREFIX}/include)
145
146 CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc)
147 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
148
149
150 #install header
151 install(FILES
152         inc/rlottie.h
153         inc/rlottie_capi.h
154         inc/rlottiecommon.h
155         DESTINATION include)
156
157 #install lib
158 install( TARGETS rlottie EXPORT rlottie-targets
159          LIBRARY     DESTINATION    ${LIB_INSTALL_DIR}
160          ARCHIVE     DESTINATION    ${LIB_INSTALL_DIR}
161          INCLUDES    DESTINATION    include
162        )
163
164 #install config file.
165
166 install( EXPORT rlottie-targets
167          FILE          rlottieTargets.cmake
168          NAMESPACE     rlottie::
169          DESTINATION   ${LIB_INSTALL_DIR}/cmake/rlottie
170        )
171
172
173 #Create a ConfigVersion.cmake file
174 include(CMakePackageConfigHelpers)
175 write_basic_package_version_file(
176     ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfigVersion.cmake
177     VERSION ${PROJECT_VERSION}
178     COMPATIBILITY AnyNewerVersion
179 )
180
181 configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/rlottieConfig.cmake.in
182     ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfig.cmake
183     INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie
184 )
185
186 #Install the config, configversion and custom find modules
187 install(FILES
188     ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfig.cmake
189     ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfigVersion.cmake
190     DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie
191 )
192
193
194 export(EXPORT rlottie-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/rlottieTargets.cmake NAMESPACE rlottie::)
195
196 #Register package in user's package registry
197 export(PACKAGE rlottie)
198