diff --git a/recipes/sleef/all/CMakeLists.txt b/recipes/sleef/all/CMakeLists.txt deleted file mode 100644 index bd3083b512cb9..0000000000000 --- a/recipes/sleef/all/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(cmake_wrapper) - -include(conanbuildinfo.cmake) -conan_basic_setup() - -add_subdirectory(source_subfolder) diff --git a/recipes/sleef/all/conandata.yml b/recipes/sleef/all/conandata.yml index d1737a7a842cf..2cb4098c3fd69 100644 --- a/recipes/sleef/all/conandata.yml +++ b/recipes/sleef/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.6": + url: "https://github.com/shibatch/sleef/archive/3.6.tar.gz" + sha256: "de4f3d992cf2183a872cd397f517c1defcd3ee6cafa2ce5fa36963bd7e562446" "3.5.1": url: "https://github.com/shibatch/sleef/archive/3.5.1.tar.gz" sha256: "415ee9b1bcc5816989d3d4d92afd0cd3f9ee89cbd5a33eb008e69751e40438ab" diff --git a/recipes/sleef/all/conanfile.py b/recipes/sleef/all/conanfile.py index 0496b1b63c7cd..7cba3764e2337 100644 --- a/recipes/sleef/all/conanfile.py +++ b/recipes/sleef/all/conanfile.py @@ -1,19 +1,25 @@ -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration import os -required_conan_version = ">=1.32.0" +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import cross_building +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rmdir +from conan.tools.scm import Version + +required_conan_version = ">=1.53.0" class SleefConan(ConanFile): name = "sleef" - description = "SLEEF is a library that implements vectorized versions " \ - "of C standard math functions." + description = "SLEEF is a library that implements vectorized versions of C standard math functions." license = "BSL-1.0" - topics = ("conan", "sleef", "vectorization", "simd") - homepage = "https://sleef.org" url = "https://github.com/conan-io/conan-center-index" + homepage = "https://sleef.org" + topics = ("vectorization", "simd") + package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -24,75 +30,92 @@ class SleefConan(ConanFile): "fPIC": True, } - short_paths = True - - exports_sources = "CMakeLists.txt" - generators = "cmake" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def layout(self): + cmake_layout(self, src_folder="src") def validate(self): if self.settings.os == "Windows" and self.options.shared: - raise ConanInvalidConfiguration("shared sleef not supported on Windows, it produces runtime errors") + raise ConanInvalidConfiguration( + "shared sleef not supported on Windows, it produces runtime errors" + ) + if self.settings.compiler == "apple-clang": + if cross_building(self): + # Fails with "No rule to make target `/bin/mkrename'" + # https://github.com/shibatch/sleef/issues/308 + raise ConanInvalidConfiguration(f"{self.ref} does not support cross-building with apple-clang") + if Version(self.version) < "3.6" and self.settings.arch == "armv8": + # clang: error: the clang compiler does not support '-march=armv7-a' + # clang: warning: argument unused during compilation: '-mfpu=vfpv4' [-Wunused-command-line-argument] + # clang: warning: argument unused during compilation: '-arch arm64' [-Wunused-command-line-argument] + # clang: warning: argument unused during compilation: '-mmacosx-version-min=11.0' [-Wunused-command-line-argument] + raise ConanInvalidConfiguration(f"{self.ref} does not support Mac M1. Please, use {self.name} version >=3.6.") + + def build_requirements(self): + if Version(self.version) >= "3.6": + self.tool_requires("cmake/[>=3.18 <4]") def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.definitions["BUILD_STATIC_TEST_BINS"] = False - self._cmake.definitions["ENABLE_LTO"] = False - self._cmake.definitions["BUILD_LIBM"] = True - self._cmake.definitions["BUILD_DFT"] = False - self._cmake.definitions["BUILD_QUAD"] = False - self._cmake.definitions["BUILD_GNUABI_LIBS"] = False - self._cmake.definitions["BUILD_TESTS"] = False - self._cmake.definitions["BUILD_INLINE_HEADERS"] = False - self._cmake.definitions["SLEEF_TEST_ALL_IUT"] = False - self._cmake.definitions["SLEEF_SHOW_CONFIG"] = True - self._cmake.definitions["SLEEF_SHOW_ERROR_LOG"] = False - self._cmake.definitions["ENFORCE_TESTER"] = False - self._cmake.definitions["ENFORCE_TESTER3"] = False - self._cmake.definitions["ENABLE_ALTDIV"] = False - self._cmake.definitions["ENABLE_ALTSQRT"] = False - self._cmake.definitions["DISABLE_FFTW"] = True - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + VirtualBuildEnv(self).generate() + + tc = CMakeToolchain(self) + tc.cache_variables["BUILD_SHARED_LIBS"] = self.options.shared + if Version(self.version) >= "3.6": + tc.cache_variables["SLEEF_BUILD_STATIC_TEST_BINS"] = False + tc.cache_variables["SLEEF_BUILD_LIBM"] = True + tc.cache_variables["SLEEF_BUILD_DFT"] = False + tc.cache_variables["SLEEF_BUILD_QUAD"] = False + tc.cache_variables["SLEEF_BUILD_GNUABI_LIBS"] = False + tc.cache_variables["SLEEF_BUILD_SCALAR_LIB"] = False + tc.cache_variables["SLEEF_BUILD_TESTS"] = False + tc.cache_variables["SLEEF_BUILD_INLINE_HEADERS"] = False + tc.cache_variables["SLEEF_SHOW_CONFIG"] = True + tc.cache_variables["SLEEF_SHOW_ERROR_LOG"] = False + tc.cache_variables["SLEEF_ENABLE_ALTDIV"] = False + tc.cache_variables["SLEEF_ENABLE_ALTSQRT"] = False + tc.cache_variables["SLEEF_DISABLE_FFTW"] = True + tc.cache_variables["SLEEF_DISABLE_MPFR"] = True + tc.cache_variables["SLEEF_DISABLE_SSL"] = True + tc.cache_variables["SLEEF_ENABLE_CUDA"] = False + tc.cache_variables["SLEEF_ENABLE_CXX"] = False + else: + tc.cache_variables["BUILD_DFT"] = False + tc.cache_variables["BUILD_GNUABI_LIBS"] = False + tc.cache_variables["BUILD_TESTS"] = False + tc.cache_variables["DISABLE_FFTW"] = True + tc.generate() def build(self): - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "LICENSE.txt", + dst=os.path.join(self.package_folder, "licenses"), + src=self.source_folder) + cmake = CMake(self) cmake.install() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "dummy")) def package_info(self): - self.cpp_info.names["pkg_config"] = "sleef" + self.cpp_info.set_property("pkg_config_name", "sleef") self.cpp_info.libs = ["sleef"] if self.settings.os == "Windows" and not self.options.shared: self.cpp_info.defines = ["SLEEF_STATIC_LIBS"] - if self.settings.os == "Linux": + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs = ["m"] diff --git a/recipes/sleef/all/test_package/CMakeLists.txt b/recipes/sleef/all/test_package/CMakeLists.txt index 7b9b613cbb24a..a5f1ed24ef5f7 100644 --- a/recipes/sleef/all/test_package/CMakeLists.txt +++ b/recipes/sleef/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.15) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(sleef REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE sleef::sleef) diff --git a/recipes/sleef/all/test_package/conanfile.py b/recipes/sleef/all/test_package/conanfile.py index 5216332f39f5c..ef5d7042163ec 100644 --- a/recipes/sleef/all/test_package/conanfile.py +++ b/recipes/sleef/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +21,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/sleef/all/test_v1_package/CMakeLists.txt b/recipes/sleef/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..91630d79f4abb --- /dev/null +++ b/recipes/sleef/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/sleef/all/test_v1_package/conanfile.py b/recipes/sleef/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a9f777f7680ff --- /dev/null +++ b/recipes/sleef/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/sleef/config.yml b/recipes/sleef/config.yml index 2276d8a2cd6a8..3c718426b97bd 100644 --- a/recipes/sleef/config.yml +++ b/recipes/sleef/config.yml @@ -1,3 +1,5 @@ versions: + "3.6": + folder: all "3.5.1": folder: all