1 cmake_minimum_required( VERSION 3.3 )
4 project( rlottie VERSION 0.1 LANGUAGES C CXX ASM)
6 if (NOT CMAKE_BUILD_TYPE)
7 set(CMAKE_BUILD_TYPE MinSizeRel)
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)
16 add_library( rlottie )
17 set_target_properties( rlottie PROPERTIES DEFINE_SYMBOL LOT_BUILD )
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}
29 #declare alias so that library can be used inside the build tree, e.g. when testing
30 add_library(rlottie::rlottie ALIAS rlottie)
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)
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.")
42 configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/config.h.in config.h)
44 target_include_directories(rlottie
46 "${CMAKE_CURRENT_BINARY_DIR}"
49 #declare target compilation options
50 target_compile_options(rlottie
56 -fno-asynchronous-unwind-tables
68 set( CMAKE_THREAD_PREFER_PTHREAD TRUE )
69 find_package( Threads )
71 target_link_libraries(rlottie
73 "${CMAKE_THREAD_LIBS_INIT}"
76 if (NOT APPLE AND NOT WIN32)
77 target_link_libraries(rlottie
79 "-Wl,--version-script=${CMAKE_SOURCE_DIR}/rlottie.expmap"
84 # for dlopen, dlsym and dlclose dependancy
85 target_link_libraries(rlottie PRIVATE ${CMAKE_DL_LIBS})
90 target_link_libraries(rlottie
92 "-Wl, -undefined error"
95 target_link_libraries(rlottie
103 find_program(CCACHE_FOUND ccache)
105 message(STATUS "Found ccache")
106 set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
107 set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
109 message(STATUS "Could NOT find ccache (this is NOT an error)")
114 target_compile_options(rlottie PUBLIC -fsanitize=address)
115 target_link_options(rlottie PUBLIC -fsanitize=address)
118 if (NOT LIB_INSTALL_DIR)
119 set (LIB_INSTALL_DIR "/usr/lib")
120 endif (NOT LIB_INSTALL_DIR)
122 #declare source and include files
123 add_subdirectory(inc)
124 add_subdirectory(src)
125 add_subdirectory(example)
129 add_subdirectory(test)
132 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
133 SET(EXEC_DIR ${PREFIX})
134 SET(LIBDIR ${LIB_INSTALL_DIR})
135 SET(INCDIR ${PREFIX}/include)
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)
149 install( TARGETS rlottie EXPORT rlottie-targets
150 LIBRARY DESTINATION ${LIB_INSTALL_DIR}
151 ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
152 INCLUDES DESTINATION include
155 #install config file.
157 install( EXPORT rlottie-targets
158 FILE rlottieTargets.cmake
160 DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie
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
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
177 #Install the config, configversion and custom find modules
179 ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfig.cmake
180 ${CMAKE_CURRENT_BINARY_DIR}/rlottieConfigVersion.cmake
181 DESTINATION ${LIB_INSTALL_DIR}/cmake/rlottie
185 export(EXPORT rlottie-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/rlottieTargets.cmake NAMESPACE rlottie::)
187 #Register package in user's package registry
188 export(PACKAGE rlottie)