allow use poly2tri from system

This commit is contained in:
Peter Petrik 2020-11-24 00:18:51 +01:00 committed by GitHub
parent 3240f788fe
commit eac5d67e6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 7 deletions

View File

@ -217,11 +217,14 @@ if(WITH_CORE)
endif()
# try to configure and build MDAL support
set (WITH_INTERNAL_MDAL TRUE CACHE BOOL "Determines whether MDAL support should be built")
set (WITH_INTERNAL_MDAL TRUE CACHE BOOL "Determines whether MDAL should be built from internal copy")
if (NOT WITH_INTERNAL_MDAL)
set (MDAL_PREFIX "" CACHE PATH "Path to MDAL base directory")
endif()
# try to configure and build POLY2TRI support
set (WITH_INTERNAL_POLY2TRI TRUE CACHE BOOL "Determines whether POLY2TRI should be built from internal copy")
# try to configure and build POSTGRESQL support
set (WITH_POSTGRESQL TRUE CACHE BOOL "Determines whether POSTGRESQL support should be built")
if (WITH_POSTGRESQL)
@ -369,6 +372,10 @@ if(WITH_CORE)
find_package(MDAL REQUIRED) # MDAL provider
endif()
if (NOT WITH_INTERNAL_POLY2TRI)
find_package(Poly2Tri REQUIRED)
endif()
find_package(SpatiaLite REQUIRED)
if (NOT PROJ_FOUND OR NOT GEOS_FOUND OR NOT GDAL_FOUND)

24
cmake/FindPoly2Tri.cmake Normal file
View File

@ -0,0 +1,24 @@
# Find Poly2Tri
# ~~~~~~~~~
# Copyright (c) 2020, Peter Petrik <zilolv at gmail dot com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
#
# Once run this will define:
# Poly2Tri_FOUND - System has Poly2Tri
# Poly2Tri_INCLUDE_DIR - The Poly2Tri include directory
# Poly2Tri_LIBRARY - The library needed to use Poly2Tri
find_path(Poly2Tri_INCLUDE_DIR poly2tri.h
HINTS $ENV{LIB_DIR}/include)
find_library(Poly2Tri_LIBRARY NAMES poly2tri libpoly2tri
HINTS $ENV{LIB_DIR}/lib)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Poly2Tri DEFAULT_MSG
Poly2Tri_LIBRARY Poly2Tri_INCLUDE_DIR)
mark_as_advanced( Poly2Tri_INCLUDE_DIR Poly2Tri_LIBRARY )

View File

@ -11,11 +11,6 @@ set(QGIS_CORE_SRCS
${CMAKE_SOURCE_DIR}/external/nmea/time.c
${CMAKE_SOURCE_DIR}/external/nmea/tok.c
${CMAKE_SOURCE_DIR}/external/poly2tri/common/shapes.cc
${CMAKE_SOURCE_DIR}/external/poly2tri/sweep/advancing_front.cc
${CMAKE_SOURCE_DIR}/external/poly2tri/sweep/cdt.cc
${CMAKE_SOURCE_DIR}/external/poly2tri/sweep/sweep_context.cc
${CMAKE_SOURCE_DIR}/external/poly2tri/sweep/sweep.cc
${CMAKE_SOURCE_DIR}/external/meshOptimizer/simplifier.cpp
callouts/qgscallout.cpp
@ -734,6 +729,19 @@ set(QGIS_CORE_SRCS
qgsuserprofilemanager.cpp
)
if (WITH_INTERNAL_POLY2TRI)
set(QGIS_CORE_SRCS ${QGIS_CORE_SRCS}
${CMAKE_SOURCE_DIR}/external/poly2tri/common/shapes.cc
${CMAKE_SOURCE_DIR}/external/poly2tri/sweep/advancing_front.cc
${CMAKE_SOURCE_DIR}/external/poly2tri/sweep/cdt.cc
${CMAKE_SOURCE_DIR}/external/poly2tri/sweep/sweep_context.cc
${CMAKE_SOURCE_DIR}/external/poly2tri/sweep/sweep.cc
)
include_directories(${CMAKE_SOURCE_DIR}/external/poly2tri)
else ()
include_directories(${Poly2Tri_INCLUDE_DIR})
endif ()
file(GLOB JSON_HELP_FILES "${CMAKE_SOURCE_DIR}/resources/function_help/json/*")
if(CMAKE_VERSION VERSION_LESS "3.18" AND NOT USING_NINJA)
string(REPLACE "$" "$$" JSON_HELP_FILES "${JSON_HELP_FILES}")
@ -1624,7 +1632,6 @@ include_directories(
${CMAKE_SOURCE_DIR}/external/nlohmann
${CMAKE_SOURCE_DIR}/external/kdbush/include
${CMAKE_SOURCE_DIR}/external/nmea
${CMAKE_SOURCE_DIR}/external/poly2tri
${CMAKE_SOURCE_DIR}/external/rtree/include
${CMAKE_SOURCE_DIR}/external/meshOptimizer
)
@ -1730,6 +1737,9 @@ if(ENABLE_MODELTEST)
target_link_libraries(qgis_core ${Qt5Test_LIBRARIES})
endif()
if (NOT WITH_INTERNAL_POLY2TRI)
target_link_libraries(qgis_core ${Poly2Tri_LIBRARY})
endif()
if(HAVE_OPENCL)
target_link_libraries(qgis_core ${OpenCL_LIBRARY})