Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmake version and target #1172

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}/@[email protected]")