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