Skip to content

Commit

Permalink
cern-root: fix invalid define flags in cling build
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Jan 4, 2024
1 parent 0b21198 commit 9998b16
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 9 deletions.
4 changes: 4 additions & 0 deletions recipes/cern-root/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ patches:
"v6-22-06":
- patch_file: "patches/0001-add-missing-includes.patch"

Check warning on line 7 in recipes/cern-root/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0001-add ... ^ (line: 7)
- patch_file: "patches/0002-cmake-missing-link-libraries.patch"

Check warning on line 8 in recipes/cern-root/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. required key(s) 'patch_description', 'patch_type' not found in - patch_file: patches/0002-cma ... ^ (line: 8)
- 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"
14 changes: 5 additions & 9 deletions recipes/cern-root/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
--- cmake/modules/RootMacros.cmake
+++ cmake/modules/RootMacros.cmake
@@ -179,7 +179,10 @@

IF(TARGET ${dictionary})
LIST(APPEND include_dirs $<TARGET_PROPERTY:${dictionary},INCLUDE_DIRECTORIES>)
- LIST(APPEND definitions $<TARGET_PROPERTY:${dictionary},COMPILE_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 "$<FILTER:$<TARGET_PROPERTY:${dictionary},COMPILE_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$<JOIN:${include_dirs},;-I>"
+ "-I$<JOIN:$<REMOVE_DUPLICATES:$<FILTER:${include_dirs},EXCLUDE,^$>>,;-I>"
"$<$<BOOL:$<JOIN:${definitions},>>:-D$<JOIN:${definitions},;-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 $<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${ARG_MODULE},INCLUDE_DIRECTORIES>>)
- else()
- set(module_incs $<TARGET_PROPERTY:${ARG_MODULE},INCLUDE_DIRECTORIES>)
- endif()
- set(module_defs $<TARGET_PROPERTY:${ARG_MODULE},COMPILE_DEFINITIONS>)
+ # 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 $<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${ARG_MODULE},INCLUDE_DIRECTORIES>>)
+ set(module_sysincs $<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${ARG_MODULE},INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>>)
+ # 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 "$<FILTER:$<TARGET_PROPERTY:${ARG_MODULE},COMPILE_DEFINITIONS>,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} "$<$<BOOL:${module_defs}>:-D$<JOIN:${module_defs},;-D>>"
+ ${compIncPaths}
+ "$<$<BOOL:${module_sysincs}>:-isystem;$<JOIN:${module_sysincs},;-isystem;>>"
${includedirs} "$<$<BOOL:${module_incs}>:-I$<JOIN:${module_incs},;-I>>"
- ${ARG_OPTIONS} ${headerfiles} ${_linkdef}
+ ${headerfiles} ${_linkdef}
IMPLICIT_DEPENDS ${_implicitdeps}
DEPENDS ${_list_of_header_dependencies} ${_linkdef} ${ROOTCINTDEP}
${MODULE_LIB_DEPENDENCY} ${ARG_EXTRA_DEPENDENCIES}

0 comments on commit 9998b16

Please sign in to comment.