Skip to content

Commit

Permalink
Added cmake version and target
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarques1995 committed May 26, 2024
1 parent 8a626fd commit fbfed3a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
29 changes: 28 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cmake_minimum_required(VERSION 3.15)
# This policy is set because we can't provide "VERSION" in "project" command.
# Use `cmake --help-policy CMP0048` for more information.
cmake_policy(SET CMP0048 NEW)
project(brotli C)
project(brotli LANGUAGES C VERSION 1.1.1)

option(BUILD_SHARED_LIBS "Build shared libraries" ON)
set(BROTLI_BUILD_TOOLS ON CACHE BOOL "Build/install CLI tools")
Expand Down Expand Up @@ -162,6 +162,32 @@ endif()

# Installation
if(NOT BROTLI_BUNDLED_MODE)
#CMake package

set(BROTLI_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(BROTLI_VERSION_CONFIG "${BROTLI_GENERATED_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
set(BROTLI_PROJECT_CONFIG "${BROTLI_GENERATED_DIR}/${PROJECT_NAME}Config.cmake")
set(BROTLI_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(BROTLI_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}")
set(BROTLI_NAMESPACE "${PROJECT_NAME}::")
set(BROTLI_VERSION ${PROJECT_VERSION})

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${BROTLI_VERSION_CONFIG}" VERSION ${BROTLI_VERSION} COMPATIBILITY SameMajorVersion
)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in" "${BROTLI_PROJECT_CONFIG}" @ONLY)

# Install cmake config files
install(
FILES "${BROTLI_PROJECT_CONFIG}" "${BROTLI_VERSION_CONFIG}"
DESTINATION "${BROTLI_CONFIG_INSTALL_DIR}")

install(
EXPORT "${BROTLI_TARGETS_EXPORT_NAME}"
NAMESPACE "${BROTLI_NAMESPACE}"
DESTINATION "${BROTLI_CONFIG_INSTALL_DIR}")

if (BROTLI_BUILD_TOOLS)
install(
TARGETS brotli
Expand All @@ -171,6 +197,7 @@ if(NOT BROTLI_BUNDLED_MODE)

install(
TARGETS ${BROTLI_LIBRARIES_CORE}
EXPORT ${BROTLI_TARGETS_EXPORT_NAME}
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
Expand Down
3 changes: 3 additions & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include(CMakeFindDependencyMacro)

include("${CMAKE_CURRENT_LIST_DIR}/@NGHTTP3_TARGETS_EXPORT_NAME@.cmake")

0 comments on commit fbfed3a

Please sign in to comment.