diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f8148fc0..1267e4fcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -296,15 +296,15 @@ if(USE_TIFF) endif() if(USE_WEBP) - mapnik_find_package(WebP REQUIRED) + pkg_check_modules(WebP REQUIRED IMPORTED_TARGET libwebp) list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP) - list(APPEND MAPNIK_OPTIONAL_LIBS WebP::WebP) + list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::WebP) endif() if(USE_CAIRO) pkg_check_modules(Cairo REQUIRED IMPORTED_TARGET cairo) - list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::Cairo) list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO) + list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::Cairo) endif() if(USE_PROJ) diff --git a/cmake/FindWebP.cmake b/cmake/FindWebP.cmake deleted file mode 100644 index 860dc3dfe..000000000 --- a/cmake/FindWebP.cmake +++ /dev/null @@ -1,97 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindWebP -------- - -Finds the WebP library. - -Imported Targets -^^^^^^^^^^^^^^^^ - -This module provides the following imported targets, if found: - -``WebP::WebP`` - The WebP library - -Result Variables -^^^^^^^^^^^^^^^^ - -This will define the following variables: - -``WebP_FOUND`` - True if the system has the WebP library. -``WebP_VERSION`` - The version of the WebP library which was found. -``WebP_INCLUDE_DIRS`` - Include directories needed to use WebP. -``WebP_LIBRARIES`` - Libraries needed to link to WebP. - -Cache Variables -^^^^^^^^^^^^^^^ - -The following cache variables may also be set: - -``WebP_INCLUDE_DIR`` - The directory containing ``decode.h``. -``WebP_LIBRARY`` - The path to the Foo library. - -#]=======================================================================] - -if(NOT WebP_LIBRARY) - find_package(PkgConfig QUIET) - pkg_check_modules(PC_WebP QUIET libwebp) - set(WebP_VERSION ${PC_WebP_VERSION}) - find_path(WebP_INCLUDE_DIR NAMES decode.h HINTS ${PC_WebP_INCLUDEDIR} ${PC_WebP_INCLUDE_DIR} PATH_SUFFIXES webp) - find_library(WebP_LIBRARY_RELEASE NAMES ${WebP_NAMES} webp HINTS ${PC_WebP_LIBDIR} ${PC_WebP_LIBRARY_DIRS}) - find_library(WebP_LIBRARY_DEBUG NAMES ${WebP_NAMES} webpd HINTS ${PC_WebP_LIBDIR} ${PC_WebP_LIBRARY_DIRS}) - include(SelectLibraryConfigurations) - select_library_configurations(WebP) -else() - file(TO_CMAKE_PATH "${WebP_LIBRARY}" WebP_LIBRARY) -endif() - -if ("${WebP_FIND_VERSION}" VERSION_GREATER "${WebP_VERSION}") - if (WebP_VERSION) - message(FATAL_ERROR "Required version (" ${WebP_FIND_VERSION} ") is higher than found version (" ${PC_WebP_VERSION} ")") - else () - message(WARNING "Cannot determine WebP version without pkg-config") - endif () -endif () - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(WebP - REQUIRED_VARS - WebP_LIBRARY - WebP_INCLUDE_DIR - VERSION_VAR WebP_VERSION -) -mark_as_advanced(WebP_INCLUDE_DIR WebP_LIBRARY) - -if (WebP_FOUND) - set(WebP_LIBRARIES ${WebP_LIBRARY}) - set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR}) - if(NOT TARGET WebP::WebP) - add_library(WebP::WebP UNKNOWN IMPORTED) - set_target_properties(WebP::WebP PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${WebP_INCLUDE_DIR} - IMPORTED_LINK_INTERFACE_LANGUAGES C) - - if(WebP_LIBRARY_RELEASE) - set_property(TARGET WebP::WebP APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(WebP::WebP PROPERTIES IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY_RELEASE}") - endif() - - if(WebP_LIBRARY_DEBUG) - set_property(TARGET WebP::WebP APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(WebP::WebP PROPERTIES IMPORTED_LOCATION_DEBUG "${WebP_LIBRARY_DEBUG}") - endif() - - if(NOT WebP_LIBRARY_RELEASE AND NOT WebP_LIBRARY_DEBUG) - set_target_properties(WebP::WebP PROPERTIES IMPORTED_LOCATION "${WebP_LIBRARY}") - endif() - endif() -endif () diff --git a/cmake/MapnikExport.cmake b/cmake/MapnikExport.cmake index 5d63f0050..267c64f9f 100644 --- a/cmake/MapnikExport.cmake +++ b/cmake/MapnikExport.cmake @@ -1,34 +1,31 @@ include(CMakePackageConfigHelpers) -# export mapnik configuration -write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake" - VERSION ${MAPNIK_VERSION} - COMPATIBILITY ExactVersion -) -get_property(MAPNIK_UTILITIES GLOBAL PROPERTY MAPNIK_UTILITIES) -list(JOIN MAPNIK_DEPENDENCIES "\n" MAPNIK_DEPENDENCIES) -configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mapnikConfig.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake" - INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR} - PATH_VARS MAPNIK_INCLUDE_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR MAPNIK_DEPENDENCIES MAPNIK_UTILITIES - NO_CHECK_REQUIRED_COMPONENTS_MACRO -) - -install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake" +### exports mapnik cmake config files (mapnikConfigVersion and mapnikConfig) +function(mapnik_export_cmake_config) + # export mapnik configuration + write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake" - DESTINATION ${MAPNIK_CMAKE_DIR} -) + VERSION ${MAPNIK_VERSION} + COMPATIBILITY ExactVersion + ) + get_property(MAPNIK_UTILITIES GLOBAL PROPERTY MAPNIK_UTILITIES) + list(JOIN MAPNIK_DEPENDENCIES "\n" MAPNIK_DEPENDENCIES) + configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/mapnikConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake" + INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR} + PATH_VARS MAPNIK_INCLUDE_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR MAPNIK_DEPENDENCIES MAPNIK_UTILITIES + NO_CHECK_REQUIRED_COMPONENTS_MACRO + ) + install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake" + DESTINATION ${MAPNIK_CMAKE_DIR} + ) +endfunction() -# install our modules, so that the expected target names are found. -install( - FILES - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindCairo.cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindWebP.cmake" - DESTINATION ${MAPNIK_CMAKE_DIR}/Modules -) + +mapnik_export_cmake_config() install(EXPORT MapnikTargets DESTINATION ${MAPNIK_CMAKE_DIR} @@ -36,21 +33,21 @@ install(EXPORT MapnikTargets NAMESPACE mapnik:: ) - +### install plugin cmake config files ### # Create configuration dependend files for the plugin install dirs. # some package managers are using different paths per configuration. string(TOLOWER "${CMAKE_BUILD_TYPE}" _build_type) string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type_l) -set(_mapnik_plugin_file_name "mapnikPlugins-${_build_type}") -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_mapnik_plugin_file_name}.cmake.in "set(MAPNIK_PLUGINS_DIR_${_build_type_l} \"@PACKAGE_PLUGINS_INSTALL_DIR@\" CACHE STRING \"\")\n") +set(m_mapnik_plugin_file_name mapnikPlugins-${_build_type}) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake.in" "set(MAPNIK_PLUGINS_DIR_${_build_type_l} \"@PACKAGE_PLUGINS_INSTALL_DIR@\" CACHE STRING \"\")\n") include(CMakePackageConfigHelpers) configure_package_config_file( - ${CMAKE_CURRENT_BINARY_DIR}/${_mapnik_plugin_file_name}.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/${_mapnik_plugin_file_name}.cmake + "${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake" PATH_VARS PLUGINS_INSTALL_DIR INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR} ) install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${_mapnik_plugin_file_name}.cmake + FILES "${CMAKE_CURRENT_BINARY_DIR}/${m_mapnik_plugin_file_name}.cmake" DESTINATION ${MAPNIK_CMAKE_DIR} ) diff --git a/cmake/MapnikFindPackage.cmake b/cmake/MapnikFindPackage.cmake index 8bcd96216..ed2997f23 100644 --- a/cmake/MapnikFindPackage.cmake +++ b/cmake/MapnikFindPackage.cmake @@ -1,16 +1,16 @@ macro(mapnik_print_version) - string(TOUPPER ${ARGV0} TLNUP) - set(TLN ${ARGV0}) - if(${TLN}_VERSION_STRING) - message(STATUS "Using ${ARGV0} version: ${${TLN}_VERSION_STRING}") - elseif(${TLN}_VERSION) - message(STATUS "Using ${ARGV0} version: ${${TLN}_VERSION}") - elseif(${TLNUP}_VERSION_STRING) - message(STATUS "Using ${ARGV0} version: ${${TLNUP}_VERSION_STRING}") - elseif(${TLNUP}_VERSION) - message(STATUS "Using ${ARGV0} version: ${${TLNUP}_VERSION}") + string(TOUPPER ${ARGV0} m_package_name_upc) + set(m_package_name ${ARGV0}) + if(${m_package_name}_VERSION_STRING) + message(STATUS "Using ${m_package_name} version: ${${m_package_name}_VERSION_STRING}") + elseif(${m_package_name}_VERSION) + message(STATUS "Using ${m_package_name} version: ${${m_package_name}_VERSION}") + elseif(${m_package_name_upc}_VERSION_STRING) + message(STATUS "Using ${m_package_name} version: ${${m_package_name_upc}_VERSION_STRING}") + elseif(${m_package_name_upc}_VERSION) + message(STATUS "Using ${m_package_name} version: ${${m_package_name_upc}_VERSION}") else() - message(STATUS "Using ${ARGV0}") + message(STATUS "Using ${m_package_name}") endif() endmacro()