Skip to content

Commit 67636a1

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 60d105c commit 67636a1

21 files changed

Lines changed: 162 additions & 446 deletions

File tree

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
@@ -590,7 +590,6 @@ if(NOT CMAKE_CROSSCOMPILING)
590590
COMMAND
591591
${CMAKE_COMMAND} -E env
592592
ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH}
593-
ROOTIGNOREPREFIX=1
594593
ROOT_HIST=0
595594
$<TARGET_FILE:root.exe> -q -b -n
596595
-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: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,12 +636,12 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
636636
else()
637637
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
638638
if(MSVC AND CMAKE_ROOTTEST_DICT)
639-
set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" ${CMAKE_BINARY_DIR}/bin/rootcling.exe -rootbuild)
639+
set(command ${CMAKE_BINARY_DIR}/bin/rootcling.exe -rootbuild)
640640
else()
641641
if(APPLE)
642-
set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" SDKROOT=${CMAKE_OSX_SYSROOT} $<TARGET_FILE:rootcling> -rootbuild)
642+
set(command ${CMAKE_COMMAND} -E env SDKROOT=${CMAKE_OSX_SYSROOT} $<TARGET_FILE:rootcling> -rootbuild)
643643
else()
644-
set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" $<TARGET_FILE:rootcling> -rootbuild)
644+
set(command $<TARGET_FILE:rootcling> -rootbuild)
645645
endif()
646646
# Modules need RConfigure.h copied into include/.
647647
set(ROOTCLINGDEP rootcling rconfigure)
@@ -1802,9 +1802,6 @@ function(ROOT_ADD_TEST test)
18021802
set_property(TEST ${test} PROPERTY ENVIRONMENT ROOT_DIR=${CMAKE_BINARY_DIR})
18031803
else()
18041804
add_test(NAME ${test} COMMAND ${_command})
1805-
if (gnuinstall)
1806-
set_property(TEST ${test} PROPERTY ENVIRONMENT ROOTIGNOREPREFIX=1)
1807-
endif()
18081805
endif()
18091806

18101807
#- provided fixtures and resource lock are set here

cmake/scripts/compiledata.win32.in

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
/* This file is automatically generated */
21
#define BUILD_ARCH "@ROOT_ARCHITECTURE@"
32
#define BUILD_NODE "@BuildNodeInfo@"
43
#define CXX "@CMAKE_CXX_COMPILER@"
54
#define COMPILER "@CMAKE_CXX_COMPILER@"
65
#define COMPILERVERS "@CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@"
76
#define COMPILERVERSSTR "@CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@"
8-
#define MAKESHAREDLIB "cl $Opt -nologo -TP -c @CMAKE_CXX_FLAGS@ @BLDCXXFLAGS@ $IncludePath $SourceFiles -Fo$ObjectFiles && bindexplib $LibName $ObjectFiles > $BuildDir\\$LibName.def && lib -nologo -MACHINE:@MACHINE_ARCH@ -out:$BuildDir\\$LibName.lib $ObjectFiles -def:$BuildDir\\$LibName.def && link -nologo $ObjectFiles -DLL -out:$BuildDir\\$LibName.dll $BuildDir\\$LibName.exp -LIBPATH:%ROOTSYS%\\lib $LinkedLibs libCore.lib kernel32.lib advapi32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib && if EXIST \"$BuildDir\\$LibName.dll.manifest\" ( mt -nologo -manifest \"$BuildDir\\$LibName.dll.manifest\" \"-outputresource:$BuildDir\\$LibName.dll;2\" && del \"$BuildDir\\$LibName.dll.manifest\" )"
7+
#define MAKESHAREDLIB "cl $Opt -nologo -TP -c @CMAKE_CXX_FLAGS@ @BLDCXXFLAGS@ $IncludePath $SourceFiles -Fo$ObjectFiles && $BinDir\\bindexplib $LibName $ObjectFiles > $BuildDir\\$LibName.def && lib -nologo -MACHINE:@MACHINE_ARCH@ -out:$BuildDir\\$LibName.lib $ObjectFiles -def:$BuildDir\\$LibName.def && link -nologo $ObjectFiles -DLL -out:$BuildDir\\$LibName.dll $BuildDir\\$LibName.exp -LIBPATH:$LibDir $LinkedLibs libCore.lib kernel32.lib advapi32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib && if EXIST \"$BuildDir\\$LibName.dll.manifest\" ( mt -nologo -manifest \"$BuildDir\\$LibName.dll.manifest\" \"-outputresource:$BuildDir\\$LibName.dll;2\" && del \"$BuildDir\\$LibName.dll.manifest\" )"
98
#define MAKEEXE "cl -nologo -TP -Iinclude -I..\\include -c $Opt @CMAKE_CXX_FLAGS@ @BLDCXXFLAGS@ $IncludePath $SourceFiles && link -opt:ref @CMAKE_EXE_FLAGS@ $ObjectFiles $LinkedLibs advapi32.lib -out:$ExeName && if EXIST \"$ExeName.exe.manifest\" ( mt -nologo -manifest \"$ExeName.exe.manifest\" \"-outputresource:$ExeName.exe;1\" && del \"$ExeName.exe.manifest\" )"
109
#define CXXOPT "@CMAKE_CXX_FLAGS_RELEASE@ @BLDCXXFLAGS@"
1110
#define CXXDEBUG "@CMAKE_CXX_FLAGS_DEBUG@ @BLDCXXFLAGS@"
1211
#define ROOTBUILD "release"
13-
#define LINKEDLIBS "-LIBPATH:%ROOTSYS%\\lib libCore.lib "
12+
#define LINKEDLIBS "-LIBPATH:$LibDir libCore.lib "
1413
#define OBJEXT "obj"
1514
#define SOEXT "dll"

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
@@ -240,20 +240,49 @@ endif()
240240

