Integrating incomplete system ROOT installation into CMake project issues warnings about missing files

Issue

Hello!
When configuring CMake project which uses incomplete system ROOT installation, a lot of warnings appear like this:

CMake Warning at /usr/share/root/cmake/ROOTConfig-targets.cmake:1552 (message):
  The imported target "ROOT::TestSupport" references the file

     "/usr/lib64/root/TestSupport/objects-RelWithDebInfo/TestSupport/src/TestSupport.cxx.o"

  but this file does not exist.

  If this target is used you need to install the package that provides this

  file using "dnf install".

  If this target is not used this warning can be ignored.
Call Stack (most recent call first):
  /usr/share/root/cmake/ROOTConfig.cmake:113 (include)
  CMakeLists.txt:33 (find_package)

This is happening despite I explicitly declare only needed components:

cmake_minimum_required(VERSION 3.26)

project(Test VERSION 0.1.0 LANGUAGES CXX)

find_package(ROOT 6 QUIET CONFIG REQUIRED COMPONENTS Core)

Note that I use QUIET option and don’t add any libraries and executables. This must be a minimum configuration.

I think that there is a problem are two problems

  1. ROOTConfig-targets.cmake generated during build unconditionally imports all targets which were built. This behavior might be hard to fix, as it would require refactoring of CMake config scripts.
  2. ROOT config script doesn’t respect QUIET option.

Upd: issue reproduced with latest CMake 3.31.5, and docs say

In Config mode find_package handles REQUIRED, QUIET, and [version] options automatically but leaves it to the package configuration file to handle components in a way that makes sense for the package.
find_package — CMake 3.31.5 Documentation

Currently the only option to avoid warnings seems to be to install all system ROOT packages, which, however, somewhat contradicts the intent to make ROOT more modular and lightweight in usage (that’s my impression).

So I would like to ask if the problems mentioned could be addressed?
May be there is some CMake trick or approach that I’m missing?

Edit: I found similar but unresolved thread:

To reproduce

# make a minimal project structure
mkdir test-root-project
cd test-root-project
mkdir build

# enter CMake code from above text
cat << EOF > CMakeLists.txt
cmake_minimum_required(VERSION 3.26)

project(Test VERSION 0.1.0 LANGUAGES CXX)

find_package(ROOT 6 QUIET CONFIG REQUIRED COMPONENTS Core)
EOF

dnf install --assumeyes epel-release
dnf config-manager --set-enabled crb
dnf upgrade --assumeyes 

# make sure that no ROOT packages are installed!
# dnf remove root-*

dnf install --assumeyes cmake root

# observe warnings
cmake -S . -B build

Setup

ROOT Version: 6.34.02
Platform: AlmaLinux 9.5 (Teal Serval) x86-64
Compiler: gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-2)

I have updated the post after some investigation if the problem is on CMake side. It seems that QUIET option works as intended (errors aren’t silenced, and missing file is an error).

To summarize, I think ROOT config script could be improved to check components passed to find_package and only import the necessary ones, if I’m not missing anything.

Hi @Ako_b,

Thank you for your initial post and for sharing your additional findings!
Adding @danilo and @bellenot who are experts on ROOT’s build system.

Best,
Lukas

1 Like

@Ako_b thanks for reporting, we will investigate

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.