Please read tips for efficient and successful posting and posting code
ROOT Version: 6.16+
Platform: M1 macOS with Docker Fedora 41 (personal); RHEL (Collaboration)
Compiler: g++ (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3)
Hello ROOT experts,
I am trying to update our collaborations CMakeLists.txt.
From the example,
# CMakeLists.txt for the "event" package. It creates a library and a main program.
# If ROOT is not installed in a default system location you need to tell CMake where to find it.
# Sourcing `thisroot.sh` already sets the required environment variables.
# Otherwise, you must tell the build system where to look for ROOT,
# for example by passing `-DROOT_DIR="/path/to/root/installation` at CMake configuration time.
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(event)
# Locate the ROOT package and define a number of useful targets and variables.
find_package(ROOT REQUIRED COMPONENTS RIO Net)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
# Create a shared library.
# Passing cmake targets such as `ROOT::RIO` as dependencies (rather than plain
# library names for example via ${ROOT_LIBRARIES}) ensures that properties such as required
# include directories and C++ standard are propagated to our libraries or executables.
# Note: To ensure compatibility with Cling, targets *must* be compiled using the
# same C++ standard as ROOT was compiled with.
add_library(Event SHARED Event.cxx)
target_link_libraries(Event PUBLIC ROOT::RIO ROOT::Net)
# Create the main program using the library.
add_executable(Main MainEvent.cxx)
target_link_libraries(Main Event)
It sounds like if I link against the libraries via the ROOT::target
syntax, I should not have to worry about setting the -std=cxx${ROOT_CXX_STANDARDS}
flag manually.
Is this true?