Skip to content

Commit

Permalink
[CMake] Only replace find_package if required
Browse files Browse the repository at this point in the history
Our CMake code modifies `find_package` to ignore any ROOT builtins, such
that the builtin LLVM doesn't find and use system versions of the
builtin dependencies.

This is a bit hacky, but fortunately this needs to be done only when
builtins are used.

Therefore, this commit suggests to only do this redefinition of
`find_package` if any builtins are used.

This closes #8633, where it was requested to avoid this hack for the
sake of being compatible with the `vcpkg` package manager.

Although the hack is not completely removed, it is removed for the case
where not builtins are used, which is probably what is done when using a
C++ package manager to manage dependencies.
  • Loading branch information
guitargeek authored and pcanal committed Dec 26, 2024
1 parent 25cdee1 commit b1bf58d
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions cmake/modules/SearchInstalledSoftware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ include(FindPackageHandleStandardArgs)
set(lcgpackages http://lcgpackages.web.cern.ch/lcgpackages/tarFiles/sources)
string(REPLACE "-Werror " "" ROOT_EXTERNAL_CXX_FLAGS "${CMAKE_CXX_FLAGS} ")

macro(find_package)
if(NOT "${ARGV0}" IN_LIST ROOT_BUILTINS)
_find_package(${ARGV})
endif()
endmacro()

#---On MacOSX, try to find frameworks after standard libraries or headers------------
set(CMAKE_FIND_FRAMEWORK LAST)

Expand Down Expand Up @@ -2078,3 +2072,17 @@ endif()
if(test_distrdf_dask)
find_package(Dask 2022.08.1 REQUIRED)
endif()

#------------------------------------------------------------------------------------
# Modify find_package to ignore any ROOT builtins, such that the builtin LLVM
# doesn't find and use system versions of the builtin dependencies. This is a
# bit hacky, but fortunately this needs to be done only when builtins are used.
#
# See also discussion on GitHub: https://github.com/root-project/root/issues/8633
if(ROOT_BUILTINS)
macro(find_package)
if(NOT "${ARGV0}" IN_LIST ROOT_BUILTINS)
_find_package(${ARGV})
endif()
endmacro()
endif()

0 comments on commit b1bf58d

Please sign in to comment.