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}