Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qhull: add libqhullcpp component, add v8.1-alpha4 #24532

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions recipes/qhull/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
sources:
"8.1-alpha4":
url: "https://github.com/qhull/qhull/archive/refs/tags/v8.1-alpha4.tar.gz"
sha256: "81c4696ea54a2441178b8c5f4a49f63e1fa3550ebed0aecbe787cdbd8e34af02"
"8.0.1":
url: "https://github.com/qhull/qhull/archive/v8.0.1.tar.gz"
sha256: "33c442518b033862978089776a3ec29cd771ebb535c2b4a6d604fcef043c4264"
"8.0.0":
url: "https://github.com/qhull/qhull/archive/v8.0.0.tar.gz"
sha256: "0a1b26607b28b1cf6f90c8dbb0132a0e087f85baea03ec2dcdc4100a0646dead"
"7.3.2":
url: "https://github.com/qhull/qhull/archive/v7.3.2.tar.gz"
sha256: "619c8a954880d545194bc03359404ef36a1abd2dde03678089459757fd790cb0"
patches:
"8.1-alpha4":
- patch_file: "patches/0005-install-non-reentrant-shared.patch"
patch_description: "Install non-reentrant shared library"
patch_type: "conan"
- patch_file: "patches/0006-use-default-rpaths-8.1.x.patch"
patch_description: "Use default RPATH settings from CMake"
patch_type: "conan"
"8.0.1":
- patch_file: "patches/0002-fix-cmake-minimum-required-location-8.0.1.patch"
patch_description: "Fix cmake_minimum_required() position"
patch_type: "backport"
patch_source: "https://github.com/qhull/qhull/pull/120"
- patch_file: "patches/0003-fix-cmake-8.0.x.patch"
"8.0.0":
- patch_file: "patches/0002-fix-cmake-minimum-required-location-8.0.0.patch"
patch_description: "Fix cmake_minimum_required() position"
patch_type: "backport"
patch_source: "https://github.com/qhull/qhull/pull/120"
- patch_file: "patches/0003-fix-cmake-8.0.x.patch"
- patch_file: "patches/0004-no-cpp11.patch"
"7.3.2":
- patch_file: "patches/0001-fix-cmake-conflict-exec-dir.patch"
patch_description: "Fix build failure on macOS due to conflict between an exec & dir name"
Expand Down
112 changes: 74 additions & 38 deletions recipes/qhull/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Version
import os

required_conan_version = ">=1.53.0"


class QhullConan(ConanFile):
name = "qhull"
description = "Qhull computes the convex hull, Delaunay triangulation, " \
"Voronoi diagram, halfspace intersection about a point, " \
"furthest-site Delaunay triangulation, and furthest-site " \
"Voronoi diagram."
description = ("Qhull computes the convex hull, Delaunay triangulation, "
"Voronoi diagram, halfspace intersection about a point, "
"furthest-site Delaunay triangulation, and furthest-site "
"Voronoi diagram.")
license = "Qhull"
topics = ("geometry", "convex", "triangulation", "intersection")
homepage = "http://www.qhull.org"
Expand All @@ -23,11 +25,13 @@ class QhullConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"cpp": [True, False],
"reentrant": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"cpp": False,
"reentrant": True,
}

Expand All @@ -41,20 +45,36 @@ def config_options(self):
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
if Version(self.version) >= "8.1-alpha4":
if not self.options.cpp:
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")
else:
del self.options.cpp

def layout(self):
cmake_layout(self, src_folder="src")

def package_id(self):
del self.info.options.reentrant
self.info.options.rm_safe("cpp")

def validate(self):
if self.options.get_safe("cpp"):
if self.options.shared:
raise ConanInvalidConfiguration("-o cpp=True is only available with -o shared=False")
if not self.options.reentrant:
raise ConanInvalidConfiguration("-o cpp=True is only available with -o reentrant=True")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_STATIC_LIBS"] = not self.options.shared
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared
tc.variables["QHULL_ENABLE_TESTING"] = False
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
tc.generate()

def build(self):
Expand All @@ -75,53 +95,69 @@ def package(self):

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "Qhull")
self.cpp_info.set_property("cmake_target_name", f"Qhull::{self._qhull_cmake_name}")
self.cpp_info.set_property("pkg_config_name", self._qhull_pkgconfig_name)

