Skip to content

Commit 40c9ae3

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 48db120 commit 40c9ae3

22 files changed

Lines changed: 171 additions & 429 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ else()
507507
${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/cmake/unix/makepchinput.py
508508
${CMAKE_SOURCE_DIR} . ${pyroot_legacy} ${__cling_pch}
509509
COMMAND
510-
${CMAKE_COMMAND} -E env ROOTIGNOREPREFIX=1 ${Python3_EXECUTABLE}
510+
${Python3_EXECUTABLE}
511511
${CMAKE_SOURCE_DIR}/etc/dictpch/makepch.py etc/allDict.cxx.pch
512512
${__allIncludes} -I${CMAKE_BINARY_DIR}/include -I${CMAKE_SOURCE_DIR}/core
513513
DEPENDS
@@ -541,10 +541,10 @@ if(runtime_cxxmodules)
541541
get_property(modules_idx_deps GLOBAL PROPERTY modules_idx_deps_property)
542542
if(WIN32)
543543
set(modules_idx_cmd COMMAND ${CMAKE_COMMAND} -E env PATH="${library_output_dir}\\\;%PATH%"
544-
ROOTIGNOREPREFIX=1 ROOT_HIST=0 $<TARGET_FILE:root.exe> -l -q -b)
544+
ROOT_HIST=0 $<TARGET_FILE:root.exe> -l -q -b)
545545
else()
546546
set(modules_idx_cmd COMMAND ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH}
547-
ROOTIGNOREPREFIX=1 ROOT_HIST=0 $<TARGET_FILE:root.exe> -l -q -b)
547+
ROOT_HIST=0 $<TARGET_FILE:root.exe> -l -q -b)
548548
endif()
549549
add_custom_command(OUTPUT ${library_output_dir}/modules.idx
550550
COMMAND ${CMAKE_COMMAND} -E remove -f modules.idx modules.timestamp
@@ -570,7 +570,6 @@ if(NOT CMAKE_CROSSCOMPILING)
570570
COMMAND
571571
${CMAKE_COMMAND} -E env
572572
ROOT_INCLUDE_PATH=${DEFAULT_ROOT_INCLUDE_PATH}
573-
ROOTIGNOREPREFIX=1
574573
ROOT_HIST=0
575574
$<TARGET_FILE:root.exe> -q -b -n
576575
-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
@@ -255,7 +255,3 @@ if(gcctoolchain)
255255
set(CMAKE_CXX_FLAGS "--gcc-toolchain=${gcctoolchain} ${CMAKE_CXX_FLAGS}")
256256
endif()
257257
endif()
258-
259-
if(gnuinstall)
260-
set(R__HAVE_CONFIG 1)
261-
endif()

cmake/modules/RootMacros.cmake

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,12 @@ function(ROOT_GENERATE_DICTIONARY dictionary)
653653
else()
654654
if(CMAKE_PROJECT_NAME STREQUAL ROOT)
655655
if(MSVC AND CMAKE_ROOTTEST_DICT)
656-
set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" ${CMAKE_BINARY_DIR}/bin/rootcling.exe -rootbuild)
656+
set(command ${CMAKE_BINARY_DIR}/bin/rootcling.exe -rootbuild)
657657
else()
658658
if(APPLE)
659-
set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" SDKROOT=${CMAKE_OSX_SYSROOT} $<TARGET_FILE:rootcling> -rootbuild)
659+
set(command ${CMAKE_COMMAND} -E env SDKROOT=${CMAKE_OSX_SYSROOT} $<TARGET_FILE:rootcling> -rootbuild)
660660
else()
661-
set(command ${CMAKE_COMMAND} -E env "ROOTIGNOREPREFIX=1" $<TARGET_FILE:rootcling> -rootbuild)
661+
set(command $<TARGET_FILE:rootcling> -rootbuild)
662662
endif()
663663
# Modules need RConfigure.h copied into include/.
664664
set(ROOTCLINGDEP rootcling rconfigure)
@@ -1819,9 +1819,6 @@ function(ROOT_ADD_TEST test)
18191819
set_property(TEST ${test} PROPERTY ENVIRONMENT ROOT_DIR=${CMAKE_BINARY_DIR})
18201820
else()
18211821
add_test(NAME ${test} COMMAND ${_command})
1822-
if (gnuinstall)
1823-
set_property(TEST ${test} PROPERTY ENVIRONMENT ROOTIGNOREPREFIX=1)
1824-
endif()
18251822
endif()
18261823

18271824
#- provided fixtures and resource lock are set here

cmake/scripts/compiledata.win32.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#define COMPILER "@CMAKE_CXX_COMPILER@"
66
#define COMPILERVERS "@CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@"
77
#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\" )"
8+
#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\" )"
99
#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\" )"
1010
#define CXXOPT "@CMAKE_CXX_FLAGS_RELEASE@ @BLDCXXFLAGS@"
1111
#define CXXDEBUG "@CMAKE_CXX_FLAGS_DEBUG@ @BLDCXXFLAGS@"
1212
#define ROOTBUILD "release"
13-
#define LINKEDLIBS "-LIBPATH:%ROOTSYS%\\lib libCore.lib "
13+
#define LINKEDLIBS "-LIBPATH:$LibDir libCore.lib "
1414
#define OBJEXT "obj"
1515
#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: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,20 +241,48 @@ endif()
241241

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

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

core/base/inc/TROOT.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,21 @@ namespace ROOT {
397397
inline Bool_t RequiresCleanup(TObject &obj) {
398398
return obj.TestBit(kIsReferenced) && obj.GetUniqueID() == 0;
399399
}
400+
401+
struct ResourceDirs {
402+
TString bin;
403+
TString data;
404+
TString docs;
405+
TString etc;
406+
TString fonts;
407+
TString icons;
408+
TString include;
409+
TString macros;
410+
TString rootsys;
411+
TString tutorials;
412+
};
413+
414+
ResourceDirs const &GetResourceDirs();
400415
}
401416

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

0 commit comments

Comments
 (0)