tinyspline: CMake 4 support (#27112)

* tinyspline: CMake 4 support

* Added missing cmake policy to version 0.2.0
This commit is contained in:
PerseoGI
2025-04-04 10:56:18 +02:00
committed by GitHub
parent e76153906c
commit ec254a40d1
2 changed files with 10 additions and 17 deletions

View File

@ -7,7 +7,7 @@ from conan.tools.scm import Version
import os
import textwrap
required_conan_version = ">=1.53.0"
required_conan_version = ">=2.1"
class TinysplineConan(ConanFile):
name = "tinyspline"
@ -17,7 +17,7 @@ class TinysplineConan(ConanFile):
topics = ("tinyspline ", "nurbs", "b-splines", "bezier")
homepage = "https://github.com/msteinbeck/tinyspline"
url = "https://github.com/conan-io/conan-center-index"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
@ -78,6 +78,7 @@ class TinysplineConan(ConanFile):
tc.variables["TINYSPLINE_DISABLE_PYTHON"] = True
tc.variables["TINYSPLINE_DISABLE_R"] = True
tc.variables["TINYSPLINE_DISABLE_RUBY"] = True
tc.cache_variables["CMAKE_POLICY_VERSION_MINIMUM"] = "3.5" # CMake 4 support
else:
tc.variables["TINYSPLINE_WARNINGS_AS_ERRORS"] = False
tc.variables["TINYSPLINE_ENABLE_CXX"] = self.options.cxx
@ -162,9 +163,3 @@ class TinysplineConan(ConanFile):
# Workaround to always provide a global target or pkg-config file with all components
self.cpp_info.set_property("cmake_target_name", "tinyspline-do-not-use")
self.cpp_info.set_property("pkg_config_name", "tinyspline-do-not-use")
# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.components["libtinyspline"].names["cmake_find_package"] = "tinyspline"
if self.options.cxx:
self.cpp_info.components["libtinysplinecxx"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
self.cpp_info.components["libtinysplinecxx"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]

View File

@ -1,5 +1,5 @@
from conan import ConanFile
from conan.tools.build import cross_building
from conan.tools.build import can_run
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
import os
@ -25,12 +25,10 @@ class TestPackageConan(ConanFile):
cmake.build()
def test(self):
if not cross_building(self):
bin_c_path = os.path.join(self.cpp.build.bindirs[0], "test_package_c")
self.run(bin_c_path, run_environment=True)
if can_run(self):
bin_c_path = os.path.join(self.cpp.build.bindir, "test_package_c")
self.run(bin_c_path, env="conanrun")
# TODO: rely on self.dependencies["tinyspline"].options.cxx in CONAN_V2 mode
# see https://github.com/conan-io/conan/issues/11940#issuecomment-1223940786
bin_cpp_path = os.path.join(self.cpp.build.bindirs[0], "test_package_cpp")
if os.path.exists(bin_cpp_path):
self.run(bin_cpp_path, run_environment=True)
if self.dependencies["tinyspline"].options.cxx:
bin_cpp_path = os.path.join(self.cpp.build.bindir, "test_package_cpp")
self.run(bin_cpp_path, env="conanrun")