From a87745e2fffd41dcfb9f64c114a32a01f15278ff Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 20 Jul 2023 23:15:04 +0300 Subject: [PATCH 1/7] cern-root: migrate to Conan v2 --- recipes/cern-root/all/conandata.yml | 2 - recipes/cern-root/all/conanfile.py | 367 ++++++++---------- .../cern-root/all/test_package/CMakeLists.txt | 7 +- .../cern-root/all/test_package/conanfile.py | 51 +-- .../all/test_package/testrootdictionaries.cpp | 13 +- .../all/test_v1_package/CMakeLists.txt | 8 + .../all/test_v1_package/conanfile.py | 46 +++ 7 files changed, 233 insertions(+), 261 deletions(-) create mode 100644 recipes/cern-root/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/cern-root/all/test_v1_package/conanfile.py diff --git a/recipes/cern-root/all/conandata.yml b/recipes/cern-root/all/conandata.yml index ea1780c15b67b..95fdfa6c18619 100644 --- a/recipes/cern-root/all/conandata.yml +++ b/recipes/cern-root/all/conandata.yml @@ -5,6 +5,4 @@ sources: patches: "v6-22-06": - patch_file: "patches/0001-add-missing-includes.patch" - base_path: "source_subfolder" - patch_file: "patches/0002-cmake-missing-link-libraries.patch" - base_path: "source_subfolder" diff --git a/recipes/cern-root/all/conanfile.py b/recipes/cern-root/all/conanfile.py index be3871ebefe4c..3b67e4bd743c8 100644 --- a/recipes/cern-root/all/conanfile.py +++ b/recipes/cern-root/all/conanfile.py @@ -1,64 +1,46 @@ -from conans import CMake, ConanFile, tools -from conans.errors import ConanInvalidConfiguration import glob import os import shutil import stat -import textwrap +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.scm import Version -class PythonOption: - OFF = "off" - SYSTEM = "system" - # in future we may allow the user to specify a version when - # libPython is available in Conan Center Index. - # FIXME: add option to use CCI Python package when it is available - ALL = [OFF, SYSTEM] - - -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.53.0" class CernRootConan(ConanFile): name = "cern-root" # version format is intentional, ROOT does not follow strict SemVer. # see: https://root.cern/about/versioning/ - license = "LGPL-2.1-or-later" # of ROOT itself, the recipe is under MIT license. - homepage = "https://root.cern/" - # ROOT itself is located at: https://github.com/root-project/root - url = "https://github.com/conan-io/conan-center-index" description = "CERN ROOT data analysis framework." + license = "LGPL-2.1-or-later" + url = "https://github.com/conan-io/conan-center-index" + # ROOT itself is located at: https://github.com/root-project/root + homepage = "https://root.cern/" topics = ("data-analysis", "physics") - settings = ("os", "compiler", "build_type", "arch") + + package_type = "shared-library" + settings = "os", "arch", "compiler", "build_type" options = { # Don't allow static build as it is not supported # see: https://sft.its.cern.ch/jira/browse/ROOT-6446 - # FIXME: shared option should be reinstated when hooks issue is resolved - # (see: https://github.com/conan-io/hooks/issues/252) - # "shared": [True], "fPIC": [True, False], - "python": PythonOption.ALL, + # in future we may allow the user to specify a version when + # libPython is available in Conan Center Index. + # FIXME: add option to use CCI Python package when it is available + "python": ["off", "system"], } default_options = { - # "shared": True, "fPIC": True, # default python=off as there is currently no libpython in Conan center - "python": PythonOption.OFF, + "python": "off", } - exports_sources = "patches/*" - generators = "cmake", "cmake_find_package" - - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - @property def _minimum_cpp_standard(self): return 11 @@ -67,35 +49,42 @@ def _minimum_cpp_standard(self): def _minimum_compilers_version(self): return { "Visual Studio": "16.1", + "msvc": "192", "gcc": "4.8", "clang": "3.4", "apple-clang": "5.1", } + def export_sources(self): + export_conandata_patches(self) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + def layout(self): + cmake_layout(self, src_folder="src") + def requirements(self): - self.requires("cfitsio/4.0.0") - self.requires("fftw/3.3.9") + self.requires("cfitsio/4.2.0") + self.requires("fftw/3.3.10") self.requires("giflib/5.2.1") self.requires("glew/2.2.0") self.requires("glu/system") - self.requires("libcurl/7.78.0") - self.requires("libjpeg/9d") - self.requires("libpng/1.6.37") - self.requires("libxml2/2.9.12") - self.requires("lz4/1.9.3") + self.requires("libcurl/8.1.2") + self.requires("libjpeg/9e") + self.requires("libpng/1.6.40") + self.requires("libxml2/2.11.4") + self.requires("lz4/1.9.4") self.requires("opengl/system") - self.requires("openssl/1.1.1l") - self.requires("pcre/8.44") - self.requires("sqlite3/3.36.0") - self.requires("tbb/2020.3") + self.requires("openssl/[>=1.1 <4]") + self.requires("pcre/8.45") + self.requires("sqlite3/3.42.0") + self.requires("onetbb/2020.3") self.requires("xorg/system") - self.requires("xxhash/0.8.0") - self.requires("xz_utils/5.2.5") - self.requires("zstd/1.5.0") + self.requires("xxhash/0.8.1") + self.requires("xz_utils/5.4.2") + self.requires("zstd/1.5.5") def validate(self): self._enforce_minimum_compiler_version() @@ -103,203 +92,149 @@ def validate(self): def _enforce_minimum_compiler_version(self): if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, self._minimum_cpp_standard) + check_min_cppstd(self, self._minimum_cpp_standard) min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) if not min_version: - self.output.warn( - "{} recipe lacks information about the {} compiler support.".format( - self.name, self.settings.compiler - ) + self.output.warning( + f"{self.name} recipe lacks information about the {self.settings.compiler} compiler support." ) else: - if tools.Version(self.settings.compiler.version) < min_version: + if Version(self.settings.compiler.version) < min_version: raise ConanInvalidConfiguration( - "{} requires C++{} support. The current compiler {} {} does not support it.".format( - self.name, - self._minimum_cpp_standard, - self.settings.compiler, - self.settings.compiler.version, - ) + f"{self.name} requires C++{self._minimum_cpp_standard} support. " + f"The current compiler {self.settings.compiler} {self.settings.compiler.version} does not support it." ) def _enforce_libcxx_requirements(self): - compiler = self.settings.compiler - libcxx = compiler.get_safe("libcxx") + libcxx = self.settings.get_safe("compiler.libcxx") # ROOT doesn't currently build with libc++. # This restriction may be lifted in future if the problems are fixed upstream if libcxx and libcxx == "libc++": - raise ConanInvalidConfiguration( - '{} is incompatible with libc++".'.format(self.name) - ) + raise ConanInvalidConfiguration(f'{self.name} is incompatible with libc++".') def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + @staticmethod + def _make_file_executable(filename): + st = os.stat(filename) + os.chmod(filename, st.st_mode | stat.S_IEXEC) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_SHARED_LIBS"] = True + tc.variables["fail-on-missing"] = True + tc.variables["CMAKE_CXX_STANDARD"] = self._cmake_cxx_standard + tc.variables["gnuinstall"] = True + tc.variables["soversion"] = True + # Disable builtins and use Conan deps where available + tc.variables["builtin_cfitsio"] = False + tc.variables["builtin_davix"] = False + tc.variables["builtin_fftw3"] = False + tc.variables["builtin_freetype"] = False + tc.variables["builtin_glew"] = False + tc.variables["builtin_lz4"] = False + tc.variables["builtin_lzma"] = False + tc.variables["builtin_openssl"] = False + tc.variables["builtin_pcre"] = False + tc.variables["builtin_tbb"] = False + tc.variables["builtin_xxhash"] = False + tc.variables["builtin_zlib"] = False + tc.variables["builtin_zstd"] = False + # Enable builtins where there is no Conan package + tc.variables["builtin_afterimage"] = True # FIXME : replace with afterimage CCI package when available + tc.variables["builtin_gsl"] = True # FIXME : replace with gsl CCI package when available + tc.variables["builtin_gl2ps"] = True # FIXME : replace with gl2ps CCI package when available + tc.variables["builtin_ftgl"] = True # FIXME : replace with ftgl CCI package when available + tc.variables["builtin_vdt"] = True # FIXME : replace with vdt CCI package when available + # No Conan packages available for these dependencies yet + tc.variables["davix"] = False # FIXME : switch on if davix CCI package available + tc.variables["pythia6"] = False # FIXME : switch on if pythia6 CCI package available + tc.variables["pythia8"] = False # FIXME : switch on if pythia8 CCI package available + tc.variables["mysql"] = False # FIXME : switch on if mysql CCI package available + tc.variables["oracle"] = False + tc.variables["pgsql"] = False # FIXME: switch on if PostgreSQL CCI package available + tc.variables["gfal"] = False # FIXME: switch on if gfal CCI package available + tc.variables["tmva-pymva"] = False # FIXME: switch on if Python CCI package available + tc.variables["xrootd"] = False # FIXME: switch on if xrootd CCI package available + tc.variables["pyroot"] = self._cmake_pyrootopt + # clad is built with ExternalProject_Add and its + # COMPILE_DEFINITIONS property is not propagated causing the build to + # fail on some systems if libcxx != libstdc++11 + tc.variables["clad"] = False + # Configure install directories + # Conan CCI hooks restrict the allowed install directory + # names but ROOT is very picky about where build/runtime + # resources get installed. + # Set install prefix to work around these limitations + # Following: https://github.com/conan-io/conan/issues/3695 + tc.variables["CMAKE_INSTALL_CMAKEDIR"] = "lib/cmake" + tc.variables["CMAKE_INSTALL_DATAROOTDIR"] = "res/share" + tc.variables["CMAKE_INSTALL_SYSCONFDIR"] = "res/etc" + tc.generate() + + tc = CMakeDeps(self) + tc.set_property("pcre", "cmake_target_name", "PCRE::PCRE") + tc.set_property("xxhash", "cmake_target_name", "xxHash::xxHash") + tc.set_property("lz4", "cmake_target_name", "LZ4::LZ4") + tc.generate() def _patch_source_cmake(self): - try: - os.remove(os.path.join(self._source_subfolder, "cmake", "modules", "FindTBB.cmake")) - except OSError: - pass - # Conan generated cmake_find_packages names differ from - # names ROOT expects (usually only due to case differences) - # There is currently no way to change these names - # see: https://github.com/conan-io/conan/issues/4430 - # Patch ROOT CMake to use Conan dependencies - tools.replace_in_file( - os.path.join(self.source_folder, self._source_subfolder, "CMakeLists.txt"), - "project(ROOT)", - textwrap.dedent("""\ - project(ROOT) - # sets the current C runtime on MSVC (MT vs MD vd MTd vs MDd) - include("{install_folder}/conanbuildinfo.cmake") - conan_basic_setup(NO_OUTPUT_DIRS) - find_package(OpenSSL REQUIRED) - set(OPENSSL_VERSION ${{OpenSSL_VERSION}}) - find_package(LibXml2 REQUIRED) - set(LIBXML2_INCLUDE_DIR ${{LibXml2_INCLUDE_DIR}}) - set(LIBXML2_LIBRARIES ${{LibXml2_LIBRARIES}}) - find_package(SQLite3 REQUIRED) - set(SQLITE_INCLUDE_DIR ${{SQLITE3_INCLUDE_DIRS}}) - set(SQLITE_LIBRARIES SQLite::SQLite3) - """).format(install_folder=self.install_folder.replace("\\", "/")) - ) - tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "CMakeLists.txt"), - "set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)", - "list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)") + rm(self, "FindTBB.cmake", os.path.join(self.source_folder, "cmake", "modules")) + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)", + "list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)") def _fix_source_permissions(self): # Fix execute permissions on scripts - scripts = [ - filename - for pattern in ( - os.path.join("**", "configure"), - os.path.join("**", "*.sh"), - os.path.join("**", "*.csh"), - os.path.join("**", "*.bat"), - ) - for filename in glob.glob(os.path.join(self.source_folder, pattern), recursive=True) - ] - for s in scripts: - self._make_file_executable(s) + for pattern in [ + os.path.join(self.source_folder, "**", "configure"), + os.path.join(self.source_folder, "**", "*.sh"), + os.path.join(self.source_folder, "**", "*.csh"), + os.path.join(self.source_folder, "**", "*.bat"), + ]: + for filename in glob.glob(os.path.join(self.source_folder, pattern), recursive=True): + self._make_file_executable(filename) def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + apply_conandata_patches(self) self._patch_source_cmake() self._fix_source_permissions() - @staticmethod - def _make_file_executable(filename): - st = os.stat(filename) - os.chmod(filename, st.st_mode | stat.S_IEXEC) - - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - cmakelibpath = ";".join(self.deps_cpp_info.lib_paths) - cmakeincludepath = ";".join(self.deps_cpp_info.include_paths) - self._cmake.definitions.update({ - "BUILD_SHARED_LIBS": True, - "fail-on-missing": True, - "CMAKE_CXX_STANDARD": self._cmake_cxx_standard, - "gnuinstall": True, - "soversion": True, - # Disable builtins and use Conan deps where available - "builtin_cfitsio": False, - "builtin_davix": False, - "builtin_fftw3": False, - "builtin_freetype": False, - "builtin_glew": False, - "builtin_lz4": False, - "builtin_lzma": False, - "builtin_openssl": False, - "builtin_pcre": False, - "builtin_tbb": False, - "builtin_xxhash": False, - "builtin_zlib": False, - "builtin_zstd": False, - # Enable builtins where there is no Conan package - "builtin_afterimage": True, # FIXME : replace with afterimage CCI package when available - "builtin_gsl": True, # FIXME : replace with gsl CCI package when available - "builtin_gl2ps": True, # FIXME : replace with gl2ps CCI package when available - "builtin_ftgl": True, # FIXME : replace with ftgl CCI package when available - "builtin_vdt": True, # FIXME : replace with vdt CCI package when available - # No Conan packages available for these dependencies yet - "davix": False, # FIXME : switch on if davix CCI package available - "pythia6": False, # FIXME : switch on if pythia6 CCI package available - "pythia8": False, # FIXME : switch on if pythia8 CCI package available - "mysql": False, # FIXME : switch on if mysql CCI package available - "oracle": False, - "pgsql": False, # FIXME: switch on if PostgreSQL CCI package available - "gfal": False, # FIXME: switch on if gfal CCI package available - "tmva-pymva": False, # FIXME: switch on if Python CCI package available - "xrootd": False, # FIXME: switch on if xrootd CCI package available - "pyroot": self._cmake_pyrootopt, - # clad is built with ExternalProject_Add and its - # COMPILE_DEFINITIONS property is not propagated causing the build to - # fail on some systems if libcxx != libstdc++11 - "clad": False, - # Tell CMake where to look for Conan provided depedencies - "CMAKE_LIBRARY_PATH": cmakelibpath.replace("\\", "/"), - "CMAKE_INCLUDE_PATH": cmakeincludepath.replace("\\", "/"), - # Configure install directories - # Conan CCI hooks restrict the allowed install directory - # names but ROOT is very picky about where build/runtime - # resources get installed. - # Set install prefix to work around these limitations - # Following: https://github.com/conan-io/conan/issues/3695 - "CMAKE_INSTALL_CMAKEDIR": "lib/cmake", - "CMAKE_INSTALL_DATAROOTDIR": "res/share", - "CMAKE_INSTALL_SYSCONFDIR": "res/etc", - # Fix some Conan-ROOT CMake variable naming differences - "PNG_PNG_INCLUDE_DIR": ";".join(self.deps_cpp_info["libpng"].include_paths).replace("\\", "/"), - "LIBLZMA_INCLUDE_DIR": ";".join(self.deps_cpp_info["xz_utils"].include_paths).replace("\\", "/"), - }) - self._cmake.configure(source_folder=self._source_subfolder, build_folder=self._build_subfolder) - return self._cmake - def _move_findcmake_conan_to_root_dir(self): for f in ["opengl_system", "GLEW", "glu", "TBB", "LibXml2", "ZLIB", "SQLite3"]: - shutil.copy( - "Find{}.cmake".format(f), - os.path.join( - self.source_folder, self._source_subfolder, "cmake", "modules" - ), - ) + shutil.copy(f"Find{f}.cmake", os.path.join(self.source_folder, "cmake", "modules")) @property def _cmake_cxx_standard(self): - return str(self.settings.compiler.get_safe("cppstd", "11")) + return str(self.settings.get_safe("compiler.cppstd", "11")) @property def _cmake_pyrootopt(self): - if self.options.python == PythonOption.OFF: - return False - else: - return True + return self.options.python != "off" def build(self): self._patch_sources() - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - cmake = self._configure_cmake() + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() # Fix for CMAKE-MODULES-CONFIG-FILES (KB-H016) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib", "cmake"), "*Config*.cmake") - tools.rmdir(os.path.join(self.package_folder, "res", "README")) - tools.rmdir(os.path.join(self.package_folder, "res", "share", "man")) - tools.rmdir(os.path.join(self.package_folder, "res", "share", "doc")) - tools.rmdir(os.path.join(self.package_folder, "res", "tutorials")) + rm(self, "*Config*.cmake", os.path.join(self.package_folder, "lib", "cmake"), recursive=True) + rmdir(self, os.path.join(self.package_folder, "res", "README")) + rmdir(self, os.path.join(self.package_folder, "res", "share", "man")) + rmdir(self, os.path.join(self.package_folder, "res", "share", "doc")) + rmdir(self, os.path.join(self.package_folder, "res", "tutorials")) def package_info(self): # FIXME: ROOT generates multiple CMake files - self.cpp_info.names["cmake_find_package"] = "ROOT" - self.cpp_info.names["cmake_find_package_multi"] = "ROOT" + self.cpp_info.set_property("cmake_file_name", "ROOT") + self.cpp_info.set_property("cmake_target_name", "ROOT::ROOT") + # See root-config --libs for a list of ordered libs self.cpp_info.libs = [ "Core", @@ -322,11 +257,17 @@ def package_info(self): "MultiProc", "ROOTDataFrame", ] - self.cpp_info.builddirs = [os.path.join("lib", "cmake")] - self.cpp_info.build_modules.extend( - [ - os.path.join("lib", "cmake", "RootMacros.cmake"), - # os.path.join("lib", "cmake", "ROOTUseFile.cmake"), - ] - ) self.cpp_info.resdirs = ["res"] + + build_modules = [ + os.path.join("lib", "cmake", "RootMacros.cmake"), + # os.path.join("lib", "cmake", "ROOTUseFile.cmake"), + ] + self.cpp_info.set_property("cmake_build_modules", build_modules) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.names["cmake_find_package"] = "ROOT" + self.cpp_info.names["cmake_find_package_multi"] = "ROOT" + self.cpp_info.builddirs = [os.path.join("lib", "cmake")] + self.cpp_info.build_modules["cmake_find_package"] = build_modules + self.cpp_info.build_modules["cmake_find_package_multi"] = build_modules diff --git a/recipes/cern-root/all/test_package/CMakeLists.txt b/recipes/cern-root/all/test_package/CMakeLists.txt index d6093677e3757..bdb89f479437a 100644 --- a/recipes/cern-root/all/test_package/CMakeLists.txt +++ b/recipes/cern-root/all/test_package/CMakeLists.txt @@ -1,13 +1,12 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.15) project(test_package CXX) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS NO_OUTPUT_DIRS) +set(CMAKE_CXX_STANDARD 11) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY bin) -find_package(ROOT REQUIRED) +find_package(ROOT REQUIRED CONFIG) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) root_generate_dictionary(G__Event Event.hpp OPTIONS -inlineInputHeader LINKDEF EventLinkDef.h ) diff --git a/recipes/cern-root/all/test_package/conanfile.py b/recipes/cern-root/all/test_package/conanfile.py index 9fcab707edbee..1e46be8babc93 100644 --- a/recipes/cern-root/all/test_package/conanfile.py +++ b/recipes/cern-root/all/test_package/conanfile.py @@ -1,46 +1,29 @@ -from conans import CMake, ConanFile, RunEnvironment, tools import os +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout + class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "cmake_find_package" - - def configure(self): - if self.settings.compiler.get_safe("cppstd"): - tools.check_min_cppstd(self, self._minimum_cpp_standard) - - @property - def _minimum_cpp_standard(self): - return 11 - - def build(self): - env_build = RunEnvironment(self) - with tools.environment_append(env_build.vars): - cmake = CMake(self) - cmake.configure( - defs={ - "CMAKE_CXX_STANDARD": self._cmake_cxx_standard, - } - ) - cmake.build() - - @property - def _cmake_cxx_standard(self): - compileropt = self.settings.compiler.get_safe("cppstd") - if compileropt: - return str(compileropt) - else: - return "11" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def test(self): - if not tools.cross_building(self): + if can_run(self): self._check_binaries_are_found() self._check_root_dictionaries() def _check_binaries_are_found(self): - self.run("root -q", run_environment=True) + self.run("root -q") def _check_root_dictionaries(self): - bin_path = os.path.join("bin", "testrootdictionaries") - self.run(bin_path, run_environment=True) + bin_path = os.path.join(self.cpp.build.bindir, "testrootdictionaries") + self.run(bin_path, env="conanrun") diff --git a/recipes/cern-root/all/test_package/testrootdictionaries.cpp b/recipes/cern-root/all/test_package/testrootdictionaries.cpp index ef52e64f2d077..34c43500fca3b 100644 --- a/recipes/cern-root/all/test_package/testrootdictionaries.cpp +++ b/recipes/cern-root/all/test_package/testrootdictionaries.cpp @@ -1,16 +1,17 @@ -#include -#include #include "TFile.h" #include "TTree.h" #include "TTreeReader.h" #include "Event.hpp" +#include +#include void check(bool result, std::string message) { - if (!result) { throw std::runtime_error("ERROR : testrootdictionaries failed : " + message); } + if (!result) { + throw std::runtime_error("ERROR : testrootdictionaries failed : " + message); + } } - void create_test_file(std::string name, const int Nevent, const int Npart) { auto tfile = TFile::Open(name.c_str(), "RECREATE"); auto tree = new TTree("tree", "tree"); @@ -30,7 +31,6 @@ void create_test_file(std::string name, const int Nevent, const int Npart) { delete tfile; } - void read_test_file(std::string name, const int Nevent, const int Npart) { auto tfile = TFile::Open(name.c_str(), "READ"); auto tree = tfile->Get("tree"); @@ -48,7 +48,6 @@ void read_test_file(std::string name, const int Nevent, const int Npart) { } } - int main() { std::cout << "--- testrootdictionaries " << std::endl; const std::string fname = "testevents.root"; @@ -59,5 +58,3 @@ int main() { std::cout << "--- testrootdictionaries... ok." << std::endl; return 0; } - - diff --git a/recipes/cern-root/all/test_v1_package/CMakeLists.txt b/recipes/cern-root/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..91630d79f4abb --- /dev/null +++ b/recipes/cern-root/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/cern-root/all/test_v1_package/conanfile.py b/recipes/cern-root/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a787e18e8a189 --- /dev/null +++ b/recipes/cern-root/all/test_v1_package/conanfile.py @@ -0,0 +1,46 @@ +from conans import CMake, ConanFile, RunEnvironment, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def configure(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._minimum_cpp_standard) + + @property + def _minimum_cpp_standard(self): + return 11 + + def build(self): + env_build = RunEnvironment(self) + with tools.environment_append(env_build.vars): + cmake = CMake(self) + cmake.configure( + defs={ + "CMAKE_CXX_STANDARD": self._cmake_cxx_standard, + } + ) + cmake.build() + + @property + def _cmake_cxx_standard(self): + compileropt = self.settings.compiler.get_safe("cppstd") + if compileropt: + return str(compileropt) + else: + return "11" + + def test(self): + if not tools.cross_building(self): + self._check_binaries_are_found() + self._check_root_dictionaries() + + def _check_binaries_are_found(self): + self.run("root -q", run_environment=True) + + def _check_root_dictionaries(self): + bin_path = os.path.join("bin", "testrootdictionaries") + self.run(bin_path, run_environment=True) From 80361f5f9c11a5bc78cb2c3f68d2ee10addebb02 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 7 Aug 2023 14:25:40 +0300 Subject: [PATCH 2/7] cern-root: bump deps --- recipes/cern-root/all/conanfile.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/recipes/cern-root/all/conanfile.py b/recipes/cern-root/all/conanfile.py index 3b67e4bd743c8..536bd6b07a88c 100644 --- a/recipes/cern-root/all/conanfile.py +++ b/recipes/cern-root/all/conanfile.py @@ -66,24 +66,24 @@ def layout(self): cmake_layout(self, src_folder="src") def requirements(self): - self.requires("cfitsio/4.2.0") + self.requires("cfitsio/4.3.0") self.requires("fftw/3.3.10") self.requires("giflib/5.2.1") self.requires("glew/2.2.0") self.requires("glu/system") - self.requires("libcurl/8.1.2") + self.requires("libcurl/[>=7.78 <9]") self.requires("libjpeg/9e") self.requires("libpng/1.6.40") - self.requires("libxml2/2.11.4") + self.requires("libxml2/2.11.5") self.requires("lz4/1.9.4") self.requires("opengl/system") self.requires("openssl/[>=1.1 <4]") self.requires("pcre/8.45") - self.requires("sqlite3/3.42.0") - self.requires("onetbb/2020.3") + self.requires("sqlite3/3.44.0") + self.requires("onetbb/2021.10.0") self.requires("xorg/system") - self.requires("xxhash/0.8.1") - self.requires("xz_utils/5.4.2") + self.requires("xxhash/0.8.2") + self.requires("xz_utils/5.4.4") self.requires("zstd/1.5.5") def validate(self): From 386b88ec9348eb051d9982f95d56c028402e5743 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 21 Nov 2023 17:32:30 +0200 Subject: [PATCH 3/7] cern-root: CMake improvements --- recipes/cern-root/all/conanfile.py | 33 +++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/recipes/cern-root/all/conanfile.py b/recipes/cern-root/all/conanfile.py index 536bd6b07a88c..6f495cfb6e320 100644 --- a/recipes/cern-root/all/conanfile.py +++ b/recipes/cern-root/all/conanfile.py @@ -1,5 +1,6 @@ import glob import os +import re import shutil import stat @@ -68,6 +69,7 @@ def layout(self): def requirements(self): self.requires("cfitsio/4.3.0") self.requires("fftw/3.3.10") + self.requires("freetype/2.13.2") self.requires("giflib/5.2.1") self.requires("glew/2.2.0") self.requires("glu/system") @@ -76,11 +78,11 @@ def requirements(self): self.requires("libpng/1.6.40") self.requires("libxml2/2.11.5") self.requires("lz4/1.9.4") + self.requires("onetbb/2021.10.0") self.requires("opengl/system") self.requires("openssl/[>=1.1 <4]") self.requires("pcre/8.45") self.requires("sqlite3/3.44.0") - self.requires("onetbb/2021.10.0") self.requires("xorg/system") self.requires("xxhash/0.8.2") self.requires("xz_utils/5.4.4") @@ -91,19 +93,14 @@ def validate(self): self._enforce_libcxx_requirements() def _enforce_minimum_compiler_version(self): - if self.settings.compiler.get_safe("cppstd"): + if self.settings.compiler.cppstd: check_min_cppstd(self, self._minimum_cpp_standard) min_version = self._minimum_compilers_version.get(str(self.settings.compiler)) - if not min_version: - self.output.warning( - f"{self.name} recipe lacks information about the {self.settings.compiler} compiler support." + if min_version and Version(self.settings.compiler.version) < min_version: + raise ConanInvalidConfiguration( + f"{self.name} requires C++{self._minimum_cpp_standard} support. " + f"The current compiler {self.settings.compiler} {self.settings.compiler.version} does not support it." ) - else: - if Version(self.settings.compiler.version) < min_version: - raise ConanInvalidConfiguration( - f"{self.name} requires C++{self._minimum_cpp_standard} support. " - f"The current compiler {self.settings.compiler} {self.settings.compiler.version} does not support it." - ) def _enforce_libcxx_requirements(self): libcxx = self.settings.get_safe("compiler.libcxx") @@ -174,6 +171,10 @@ def generate(self): tc.generate() tc = CMakeDeps(self) + tc.set_property("openssl", "cmake_file_name", "OPENSSL") + tc.set_property("xz_utils", "cmake_file_name", "LIBLZMA") + tc.set_property("xxhash", "cmake_file_name", "XXHASH") + tc.set_property("pcre", "cmake_target_name", "PCRE::PCRE") tc.set_property("pcre", "cmake_target_name", "PCRE::PCRE") tc.set_property("xxhash", "cmake_target_name", "xxHash::xxHash") tc.set_property("lz4", "cmake_target_name", "LZ4::LZ4") @@ -185,6 +186,14 @@ def _patch_source_cmake(self): "set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)", "list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)") + # Convert all find_package names to upper case to ensure the CMake vars created by Conan + # are upper case as well, matching the project's conventions. + # Add CONFIG to avoid using system libraries, if possible. + path = self.source_path.joinpath("cmake", "modules", "SearchInstalledSoftware.cmake") + content = re.sub(r"find_package\((\S+) ", lambda m: f"find_package({m[1].upper()} CONFIG ", path.read_text()) + content = content.replace("X11 CONFIG", "X11") + path.write_text(content) + def _fix_source_permissions(self): # Fix execute permissions on scripts for pattern in [ @@ -207,7 +216,7 @@ def _move_findcmake_conan_to_root_dir(self): @property def _cmake_cxx_standard(self): - return str(self.settings.get_safe("compiler.cppstd", "11")) + return str(self.settings.get_safe("compiler.cppstd", self._minimum_cpp_standard)) @property def _cmake_pyrootopt(self): From e589049430dd73bdcb46d02dc66c4a143e448092 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 28 Nov 2023 18:33:10 +0200 Subject: [PATCH 4/7] cern-root: fix build, add more deps --- recipes/cern-root/all/conan_deps.cmake | 75 ++++++++++++++ recipes/cern-root/all/conanfile.py | 131 ++++++++++++++++++------- 2 files changed, 173 insertions(+), 33 deletions(-) create mode 100644 recipes/cern-root/all/conan_deps.cmake diff --git a/recipes/cern-root/all/conan_deps.cmake b/recipes/cern-root/all/conan_deps.cmake new file mode 100644 index 0000000000000..2eab36d1be9d4 --- /dev/null +++ b/recipes/cern-root/all/conan_deps.cmake @@ -0,0 +1,75 @@ +macro(custom_find_package name) + find_package(${name} ${ARGN} + # Allow only Conan packages + NO_DEFAULT_PATH + PATHS ${CMAKE_PREFIX_PATH} + ) + string(TOUPPER ${name} name_upper) + set(${name_upper}_FOUND TRUE) + set(${name_upper}_VERSION_STRING ${${name}_VERSION_STRING}) + set(${name_upper}_INCLUDE_DIRS ${${name}_INCLUDE_DIRS}) + set(${name_upper}_INCLUDE_DIR ${${name}_INCLUDE_DIR}) + set(${name_upper}_LIBRARIES ${${name}_LIBRARIES}) + set(${name_upper}_DEFINITIONS ${${name}_DEFINITIONS}) + unset(name_upper) +endmacro() + +# All packages listed under https://github.com/root-project/root/blob/v6-22-06/cmake/modules/SearchInstalledSoftware.cmake +#custom_find_package(AfterImage REQUIRED CONFIG) +#custom_find_package(Alien REQUIRED CONFIG) +custom_find_package(Arrow REQUIRED CONFIG) +#custom_find_package(BLAS REQUIRED CONFIG) +custom_find_package(CFITSIO REQUIRED CONFIG) +#custom_find_package(CUDA REQUIRED CONFIG) +#custom_find_package(CuDNN REQUIRED CONFIG) +custom_find_package(CURL REQUIRED CONFIG) +#custom_find_package(Davix REQUIRED CONFIG) +#custom_find_package(DCAP REQUIRED CONFIG) +#custom_find_package(FastCGI REQUIRED CONFIG) +custom_find_package(FFTW REQUIRED CONFIG) +custom_find_package(Freetype REQUIRED CONFIG) +#custom_find_package(FTGL REQUIRED CONFIG) +#custom_find_package(GFAL REQUIRED CONFIG) +#custom_find_package(gl2ps REQUIRED CONFIG) +custom_find_package(GLEW REQUIRED) +#custom_find_package(Graphviz REQUIRED CONFIG) +custom_find_package(GSL REQUIRED CONFIG) +#custom_find_package(jemalloc REQUIRED CONFIG) +custom_find_package(LibLZMA REQUIRED CONFIG) +find_package(libuuid QUIET) +custom_find_package(LibXml2 REQUIRED CONFIG) +custom_find_package(LZ4 REQUIRED CONFIG) +#custom_find_package(Monalisa REQUIRED CONFIG) +#custom_find_package(MPI REQUIRED CONFIG) +custom_find_package(MySQL REQUIRED CONFIG) +custom_find_package(ODBC REQUIRED CONFIG) +find_package(OpenGL REQUIRED) +custom_find_package(OpenSSL REQUIRED CONFIG) +#custom_find_package(Oracle REQUIRED CONFIG) +custom_find_package(PCRE REQUIRED CONFIG) +custom_find_package(PostgreSQL REQUIRED CONFIG) +#custom_find_package(Pythia6 REQUIRED CONFIG) +#custom_find_package(Pythia8 REQUIRED CONFIG) +#custom_find_package(R REQUIRED CONFIG) +custom_find_package(Sqlite REQUIRED CONFIG) +custom_find_package(TBB REQUIRED CONFIG) +#custom_find_package(tcmalloc REQUIRED CONFIG) +#custom_find_package(Unuran REQUIRED CONFIG) +#custom_find_package(Vc REQUIRED CONFIG) +#custom_find_package(Vdt REQUIRED CONFIG) +#custom_find_package(VecCore REQUIRED CONFIG) +#custom_find_package(VecGeom REQUIRED CONFIG) +find_package(X11 REQUIRED) +#custom_find_package(XROOTD REQUIRED CONFIG) +custom_find_package(xxHash REQUIRED CONFIG) +custom_find_package(ZLIB REQUIRED CONFIG) +custom_find_package(ZSTD REQUIRED CONFIG) + +if(asimage) + custom_find_package(GIF REQUIRED CONFIG) + custom_find_package(JPEG REQUIRED CONFIG) + custom_find_package(PNG REQUIRED CONFIG) + custom_find_package(TIFF REQUIRED CONFIG) +endif() + +link_libraries(FreeType::FreeType) diff --git a/recipes/cern-root/all/conanfile.py b/recipes/cern-root/all/conanfile.py index 6f495cfb6e320..12f711d27541d 100644 --- a/recipes/cern-root/all/conanfile.py +++ b/recipes/cern-root/all/conanfile.py @@ -1,7 +1,5 @@ import glob import os -import re -import shutil import stat from conan import ConanFile @@ -34,13 +32,19 @@ class CernRootConan(ConanFile): # in future we may allow the user to specify a version when # libPython is available in Conan Center Index. # FIXME: add option to use CCI Python package when it is available + "asimage": [True, False], "python": ["off", "system"], } default_options = { "fPIC": True, + "asimage": False, # FIXME: requires builtin_afterimage, but its build is broken # default python=off as there is currently no libpython in Conan center "python": "off", } + options_description = { + "asimage": "Enable support for image processing via libAfterImage", + "python": "Enable support for automatic Python bindings (PyROOT)", + } @property def _minimum_cpp_standard(self): @@ -57,6 +61,7 @@ def _minimum_compilers_version(self): } def export_sources(self): + copy(self, "conan_deps.cmake", self.recipe_folder, os.path.join(self.export_sources_folder, "src")) export_conandata_patches(self) def config_options(self): @@ -67,26 +72,36 @@ def layout(self): cmake_layout(self, src_folder="src") def requirements(self): + self.requires("arrow/14.0.1") self.requires("cfitsio/4.3.0") self.requires("fftw/3.3.10") self.requires("freetype/2.13.2") - self.requires("giflib/5.2.1") self.requires("glew/2.2.0") - self.requires("glu/system") + self.requires("gsl/2.7") self.requires("libcurl/[>=7.78 <9]") - self.requires("libjpeg/9e") - self.requires("libpng/1.6.40") + self.requires("libmysqlclient/8.1.0") + self.requires("libpq/15.4") self.requires("libxml2/2.11.5") self.requires("lz4/1.9.4") - self.requires("onetbb/2021.10.0") + self.requires("odbc/2.3.11") + self.requires("onetbb/2020.3.3") self.requires("opengl/system") self.requires("openssl/[>=1.1 <4]") self.requires("pcre/8.45") - self.requires("sqlite3/3.44.0") + self.requires("sqlite3/3.44.2") self.requires("xorg/system") self.requires("xxhash/0.8.2") - self.requires("xz_utils/5.4.4") + self.requires("xz_utils/5.4.5") + self.requires("zlib/[>=1.2.11 <2]") self.requires("zstd/1.5.5") + if self.settings in ["Linux", "FreeBSD"]: + self.requires("util-linux-libuuid/2.39.2") + + if self.options.asimage: + self.requires("giflib/5.2.1") + self.requires("libjpeg/9e") + self.requires("libpng/1.6.40") + self.requires("libtiff/4.6.0") def validate(self): self._enforce_minimum_compiler_version() @@ -119,10 +134,14 @@ def _make_file_executable(filename): def generate(self): tc = CMakeToolchain(self) + # Configure build options found at + # https://github.com/root-project/root/blob/v6-22-06/cmake/modules/RootBuildOptions.cmake#L80-L193 + tc.variables["CMAKE_CXX_STANDARD"] = self._cmake_cxx_standard tc.variables["BUILD_SHARED_LIBS"] = True + tc.variables["shared"] = True + tc.variables["asimage"] = self.options.asimage tc.variables["fail-on-missing"] = True - tc.variables["CMAKE_CXX_STANDARD"] = self._cmake_cxx_standard - tc.variables["gnuinstall"] = True + tc.variables["soversion"] = True tc.variables["soversion"] = True # Disable builtins and use Conan deps where available tc.variables["builtin_cfitsio"] = False @@ -130,6 +149,7 @@ def generate(self): tc.variables["builtin_fftw3"] = False tc.variables["builtin_freetype"] = False tc.variables["builtin_glew"] = False + tc.variables["builtin_gsl"] = False tc.variables["builtin_lz4"] = False tc.variables["builtin_lzma"] = False tc.variables["builtin_openssl"] = False @@ -139,18 +159,22 @@ def generate(self): tc.variables["builtin_zlib"] = False tc.variables["builtin_zstd"] = False # Enable builtins where there is no Conan package - tc.variables["builtin_afterimage"] = True # FIXME : replace with afterimage CCI package when available - tc.variables["builtin_gsl"] = True # FIXME : replace with gsl CCI package when available + tc.variables["builtin_afterimage"] = False # FIXME : replace with afterimage CCI package when available tc.variables["builtin_gl2ps"] = True # FIXME : replace with gl2ps CCI package when available tc.variables["builtin_ftgl"] = True # FIXME : replace with ftgl CCI package when available tc.variables["builtin_vdt"] = True # FIXME : replace with vdt CCI package when available + tc.variables["builtin_clang"] = True + tc.variables["builtin_llvm"] = True + # Enable optional dependencies + tc.variables["arrow"] = True + tc.variables["mysql"] = True + tc.variables["odbc"] = True + tc.variables["pgsql"] = True # No Conan packages available for these dependencies yet tc.variables["davix"] = False # FIXME : switch on if davix CCI package available tc.variables["pythia6"] = False # FIXME : switch on if pythia6 CCI package available tc.variables["pythia8"] = False # FIXME : switch on if pythia8 CCI package available - tc.variables["mysql"] = False # FIXME : switch on if mysql CCI package available tc.variables["oracle"] = False - tc.variables["pgsql"] = False # FIXME: switch on if PostgreSQL CCI package available tc.variables["gfal"] = False # FIXME: switch on if gfal CCI package available tc.variables["tmva-pymva"] = False # FIXME: switch on if Python CCI package available tc.variables["xrootd"] = False # FIXME: switch on if xrootd CCI package available @@ -170,30 +194,73 @@ def generate(self): tc.variables["CMAKE_INSTALL_SYSCONFDIR"] = "res/etc" tc.generate() + cmake_pkgs = { + "arrow": "Arrow", + "cfitsio": "CFITSIO", + "fftw": "FFTW", + "freetype": "Freetype", + "giflib": "GIF", + "glew": "GLEW", + "gsl": "GSL", + "libcurl": "CURL", + "libjpeg": "JPEG", + "libmysqlclient": "MySQL", + "libpng": "PNG", + "libpq": "PostgreSQL", + "libxml2": "LibXml2", + "lz4": "LZ4", + "odbc": "ODBC", + "onetbb": "TBB", + "openssl": "OpenSSL", + "pcre": "PCRE", + "sqlite3": "Sqlite", + "tiff": "TIFF", + "xxhash": "xxHash", + "xz_utils": "LibLZMA", + "zlib": "ZLIB", + "zstd": "ZSTD", + # "afterimage": "AfterImage", + # "alien": "Alien", + # "blas": "BLAS", + # "cuda": "CUDA", + # "cudnn": "CuDNN", + # "davix": "Davix", + # "dcap": "DCAP", + # "fastcgi": "FastCGI", + # "ftgl": "FTGL", + # "gfal": "GFAL", + # "gl2ps": "gl2ps", + # "graphviz": "Graphviz", + # "jemalloc": "jemalloc", + # "monalisa": "Monalisa", + # "mpi": "MPI", + # "oracle": "Oracle", + # "pythia6": "Pythia6", + # "pythia8": "Pythia8", + # "r": "R", + # "tcmalloc": "tcmalloc", + # "unuran": "Unuran", + # "vc": "Vc", + # "vdt": "Vdt", + # "veccore": "VecCore", + # "vecgeom": "VecGeom", + # "xrootd": "XROOTD", + } + tc = CMakeDeps(self) - tc.set_property("openssl", "cmake_file_name", "OPENSSL") - tc.set_property("xz_utils", "cmake_file_name", "LIBLZMA") - tc.set_property("xxhash", "cmake_file_name", "XXHASH") - tc.set_property("pcre", "cmake_target_name", "PCRE::PCRE") + for package, cmake_name in cmake_pkgs.items(): + tc.set_property(package, "cmake_file_name", cmake_name) + tc.set_property("freetype", "cmake_target_name", "FreeType::FreeType") tc.set_property("pcre", "cmake_target_name", "PCRE::PCRE") tc.set_property("xxhash", "cmake_target_name", "xxHash::xxHash") tc.set_property("lz4", "cmake_target_name", "LZ4::LZ4") tc.generate() def _patch_source_cmake(self): - rm(self, "FindTBB.cmake", os.path.join(self.source_folder, "cmake", "modules")) replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)", "list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)") - # Convert all find_package names to upper case to ensure the CMake vars created by Conan - # are upper case as well, matching the project's conventions. - # Add CONFIG to avoid using system libraries, if possible. - path = self.source_path.joinpath("cmake", "modules", "SearchInstalledSoftware.cmake") - content = re.sub(r"find_package\((\S+) ", lambda m: f"find_package({m[1].upper()} CONFIG ", path.read_text()) - content = content.replace("X11 CONFIG", "X11") - path.write_text(content) - def _fix_source_permissions(self): # Fix execute permissions on scripts for pattern in [ @@ -209,10 +276,8 @@ def _patch_sources(self): apply_conandata_patches(self) self._patch_source_cmake() self._fix_source_permissions() - - def _move_findcmake_conan_to_root_dir(self): - for f in ["opengl_system", "GLEW", "glu", "TBB", "LibXml2", "ZLIB", "SQLite3"]: - shutil.copy(f"Find{f}.cmake", os.path.join(self.source_folder, "cmake", "modules")) + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "project(ROOT)", "project(ROOT)\n\ninclude(conan_deps.cmake)") @property def _cmake_cxx_standard(self): @@ -229,7 +294,7 @@ def build(self): cmake.build() def package(self): - copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) cmake = CMake(self) cmake.install() # Fix for CMAKE-MODULES-CONFIG-FILES (KB-H016) From 90791685b3e11dbc9604e6092add5bbd9083343c Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 28 Nov 2023 20:00:25 +0200 Subject: [PATCH 5/7] cern-root: fix libXft not being found --- recipes/cern-root/all/conan_deps.cmake | 11 ++++++++++- recipes/cern-root/all/conanfile.py | 13 +++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/recipes/cern-root/all/conan_deps.cmake b/recipes/cern-root/all/conan_deps.cmake index 2eab36d1be9d4..5a8af00926720 100644 --- a/recipes/cern-root/all/conan_deps.cmake +++ b/recipes/cern-root/all/conan_deps.cmake @@ -59,7 +59,6 @@ custom_find_package(TBB REQUIRED CONFIG) #custom_find_package(Vdt REQUIRED CONFIG) #custom_find_package(VecCore REQUIRED CONFIG) #custom_find_package(VecGeom REQUIRED CONFIG) -find_package(X11 REQUIRED) #custom_find_package(XROOTD REQUIRED CONFIG) custom_find_package(xxHash REQUIRED CONFIG) custom_find_package(ZLIB REQUIRED CONFIG) @@ -72,4 +71,14 @@ if(asimage) custom_find_package(TIFF REQUIRED CONFIG) endif() +if(x11) + find_package(X11 REQUIRED) + custom_find_package(X11_Xft REQUIRED CONFIG) + set(X11_Xft_LIB ${X11_Xft_LIBRARIES}) + set(X11_Xft_INCLUDE_PATH ${X11_Xft_INCLUDE_DIR}/X11/Xft/Xft.h) + custom_find_package(X11_Xpm REQUIRED CONFIG) + set(X11_Xpm_LIB ${X11_Xpm_LIBRARIES}) + set(X11_Xpm_INCLUDE_PATH ${X11_Xpm_INCLUDE_DIR}/X11/xpm.h) +endif() + link_libraries(FreeType::FreeType) diff --git a/recipes/cern-root/all/conanfile.py b/recipes/cern-root/all/conanfile.py index 12f711d27541d..ba67402ea079e 100644 --- a/recipes/cern-root/all/conanfile.py +++ b/recipes/cern-root/all/conanfile.py @@ -89,12 +89,15 @@ def requirements(self): self.requires("openssl/[>=1.1 <4]") self.requires("pcre/8.45") self.requires("sqlite3/3.44.2") - self.requires("xorg/system") self.requires("xxhash/0.8.2") self.requires("xz_utils/5.4.5") self.requires("zlib/[>=1.2.11 <2]") self.requires("zstd/1.5.5") - if self.settings in ["Linux", "FreeBSD"]: + + if self.settings.os in ["Linux", "FreeBSD"]: + self.requires("xorg/system") + self.requires("libxft/2.3.8") + self.requires("libxpm/3.5.13") self.requires("util-linux-libuuid/2.39.2") if self.options.asimage: @@ -142,7 +145,7 @@ def generate(self): tc.variables["asimage"] = self.options.asimage tc.variables["fail-on-missing"] = True tc.variables["soversion"] = True - tc.variables["soversion"] = True + tc.variables["x11"] = self.settings.os in ["Linux", "FreeBSD"] # Disable builtins and use Conan deps where available tc.variables["builtin_cfitsio"] = False tc.variables["builtin_davix"] = False @@ -159,7 +162,7 @@ def generate(self): tc.variables["builtin_zlib"] = False tc.variables["builtin_zstd"] = False # Enable builtins where there is no Conan package - tc.variables["builtin_afterimage"] = False # FIXME : replace with afterimage CCI package when available + tc.variables["builtin_afterimage"] = self.options.asimage # FIXME : replace with afterimage CCI package when available tc.variables["builtin_gl2ps"] = True # FIXME : replace with gl2ps CCI package when available tc.variables["builtin_ftgl"] = True # FIXME : replace with ftgl CCI package when available tc.variables["builtin_vdt"] = True # FIXME : replace with vdt CCI package when available @@ -208,6 +211,8 @@ def generate(self): "libpng": "PNG", "libpq": "PostgreSQL", "libxml2": "LibXml2", + "libxft": "X11_Xft", + "libxpm": "X11_Xpm", "lz4": "LZ4", "odbc": "ODBC", "onetbb": "TBB", From 0b21198295c8b48a513bb8801e243177e347dd2e Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 29 Nov 2023 14:56:10 +0200 Subject: [PATCH 6/7] cern-root: relax TBB version check --- recipes/cern-root/all/conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/cern-root/all/conanfile.py b/recipes/cern-root/all/conanfile.py index ba67402ea079e..a6e288368cf09 100644 --- a/recipes/cern-root/all/conanfile.py +++ b/recipes/cern-root/all/conanfile.py @@ -283,6 +283,9 @@ def _patch_sources(self): self._fix_source_permissions() replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "project(ROOT)", "project(ROOT)\n\ninclude(conan_deps.cmake)") + # Relax TBB version check + replace_in_file(self, os.path.join(self.source_folder, "cmake", "modules", "SearchInstalledSoftware.cmake"), + "TBB 2018", "TBB") @property def _cmake_cxx_standard(self): From 9998b16bc6da3c05bab5b1e2d3e3779c4f1d24bc Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 4 Jan 2024 12:43:09 +0200 Subject: [PATCH 7/7] cern-root: fix invalid define flags in cling build --- recipes/cern-root/all/conandata.yml | 4 ++ recipes/cern-root/all/conanfile.py | 14 ++--- ...0003-backport-empty-define-filtering.patch | 57 +++++++++++++++++++ 3 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 recipes/cern-root/all/patches/0003-backport-empty-define-filtering.patch diff --git a/recipes/cern-root/all/conandata.yml b/recipes/cern-root/all/conandata.yml index 95fdfa6c18619..5cd0942b4f4fb 100644 --- a/recipes/cern-root/all/conandata.yml +++ b/recipes/cern-root/all/conandata.yml @@ -6,3 +6,7 @@ patches: "v6-22-06": - patch_file: "patches/0001-add-missing-includes.patch" - patch_file: "patches/0002-cmake-missing-link-libraries.patch" + - patch_file: "patches/0003-backport-empty-define-filtering.patch" + patch_description: "Backport filtering of empty -D flags" + patch_type: "portability" + patch_source: "https://github.com/root-project/root/blob/798b9b079f7b6c136bdaaf6787729a1bef865429/cmake/modules/RootMacros.cmake" diff --git a/recipes/cern-root/all/conanfile.py b/recipes/cern-root/all/conanfile.py index a6e288368cf09..eccbe35013d65 100644 --- a/recipes/cern-root/all/conanfile.py +++ b/recipes/cern-root/all/conanfile.py @@ -4,7 +4,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration -from conan.tools.build import check_min_cppstd +from conan.tools.build import check_min_cppstd, valid_min_cppstd from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir from conan.tools.scm import Version @@ -137,10 +137,12 @@ def _make_file_executable(filename): def generate(self): tc = CMakeToolchain(self) + tc.variables["CMAKE_PROJECT_ROOT_INCLUDE"] = "conan_deps.cmake" + if not valid_min_cppstd(self, self._minimum_cpp_standard): + tc.variables["CMAKE_CXX_STANDARD"] = self._minimum_cpp_standard + tc.variables["BUILD_SHARED_LIBS"] = True # Configure build options found at # https://github.com/root-project/root/blob/v6-22-06/cmake/modules/RootBuildOptions.cmake#L80-L193 - tc.variables["CMAKE_CXX_STANDARD"] = self._cmake_cxx_standard - tc.variables["BUILD_SHARED_LIBS"] = True tc.variables["shared"] = True tc.variables["asimage"] = self.options.asimage tc.variables["fail-on-missing"] = True @@ -281,16 +283,10 @@ def _patch_sources(self): apply_conandata_patches(self) self._patch_source_cmake() self._fix_source_permissions() - replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), - "project(ROOT)", "project(ROOT)\n\ninclude(conan_deps.cmake)") # Relax TBB version check replace_in_file(self, os.path.join(self.source_folder, "cmake", "modules", "SearchInstalledSoftware.cmake"), "TBB 2018", "TBB") - @property - def _cmake_cxx_standard(self): - return str(self.settings.get_safe("compiler.cppstd", self._minimum_cpp_standard)) - @property def _cmake_pyrootopt(self): return self.options.python != "off" diff --git a/recipes/cern-root/all/patches/0003-backport-empty-define-filtering.patch b/recipes/cern-root/all/patches/0003-backport-empty-define-filtering.patch new file mode 100644 index 0000000000000..37b86fd1997f9 --- /dev/null +++ b/recipes/cern-root/all/patches/0003-backport-empty-define-filtering.patch @@ -0,0 +1,57 @@ +--- cmake/modules/RootMacros.cmake ++++ cmake/modules/RootMacros.cmake +@@ -179,7 +179,10 @@ + + IF(TARGET ${dictionary}) + LIST(APPEND include_dirs $) +- LIST(APPEND definitions $) ++ # The COMPILE_DEFINITIONS list might contain empty elements. These are ++ # removed with the FILTER generator expression, excluding elements that ++ # match the ^$ regexp (only matches empty strings). ++ LIST(APPEND definitions "$,EXCLUDE,^$>") + ENDIF() + + add_custom_command( +@@ -187,7 +190,7 @@ + COMMAND ${ROOT_genreflex_CMD} + ARGS ${headerfiles} -o ${gensrcdict} ${rootmapopts} --select=${selectionfile} + --gccxmlpath=${GCCXML_home}/bin ${ARG_OPTIONS} +- "-I$" ++ "-I$>,;-I>" + "$<$>:-D$>" + DEPENDS ${headerfiles} ${selectionfile} ${ARG_DEPENDS} + +@@ -633,21 +636,26 @@ + + # get target properties added after call to ROOT_GENERATE_DICTIONARY() + if(TARGET ${ARG_MODULE}) +- if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15) +- set(module_incs $>) +- else() +- set(module_incs $) +- endif() +- set(module_defs $) ++ # NOTE that module_sysincs is already part of ${module_sysincs}. But -isystem "wins", ++ # and list exclusion for generator expressions is too complex. ++ set(module_incs $>) ++ set(module_sysincs $>) ++ # The COMPILE_DEFINITIONS list might contain empty elements. These are ++ # removed with the FILTER generator expression, excluding elements that ++ # match the ^$ regexp (only matches empty strings). ++ set(module_defs "$,EXCLUDE,^$>") + endif() + endif() + + #---call rootcint------------------------------------------ + add_custom_command(OUTPUT ${dictionary}.cxx ${pcm_name} ${rootmap_name} ${cpp_module_file} + COMMAND ${command} -v2 -f ${dictionary}.cxx ${newargs} ${excludepathsargs} ${rootmapargs} ++ ${ARG_OPTIONS} + ${definitions} "$<$:-D$>" ++ ${compIncPaths} ++ "$<$:-isystem;$>" + ${includedirs} "$<$:-I$>" +- ${ARG_OPTIONS} ${headerfiles} ${_linkdef} ++ ${headerfiles} ${_linkdef} + IMPLICIT_DEPENDS ${_implicitdeps} + DEPENDS ${_list_of_header_dependencies} ${_linkdef} ${ROOTCINTDEP} + ${MODULE_LIB_DEPENDENCY} ${ARG_EXTRA_DEPENDENCIES}