# TODO: back to global scope once cmake_find_package* generators removed
self.cpp_info.components["libqhull"].libs = [self._qhull_lib_name]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["libqhull"].system_libs.append("m")
if is_msvc(self) and self.options.shared:
self.cpp_info.components["libqhull"].defines.extend(["qh_dllimport"])
self.cpp_info.set_property("pkg_config_name", "_qhull_all")

# TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed
if self.options.reentrant:
self.cpp_info.components["libqhull_r"].set_property("cmake_target_name", f"Qhull::{self._qhull_cmake_name(True)}")
self.cpp_info.components["libqhull_r"].set_property("pkg_config_name", self._qhull_pkgconfig_name(True))
self.cpp_info.components["libqhull_r"].libs = [self._qhull_lib_name(True)]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["libqhull_r"].system_libs.append("m")
if is_msvc(self) and self.options.shared:
self.cpp_info.components["libqhull_r"].defines.append("qh_dllimport")
else:
self.cpp_info.components["libqhull"].set_property("cmake_target_name", f"Qhull::{self._qhull_cmake_name(False)}")
self.cpp_info.components["libqhull"].set_property("pkg_config_name", self._qhull_pkgconfig_name(False))
self.cpp_info.components["libqhull"].libs = [self._qhull_lib_name(False)]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["libqhull"].system_libs.append("m")
if is_msvc(self) and self.options.shared:
self.cpp_info.components["libqhull"].defines.append("qh_dllimport")

if self.options.get_safe("cpp"):
suffix = "_d" if self.settings.build_type == "Debug" else ""
self.cpp_info.components["libqhullcpp"].set_property("cmake_target_name", "Qhull::qhullcpp")
self.cpp_info.components["libqhullcpp"].set_property("pkg_config_name", "qhullcpp")
self.cpp_info.components["libqhullcpp"].libs = [f"qhullcpp{suffix}"]
self.cpp_info.components["libqhullcpp"].requires = ["libqhull_r"]

# TODO: Legacy, to be removed on Conan 2.0
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
self.cpp_info.names["cmake_find_package"] = "Qhull"
self.cpp_info.names["cmake_find_package_multi"] = "Qhull"
self.cpp_info.names["pkg_config"] = self._qhull_pkgconfig_name
self.cpp_info.components["libqhull"].names["cmake_find_package"] = self._qhull_cmake_name
self.cpp_info.components["libqhull"].names["cmake_find_package_multi"] = self._qhull_cmake_name
self.cpp_info.components["libqhull"].names["pkg_config"] = self._qhull_pkgconfig_name
self.cpp_info.components["libqhull"].set_property("cmake_target_name", f"Qhull::{self._qhull_cmake_name}")
self.cpp_info.components["libqhull"].set_property("pkg_config_name", self._qhull_pkgconfig_name)
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))

@property
def _qhull_cmake_name(self):
name = ""
if self.options.reentrant:
name = "qhull_r" if self.options.shared else "qhullstatic_r"
self.cpp_info.components["libqhull_r"].names["cmake_find_package"] = self._qhull_cmake_name(True)
self.cpp_info.components["libqhull_r"].names["cmake_find_package_multi"] = self._qhull_cmake_name(True)
self.cpp_info.components["libqhull_r"].names["pkg_config"] = self._qhull_pkgconfig_name(True)
else:
name = "libqhull" if self.options.shared else "qhullstatic"
return name

@property
def _qhull_pkgconfig_name(self):
self.cpp_info.components["libqhull"].names["cmake_find_package"] = self._qhull_cmake_name(False)
self.cpp_info.components["libqhull"].names["cmake_find_package_multi"] = self._qhull_cmake_name(False)
self.cpp_info.components["libqhull"].names["pkg_config"] = self._qhull_pkgconfig_name(False)
if self.options.get_safe("cpp"):
self.cpp_info.components["libqhullcpp"].names["cmake_find_package"] = "qhullcpp"
self.cpp_info.components["libqhullcpp"].names["cmake_find_package_multi"] = "qhullcpp"
self.cpp_info.components["libqhullcpp"].names["pkg_config"] = "qhullcpp"

def _qhull_cmake_name(self, reentrant):
if Version(self.version) < "8.1-alpha4" and not reentrant and self.options.shared:
return "libqhull"
return self._qhull_pkgconfig_name(reentrant)

def _qhull_pkgconfig_name(self, reentrant):
name = "qhull"
if not self.options.shared:
name += "static"
if self.options.reentrant:
if reentrant:
name += "_r"
return name

