From eb4390b5a6840584749b05a3f28a6502852c7f31 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 19 Nov 2021 19:47:50 +0100 Subject: [PATCH 1/2] fix proj version detection for cmake --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d76303d2..42ef65651 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,7 +306,7 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ ${PROJ_MIN_VERSION} QUIET) + mapnik_find_package(PROJ QUIET) # currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config if(NOT PROJ_FOUND) message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...") @@ -317,6 +317,9 @@ if(USE_PROJ) set(PROJ_VERSION_PATCH "${CMAKE_MATCH_3}") list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::PROJ) else() + if(PROJ_VERSION VERSION_LESS PROJ_MIN_VERSION) + message(FATAL_ERROR "Proj needs to be at least version ${PROJ_MIN_VERSION}") + endif() list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES}) list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE $) endif() From d546cda6d5b82c88f16a251ced64e00d7f96e500 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 20 Nov 2021 12:53:58 +0100 Subject: [PATCH 2/2] [CMake] drop harfbuzz and use pkg-config as a backup --- CMakeLists.txt | 10 ++- cmake/FindHarfBuzz.cmake | 187 --------------------------------------- 2 files changed, 6 insertions(+), 191 deletions(-) delete mode 100644 cmake/FindHarfBuzz.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 42ef65651..a9be165f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,10 +159,12 @@ if(harfbuzz_FOUND) message(STATUS "Found harfbuzz native cmake") list(APPEND MAPNIK_OPTIONAL_LIBS harfbuzz::harfbuzz) else() - # we use our "own" FindHarfBuzz. See https://github.com/mapnik/mapnik/pull/4191#issuecomment-874728157 for more details - message(STATUS "Fallback to FindHarfBuzz") - mapnik_find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION} REQUIRED COMPONENTS ICU) - list(APPEND MAPNIK_OPTIONAL_LIBS HarfBuzz::HarfBuzz HarfBuzz::ICU) + # Use pkg-config when harfbuzz is not found. + # It might be possible that in future version harfbuzz could only be found via pkg-config. + # harfbuzz related discussion: https://github.com/harfbuzz/harfbuzz/issues/2653 + message(STATUS "harfbuzz not found via cmake. Searching via pkg-config...") + pkg_check_modules(harfbuzz REQUIRED IMPORTED_TARGET harfbuzz>=${HARFBUZZ_MIN_VERSION}) + list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::harfbuzz) endif() if(USE_EXTERNAL_MAPBOX_GEOMETRY) diff --git a/cmake/FindHarfBuzz.cmake b/cmake/FindHarfBuzz.cmake deleted file mode 100644 index a0296f321..000000000 --- a/cmake/FindHarfBuzz.cmake +++ /dev/null @@ -1,187 +0,0 @@ -# Copyright (c) 2012, Intel Corporation -# Copyright (c) 2019 Sony Interactive Entertainment Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# * Neither the name of Intel Corporation nor the names of its contributors may -# be used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# Try to find Harfbuzz include and library directories. -# -# After successful discovery, this will set for inclusion where needed: -# HarfBuzz_INCLUDE_DIRS - containg the HarfBuzz headers -# HarfBuzz_LIBRARIES - containg the HarfBuzz library - -#[=======================================================================[.rst: -FindHarfBuzz --------------- - -Find HarfBuzz headers and libraries. - -Imported Targets -^^^^^^^^^^^^^^^^ - -``HarfBuzz::HarfBuzz`` - The HarfBuzz library, if found. - -``HarfBuzz::ICU`` - The HarfBuzz ICU library, if found. - -Result Variables -^^^^^^^^^^^^^^^^ - -This will define the following variables in your project: - -``HarfBuzz_FOUND`` - true if (the requested version of) HarfBuzz is available. -``HarfBuzz_VERSION`` - the version of HarfBuzz. -``HarfBuzz_LIBRARIES`` - the libraries to link against to use HarfBuzz. -``HarfBuzz_INCLUDE_DIRS`` - where to find the HarfBuzz headers. -``HarfBuzz_COMPILE_OPTIONS`` - this should be passed to target_compile_options(), if the - target is not used for linking - -#]=======================================================================] - -find_package(PkgConfig QUIET) -pkg_check_modules(PC_HARFBUZZ QUIET harfbuzz) -set(HarfBuzz_COMPILE_OPTIONS ${PC_HARFBUZZ_CFLAGS_OTHER}) -set(HarfBuzz_VERSION ${PC_HARFBUZZ_CFLAGS_VERSION}) - -find_path(HarfBuzz_INCLUDE_DIR - NAMES hb.h - HINTS ${PC_HARFBUZZ_INCLUDEDIR} ${PC_HARFBUZZ_INCLUDE_DIRS} - PATH_SUFFIXES harfbuzz -) - -find_library(HarfBuzz_LIBRARY - NAMES ${HarfBuzz_NAMES} harfbuzz - HINTS ${PC_HARFBUZZ_LIBDIR} ${PC_HARFBUZZ_LIBRARY_DIRS} -) - -if (HarfBuzz_INCLUDE_DIR AND NOT HarfBuzz_VERSION) - if (EXISTS "${HarfBuzz_INCLUDE_DIR}/hb-version.h") - file(READ "${HarfBuzz_INCLUDE_DIR}/hb-version.h" _harfbuzz_version_content) - - string(REGEX MATCH "#define +HB_VERSION_STRING +\"([0-9]+\.[0-9]+\.[0-9]+)\"" _dummy "${_harfbuzz_version_content}") - set(HarfBuzz_VERSION "${CMAKE_MATCH_1}") - endif () -endif () - -if ("${HarfBuzz_FIND_VERSION}" VERSION_GREATER "${HarfBuzz_VERSION}") - message(FATAL_ERROR "Required version (" ${HarfBuzz_FIND_VERSION} ") is higher than found version (" ${HarfBuzz_VERSION} ")") -endif () - -# Find components -if (HarfBuzz_INCLUDE_DIR AND HarfBuzz_LIBRARY) - set(_HarfBuzz_REQUIRED_LIBS_FOUND ON) - set(HarfBuzz_LIBS_FOUND "HarfBuzz (required): ${HarfBuzz_LIBRARY}") -else () - set(_HarfBuzz_REQUIRED_LIBS_FOUND OFF) - set(HarfBuzz_LIBS_NOT_FOUND "HarfBuzz (required)") -endif () - -if ("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS) - pkg_check_modules(PC_HARFBUZZ_ICU QUIET harfbuzz-icu) - set(HarfBuzz_ICU_COMPILE_OPTIONS ${PC_HARFBUZZ_ICU_CFLAGS_OTHER}) - - find_path(HarfBuzz_ICU_INCLUDE_DIR - NAMES hb-icu.h - HINTS ${PC_HARFBUZZ_ICU_INCLUDEDIR} ${PC_HARFBUZZ_ICU_INCLUDE_DIRS} - PATH_SUFFIXES harfbuzz - ) - - find_library(HarfBuzz_ICU_LIBRARY - NAMES ${HarfBuzz_ICU_NAMES} harfbuzz-icu - HINTS ${PC_HARFBUZZ_ICU_LIBDIR} ${PC_HARFBUZZ_ICU_LIBRARY_DIRS} - ) - - if (HarfBuzz_ICU_LIBRARY) - if (HarfBuzz_FIND_REQUIRED_ICU) - list(APPEND HarfBuzz_LIBS_FOUND "ICU (required): ${HarfBuzz_ICU_LIBRARY}") - else () - list(APPEND HarfBuzz_LIBS_FOUND "ICU (optional): ${HarfBuzz_ICU_LIBRARY}") - endif () - else () - if (HarfBuzz_FIND_REQUIRED_ICU) - set(_HarfBuzz_REQUIRED_LIBS_FOUND OFF) - list(APPEND HarfBuzz_LIBS_NOT_FOUND "ICU (required)") - else () - list(APPEND HarfBuzz_LIBS_NOT_FOUND "ICU (optional)") - endif () - endif () -endif () - -if (NOT HarfBuzz_FIND_QUIETLY) - if (HarfBuzz_LIBS_FOUND) - message(STATUS "Found the following HarfBuzz libraries:") - foreach (found ${HarfBuzz_LIBS_FOUND}) - message(STATUS " ${found}") - endforeach () - endif () - if (HarfBuzz_LIBS_NOT_FOUND) - message(STATUS "The following HarfBuzz libraries were not found:") - foreach (found ${HarfBuzz_LIBS_NOT_FOUND}) - message(STATUS " ${found}") - endforeach () - endif () -endif () - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(HarfBuzz - FOUND_VAR HarfBuzz_FOUND - REQUIRED_VARS HarfBuzz_INCLUDE_DIR HarfBuzz_LIBRARY _HarfBuzz_REQUIRED_LIBS_FOUND - VERSION_VAR HarfBuzz_VERSION -) - -if (HarfBuzz_LIBRARY AND NOT TARGET HarfBuzz::HarfBuzz) - add_library(HarfBuzz::HarfBuzz UNKNOWN IMPORTED GLOBAL) - set_target_properties(HarfBuzz::HarfBuzz PROPERTIES - IMPORTED_LOCATION "${HarfBuzz_LIBRARY}" - INTERFACE_COMPILE_OPTIONS "${HarfBuzz_COMPILE_OPTIONS}" - INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_INCLUDE_DIR}" - ) -endif () - -if (HarfBuzz_ICU_LIBRARY AND NOT TARGET HarfBuzz::ICU) - add_library(HarfBuzz::ICU UNKNOWN IMPORTED GLOBAL) - set_target_properties(HarfBuzz::ICU PROPERTIES - IMPORTED_LOCATION "${HarfBuzz_ICU_LIBRARY}" - INTERFACE_COMPILE_OPTIONS "${HarfBuzz_ICU_COMPILE_OPTIONS}" - INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_ICU_INCLUDE_DIR}" - ) -endif () - -mark_as_advanced( - HarfBuzz_INCLUDE_DIR - HarfBuzz_ICU_INCLUDE_DIR - HarfBuzz_LIBRARY - HarfBuzz_ICU_LIBRARY -) - -if (HarfBuzz_FOUND) - set(HarfBuzz_LIBRARIES ${HarfBuzz_LIBRARY} ${HarfBuzz_ICU_LIBRARY}) - set(HarfBuzz_INCLUDE_DIRS ${HarfBuzz_INCLUDE_DIR} ${HarfBuzz_ICU_INCLUDE_DIR}) -endif ()