Skip to content

Commit

Permalink
build: support find_package(basisu CONFIG)
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Nov 1, 2024
1 parent 3e3d294 commit bad9c43
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ endif()

# Create the static library
add_library(basisu_encoder STATIC ${ENCODER_LIB_SRC_LIST})
target_include_directories(basisu_encoder PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/transcoder>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/encoder>
$<INSTALL_INTERFACE:include>)

# Create the basisu executable and link against the static library
add_executable(basisu basisu_tool.cpp)
Expand Down Expand Up @@ -270,3 +274,31 @@ if (MSVC)
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
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::)
7 changes: 7 additions & 0 deletions basisu-config.cmake.in
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit bad9c43

Please sign in to comment.