Skip to content

Commit

Permalink
unvendor meshoptimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 21, 2024
1 parent 5d6e1b8 commit 155b701
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmake/qgis-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ if(TRUE) # Should possibly have a "static only" check
endif()
find_package(poly2tri CONFIG)
target_link_libraries(QGIS::Core INTERFACE poly2tri::poly2tri)
find_package(meshoptimizer CONFIG REQUIRED)
target_link_libraries(QGIS::Core INTERFACE meshoptimizer::meshoptimizer)

pkg_check_modules(freexl REQUIRED IMPORTED_TARGET freexl)
target_link_libraries(QGIS::Core INTERFACE PkgConfig::freexl)
Expand Down
52 changes: 52 additions & 0 deletions vcpkg/ports/qgis/meshoptimizer.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 82c4f3e8108..881a39c19ec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -273,6 +273,7 @@ if(WITH_CORE)

# try to configure and build POLY2TRI support
set (WITH_INTERNAL_POLY2TRI TRUE CACHE BOOL "Determines whether POLY2TRI should be built from internal copy")
+ set (WITH_INTERNAL_MESHOPTIMIZER TRUE CACHE BOOL "Determines whether MESHOPTIMIZER 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")
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 03a4571d701..f59807951f5 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -19,6 +19,18 @@ if (WITH_PDF4QT)
SUBDIRS(${CMAKE_SOURCE_DIR}/external/PDF4QT)
endif()

+if(WITH_INTERNAL_MESHOPTIMIZER)
+ add_library(STATIC meshoptimizer::meshoptimizer
+ ${CMAKE_SOURCE_DIR}/external/meshOptimizer/simplifier.cpp
+ )
+
+ target_include_directories(meshoptimizer::meshoptimizer
+ ${CMAKE_SOURCE_DIR}/external/meshOptimizer
+ )
+else()
+ find_package(meshoptimizer CONFIG REQUIRED)
+endif()
+
set(QGIS_CORE_SRCS
${CMAKE_SOURCE_DIR}/external/kdbush/include/kdbush.hpp

@@ -30,8 +42,6 @@ set(QGIS_CORE_SRCS
${CMAKE_SOURCE_DIR}/external/nmea/time.c
${CMAKE_SOURCE_DIR}/external/nmea/tok.c

- ${CMAKE_SOURCE_DIR}/external/meshOptimizer/simplifier.cpp
-
${FLEX_QgsExpressionLexer_OUTPUTS}
${BISON_QgsExpressionParser_OUTPUTS}
${FLEX_QgsSqlStatementLexer_OUTPUTS}
@@ -2436,7 +2446,6 @@ target_include_directories(qgis_core PUBLIC
${CMAKE_SOURCE_DIR}/external/kdbush/include
${CMAKE_SOURCE_DIR}/external/nmea
${CMAKE_SOURCE_DIR}/external/rtree/include
- ${CMAKE_SOURCE_DIR}/external/meshOptimizer
${CMAKE_SOURCE_DIR}/external/tinygltf
)

2 changes: 2 additions & 0 deletions vcpkg/ports/qgis/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ vcpkg_from_github(
include-qthread.patch
processing.patch # Needed to avoid link issue with tinygltf (ATM embedded into QGIS) and _GEOSQueryCallback defined multiple times
font_download.patch
meshoptimizer.patch # Unvendor meshoptimizer
)

file(REMOVE ${SOURCE_PATH}/cmake/FindGDAL.cmake)
Expand All @@ -38,6 +39,7 @@ list(APPEND QGIS_OPTIONS "-DWITH_QSPATIALITE:BOOL=OFF")
list(APPEND QGIS_OPTIONS "-DWITH_PDAL:BOOL=OFF")
list(APPEND QGIS_OPTIONS "-DWITH_DRACO:BOOL=ON")
list(APPEND QGIS_OPTIONS "-DWITH_INTERNAL_POLY2TRI:BOOL=OFF")
list(APPEND QGIS_OPTIONS "-DWITH_INTERNAL_MESHOPTIMIZER:BOOL=OFF")

list(APPEND QGIS_OPTIONS "-DBISON_EXECUTABLE=${BISON}")
list(APPEND QGIS_OPTIONS "-DFLEX_EXECUTABLE=${FLEX}")
Expand Down
1 change: 1 addition & 0 deletions vcpkg/ports/qgis/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"libxml2",
"libzip",
"meshoptimizer",
"proj",
"protobuf",
{
Expand Down

0 comments on commit 155b701

Please sign in to comment.