From c52935ba3c44bb8dfaba817822198f614d645663 Mon Sep 17 00:00:00 2001 From: Arnaud TANGUY Date: Thu, 16 Apr 2026 18:45:54 +0200 Subject: [PATCH] build: use external qhull if possible --- CMakeLists.txt | 22 ++++++++++++++++++++-- src/CMakeLists.txt | 6 +++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea50ec85c9..c358e7cada 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,8 +233,26 @@ elseif(NOT HOST_IS_WSL AND WIN32) message("-- Use WinToast for notifications") endif() -# qhull (build re-entrant static version) -add_subdirectory(3rd-party/qhull) +find_package( + Qhull + COMPONENTS qhullcpp qhullstatic_r + QUIET +) +message(STATUS "Using system Qhull") +if(Qhull_FOUND) + set(QHULL_TARGETS Qhull::qhullcpp Qhull::qhullstatic_r) +else() + message(STATUS "Using bundled Qhull (re-entrant static version)") + # qhull (build re-entrant static version) + add_subdirectory(3rd-party/qhull) + # Alias bundled targets to Qhull:: namespace if not already present + if(NOT TARGET Qhull::qhullcpp) + add_library(Qhull::qhullcpp ALIAS qhullcpp) + endif() + if(NOT TARGET Qhull::qhullstatic_r) + add_library(Qhull::qhullstatic_r ALIAS qhullstatic_r) + endif() +endif() # mpack (build static version) add_subdirectory(3rd-party/mpack) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8f8c0c203b..857d44885b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -361,11 +361,11 @@ target_compile_definitions(mc_rbdyn PUBLIC -DUSE_UNSTABLE_GEOS_CPP_API) # qhull if(MC_RTC_BUILD_STATIC) target_link_libraries( - mc_rbdyn PRIVATE "-Wl,--no-whole-archive" qhullstatic_r "-Wl,--no-whole-archive" - qhullcpp + mc_rbdyn PRIVATE "-Wl,--no-whole-archive" Qhull::qhullstatic_r + "-Wl,--no-whole-archive" Qhull::qhullcpp ) else() - target_link_libraries(mc_rbdyn PRIVATE qhullstatic_r qhullcpp) + target_link_libraries(mc_rbdyn PRIVATE Qhull::qhullstatic_r Qhull::qhullcpp) endif() if(TARGET mc_rtc_3rd_party::ROS)