better export [wip]

This commit is contained in:
Mathis Logemann 2022-08-25 19:59:29 +02:00
parent 4cd4985e75
commit ce8bd250dd
4 changed files with 61 additions and 24 deletions

View file

@ -148,7 +148,7 @@ else()
endif() endif()
find_package(PkgConfig) mapnik_find_package(PkgConfig REQUIRED)
mapnik_find_threads() mapnik_find_threads()
mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data)
@ -177,7 +177,7 @@ else()
# It might be possible that in future version harfbuzz could only be found via pkg-config. # 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 # harfbuzz related discussion: https://github.com/harfbuzz/harfbuzz/issues/2653
message(STATUS "harfbuzz not found via cmake. Searching via pkg-config...") message(STATUS "harfbuzz not found via cmake. Searching via pkg-config...")
pkg_check_modules(harfbuzz REQUIRED IMPORTED_TARGET harfbuzz>=${HARFBUZZ_MIN_VERSION}) mapnik_pkg_check_modules(harfbuzz REQUIRED IMPORTED_TARGET harfbuzz>=${HARFBUZZ_MIN_VERSION})
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::harfbuzz) list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::harfbuzz)
endif() endif()
@ -304,13 +304,13 @@ if(USE_TIFF)
endif() endif()
if(USE_WEBP) if(USE_WEBP)
pkg_check_modules(WebP REQUIRED IMPORTED_TARGET libwebp) mapnik_pkg_check_modules(WebP REQUIRED IMPORTED_TARGET libwebp)
list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP) list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP)
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::WebP) list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::WebP)
endif() endif()
if(USE_CAIRO) if(USE_CAIRO)
pkg_check_modules(Cairo REQUIRED IMPORTED_TARGET cairo) mapnik_pkg_check_modules(Cairo REQUIRED IMPORTED_TARGET cairo)
list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO) list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO)
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::Cairo) list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::Cairo)
endif() endif()
@ -321,7 +321,7 @@ if(USE_PROJ)
# currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config # currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config
if(NOT PROJ_FOUND) if(NOT PROJ_FOUND)
message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...") message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...")
pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj>=${PROJ_MIN_VERSION}) mapnik_pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj>=${PROJ_MIN_VERSION})
string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}") string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}")
set(PROJ_VERSION_MAJOR "${CMAKE_MATCH_1}") set(PROJ_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}") set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}")

View file

@ -9,11 +9,26 @@ function(mapnik_export_cmake_config)
COMPATIBILITY ExactVersion COMPATIBILITY ExactVersion
) )
get_property(MAPNIK_UTILITIES GLOBAL PROPERTY MAPNIK_UTILITIES) get_property(MAPNIK_UTILITIES GLOBAL PROPERTY MAPNIK_UTILITIES)
list(JOIN MAPNIK_DEPENDENCIES "\n" MAPNIK_DEPENDENCIES)
# generate all find_dependency and pkg_config calls
set(mapnik_find_deps)
foreach(dep IN LISTS mapnik_deps)
set(ver_comment "# ${dep} used with version ${mapnik_${dep}_version}")
set(mapnik_find_deps "${mapnik_find_deps}\n${ver_comment}\n")
if(mapnik_${dep}_find_args)
list(REMOVE_DUPLICATES mapnik_${dep}_find_args)
list(JOIN mapnik_${dep}_find_args " " m_args_joined)
set(mapnik_find_deps "${mapnik_find_deps}find_dependency(${dep} ${m_args_joined})")
else()
list(JOIN mapnik_${dep}_pkg_args " " m_args_joined)
set(mapnik_find_deps "${mapnik_find_deps}pkg_check_modules(${dep} ${m_args_joined})")
endif()
endforeach()
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/mapnikConfig.cmake.in" configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/mapnikConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake"
INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR} INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR}
PATH_VARS MAPNIK_INCLUDE_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR MAPNIK_DEPENDENCIES MAPNIK_UTILITIES PATH_VARS MAPNIK_INCLUDE_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR mapnik_find_deps MAPNIK_UTILITIES
NO_CHECK_REQUIRED_COMPONENTS_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO
) )
install( install(

View file

@ -1,28 +1,50 @@
macro(mapnik_print_version) function(mapnik_set_dep_version dep var)
string(TOUPPER ${ARGV0} m_package_name_upc) string(TOUPPER ${dep} m_package_name_upc)
set(m_package_name ${ARGV0}) set(m_package_name ${dep})
if(${m_package_name}_VERSION_STRING) if(${m_package_name}_VERSION_STRING)
message(STATUS "Using ${m_package_name} version: ${${m_package_name}_VERSION_STRING}") set(${var} ${${m_package_name}_VERSION_STRING} PARENT_SCOPE)
elseif(${m_package_name}_VERSION) elseif(${m_package_name}_VERSION)
message(STATUS "Using ${m_package_name} version: ${${m_package_name}_VERSION}") set(${var} ${${m_package_name}_VERSION} PARENT_SCOPE)
elseif(${m_package_name_upc}_VERSION_STRING) elseif(${m_package_name_upc}_VERSION_STRING)
message(STATUS "Using ${m_package_name} version: ${${m_package_name_upc}_VERSION_STRING}") set(${var} ${${m_package_name_upc}_VERSION_STRING} PARENT_SCOPE)
elseif(${m_package_name_upc}_VERSION) elseif(${m_package_name_upc}_VERSION)
message(STATUS "Using ${m_package_name} version: ${${m_package_name_upc}_VERSION}") set(${var} ${${m_package_name_upc}_VERSION} PARENT_SCOPE)
endif()
endfunction()
function(mapnik_print_package_info dep)
message(STATUS "Using ${dep} version: ${mapnik_${dep}_version}")
endfunction()
macro(mapnik_find_package dep)
find_package(${dep} ${ARGN})
if(${dep}_FOUND)
list(APPEND mapnik_deps ${dep})
if(mapnik_${dep}_find_args)
list(APPEND mapnik_${dep}_find_args ${ARGN})
else()
set(mapnik_${dep}_find_args ${ARGN})
endif()
mapnik_set_dep_version(${dep} mapnik_${dep}_version)
mapnik_print_package_info(${dep})
else() else()
message(STATUS "Using ${m_package_name}") message(STATUS "not found: ${dep}")
endif() endif()
endmacro() endmacro()
macro(mapnik_find_package) macro(mapnik_pkg_check_modules dep)
find_package(${ARGN}) pkg_check_modules(${dep} ${ARGN})
if(${ARGV0}_FOUND) if(${dep}_FOUND)
set(MAPNIK_TMP_DEP ${ARGN}) list(APPEND mapnik_deps ${dep})
list(JOIN MAPNIK_TMP_DEP " " MAPNIK_TMP_DEP)
list(APPEND MAPNIK_DEPENDENCIES "find_dependency(${MAPNIK_TMP_DEP})") set(mapnik_${dep}_pkg_args ${ARGN})
mapnik_print_version(${ARGV0}) mapnik_set_dep_version(${dep} mapnik_${dep}_version)
mapnik_print_package_info(${dep})
else() else()
message(STATUS "not found: ${ARGV0}") message(STATUS "not found: ${dep}")
endif() endif()
endmacro() endmacro()

View file

@ -8,7 +8,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/Modules/")
include(CMakeFindDependencyMacro) include(CMakeFindDependencyMacro)
find_dependency(Threads REQUIRED) find_dependency(Threads REQUIRED)
@MAPNIK_DEPENDENCIES@ @mapnik_find_deps@
include("${CMAKE_CURRENT_LIST_DIR}/mapnikTargets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/mapnikTargets.cmake")