From 333d888a4292882adc719518ed9d311121a5d7ca Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Tue, 31 Jul 2018 10:14:46 +0900 Subject: [PATCH] lottie: add cmake config file so that library can be found with find_package() Change-Id: I4e1c29f79a1a24636808079762cc88501fe2389b --- CMakeLists.txt | 29 +++++++++++++++++++++++++++-- cmake/lottie-playerConfig.cmake.in | 16 ++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 cmake/lottie-playerConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e8f161..6a04e59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required( VERSION 3.2 ) #declare project -project( lottie-player LANGUAGES C CXX ) +project( lottie-player VERSION 0.0.1 LANGUAGES C CXX ) #declare target add_library( lottie-player SHARED "" ) @@ -53,12 +53,37 @@ install( TARGETS lottie-player EXPORT lottie-player-targets ) #install config file. + install( EXPORT lottie-player-targets - FILE lottie-player.cmake + FILE lottie-playerTargets.cmake NAMESPACE lottie-player:: DESTINATION lib/cmake/lottie-player ) +#Create a ConfigVersion.cmake file +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/lottie-playerConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion +) + +configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/lottie-playerConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/lottie-playerConfig.cmake + INSTALL_DESTINATION lib/cmake/lottie-player +) + +#Install the config, configversion and custom find modules +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/lottie-playerConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/lottie-playerConfigVersion.cmake + DESTINATION lib/cmake/lottie-player +) + + +export(EXPORT lottie-player-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/lottie-playerTargets.cmake NAMESPACE lottie-player::) + #Register package in user's package registry export(PACKAGE lottie-player) + diff --git a/cmake/lottie-playerConfig.cmake.in b/cmake/lottie-playerConfig.cmake.in new file mode 100644 index 0000000..8367242 --- /dev/null +++ b/cmake/lottie-playerConfig.cmake.in @@ -0,0 +1,16 @@ +get_filename_component(lottie-player_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +include(CMakeFindDependencyMacro) + +list(APPEND CMAKE_MODULE_PATH ${lottie-player_CMAKE_DIR}) + +# NOTE Had to use find_package because find_dependency does not support COMPONENTS or MODULE until 3.8.0 + +#find_dependency(RapidJSON 1.0 REQUIRED MODULE) +#find_package(Boost 1.55 REQUIRED COMPONENTS regex) +list(REMOVE_AT CMAKE_MODULE_PATH -1) + +if(NOT TARGET lottie-player::lottie-player) + include("${lottie-player_CMAKE_DIR}/lottie-playerTargets.cmake") +endif() + +set(lottie-player_LIBRARIES lottie-player::lottie-player) -- 2.7.4