diff --git a/CMakeLists.txt b/CMakeLists.txt index 2318388f508..368c86b6547 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -398,7 +398,7 @@ if(WITH_CORE) endif() if (NOT WITH_INTERNAL_POLY2TRI) - find_package(Poly2Tri REQUIRED) + find_package(poly2tri REQUIRED) endif() if (WITH_SPATIALITE) diff --git a/cmake/FindPoly2Tri.cmake b/cmake/FindPoly2Tri.cmake deleted file mode 100644 index 87fb34f3475..00000000000 --- a/cmake/FindPoly2Tri.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# Find Poly2Tri -# ~~~~~~~~~ -# Copyright (c) 2020, Peter Petrik -# 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 ) diff --git a/cmake/Findpoly2tri.cmake b/cmake/Findpoly2tri.cmake new file mode 100644 index 00000000000..8e3c8030ac5 --- /dev/null +++ b/cmake/Findpoly2tri.cmake @@ -0,0 +1,31 @@ +# Find poly2tri +# ~~~~~~~~~~~~~ +# Copyright (c) 2020, Peter Petrik +# 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::poly2tri - Target + +find_package(poly2tri CONFIG) +if(NOT poly2tri_FOUND) + 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) + + + add_library(poly2tri::poly2tri UNKNOWN IMPORTED) + target_link_libraries(poly2tri::poly2tri INTERFACE ${poly2tri_LIBRARY}) + target_include_directories(poly2tri::poly2tri INTERFACE ${poly2tri_INCLUDE_DIR}) + set_target_properties(poly2tri::poly2tri PROPERTIES IMPORTED_LOCATION ${poly2tri_LIBRARY}) + mark_as_advanced(poly2tri_INCLUDE_DIR poly2tri_LIBRARY) +endif() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 1dd8bfa49bf..9b3229480ea 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -973,8 +973,6 @@ if (WITH_INTERNAL_POLY2TRI) ${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/*") @@ -2347,7 +2345,7 @@ if(ENABLE_MODELTEST) endif() if (NOT WITH_INTERNAL_POLY2TRI) - target_link_libraries(qgis_core ${Poly2Tri_LIBRARY}) + target_link_libraries(qgis_core poly2tri::poly2tri) endif() if(HAVE_OPENCL)