From 56fedfe14ebd21dfec68e8f71f23feabad6c1b44 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 1 Nov 2024 04:49:41 -0700 Subject: [PATCH] build: support find_package(basisu CONFIG) --- CMakeLists.txt | 32 ++++++++++++++++++++++++++++++++ basisu-config.cmake.in | 7 +++++++ 2 files changed, 39 insertions(+) create mode 100644 basisu-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index e4e7c7e..46818dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,6 +169,10 @@ endif() # Create the static library add_library(basisu_encoder STATIC ${ENCODER_LIB_SRC_LIST}) +target_include_directories(basisu_encoder PUBLIC + $ + $ + $) # Create the basisu executable and link against the static library add_executable(basisu basisu_tool.cpp) @@ -272,3 +276,31 @@ if (MSVC) ) endif() endif() + +# Target Installation +install(TARGETS basisu_encoder basisu EXPORT basisu-targets) +install(DIRECTORY "./transcoder" DESTINATION "include/basisu/" + FILES_MATCHING PATTERN "*.h" PATTERN "*.inc" +) +install(DIRECTORY "./encoder" DESTINATION "include/basisu/" + FILES_MATCHING PATTERN "*.h" +) + +# CMake Export +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) +configure_package_config_file( + ${PROJECT_SOURCE_DIR}/basisu-config.cmake.in + ${PROJECT_BINARY_DIR}/basisu-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/basisu) +export( + TARGETS basisu_encoder basisu + NAMESPACE basisu:: + FILE ${PROJECT_BINARY_DIR}/basisu-targets.cmake) +install( + FILES ${PROJECT_BINARY_DIR}/basisu-config.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/basisu) +install( + EXPORT basisu-targets + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/basisu + NAMESPACE basisu::) diff --git a/basisu-config.cmake.in b/basisu-config.cmake.in new file mode 100644 index 0000000..6ac330e --- /dev/null +++ b/basisu-config.cmake.in @@ -0,0 +1,7 @@ +@PACKAGE_INIT@ + +if (NOT TARGET basisu::basisu_encoder) + include(${CMAKE_CURRENT_LIST_DIR}/basisu-targets.cmake) +endif () + +check_required_components(basisu)