Skip to content

Commit 99e0747

Browse files
committed
[core] Use automatic build tree detection for all resource directories
This follows up on a5b1ed9, using the mechanism to automatically detect if we are in the build tree or install tree also for the other resource directories (so far it was only implemented for the `include` directory as a first test). Several fallbacks and hacks can be removed because of this change, like the `ROOTIGNOREPREFIX` variable that was needed to run ROOT in the build tree for the tests.
1 parent 331ad62 commit 99e0747

File tree

23 files changed

+164
-487
lines changed

23 files changed

+164
-487
lines changed

CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ else()
527527
${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/cmake/unix/makepchinput.py
528528
${CMAKE_SOURCE_DIR} . ${pyroot_legacy} ${__cling_pch}
529529
COMMAND
530-
${CMAKE_COMMAND} -E env ROOTIGNOREPREFIX=1 ${Python3_EXECUTABLE}
530+
${Python3_EXECUTABLE}
531531
${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.py etc/allDict.cxx.pch
532532
${__allIncludes} -I${CMAKE_BINARY_DIR}/include -I${CMAKE_SOURCE_DIR}/core
533533
DEPENDS
@@ -561,10 +561,10 @@ if(runtime_cxxmodules)
561561
get_property(modules_idx_deps GLOBAL PROPERTY modules_idx_deps_property)
562562
if(WIN32)
563563
set(modules_idx_cmd COMMAND ${CMAKE_COMMAND} -E env PATH="${library_output_dir}\\\;%PATH%"
564-
ROOTIGNOREPREFIX=1 ROOT_HIST=0 $<TARGET_FILE:root.exe> -l -q -b)
564+
ROOT_HIST=0 $<TARGET_FILE:root.exe> -l -q -b)
565565
else()
566566
set(modules_idx_cmd COMMAND ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH}
567-
ROOTIGNOREPREFIX=1 ROOT_HIST=0 $<TARGET_FILE:root.exe> -l -q -b)
567+
ROOT_HIST=0 $<TARGET_FILE:root.exe> -l -q -b)
568568
endif()
569569
add_custom_command(OUTPUT ${library_output_dir}/modules.idx
570570
COMMAND ${CMAKE_COMMAND} -E remove -f modules.idx modules.timestamp
@@ -588,7 +588,6 @@ add_custom_command(OUTPUT tutorials/hsimple.root
588588
COMMAND
589589
${CMAKE_COMMAND} -E env
590590
ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH}
591-
ROOTIGNOREPREFIX=1
592591
ROOT_HIST=0
593592
$<TARGET_FILE:root.exe> -l -q -b -n
594593
-e ".L ${CMAKE_SOURCE_DIR}/tutorials/hsimple.C"

cmake/modules/CheckCompiler.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,6 @@ if(gcctoolchain)
264264
endif()
265265
endif()
266266

267-
if(gnuinstall)
268-
set(R__HAVE_CONFIG 1)
269-
endif()
270-
271267
#---Check if we use the new libstdc++ CXX11 ABI-----------------------------------------------------
272268
# Necessary to compile check_cxx_source_compiles this early
273269
include(CheckCXXSourceCompiles)

cmake/modules/RootMacros.cmake

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,9 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
632632
else()
633633
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
634634
if(MSVC AND CMAKE_ROOTTEST_DICT)
635-
set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" ${CMAKE_BINARY_DIR}/bin/rootcling.exe -rootbuild)
635+
set(command ${CMAKE_BINARY_DIR}/bin/rootcling.exe -rootbuild)
636636
else()
637-
set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" $<TARGET_FILE:rootcling> -rootbuild)
637+
set(command $<TARGET_FILE:rootcling> -rootbuild)
638638
# Modules need RConfigure.h copied into include/.
639639
set(ROOTCLINGDEP rootcling rconfigure)
640640
endif()
@@ -1775,9 +1775,6 @@ function(ROOT_ADD_TEST test)
17751775
set_property(TEST ${test} PROPERTY ENVIRONMENT ROOT_DIR=${CMAKE_BINARY_DIR})
17761776
else()
17771777
add_test(NAME ${test} COMMAND ${_command})
1778-
if (gnuinstall)
1779-
set_property(TEST ${test} PROPERTY ENVIRONMENT ROOTIGNOREPREFIX=1)
1780-
endif()
17811778
endif()
17821779

17831780
#- provided fixtures and resource lock are set here

config/RConfigure.in

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,6 @@
33

44
/* Configurations file for @architecture@ */
55

6-
#cmakedefine R__HAVE_CONFIG
7-
8-
#ifdef R__HAVE_CONFIG
9-
#define ROOTPREFIX "@prefix@"
10-
#define ROOTBINDIR "@bindir@"
11-
#define ROOTLIBDIR "@libdir@"
12-
#define ROOTETCDIR "@etcdir@"
13-
#define ROOTDATADIR "@datadir@"
14-
#define ROOTDOCDIR "@docdir@"
15-
#define ROOTMACRODIR "@macrodir@"
16-
#define ROOTTUTDIR "@tutdir@"
17-
#define ROOTSRCDIR "@srcdir@"
18-
#define ROOTICONPATH "@iconpath@"
19-
#define TTFFONTDIR "@ttffontdir@"
20-
#endif
21-
226
#define EXTRAICONPATH "@extraiconpath@"
237

248
#define ROOT__cplusplus @__cplusplus@

core/base/CMakeLists.txt

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,49 @@ set(full_core_filename $<TARGET_FILE_NAME:Core>)
232232

233233
# Absolue CMAKE_INSTALL_<dir> paths are discouraged in CMake, but some
234234
# packagers use them anyway. So we support it.
235-
if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
236-
set(install_lib_to_include "${CMAKE_INSTALL_INCLUDEDIR}")
237-
else()
238-
if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
239-
set(libdir "${CMAKE_INSTALL_LIBDIR}")
235+
236+
function(install_path_from_libdir out_var install_dir)
237+
if(IS_ABSOLUTE "${install_dir}")
238+
set(install_dir_absolute "${install_dir}")
240239
else()
241-
set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
240+
set(install_dir_absolute "${CMAKE_INSTALL_PREFIX}/${install_dir}")
242241
endif()
243-
file(RELATIVE_PATH install_lib_to_include "${libdir}" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
244-
unset(libdir)
242+
file(RELATIVE_PATH _rel "${libdir}" "${install_dir_absolute}")
243+
set("${out_var}" "${_rel}" PARENT_SCOPE)
244+
endfunction()
245+
246+
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
247+
set(libdir "${CMAKE_INSTALL_LIBDIR}")
248+
else()
249+
set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
245250
endif()
246251

252+
install_path_from_libdir(install_lib_to_bin "${CMAKE_INSTALL_BINDIR}")
253+
install_path_from_libdir(install_lib_to_data "${CMAKE_INSTALL_DATADIR}")
254+
install_path_from_libdir(install_lib_to_docs "${CMAKE_INSTALL_DOCDIR}")
255+
install_path_from_libdir(install_lib_to_etc "${CMAKE_INSTALL_SYSCONFDIR}")
256+
install_path_from_libdir(install_lib_to_fonts "${CMAKE_INSTALL_FONTDIR}")
257+
install_path_from_libdir(install_lib_to_icons "${CMAKE_INSTALL_ICONDIR}")
258+
install_path_from_libdir(install_lib_to_include "${CMAKE_INSTALL_INCLUDEDIR}")
259+
install_path_from_libdir(install_lib_to_macros "${CMAKE_INSTALL_MACRODIR}")
260+
install_path_from_libdir(install_lib_to_rootsys "${CMAKE_INSTALL_PREFIX}")
261+
install_path_from_libdir(install_lib_to_src "${CMAKE_INSTALL_SRCDIR}")
262+
install_path_from_libdir(install_lib_to_tutorials "${CMAKE_INSTALL_TUTDIR}")
263+
264+
unset(libdir)
265+
247266
target_compile_options(Core PRIVATE -DLIB_CORE_NAME=${full_core_filename}
267+
-DINSTALL_LIB_TO_BIN="${install_lib_to_bin}"
268+
-DINSTALL_LIB_TO_DATA="${install_lib_to_data}"
269+
-DINSTALL_LIB_TO_DOCS="${install_lib_to_docs}"
270+
-DINSTALL_LIB_TO_ETC="${install_lib_to_etc}"
271+
-DINSTALL_LIB_TO_FONTS="${install_lib_to_fonts}"
272+
-DINSTALL_LIB_TO_ICONS="${install_lib_to_icons}"
248273
-DINSTALL_LIB_TO_INCLUDE="${install_lib_to_include}"
274+
-DINSTALL_LIB_TO_MACROS="${install_lib_to_macros}"
275+
-DINSTALL_LIB_TO_ROOTSYS="${install_lib_to_rootsys}"
276+
-DINSTALL_LIB_TO_SRC="${install_lib_to_src}"
277+
-DINSTALL_LIB_TO_TUTORIALS="${install_lib_to_tutorials}"
249278
)
250279
add_dependencies(Core ensure_build_tree_marker)
251280

core/base/inc/TROOT.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,23 @@ namespace ROOT {
394394
inline Bool_t RequiresCleanup(TObject &obj) {
395395
return obj.TestBit(kIsReferenced) && obj.GetUniqueID() == 0;
396396
}
397+
398+
struct ResourceDirs {
399+
bool initialized = false;
400+
TString bin;
401+
TString data;
402+
TString docs;
403+
TString etc;
404+
TString fonts;
405+
TString icons;
406+
TString include;
407+
TString macros;
408+
TString rootsys;
409+
TString src;
410+
TString tutorials;
411+
};
412+
413+
ResourceDirs const &GetResourceDirs();
397414
}
398415

399416
/// \brief call RecursiveRemove for obj if gROOT is valid

0 commit comments

Comments
 (0)