Skip to content

Commit

Permalink
Merge pull request #59197 from qgis/meshopt
Browse files Browse the repository at this point in the history
Prefer external packages when building with vcpkg
  • Loading branch information
m-kuhn authored Oct 24, 2024
2 parents 20073da + 78dd6c3 commit 296b3f4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/windows-qt6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ jobs:
-D FLEX_EXECUTABLE="${SOURCE_DIR}/win_flex.exe" \
-D BISON_EXECUTABLE="${SOURCE_DIR}/win_bison.exe" \
-D SIP_BUILD_EXECUTABLE="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\Scripts\sip-build.exe" \
-D PYUIC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\pyuic5.bat" \
-D PYRCC_PROGRAM="${BUILD_DIR}\vcpkg_installed\x64-windows-release\tools\python3\pyrcc5.bat" \
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
-D WITH_QTWEBKIT=OFF \
Expand Down
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ set (WITH_DESKTOP TRUE CACHE BOOL "Determines whether QGIS desktop should be bui
set (WITH_GUI TRUE CACHE BOOL "Determines whether QGIS GUI library should be built")
set(WITH_VCPKG FALSE CACHE BOOL "Use the vcpkg submodule for dependency management.")

set(WITH_VCPKG TRUE CACHE BOOL "Use the vcpkg submodule for dependency management.")
set(SDK_PATH "" CACHE STRING "Build with VCPKG SDK")

if(NOT SDK_PATH STREQUAL "")
Expand All @@ -45,6 +44,9 @@ endif()

if(WITH_VCPKG)
list(APPEND CMAKE_PROGRAM_PATH "${VCPKG_INSTALL_PREFIX}/${VCPKG_TARGET_TRIPLET}/")
set(PREFER_INTERNAL_LIBS FALSE)
else()
set(PREFER_INTERNAL_LIBS TRUE)
endif()

#############################################################
Expand Down Expand Up @@ -272,7 +274,8 @@ if(WITH_CORE)
endif()

# 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_POLY2TRI PREFER_INTERNAL_LIBS CACHE BOOL "Determines whether POLY2TRI should be built from internal copy")
set (WITH_INTERNAL_MESHOPTIMIZER PREFER_INTERNAL_LIBS 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")
Expand Down Expand Up @@ -385,7 +388,7 @@ if(WITH_CORE)
find_package(EXPAT REQUIRED)
find_package(Spatialindex REQUIRED)
find_package(LibZip REQUIRED)
set (WITH_INTERNAL_NLOHMANN_JSON ON CACHE BOOL "Determines whether the vendored copy of nlohmann-json should be used")
set (WITH_INTERNAL_NLOHMANN_JSON PREFER_INTERNAL_LIBS CACHE BOOL "Determines whether the vendored copy of nlohmann-json should be used")
find_package(nlohmann_json REQUIRED)

# The following bypasses the FindSQLite3 module introduced in CMake 3.14
Expand Down
17 changes: 14 additions & 3 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,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}
Expand Down Expand Up @@ -2339,6 +2337,20 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})

add_library(qgis_core ${LIBRARY_TYPE} ${QGIS_CORE_SRCS} ${QGIS_CORE_HDRS} ${QGIS_CORE_PRIVATE_HDRS} ${IMAGE_RCCS})

# Add meshoptimizer
if(WITH_INTERNAL_MESHOPTIMIZER)
target_sources(qgis_core PRIVATE
${CMAKE_SOURCE_DIR}/external/meshOptimizer/simplifier.cpp
)

target_include_directories(qgis_core PRIVATE
${CMAKE_SOURCE_DIR}/external/meshOptimizer/simplifier.cpp
)
else()
find_package(meshoptimizer CONFIG REQUIRED)
target_link_libraries(qgis_core PRIVATE meshoptimizer::meshoptimizer)
endif()

# require c++17
target_compile_features(qgis_core PRIVATE cxx_std_17)

Expand Down Expand Up @@ -2434,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
)

Expand Down
2 changes: 2 additions & 0 deletions vcpkg/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
},
"libxml2",
"libzip",
"meshoptimizer",
"nlohmann-json",
"pdal",
"proj",
"protobuf",
Expand Down

0 comments on commit 296b3f4

Please sign in to comment.