241241
# Absolue CMAKE_INSTALL_<dir> paths are discouraged in CMake, but some
242242
# packagers use them anyway. So we support it.
243-
if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
244-
set(install_lib_to_include "${CMAKE_INSTALL_INCLUDEDIR}")
245-
else()
246-
if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
247-
set(libdir "${CMAKE_INSTALL_LIBDIR}")
243+
244+
function(install_path_from_libdir out_var install_dir)
245+
if(IS_ABSOLUTE "${install_dir}")
246+
set(install_dir_absolute "${install_dir}")
248247
else()
249-
set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
248+
set(install_dir_absolute "${CMAKE_INSTALL_PREFIX}/${install_dir}")
250249
endif()
251-
file(RELATIVE_PATH install_lib_to_include "${libdir}" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
252-
unset(libdir)
250+
file(RELATIVE_PATH _rel "${libdir}" "${install_dir_absolute}")
251+
set("${out_var}" "${_rel}" PARENT_SCOPE)
252+
endfunction()
253+
254+
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
255+
set(libdir "${CMAKE_INSTALL_LIBDIR}")
256+
else()
257+
set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
253258
endif()
254259

260+
install_path_from_libdir(install_lib_to_bin "${CMAKE_INSTALL_BINDIR}")
261+
install_path_from_libdir(install_lib_to_data "${CMAKE_INSTALL_DATADIR}")
262+
install_path_from_libdir(install_lib_to_docs "${CMAKE_INSTALL_DOCDIR}")
263+
install_path_from_libdir(install_lib_to_etc "${CMAKE_INSTALL_SYSCONFDIR}")
264+
install_path_from_libdir(install_lib_to_fonts "${CMAKE_INSTALL_FONTDIR}")
265+
install_path_from_libdir(install_lib_to_icons "${CMAKE_INSTALL_ICONDIR}")
266+
install_path_from_libdir(install_lib_to_include "${CMAKE_INSTALL_INCLUDEDIR}")
267+
install_path_from_libdir(install_lib_to_macros "${CMAKE_INSTALL_MACRODIR}")
268+
install_path_from_libdir(install_lib_to_rootsys "${CMAKE_INSTALL_PREFIX}")
269+
install_path_from_libdir(install_lib_to_src "${CMAKE_INSTALL_SRCDIR}")
270+
install_path_from_libdir(install_lib_to_tutorials "${CMAKE_INSTALL_TUTDIR}")
271+
272+
unset(libdir)
273+
255274
target_compile_options(Core PRIVATE -DLIB_CORE_NAME=${full_core_filename}
275+
-DINSTALL_LIB_TO_BIN="${install_lib_to_bin}"
276+
-DINSTALL_LIB_TO_DATA="${install_lib_to_data}"
277+
-DINSTALL_LIB_TO_DOCS="${install_lib_to_docs}"
278+
-DINSTALL_LIB_TO_ETC="${install_lib_to_etc}"
279+
-DINSTALL_LIB_TO_FONTS="${install_lib_to_fonts}"
280+
-DINSTALL_LIB_TO_ICONS="${install_lib_to_icons}"
256281
-DINSTALL_LIB_TO_INCLUDE="${install_lib_to_include}"
282+
-DINSTALL_LIB_TO_MACROS="${install_lib_to_macros}"
283+
-DINSTALL_LIB_TO_ROOTSYS="${install_lib_to_rootsys}"
284+
-DINSTALL_LIB_TO_SRC="${install_lib_to_src}"
285+
-DINSTALL_LIB_TO_TUTORIALS="${install_lib_to_tutorials}"
257286
)
258287
add_dependencies(Core ensure_build_tree_marker)
259288

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)