Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target based c make #219

Open
wants to merge 21 commits into
base: cms/master/dd0680311b
Choose a base branch
from

Conversation

smuzaffar
Copy link

No description provided.

For an unknown reason, a res/ header was included, leading to an include
error. The include could be removed without problems.
gtest.h used to be parasitically included in TestSupport.hxx, which
isn't using gtest at all. It's cleaner to include it where it is
actually used.
TestSupport.hxx isn't using gtest, so it does not make sense to include
it here.
VDT used to be configured using variables, but this creates a problem
when VDT is installed in a system directory where ROOT is installed as
well. The -I<VDT_LOCATION> will lead to headers from the installed ROOT
being picked up during compilation.
Here, VDT is configured in a target-based way. When external, it's now
an IMPORTED target, and its include directory is marked as SYSTEM, so
it will not interfere with other ROOT includes.
- Create the target XRootD::XrdCl for usage in ROOT

  Create an IMPORTED target for XRootD that we populate either with a
  system xrootd or with the builtin library. This also solves the
  problem of ROOT's build system picking up ROOT headers when it is
  trying to include xrootd from a system directory where both ROOT and
  xrootd are installed.

  All packages inside ROOT should use the target instead of any CMake
  variables. This way, an update of XRootD's CMake will only affect one
  single location in ROOT.

- Refactor builtin XRootD. Synchronise the variables that the builtin and
  SearchInstalled are setting, and use those to configure the
  ROOT-internal target.

- Add a test for XrdCl headers, since these are used in TNetXNG. If
  xrootd is installed in the system, the XrdCl library might be present
  without the corresponding headers. This would lead to a build error in
  ROOT, so cmake will try to find the headers at configure time to warn
  about a possibly missing package.

- Add a CMAKE_BUILD_RPATH to all ROOT targets in order to find the
  libraries of a builtin XRootD.
Since ROOT already has SSL support, the logic for builtin XRootD could
be simplified by requiring these options to be on.
To help find the builtin openssl location, it is now saved as a cache
variable, which is passed to xrootd.
- Create the target nlohmann_json that will configure all dependent libraries.
- Replace all uses of json with target_link_libraries(... nlohman_json)
- Remove explicit uses of the nlohmann include directory across ROOT.
- Add depedency to RooFitCore, which depends on json through exposed json interface.
- Remove the use of variables for lzma, use target_link_libraries instead.
- Use the same target name as the CMake module: LibLZMA::LibLZMA
For an unknown reason, ROOT's cmake macros were reading all include
directories from the targets they depend on, and doing some manual
processing of those. Due to more extensive use of target-based cmake,
this manual treatment should become obsolete.
This makes the management of include directories simpler, and will allow
for better debugging with CMake.
- Collect all dependency and include-related instructions in one place to
make it more clear what's going on.
- Improve documentation a bit.
- Remove manual treatmant of include directories and link configs, as they should
now be handled automatically by target_link_libraries.
This means that target_link_libraries has to use the PRIVATE/PUBLIC
keyword.
- In case ROOT_GENERATE_DICTIONARY is invoked with a dependency that
doesn't have a dictionary itself, the for loop through dependencies now
just continue()s. Before, this would raise a CMake error.
- The object library with the dictionary file is now linked into the
main library using target_link_libraries().
- When the list of include directories for the dictionary is generated,
the INTERFACE_SYSTEM_INCLUDE_DIRECTORIES of the dependencies is now
honoured. Before, system includes would decay to normal includes.

Unfortunately, PRIVATE includes still decay to normal -I includes. This
can lead header conflicts when ROOT is built while another ROOT is installed
in system include directories, but only for the dictionary files.
Since ROOT include directories are very generously prepended to all targets,
I wasn't able to provoke a header conflict.
Most unit tests in core/thread were running twice:
- Once from ROOT_ADD_UNIT_TEST_DIR, which globs all *.cxx and compiles
them into a test
- Once more from explicitly registering the tests

Here, we register all tests explicitly.
The argument COMPILEMACROS isn't used anywhere, so it can be removed.
- Remove own FindGTest, use the one from CMake.
  Starting from CMake 3.23, the GTest libraries have canonical names.
- Replace uses of legacy targets like "gtest" in ROOT with canonical
  target names such as GTest::gtest or GTest::gtest_main.
- Create ALIAS targets like in CMake 3.23 such as GTest::gtest_main.
  For CMake < 3.23, this will allow using the standard FindGTest with
  the modern names already in cmake 3.20.
Explicitly list GTest::gmock in core.
RooFit multiprocess privately depends on nlohmann_json.
The res headers use it too, but since the dependency
is private, the tests cannot use it unless they explicitly
request nlohmann_json, too.
@smuzaffar
Copy link
Author

please test for CMSSW_15_1_ROOT6_X

@cmsbuild
Copy link

A new Pull Request was created by @smuzaffar for branch cms/master/dd0680311b.

@iarspider, @smuzaffar can you please review it and eventually sign? Thanks.
@antoniovilela, @mandrenguyen, @rappoccio, @sextonkennedy you are the release manager for this.
cms-bot commands are listed here

@cmsbuild
Copy link

cms-bot internal usage

@cmsbuild
Copy link

-1

Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-1860d9/44688/summary.html
COMMIT: 164600c
CMSSW: CMSSW_15_1_ROOT6_X_2025-02-25-2300/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/root/219/44688/install.sh to create a dev area with all the needed externals and cmssw changes.

External Build

I found compilation warning when building: See details on the summary page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants