| 1 |
# pkg-config support |
| 2 |
# |
| 3 |
# Copyright © 2015 Open Microscopy Environment / University of Dundee |
| 4 |
# Copyright © 2021 Roger Leigh <[email protected]> |
| 5 |
# Written by Roger Leigh <[email protected]> |
| 6 |
# |
| 7 |
# Permission to use, copy, modify, distribute, and sell this software and |
| 8 |
# its documentation for any purpose is hereby granted without fee, provided |
| 9 |
# that (i) the above copyright notices and this permission notice appear in |
| 10 |
# all copies of the software and related documentation, and (ii) the names of |
| 11 |
# Sam Leffler and Silicon Graphics may not be used in any advertising or |
| 12 |
# publicity relating to the software without the specific, prior written |
| 13 |
# permission of Sam Leffler and Silicon Graphics. |
| 14 |
# |
| 15 |
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, |
| 16 |
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY |
| 17 |
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. |
| 18 |
# |
| 19 |
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR |
| 20 |
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, |
| 21 |
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
| 22 |
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF |
| 23 |
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
| 24 |
# OF THIS SOFTWARE. |
| 25 |
|
| 26 |
# Post-process lib files into linker flags |
| 27 |
function(set_libs_private out_var) |
| 28 |
set(tiff_libs_private "") |
| 29 |
foreach(lib IN LISTS ARGN) |
| 30 |
get_filename_component(name "${lib}" NAME) |
| 31 |
foreach(prefix IN LISTS CMAKE_FIND_LIBRARY_PREFIXES) |
| 32 |
if(NOT("${prefix}" STREQUAL "") AND name MATCHES "^${prefix}") |
| 33 |
string(REGEX REPLACE "^${prefix}" "" name "${name}") |
| 34 |
break() |
| 35 |
endif() |
| 36 |
endforeach() |
| 37 |
foreach(suffix IN LISTS CMAKE_FIND_LIBRARY_SUFFIXES) |
| 38 |
if(NOT("${suffix}" STREQUAL "") AND name MATCHES "${suffix}$") |
| 39 |
string(REGEX REPLACE "${suffix}$" "" name "${name}") |
| 40 |
break() |
| 41 |
endif() |
| 42 |
endforeach() |
| 43 |
string(APPEND tiff_libs_private " -l${name}") |
| 44 |
endforeach() |
| 45 |
set(${out_var} "${tiff_libs_private}" PARENT_SCOPE) |
| 46 |
endfunction() |
| 47 |
|
| 48 |
# Generate pkg-config file |
| 49 |
set(prefix "${CMAKE_INSTALL_PREFIX}") |
| 50 |
set(exec_prefix "\${prefix}") |
| 51 |
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") |
| 52 |
set(libdir "${CMAKE_INSTALL_LIBDIR}") |
| 53 |
else() |
| 54 |
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") |
| 55 |
endif() |
| 56 |
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") |
| 57 |
set(includedir "${CMAKE_INSTALL_INCLUDEDIR}") |
| 58 |
else() |
| 59 |
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") |
| 60 |
endif() |
| 61 |
set_libs_private(tiff_libs_private ${tiff_libs_private_list}) |
| 62 |
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libtiff-4.pc.in |
| 63 |
${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc @ONLY) |
| 64 |
|
| 65 |
# Install pkg-config file |
| 66 |
if (tiff-install) |
| 67 |
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc |
| 68 |
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") |
| 69 |
endif() |