2022-12-22 11:15:55 +00:00
|
|
|
# Available CMake versions:
|
2023-07-03 19:13:24 +00:00
|
|
|
# - Ubuntu 20.04 LTS : 3.16.3
|
|
|
|
# - Solaris 11.4 SRU 15 : 3.15
|
|
|
|
cmake_minimum_required(VERSION 3.15)
|
2016-06-20 20:07:35 +00:00
|
|
|
|
2021-12-15 10:28:25 +00:00
|
|
|
# Since this project's version is loaded from other files, this policy
|
|
|
|
# will help suppress the warning generated by cmake.
|
|
|
|
# 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)
|
2018-03-26 15:41:18 +00:00
|
|
|
project(brotli C)
|
2016-06-20 20:07:35 +00:00
|
|
|
|
2022-12-16 10:42:42 +00:00
|
|
|
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
|
|
|
|
2020-07-09 13:35:57 +00:00
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
message(STATUS "Setting build type to Release as none was specified.")
|
|
|
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
|
|
|
|
else()
|
|
|
|
message(STATUS "Build type is '${CMAKE_BUILD_TYPE}'")
|
|
|
|
endif()
|
|
|
|
|
2019-08-13 13:23:04 +00:00
|
|
|
include(CheckCSourceCompiles)
|
|
|
|
check_c_source_compiles(
|
|
|
|
"#if defined(__EMSCRIPTEN__)
|
|
|
|
int main() {return 0;}
|
|
|
|
#endif"
|
|
|
|
BROTLI_EMSCRIPTEN
|
|
|
|
)
|
|
|
|
if (BROTLI_EMSCRIPTEN)
|
|
|
|
message("-- Compiler is EMSCRIPTEN")
|
|
|
|
else()
|
|
|
|
message("-- Compiler is not EMSCRIPTEN")
|
|
|
|
endif()
|
2019-08-07 08:51:55 +00:00
|
|
|
|
2016-06-20 20:07:35 +00:00
|
|
|
# If Brotli is being bundled in another project, we don't want to
|
|
|
|
# install anything. However, we want to let people override this, so
|
|
|
|
# we'll use the BROTLI_BUNDLED_MODE variable to let them do that; just
|
|
|
|
# set it to OFF in your project before you add_subdirectory(brotli).
|
|
|
|
get_directory_property(BROTLI_PARENT_DIRECTORY PARENT_DIRECTORY)
|
2018-09-13 17:31:23 +00:00
|
|
|
if(NOT DEFINED BROTLI_BUNDLED_MODE)
|
2016-06-20 20:07:35 +00:00
|
|
|
# Bundled mode hasn't been set one way or the other, set the default
|
|
|
|
# depending on whether or not we are the top-level project.
|
|
|
|
if(BROTLI_PARENT_DIRECTORY)
|
|
|
|
set(BROTLI_BUNDLED_MODE ON)
|
2018-09-13 17:31:23 +00:00
|
|
|
else()
|
|
|
|
set(BROTLI_BUNDLED_MODE OFF)
|
2016-06-20 20:07:35 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
mark_as_advanced(BROTLI_BUNDLED_MODE)
|
|
|
|
|
2016-11-01 09:03:29 +00:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2023-07-30 10:44:38 +00:00
|
|
|
# Reads macro from .h file; it is expected to be a single-line define.
|
|
|
|
function(read_macro PATH MACRO OUTPUT)
|
|
|
|
file(STRINGS ${PATH} _line REGEX "^#define +${MACRO} +(.+)$")
|
|
|
|
string(REGEX REPLACE "^#define +${MACRO} +(.+)$" "\\1" _val "${_line}")
|
|
|
|
set(${OUTPUT} ${_val} PARENT_SCOPE)
|
|
|
|
endfunction(read_macro)
|
2016-08-22 13:44:12 +00:00
|
|
|
|
2016-11-01 09:03:29 +00:00
|
|
|
# Version information
|
2023-07-30 10:44:38 +00:00
|
|
|
read_macro("c/common/version.h" "BROTLI_VERSION_MAJOR" BROTLI_VERSION_MAJOR)
|
|
|
|
read_macro("c/common/version.h" "BROTLI_VERSION_MINOR" BROTLI_VERSION_MINOR)
|
|
|
|
read_macro("c/common/version.h" "BROTLI_VERSION_PATCH" BROTLI_VERSION_PATCH)
|
2023-07-31 16:36:54 +00:00
|
|
|
set(BROTLI_VERSION "${BROTLI_VERSION_MAJOR}.${BROTLI_VERSION_MINOR}.${BROTLI_VERSION_PATCH}")
|
2017-11-28 14:37:28 +00:00
|
|
|
mark_as_advanced(BROTLI_VERSION BROTLI_VERSION_MAJOR BROTLI_VERSION_MINOR BROTLI_VERSION_PATCH)
|
|
|
|
|
|
|
|
# ABI Version information
|
2023-07-30 10:44:38 +00:00
|
|
|
read_macro("c/common/version.h" "BROTLI_ABI_CURRENT" BROTLI_ABI_CURRENT)
|
|
|
|
read_macro("c/common/version.h" "BROTLI_ABI_REVISION" BROTLI_ABI_REVISION)
|
|
|
|
read_macro("c/common/version.h" "BROTLI_ABI_AGE" BROTLI_ABI_AGE)
|
2017-11-28 14:37:28 +00:00
|
|
|
math(EXPR BROTLI_ABI_COMPATIBILITY "${BROTLI_ABI_CURRENT} - ${BROTLI_ABI_AGE}")
|
|
|
|
mark_as_advanced(BROTLI_ABI_CURRENT BROTLI_ABI_REVISION BROTLI_ABI_AGE BROTLI_ABI_COMPATIBILITY)
|
2016-06-20 20:07:35 +00:00
|
|
|
|
2016-06-29 03:35:16 +00:00
|
|
|
if (ENABLE_SANITIZER)
|
|
|
|
set(CMAKE_C_FLAGS " ${CMAKE_C_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
|
|
|
|
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
|
|
|
|
endif ()
|
|
|
|
|
2016-07-29 18:52:15 +00:00
|
|
|
include(CheckFunctionExists)
|
|
|
|
set(LIBM_LIBRARY)
|
|
|
|
CHECK_FUNCTION_EXISTS(log2 LOG2_RES)
|
|
|
|
if(NOT LOG2_RES)
|
|
|
|
set(orig_req_libs "${CMAKE_REQUIRED_LIBRARIES}")
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};m")
|
2016-08-05 01:51:20 +00:00
|
|
|
CHECK_FUNCTION_EXISTS(log2 LOG2_LIBM_RES)
|
|
|
|
if(LOG2_LIBM_RES)
|
2016-07-29 18:52:15 +00:00
|
|
|
set(LIBM_LIBRARY "m")
|
2020-03-19 09:46:52 +00:00
|
|
|
add_definitions(-DBROTLI_HAVE_LOG2=1)
|
2016-07-29 18:52:15 +00:00
|
|
|
else()
|
2020-03-19 09:46:52 +00:00
|
|
|
add_definitions(-DBROTLI_HAVE_LOG2=0)
|
2016-07-29 18:52:15 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES "${orig_req_libs}")
|
2016-08-05 01:51:20 +00:00
|
|
|
unset(LOG2_LIBM_RES)
|
2016-07-29 18:52:15 +00:00
|
|
|
unset(orig_req_libs)
|
2020-03-19 09:46:52 +00:00
|
|
|
else()
|
|
|
|
add_definitions(-DBROTLI_HAVE_LOG2=1)
|
2016-07-29 18:52:15 +00:00
|
|
|
endif()
|
|
|
|
unset(LOG2_RES)
|
|
|
|
|
2017-04-23 12:07:08 +00:00
|
|
|
set(BROTLI_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/c/include")
|
2017-09-19 07:40:48 +00:00
|
|
|
mark_as_advanced(BROTLI_INCLUDE_DIRS)
|
|
|
|
|
2016-10-12 16:23:34 +00:00
|
|
|
set(BROTLI_LIBRARIES_CORE brotlienc brotlidec brotlicommon)
|
2016-08-27 10:04:48 +00:00
|
|
|
set(BROTLI_LIBRARIES ${BROTLI_LIBRARIES_CORE} ${LIBM_LIBRARY})
|
2017-09-19 07:40:48 +00:00
|
|
|
mark_as_advanced(BROTLI_LIBRARIES)
|
|
|
|
|
2016-06-20 20:07:35 +00:00
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
add_definitions(-DOS_LINUX)
|
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
|
|
|
add_definitions(-DOS_FREEBSD)
|
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
|
|
add_definitions(-DOS_MACOSX)
|
2022-11-17 13:37:20 +00:00
|
|
|
set(CMAKE_MACOS_RPATH TRUE)
|
|
|
|
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
2016-06-20 20:07:35 +00:00
|
|
|
endif()
|
|
|
|
|
2019-08-13 13:23:04 +00:00
|
|
|
if(BROTLI_EMSCRIPTEN)
|
2022-12-16 10:42:42 +00:00
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
2019-08-07 08:51:55 +00:00
|
|
|
endif()
|
2017-11-28 14:37:28 +00:00
|
|
|
|
2023-07-30 10:44:38 +00:00
|
|
|
file(GLOB_RECURSE BROTLI_COMMON_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} c/common/*.c)
|
|
|
|
add_library(brotlicommon ${BROTLI_COMMON_SOURCES})
|
|
|
|
|
|
|
|
file(GLOB_RECURSE BROTLI_DEC_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} c/dec/*.c)
|
|
|
|
add_library(brotlidec ${BROTLI_DEC_SOURCES})
|
|
|
|
|
|
|
|
file(GLOB_RECURSE BROTLI_ENC_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} c/enc/*.c)
|
|
|
|
add_library(brotlienc ${BROTLI_ENC_SOURCES})
|
2017-09-19 07:40:48 +00:00
|
|
|
|
2016-08-23 13:35:54 +00:00
|
|
|
# Older CMake versions does not understand INCLUDE_DIRECTORIES property.
|
|
|
|
include_directories(${BROTLI_INCLUDE_DIRS})
|
|
|
|
|
2022-12-16 10:42:42 +00:00
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
foreach(lib ${BROTLI_LIBRARIES_CORE})
|
|
|
|
target_compile_definitions(${lib} PUBLIC "BROTLI_SHARED_COMPILATION" )
|
|
|
|
string(TOUPPER "${lib}" LIB)
|
|
|
|
set_target_properties (${lib} PROPERTIES DEFINE_SYMBOL "${LIB}_SHARED_COMPILATION")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2017-09-19 07:40:48 +00:00
|
|
|
|
2022-12-16 10:42:42 +00:00
|
|
|
foreach(lib ${BROTLI_LIBRARIES_CORE})
|
2016-07-29 18:52:15 +00:00
|
|
|
target_link_libraries(${lib} ${LIBM_LIBRARY})
|
2016-06-20 20:07:35 +00:00
|
|
|
set_property(TARGET ${lib} APPEND PROPERTY INCLUDE_DIRECTORIES ${BROTLI_INCLUDE_DIRS})
|
|
|
|
set_target_properties(${lib} PROPERTIES
|
2017-11-28 14:37:28 +00:00
|
|
|
VERSION "${BROTLI_ABI_COMPATIBILITY}.${BROTLI_ABI_AGE}.${BROTLI_ABI_REVISION}"
|
2019-08-13 13:23:04 +00:00
|
|
|
SOVERSION "${BROTLI_ABI_COMPATIBILITY}")
|
|
|
|
if(NOT BROTLI_EMSCRIPTEN)
|
|
|
|
set_target_properties(${lib} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
|
|
|
endif()
|
2022-05-12 07:50:48 +00:00
|
|
|
set_property(TARGET ${lib} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${BROTLI_INCLUDE_DIRS}>")
|
2016-06-20 20:07:35 +00:00
|
|
|
endforeach()
|
2016-10-18 14:45:32 +00:00
|
|
|
|
2019-08-13 13:23:04 +00:00
|
|
|
if(NOT BROTLI_EMSCRIPTEN)
|
2016-11-01 09:03:29 +00:00
|
|
|
target_link_libraries(brotlidec brotlicommon)
|
|
|
|
target_link_libraries(brotlienc brotlicommon)
|
2019-08-07 08:51:55 +00:00
|
|
|
endif()
|
2016-06-20 20:07:35 +00:00
|
|
|
|
|
|
|
# For projects stuck on older versions of CMake, this will set the
|
|
|
|
# BROTLI_INCLUDE_DIRS and BROTLI_LIBRARIES variables so they still
|
|
|
|
# have a relatively easy way to use Brotli:
|
|
|
|
#
|
|
|
|
# include_directories(${BROTLI_INCLUDE_DIRS})
|
|
|
|
# target_link_libraries(foo ${BROTLI_LIBRARIES})
|
|
|
|
if(BROTLI_PARENT_DIRECTORY)
|
|
|
|
set(BROTLI_INCLUDE_DIRS "${BROTLI_INCLUDE_DIRS}" PARENT_SCOPE)
|
|
|
|
set(BROTLI_LIBRARIES "${BROTLI_LIBRARIES}" PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
|
2017-05-29 15:55:14 +00:00
|
|
|
# Build the brotli executable
|
2023-07-30 10:44:38 +00:00
|
|
|
add_executable(brotli c/tools/brotli.c)
|
2022-12-16 10:42:42 +00:00
|
|
|
target_link_libraries(brotli ${BROTLI_LIBRARIES})
|
2016-06-20 20:07:35 +00:00
|
|
|
|
|
|
|
# Installation
|
2016-08-27 10:14:13 +00:00
|
|
|
if(NOT BROTLI_BUNDLED_MODE)
|
2017-05-24 15:19:34 +00:00
|
|
|
install(
|
2017-05-29 15:55:14 +00:00
|
|
|
TARGETS brotli
|
2017-05-24 15:19:34 +00:00
|
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
|
|
)
|
|
|
|
|
2022-12-20 10:03:21 +00:00
|
|
|
install(
|
|
|
|
TARGETS ${BROTLI_LIBRARIES_CORE}
|
|
|
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
|
|
)
|
2017-05-24 15:19:34 +00:00
|
|
|
|
|
|
|
install(
|
|
|
|
DIRECTORY ${BROTLI_INCLUDE_DIRS}/brotli
|
|
|
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
|
|
)
|
2019-08-13 13:23:04 +00:00
|
|
|
endif() # BROTLI_BUNDLED_MODE
|
2016-06-20 20:07:35 +00:00
|
|
|
|
|
|
|
# Tests
|
2016-07-28 20:31:09 +00:00
|
|
|
|
|
|
|
# If we're targeting Windows but not running on Windows, we need Wine
|
|
|
|
# to run the tests...
|
|
|
|
if(NOT BROTLI_DISABLE_TESTS)
|
|
|
|
if(WIN32 AND NOT CMAKE_HOST_WIN32)
|
2018-09-27 09:00:33 +00:00
|
|
|
find_program(BROTLI_WRAPPER NAMES wine)
|
2016-07-28 20:31:09 +00:00
|
|
|
|
2018-09-27 09:00:33 +00:00
|
|
|
if(NOT BROTLI_WRAPPER)
|
2016-07-29 18:52:15 +00:00
|
|
|
message(STATUS "wine not found, disabling tests")
|
|
|
|
set(BROTLI_DISABLE_TESTS TRUE)
|
|
|
|
endif()
|
2016-07-28 20:31:09 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-09-27 09:00:33 +00:00
|
|
|
# If our compiler is a cross-compiler that we know about (arm/aarch64),
|
|
|
|
# then we need to use qemu to execute the tests.
|
|
|
|
if(NOT BROTLI_DISABLE_TESTS)
|
|
|
|
if ("${CMAKE_C_COMPILER}" MATCHES "^.*/arm-linux-gnueabihf-.*$")
|
|
|
|
message(STATUS "Detected arm-linux-gnueabihf cross-compilation")
|
|
|
|
set(BROTLI_WRAPPER "qemu-arm")
|
|
|
|
set(BROTLI_WRAPPER_LD_PREFIX "/usr/arm-linux-gnueabihf")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if ("${CMAKE_C_COMPILER}" MATCHES "^.*/arm-linux-gnueabi-.*$")
|
|
|
|
message(STATUS "Detected arm-linux-gnueabi cross-compilation")
|
|
|
|
set(BROTLI_WRAPPER "qemu-arm")
|
|
|
|
set(BROTLI_WRAPPER_LD_PREFIX "/usr/arm-linux-gnueabi")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if ("${CMAKE_C_COMPILER}" MATCHES "^.*/aarch64-linux-gnu-.*$")
|
|
|
|
message(STATUS "Detected aarch64-linux-gnu cross-compilation")
|
|
|
|
set(BROTLI_WRAPPER "qemu-aarch64")
|
|
|
|
set(BROTLI_WRAPPER_LD_PREFIX "/usr/aarch64-linux-gnu")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-06-20 20:07:35 +00:00
|
|
|
if(NOT BROTLI_DISABLE_TESTS)
|
|
|
|
include(CTest)
|
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
set(ROUNDTRIP_INPUTS
|
|
|
|
tests/testdata/alice29.txt
|
|
|
|
tests/testdata/asyoulik.txt
|
|
|
|
tests/testdata/lcet10.txt
|
|
|
|
tests/testdata/plrabn12.txt
|
2017-04-23 12:07:08 +00:00
|
|
|
c/enc/encode.c
|
|
|
|
c/common/dictionary.h
|
|
|
|
c/dec/decode.c)
|
2016-06-20 20:07:35 +00:00
|
|
|
|
|
|
|
foreach(INPUT ${ROUNDTRIP_INPUTS})
|
2016-07-28 20:31:09 +00:00
|
|
|
get_filename_component(OUTPUT_NAME "${INPUT}" NAME)
|
|
|
|
|
|
|
|
set(OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}")
|
|
|
|
set(INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}")
|
|
|
|
|
2020-08-26 15:13:31 +00:00
|
|
|
if (EXISTS "${INPUT_FILE}")
|
|
|
|
foreach(quality 1 6 9 11)
|
|
|
|
add_test(NAME "${BROTLI_TEST_PREFIX}roundtrip/${INPUT}/${quality}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
-DBROTLI_WRAPPER=${BROTLI_WRAPPER}
|
|
|
|
-DBROTLI_WRAPPER_LD_PREFIX=${BROTLI_WRAPPER_LD_PREFIX}
|
|
|
|
-DBROTLI_CLI=$<TARGET_FILE:brotli>
|
|
|
|
-DQUALITY=${quality}
|
|
|
|
-DINPUT=${INPUT_FILE}
|
|
|
|
-DOUTPUT=${OUTPUT_FILE}.${quality}
|
|
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/tests/run-roundtrip-test.cmake)
|
|
|
|
endforeach()
|
|
|
|
else()
|
|
|
|
message(WARNING "Test file ${INPUT} does not exist.")
|
|
|
|
endif()
|
2016-06-20 20:07:35 +00:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
file(GLOB_RECURSE
|
|
|
|
COMPATIBILITY_INPUTS
|
|
|
|
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
tests/testdata/*.compressed*)
|
|
|
|
|
|
|
|
foreach(INPUT ${COMPATIBILITY_INPUTS})
|
|
|
|
add_test(NAME "${BROTLI_TEST_PREFIX}compatibility/${INPUT}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
2018-09-27 09:00:33 +00:00
|
|
|
-DBROTLI_WRAPPER=${BROTLI_WRAPPER}
|
|
|
|
-DBROTLI_WRAPPER_LD_PREFIX=${BROTLI_WRAPPER_LD_PREFIX}
|
2017-05-29 15:55:14 +00:00
|
|
|
-DBROTLI_CLI=$<TARGET_FILE:brotli>
|
2016-06-20 20:07:35 +00:00
|
|
|
-DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}
|
|
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/tests/run-compatibility-test.cmake)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2016-11-01 09:03:29 +00:00
|
|
|
|
2017-11-28 14:37:28 +00:00
|
|
|
# Generate a pkg-config files
|
2016-11-01 09:03:29 +00:00
|
|
|
|
|
|
|
function(generate_pkg_config_path outvar path)
|
|
|
|
string(LENGTH "${path}" path_length)
|
|
|
|
|
|
|
|
set(path_args ${ARGV})
|
|
|
|
list(REMOVE_AT path_args 0 1)
|
|
|
|
list(LENGTH path_args path_args_remaining)
|
|
|
|
|
|
|
|
set("${outvar}" "${path}")
|
|
|
|
|
|
|
|
while(path_args_remaining GREATER 1)
|
|
|
|
list(GET path_args 0 name)
|
|
|
|
list(GET path_args 1 value)
|
|
|
|
|
|
|
|
get_filename_component(value_full "${value}" ABSOLUTE)
|
|
|
|
string(LENGTH "${value}" value_length)
|
|
|
|
|
|
|
|
if(path_length EQUAL value_length AND path STREQUAL value)
|
|
|
|
set("${outvar}" "\${${name}}")
|
|
|
|
break()
|
|
|
|
elseif(path_length GREATER value_length)
|
|
|
|
# We might be in a subdirectory of the value, but we have to be
|
|
|
|
# careful about a prefix matching but not being a subdirectory
|
|
|
|
# (for example, /usr/lib64 is not a subdirectory of /usr/lib).
|
|
|
|
# We'll do this by making sure the next character is a directory
|
|
|
|
# separator.
|
|
|
|
string(SUBSTRING "${path}" ${value_length} 1 sep)
|
|
|
|
if(sep STREQUAL "/")
|
|
|
|
string(SUBSTRING "${path}" 0 ${value_length} s)
|
|
|
|
if(s STREQUAL value)
|
|
|
|
string(SUBSTRING "${path}" "${value_length}" -1 suffix)
|
|
|
|
set("${outvar}" "\${${name}}${suffix}")
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(REMOVE_AT path_args 0 1)
|
|
|
|
list(LENGTH path_args path_args_remaining)
|
|
|
|
endwhile()
|
|
|
|
|
|
|
|
set("${outvar}" "${${outvar}}" PARENT_SCOPE)
|
|
|
|
endfunction(generate_pkg_config_path)
|
|
|
|
|
2017-11-28 14:37:28 +00:00
|
|
|
function(transform_pc_file INPUT_FILE OUTPUT_FILE VERSION)
|
|
|
|
file(READ ${INPUT_FILE} TEXT)
|
2016-11-01 09:03:29 +00:00
|
|
|
|
2017-11-28 14:37:28 +00:00
|
|
|
set(PREFIX "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
string(REGEX REPLACE "@prefix@" "${PREFIX}" TEXT ${TEXT})
|
|
|
|
string(REGEX REPLACE "@exec_prefix@" "${PREFIX}" TEXT ${TEXT})
|
2016-11-01 09:03:29 +00:00
|
|
|
|
2017-11-28 14:37:28 +00:00
|
|
|
generate_pkg_config_path(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}" prefix "${PREFIX}")
|
|
|
|
string(REGEX REPLACE "@libdir@" "${LIBDIR}" TEXT ${TEXT})
|
2016-11-01 09:03:29 +00:00
|
|
|
|
2017-11-28 14:37:28 +00:00
|
|
|
generate_pkg_config_path(INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}" prefix "${PREFIX}")
|
|
|
|
string(REGEX REPLACE "@includedir@" "${INCLUDEDIR}" TEXT ${TEXT})
|
2016-11-01 09:03:29 +00:00
|
|
|
|
2017-11-28 14:37:28 +00:00
|
|
|
string(REGEX REPLACE "@PACKAGE_VERSION@" "${VERSION}" TEXT ${TEXT})
|
2016-11-01 09:03:29 +00:00
|
|
|
|
2017-11-28 14:37:28 +00:00
|
|
|
file(WRITE ${OUTPUT_FILE} ${TEXT})
|
|
|
|
endfunction()
|
2016-11-01 09:03:29 +00:00
|
|
|
|
2017-11-28 14:37:28 +00:00
|
|
|
transform_pc_file("scripts/libbrotlicommon.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libbrotlicommon.pc" "${BROTLI_VERSION}")
|
2016-12-22 07:57:44 +00:00
|
|
|
|
2017-11-28 14:37:28 +00:00
|
|
|
transform_pc_file("scripts/libbrotlidec.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libbrotlidec.pc" "${BROTLI_VERSION}")
|
2016-11-01 09:03:29 +00:00
|
|
|
|
2017-11-28 14:37:28 +00:00
|
|
|
transform_pc_file("scripts/libbrotlienc.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libbrotlienc.pc" "${BROTLI_VERSION}")
|
2016-11-01 09:03:29 +00:00
|
|
|
|
|
|
|
if(NOT BROTLI_BUNDLED_MODE)
|
2016-12-22 07:57:44 +00:00
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlicommon.pc"
|
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlidec.pc"
|
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlienc.pc"
|
2016-11-01 09:03:29 +00:00
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
2019-08-13 13:23:04 +00:00
|
|
|
endif() # BROTLI_BUNDLED_MODE
|
2016-11-01 09:03:29 +00:00
|
|
|
|
|
|
|
if (ENABLE_COVERAGE STREQUAL "yes")
|
|
|
|
SETUP_TARGET_FOR_COVERAGE(coverage test coverage)
|
|
|
|
endif ()
|