1 cmake_minimum_required( VERSION 3.2 )
4 project( lottie-player VERSION 0.0.1 LANGUAGES C CXX )
7 add_library( lottie-player SHARED "" )
9 #declare version of the target
10 set(player_version_major 0)
11 set(player_version_minor 0)
12 set(player_version_patch 1)
13 set(player_version ${player_version_major}.${player_version_minor}.${player_version_patch} )
14 set_target_properties(lottie-player PROPERTIES
15 VERSION ${player_version}
16 SOVERSION ${player_version_major}
19 #declare alias so that library can be used inside the build tree, e.g. when testing
20 add_library(lottie-player::lottie-player ALIAS lottie-player)
22 #declare target compilation options
23 target_compile_options(lottie-player
27 -Wall -fvisibility=hidden -O2)
30 set( CMAKE_THREAD_PREFER_PTHREAD TRUE )
31 find_package( Threads )
33 target_link_libraries(lottie-player
35 "${CMAKE_THREAD_LIBS_INIT}"
38 #declare source and include files
42 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
43 SET(EXEC_DIR ${PREFIX})
44 SET(LIBDIR ${LIB_INSTALL_DIR})
45 SET(INCDIR ${PREFIX}/include)
46 CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
47 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
50 install(FILES inc/lottieplayer.h DESTINATION include)
53 install( TARGETS lottie-player EXPORT lottie-player-targets
54 LIBRARY DESTINATION lib
55 ARCHIVE DESTINATION lib
56 INCLUDES DESTINATION include
61 install( EXPORT lottie-player-targets
62 FILE lottie-playerTargets.cmake
63 NAMESPACE lottie-player::
64 DESTINATION lib/cmake/lottie-player
68 #Create a ConfigVersion.cmake file
69 include(CMakePackageConfigHelpers)
70 write_basic_package_version_file(
71 ${CMAKE_CURRENT_BINARY_DIR}/lottie-playerConfigVersion.cmake
72 VERSION ${PROJECT_VERSION}
73 COMPATIBILITY AnyNewerVersion
76 configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/lottie-playerConfig.cmake.in
77 ${CMAKE_CURRENT_BINARY_DIR}/lottie-playerConfig.cmake
78 INSTALL_DESTINATION lib/cmake/lottie-player
81 #Install the config, configversion and custom find modules
83 ${CMAKE_CURRENT_BINARY_DIR}/lottie-playerConfig.cmake
84 ${CMAKE_CURRENT_BINARY_DIR}/lottie-playerConfigVersion.cmake
85 DESTINATION lib/cmake/lottie-player
89 export(EXPORT lottie-player-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/lottie-playerTargets.cmake NAMESPACE lottie-player::)
91 #Register package in user's package registry
92 export(PACKAGE lottie-player)