blob: 99b925806646d225e6d3cb90c44cda8f256cbe93 [file] [log] [blame]
Evan Nemerson93ef13f2016-06-20 13:07:35 -07001# Ubuntu 12.04 LTS has CMake 2.8.7, and is an important target since
2# several CI services, such as Travis and Drone, use it. Solaris 11
3# has 2.8.6, and it's not difficult to support if you already have to
4# support 2.8.7.
5cmake_minimum_required(VERSION 2.8.6)
6
Adrian Perez515fc622018-03-26 16:41:18 +01007project(brotli C)
Evan Nemerson93ef13f2016-06-20 13:07:35 -07008
9# If Brotli is being bundled in another project, we don't want to
10# install anything. However, we want to let people override this, so
11# we'll use the BROTLI_BUNDLED_MODE variable to let them do that; just
12# set it to OFF in your project before you add_subdirectory(brotli).
13get_directory_property(BROTLI_PARENT_DIRECTORY PARENT_DIRECTORY)
14if(BROTLI_BUNDLED_MODE STREQUAL "")
15 # Bundled mode hasn't been set one way or the other, set the default
16 # depending on whether or not we are the top-level project.
17 if(BROTLI_PARENT_DIRECTORY)
18 set(BROTLI_BUNDLED_MODE OFF)
19 else()
20 set(BROTLI_BUNDLED_MODE ON)
21 endif()
22endif()
23mark_as_advanced(BROTLI_BUNDLED_MODE)
24
Evan Nemerson6c470092016-11-01 02:03:29 -070025include(GNUInstallDirs)
26
Eugene Kliuchnikovb93cb692016-10-18 17:14:49 +020027# Parse version information from common/version.h. Normally we would
Evan Nemerson93ef13f2016-06-20 13:07:35 -070028# define these values here and write them out to configuration file(s)
29# (i.e., config.h), but in this case we parse them from
Eugene Kliuchnikov2c2d5572016-08-22 15:44:12 +020030# common/version.h to be less intrusive.
31function(hex_to_dec HEXADECIMAL DECIMAL)
32 string(TOUPPER "${HEXADECIMAL}" _tail)
33 set(_decimal 0)
34 string(LENGTH "${_tail}" _tail_length)
35 while (_tail_length GREATER 0)
36 math(EXPR _decimal "${_decimal} * 16")
37 string(SUBSTRING "${_tail}" 0 1 _digit)
38 string(SUBSTRING "${_tail}" 1 -1 _tail)
39 if (_digit STREQUAL "A")
40 math(EXPR _decimal "${_decimal} + 10")
41 elseif (_digit STREQUAL "B")
42 math(EXPR _decimal "${_decimal} + 11")
43 elseif (_digit STREQUAL "C")
44 math(EXPR _decimal "${_decimal} + 12")
45 elseif (_digit STREQUAL "D")
46 math(EXPR _decimal "${_decimal} + 13")
47 elseif (_digit STREQUAL "E")
48 math(EXPR _decimal "${_decimal} + 14")
49 elseif (_digit STREQUAL "F")
50 math(EXPR _decimal "${_decimal} + 15")
51 else()
52 math(EXPR _decimal "${_decimal} + ${_digit}")
53 endif()
54 string(LENGTH "${_tail}" _tail_length)
55 endwhile()
56 set(${DECIMAL} ${_decimal} PARENT_SCOPE)
57endfunction(hex_to_dec)
58
Evan Nemerson6c470092016-11-01 02:03:29 -070059# Version information
Eugene Kliuchnikov6ece1d82017-04-23 14:07:08 +020060file(STRINGS "c/common/version.h" _brotli_version_line REGEX "^#define BROTLI_VERSION (0x[0-9a-fA-F]+)$")
Eugene Kliuchnikov2c2d5572016-08-22 15:44:12 +020061string(REGEX REPLACE "^#define BROTLI_VERSION 0x([0-9a-fA-F]+)$" "\\1" _brotli_version_hex "${_brotli_version_line}")
62hex_to_dec("${_brotli_version_hex}" _brotli_version)
63math(EXPR BROTLI_VERSION_MAJOR "${_brotli_version} >> 24")
64math(EXPR BROTLI_VERSION_MINOR "(${_brotli_version} >> 12) & 4095")
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +010065math(EXPR BROTLI_VERSION_PATCH "${_brotli_version} & 4095")
66set(BROTLI_VERSION "${BROTLI_VERSION_MAJOR}.${BROTLI_VERSION_MINOR}.${BROTLI_VERSION_PATCH}")
67mark_as_advanced(BROTLI_VERSION BROTLI_VERSION_MAJOR BROTLI_VERSION_MINOR BROTLI_VERSION_PATCH)
68
69# ABI Version information
70file(STRINGS "c/common/version.h" _brotli_abi_info_line REGEX "^#define BROTLI_ABI_VERSION (0x[0-9a-fA-F]+)$")
71string(REGEX REPLACE "^#define BROTLI_ABI_VERSION 0x([0-9a-fA-F]+)$" "\\1" _brotli_abi_info_hex "${_brotli_abi_info_line}")
72hex_to_dec("${_brotli_abi_info_hex}" _brotli_abi_info)
73math(EXPR BROTLI_ABI_CURRENT "${_brotli_abi_info} >> 24")
74math(EXPR BROTLI_ABI_REVISION "(${_brotli_abi_info} >> 12) & 4095")
75math(EXPR BROTLI_ABI_AGE "${_brotli_abi_info} & 4095")
76math(EXPR BROTLI_ABI_COMPATIBILITY "${BROTLI_ABI_CURRENT} - ${BROTLI_ABI_AGE}")
77mark_as_advanced(BROTLI_ABI_CURRENT BROTLI_ABI_REVISION BROTLI_ABI_AGE BROTLI_ABI_COMPATIBILITY)
Evan Nemerson93ef13f2016-06-20 13:07:35 -070078
Evan Nemerson37be4e32016-06-28 20:35:16 -070079if (ENABLE_SANITIZER)
80 set(CMAKE_C_FLAGS " ${CMAKE_C_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
81 set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
82 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
Evan Nemerson26a59352016-07-26 08:22:58 -070083
84 # By default, brotli depends on undefined behavior, but setting
85 # BROTLI_BUILD_PORTABLE should result in a build which does not.
86 if(ENABLE_SANITIZER STREQUAL "undefined")
87 add_definitions(-DBROTLI_BUILD_PORTABLE)
88 endif()
Evan Nemerson37be4e32016-06-28 20:35:16 -070089endif ()
90
Evan Nemersonc1ec7ba2016-07-29 11:52:15 -070091include(CheckFunctionExists)
92set(LIBM_LIBRARY)
93CHECK_FUNCTION_EXISTS(log2 LOG2_RES)
94if(NOT LOG2_RES)
Evan Nemersonc1ec7ba2016-07-29 11:52:15 -070095 set(orig_req_libs "${CMAKE_REQUIRED_LIBRARIES}")
96 set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};m")
Evan Nemersonfe0e1532016-08-04 18:51:20 -070097 CHECK_FUNCTION_EXISTS(log2 LOG2_LIBM_RES)
98 if(LOG2_LIBM_RES)
Evan Nemersonc1ec7ba2016-07-29 11:52:15 -070099 set(LIBM_LIBRARY "m")
100 else()
101 message(FATAL_ERROR "log2() not found")
102 endif()
103
104 set(CMAKE_REQUIRED_LIBRARIES "${orig_req_libs}")
Evan Nemersonfe0e1532016-08-04 18:51:20 -0700105 unset(LOG2_LIBM_RES)
Evan Nemersonc1ec7ba2016-07-29 11:52:15 -0700106 unset(orig_req_libs)
107endif()
108unset(LOG2_RES)
109
Eugene Kliuchnikov6ece1d82017-04-23 14:07:08 +0200110set(BROTLI_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/c/include")
Eugene Kliuchnikov52f04832017-09-19 09:40:48 +0200111mark_as_advanced(BROTLI_INCLUDE_DIRS)
112
Frédéric Wanged2748a2016-10-12 18:23:34 +0200113set(BROTLI_LIBRARIES_CORE brotlienc brotlidec brotlicommon)
Frédéric Wang074e4ac2016-08-27 12:04:48 +0200114set(BROTLI_LIBRARIES ${BROTLI_LIBRARIES_CORE} ${LIBM_LIBRARY})
Eugene Kliuchnikov52f04832017-09-19 09:40:48 +0200115mark_as_advanced(BROTLI_LIBRARIES)
116
117set(BROTLI_LIBRARIES_CORE_STATIC brotlienc-static brotlidec-static brotlicommon-static)
118set(BROTLI_LIBRARIES_STATIC ${BROTLI_LIBRARIES_CORE_STATIC} ${LIBM_LIBRARY})
119mark_as_advanced(BROTLI_LIBRARIES_STATIC)
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700120
121if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
122 add_definitions(-DOS_LINUX)
123elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
124 add_definitions(-DOS_FREEBSD)
125elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
126 add_definitions(-DOS_MACOSX)
127endif()
128
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100129function(transform_sources_list INPUT_FILE OUTPUT_FILE)
130 file(READ ${INPUT_FILE} TEXT)
131 string(REGEX REPLACE "\\\\\n" "~continuation~" TEXT ${TEXT})
132 string(REGEX REPLACE "([a-zA-Z_][a-zA-Z0-9_]*)[\t ]*=[\t ]*([^\n]*)" "SET(\\1 \\2)" TEXT ${TEXT})
133 string(REPLACE "~continuation~" "\n" TEXT ${TEXT})
134 file(WRITE ${OUTPUT_FILE} ${TEXT})
135endfunction()
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700136
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100137transform_sources_list("scripts/sources.lst" "${CMAKE_CURRENT_BINARY_DIR}/sources.lst.cmake")
138include("${CMAKE_CURRENT_BINARY_DIR}/sources.lst.cmake")
Eugene Kliuchnikov52f04832017-09-19 09:40:48 +0200139
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100140add_library(brotlicommon SHARED ${BROTLI_COMMON_C})
141add_library(brotlidec SHARED ${BROTLI_DEC_C})
142add_library(brotlienc SHARED ${BROTLI_ENC_C})
143
144add_library(brotlicommon-static STATIC ${BROTLI_COMMON_C})
145add_library(brotlidec-static STATIC ${BROTLI_DEC_C})
146add_library(brotlienc-static STATIC ${BROTLI_ENC_C})
Eugene Kliuchnikov52f04832017-09-19 09:40:48 +0200147
Eugene Kliuchnikov532921b2016-08-23 15:35:54 +0200148# Older CMake versions does not understand INCLUDE_DIRECTORIES property.
149include_directories(${BROTLI_INCLUDE_DIRS})
150
Frédéric Wanged2748a2016-10-12 18:23:34 +0200151foreach(lib brotlicommon brotlidec brotlienc)
Eugene Kliuchnikov52f04832017-09-19 09:40:48 +0200152 target_compile_definitions(${lib} PUBLIC "BROTLI_SHARED_COMPILATION" )
153 string(TOUPPER "${lib}" LIB)
154 set_target_properties (${lib} PROPERTIES DEFINE_SYMBOL "${LIB}_SHARED_COMPILATION" )
155endforeach()
156
157foreach(lib brotlicommon brotlidec brotlienc brotlicommon-static brotlidec-static brotlienc-static)
Evan Nemersonc1ec7ba2016-07-29 11:52:15 -0700158 target_link_libraries(${lib} ${LIBM_LIBRARY})
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700159 set_property(TARGET ${lib} APPEND PROPERTY INCLUDE_DIRECTORIES ${BROTLI_INCLUDE_DIRS})
160 set_target_properties(${lib} PROPERTIES
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100161 VERSION "${BROTLI_ABI_COMPATIBILITY}.${BROTLI_ABI_AGE}.${BROTLI_ABI_REVISION}"
162 SOVERSION "${BROTLI_ABI_COMPATIBILITY}"
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700163 POSITION_INDEPENDENT_CODE TRUE)
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700164 set_property(TARGET ${lib} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIRS}")
165endforeach()
Eugene Kliuchnikov69982c22016-10-18 16:45:32 +0200166
Evan Nemerson6c470092016-11-01 02:03:29 -0700167target_link_libraries(brotlidec brotlicommon)
168target_link_libraries(brotlienc brotlicommon)
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700169
Eugene Kliuchnikov52f04832017-09-19 09:40:48 +0200170target_link_libraries(brotlidec-static brotlicommon-static)
171target_link_libraries(brotlienc-static brotlicommon-static)
172
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700173# For projects stuck on older versions of CMake, this will set the
174# BROTLI_INCLUDE_DIRS and BROTLI_LIBRARIES variables so they still
175# have a relatively easy way to use Brotli:
176#
177# include_directories(${BROTLI_INCLUDE_DIRS})
178# target_link_libraries(foo ${BROTLI_LIBRARIES})
179if(BROTLI_PARENT_DIRECTORY)
180 set(BROTLI_INCLUDE_DIRS "${BROTLI_INCLUDE_DIRS}" PARENT_SCOPE)
181 set(BROTLI_LIBRARIES "${BROTLI_LIBRARIES}" PARENT_SCOPE)
182endif()
183
Eugene Kliuchnikov03739d22017-05-29 17:55:14 +0200184# Build the brotli executable
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100185add_executable(brotli ${BROTLI_CLI_C})
Eugene Kliuchnikov52f04832017-09-19 09:40:48 +0200186target_link_libraries(brotli ${BROTLI_LIBRARIES_STATIC})
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700187
188# Installation
Frédéric Wang5e1219a2016-08-27 12:14:13 +0200189if(NOT BROTLI_BUNDLED_MODE)
Eugene Kliuchnikov2c001012017-05-24 17:19:34 +0200190 install(
Eugene Kliuchnikov03739d22017-05-29 17:55:14 +0200191 TARGETS brotli
Eugene Kliuchnikov2c001012017-05-24 17:19:34 +0200192 RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
193 )
Frédéric Wang074e4ac2016-08-27 12:04:48 +0200194
Eugene Kliuchnikov2c001012017-05-24 17:19:34 +0200195 install(
196 TARGETS ${BROTLI_LIBRARIES_CORE}
197 ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
198 LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
199 RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
200 )
Frédéric Wang074e4ac2016-08-27 12:04:48 +0200201
Eugene Kliuchnikov2c001012017-05-24 17:19:34 +0200202 install(
Eugene Kliuchnikovb6a01742017-09-20 10:04:06 +0200203 TARGETS ${BROTLI_LIBRARIES_CORE_STATIC}
204 ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
205 LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
206 RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
207 )
208
209 install(
Eugene Kliuchnikov2c001012017-05-24 17:19:34 +0200210 DIRECTORY ${BROTLI_INCLUDE_DIRS}/brotli
211 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
212 )
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700213endif()
214
215# Tests
Evan Nemerson03657e82016-07-28 13:31:09 -0700216
217# If we're targeting Windows but not running on Windows, we need Wine
218# to run the tests...
219if(NOT BROTLI_DISABLE_TESTS)
220 if(WIN32 AND NOT CMAKE_HOST_WIN32)
221 find_program(BROTLI_WINE NAMES wine)
Evan Nemerson03657e82016-07-28 13:31:09 -0700222
Evan Nemersonc1ec7ba2016-07-29 11:52:15 -0700223 if(NOT BROTLI_WINE)
224 message(STATUS "wine not found, disabling tests")
225 set(BROTLI_DISABLE_TESTS TRUE)
226 endif()
Evan Nemerson03657e82016-07-28 13:31:09 -0700227 endif()
228endif()
229
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700230if(NOT BROTLI_DISABLE_TESTS)
231 include(CTest)
232 enable_testing()
233
234 set(ROUNDTRIP_INPUTS
235 tests/testdata/alice29.txt
236 tests/testdata/asyoulik.txt
237 tests/testdata/lcet10.txt
238 tests/testdata/plrabn12.txt
Eugene Kliuchnikov6ece1d82017-04-23 14:07:08 +0200239 c/enc/encode.c
240 c/common/dictionary.h
241 c/dec/decode.c)
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700242
243 foreach(INPUT ${ROUNDTRIP_INPUTS})
Evan Nemerson03657e82016-07-28 13:31:09 -0700244 get_filename_component(OUTPUT_NAME "${INPUT}" NAME)
245
246 set(OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}")
247 set(INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}")
248
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700249 foreach(quality 1 6 9 11)
250 add_test(NAME "${BROTLI_TEST_PREFIX}roundtrip/${INPUT}/${quality}"
251 COMMAND "${CMAKE_COMMAND}"
Evan Nemerson03657e82016-07-28 13:31:09 -0700252 -DBROTLI_WRAPPER=${BROTLI_WINE}
Eugene Kliuchnikov03739d22017-05-29 17:55:14 +0200253 -DBROTLI_CLI=$<TARGET_FILE:brotli>
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700254 -DQUALITY=${quality}
Evan Nemerson03657e82016-07-28 13:31:09 -0700255 -DINPUT=${INPUT_FILE}
Eugene Kliuchnikovb6a01742017-09-20 10:04:06 +0200256 -DOUTPUT=${OUTPUT_FILE}.${quality}
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700257 -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/run-roundtrip-test.cmake)
258 endforeach()
259 endforeach()
260
261 file(GLOB_RECURSE
262 COMPATIBILITY_INPUTS
263 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
264 tests/testdata/*.compressed*)
265
266 foreach(INPUT ${COMPATIBILITY_INPUTS})
267 add_test(NAME "${BROTLI_TEST_PREFIX}compatibility/${INPUT}"
268 COMMAND "${CMAKE_COMMAND}"
Evan Nemerson03657e82016-07-28 13:31:09 -0700269 -DBROTLI_WRAPPER=${BROTLI_WINE}
Eugene Kliuchnikov03739d22017-05-29 17:55:14 +0200270 -DBROTLI_CLI=$<TARGET_FILE:brotli>
Evan Nemerson93ef13f2016-06-20 13:07:35 -0700271 -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}
272 -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/run-compatibility-test.cmake)
273 endforeach()
274endif()
Evan Nemerson6c470092016-11-01 02:03:29 -0700275
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100276# Generate a pkg-config files
Evan Nemerson6c470092016-11-01 02:03:29 -0700277
278function(generate_pkg_config_path outvar path)
279 string(LENGTH "${path}" path_length)
280
281 set(path_args ${ARGV})
282 list(REMOVE_AT path_args 0 1)
283 list(LENGTH path_args path_args_remaining)
284
285 set("${outvar}" "${path}")
286
287 while(path_args_remaining GREATER 1)
288 list(GET path_args 0 name)
289 list(GET path_args 1 value)
290
291 get_filename_component(value_full "${value}" ABSOLUTE)
292 string(LENGTH "${value}" value_length)
293
294 if(path_length EQUAL value_length AND path STREQUAL value)
295 set("${outvar}" "\${${name}}")
296 break()
297 elseif(path_length GREATER value_length)
298 # We might be in a subdirectory of the value, but we have to be
299 # careful about a prefix matching but not being a subdirectory
300 # (for example, /usr/lib64 is not a subdirectory of /usr/lib).
301 # We'll do this by making sure the next character is a directory
302 # separator.
303 string(SUBSTRING "${path}" ${value_length} 1 sep)
304 if(sep STREQUAL "/")
305 string(SUBSTRING "${path}" 0 ${value_length} s)
306 if(s STREQUAL value)
307 string(SUBSTRING "${path}" "${value_length}" -1 suffix)
308 set("${outvar}" "\${${name}}${suffix}")
309 break()
310 endif()
311 endif()
312 endif()
313
314 list(REMOVE_AT path_args 0 1)
315 list(LENGTH path_args path_args_remaining)
316 endwhile()
317
318 set("${outvar}" "${${outvar}}" PARENT_SCOPE)
319endfunction(generate_pkg_config_path)
320
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100321function(transform_pc_file INPUT_FILE OUTPUT_FILE VERSION)
322 file(READ ${INPUT_FILE} TEXT)
Evan Nemerson6c470092016-11-01 02:03:29 -0700323
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100324 set(PREFIX "${CMAKE_INSTALL_PREFIX}")
325 string(REGEX REPLACE "@prefix@" "${PREFIX}" TEXT ${TEXT})
326 string(REGEX REPLACE "@exec_prefix@" "${PREFIX}" TEXT ${TEXT})
Evan Nemerson6c470092016-11-01 02:03:29 -0700327
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100328 generate_pkg_config_path(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}" prefix "${PREFIX}")
329 string(REGEX REPLACE "@libdir@" "${LIBDIR}" TEXT ${TEXT})
Evan Nemerson6c470092016-11-01 02:03:29 -0700330
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100331 generate_pkg_config_path(INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}" prefix "${PREFIX}")
332 string(REGEX REPLACE "@includedir@" "${INCLUDEDIR}" TEXT ${TEXT})
Evan Nemerson6c470092016-11-01 02:03:29 -0700333
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100334 string(REGEX REPLACE "@PACKAGE_VERSION@" "${VERSION}" TEXT ${TEXT})
Evan Nemerson6c470092016-11-01 02:03:29 -0700335
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100336 file(WRITE ${OUTPUT_FILE} ${TEXT})
337endfunction()
Evan Nemerson6c470092016-11-01 02:03:29 -0700338
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100339transform_pc_file("scripts/libbrotlicommon.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libbrotlicommon.pc" "${BROTLI_VERSION}")
Evan Nemerson6c470092016-11-01 02:03:29 -0700340
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100341transform_pc_file("scripts/libbrotlidec.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libbrotlidec.pc" "${BROTLI_VERSION}")
Eugene Kliuchnikovfe9f9a92016-12-22 08:57:44 +0100342
Eugene Kliuchnikov0ad94ee2017-11-28 15:37:28 +0100343transform_pc_file("scripts/libbrotlienc.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libbrotlienc.pc" "${BROTLI_VERSION}")
Evan Nemerson6c470092016-11-01 02:03:29 -0700344
345if(NOT BROTLI_BUNDLED_MODE)
Eugene Kliuchnikovfe9f9a92016-12-22 08:57:44 +0100346 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlicommon.pc"
347 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
348 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlidec.pc"
349 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
350 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlienc.pc"
Evan Nemerson6c470092016-11-01 02:03:29 -0700351 DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
352endif()
353
354if (ENABLE_COVERAGE STREQUAL "yes")
355 SETUP_TARGET_FOR_COVERAGE(coverage test coverage)
356endif ()