@property
def _qhull_lib_name(self):
def _qhull_lib_name(self, reentrant):
name = "qhull"
if not self.options.shared:
name += "static"
if self.settings.build_type == "Debug" or self.options.reentrant:
if self.settings.build_type == "Debug" or reentrant:
name += "_"
if self.options.reentrant:
if reentrant:
name += "r"
if self.settings.build_type == "Debug":
name += "d"
Expand Down

This file was deleted.

46 changes: 0 additions & 46 deletions recipes/qhull/all/patches/0004-no-cpp11.patch

This file was deleted.

20 changes: 20 additions & 0 deletions recipes/qhull/all/patches/0005-install-non-reentrant-shared.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -349,7 +349,7 @@

set(qhull_TARGETS_APPLICATIONS qhull rbox qconvex qdelaunay qvoronoi qhalf)
set(qhull_TARGETS_STATIC ${qhull_CPP} ${qhull_STATIC} ${qhull_STATICR})
-set(qhull_TARGETS_SHARED ${qhull_SHAREDR})
+set(qhull_TARGETS_SHARED ${qhull_SHARED} ${qhull_SHAREDR})

set(
qhull_TARGETS_TEST # Unused
@@ -401,7 +401,7 @@
src/libqhull/qhull-exports.def)

set_target_properties(${qhull_SHARED} PROPERTIES
- EXCLUDE_FROM_ALL TRUE
+ # EXCLUDE_FROM_ALL TRUE
SOVERSION ${qhull_SOVERSION}
VERSION ${qhull_VERSION}
OUTPUT_NAME "qhull$<$<CONFIG:Debug>:_d>")
25 changes: 25 additions & 0 deletions recipes/qhull/all/patches/0006-use-default-rpaths-8.1.x.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -364,22 +364,6 @@
# Define shared library for reentrant qhull (installed)
# ---------------------------------------

-if (NOT DEFINED CMAKE_INSTALL_NAME_DIR)
- set(CMAKE_INSTALL_NAME_DIR "${LIB_INSTALL_DIR}")
-endif ()
-
-if (NOT DEFINED CMAKE_INSTALL_RPATH)
- set(CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}")
-endif ()
-
-if (NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH)
- set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
-endif ()
-
-if (NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH)
- set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
-endif ()
-
add_library(${qhull_SHAREDR} SHARED
${libqhullr_SOURCES}
src/libqhull_r/qhull_r-exports.def)
11 changes: 9 additions & 2 deletions recipes/qhull/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)
project(test_package LANGUAGES C CXX)

find_package(Qhull REQUIRED CONFIG)

Expand All @@ -12,9 +12,16 @@ if(QHULL_REENTRANT)
endif()
else()
add_executable(${PROJECT_NAME} test_package.c)
if(TARGET Qhull::libqhull)
if(TARGET Qhull::qhull)
target_link_libraries(${PROJECT_NAME} PRIVATE Qhull::qhull)
elseif(TARGET Qhull::libqhull)
target_link_libraries(${PROJECT_NAME} PRIVATE Qhull::libqhull)
else()
target_link_libraries(${PROJECT_NAME} PRIVATE Qhull::qhullstatic)
endif()
endif()

if(QHULL_CPP)
add_executable(${PROJECT_NAME}_cpp test_package.cpp)
target_link_libraries(${PROJECT_NAME}_cpp PRIVATE Qhull::qhullcpp)
endif()
9 changes: 7 additions & 2 deletions recipes/qhull/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def requirements(self):

def generate(self):
tc = CMakeToolchain(self)
tc.variables["QHULL_REENTRANT"] = self.dependencies["qhull"].options.reentrant
tc.variables["QHULL_REENTRANT"] = self.dependencies["qhull"].options.get_safe("reentrant", True)
tc.variables["QHULL_CPP"] = self.dependencies["qhull"].options.get_safe("cpp", False)
tc.generate()

def build(self):
Expand All @@ -27,5 +28,9 @@ def build(self):

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")

bin_path = os.path.join(self.cpp.build.bindir, "test_package_cpp")
if os.path.exists(bin_path):
self.run(bin_path, env="conanrun")
9 changes: 9 additions & 0 deletions recipes/qhull/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <libqhullcpp/Qhull.h>

#include <iostream>

int main() {
orgQhull::Qhull qhull;
std::cout << "Qhull default hull dimension: " << qhull.hullDimension() << std::endl;
return 0;
}
4 changes: 2 additions & 2 deletions recipes/qhull/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
versions:
"8.0.1":
"8.1-alpha4":
folder: all
"8.0.0":
"8.0.1":
folder: all
"7.3.2":
folder: all