From fc1e657753197d477e48b641cb7e1355db0112bf Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Fri, 4 Sep 2026 17:17:23 +0200 Subject: [PATCH 1/4] [cmake] modernize and simplify RConfigure generation inbuilt configure file and mention also current cplusplus not just ROOT in error message --- cmake/modules/RootConfiguration.cmake | 244 +++++++++----------------- config/RConfigure.in | 68 ------- 2 files changed, 79 insertions(+), 233 deletions(-) delete mode 100644 config/RConfigure.in diff --git a/cmake/modules/RootConfiguration.cmake b/cmake/modules/RootConfiguration.cmake index 7055457189e9d..88ed02d007ff8 100644 --- a/cmake/modules/RootConfiguration.cmake +++ b/cmake/modules/RootConfiguration.cmake @@ -159,11 +159,6 @@ set(builddavix ${value${davix}}) set(davixlibdir ${DAVIX_LIBRARY_DIR}) set(davixlib ${DAVIX_LIBRARY}) set(davixincdir ${DAVIX_INCLUDE_DIR}) -if(davix) - set(hasdavix define) -else() - set(hasdavix undef) -endif() set(buildnetxng ${value${xrootd}}) @@ -171,11 +166,6 @@ set(buildcurl ${value${curl}}) set(curllibdir ${CURL_LIBRARY_DIR}) set(curllib ${CURL_LIBRARY}) set(curlincdir ${CURL_INCLUDE_DIR}) -if(curl) - set(hascurl define) -else() - set(hascurl undef) -endif() set(builddcap ${value${dcap}}) set(dcaplibdir ${DCAP_LIBRARY_DIR}) @@ -322,169 +312,16 @@ endif() # set(setresuid undef) CHECK_CXX_SOURCE_COMPILES("#include int main() { uid_t r = 0, e = 0, s = 0; if (setresuid(r, e, s) != 0) { }; return 0;}" found_setresuid) -if(found_setresuid) - set(setresuid define) -else() - set(setresuid undef) -endif() - -if(mathmore) - set(hasmathmore define) -else() - set(hasmathmore undef) -endif() -if(imt) - set(useimt define) -else() - set(useimt undef) -endif() -if(CMAKE_USE_PTHREADS_INIT) - set(haspthread define) -else() - set(haspthread undef) -endif() -if(x11) - set(hasxft define) -else() - set(hasxft undef) -endif() -if(lzma) - set(haslzmacompression define) -else() - set(haslzmacompression undef) -endif() -if(lz4) - set(haslz4compression define) -else() - set(haslz4compression undef) -endif() -if(clad) - set(hasclad define) -else() - set(hasclad undef) -endif() -if(cocoa) - set(hascocoa define) -else() - set(hascocoa undef) -endif() -if(vdt) - set(hasvdt define) -else() - set(hasvdt undef) -endif() -if(ROOT_HAVE_EXPERIMENTAL_SIMD) - set(hasstdexperimentalsimd define) -else() - set(hasstdexperimentalsimd undef) -endif() -if(ROOT_EXPERIMENTAL_SIMD_PIN_AVX_ABI) - set(experimentalsimdpinavxabi define) -else() - set(experimentalsimdpinavxabi undef) -endif() -if(dataframe) - set(hasdataframe define) -else() - set(hasdataframe undef) -endif() -if(dev) - set(use_less_includes define) -else() - set(use_less_includes undef) -endif() -if(root7) - set(hasroot7 define) -else() - set(hasroot7 undef) -endif() - -if(ZLIB_NG) - set(usezlibng define) -else() - set(usezlibng undef) -endif() -if(runtime_cxxmodules) - set(usecxxmodules define) -else() - set(usecxxmodules undef) -endif() -if(libcxx) - set(uselibc++ define) -else() - set(uselibc++ undef) -endif() -if(gcctoolchain) - set(setgcctoolchain define) -else() - set(setgcctoolchain undef) -endif() -if(memory_termination) - set(memory_term define) -else() - set(memory_term undef) -endif() -if(cefweb) - set(hascefweb define) -else() - set(hascefweb undef) -endif() -if(qt6web) - set(hasqt6webengine define) -else() - set(hasqt6webengine undef) -endif() -if (tmva-cpu) - set(hastmvacpu define) -else() - set(hastmvacpu undef) -endif() -if (tmva-gpu) - set(hastmvagpu define) -else() - set(hastmvagpu undef) -endif() -if (tmva-cudnn) - set(hastmvacudnn define) -else() - set(hastmvacudnn undef) -endif() -if (tmva-pymva) - set(haspymva define) -else() - set(haspymva undef) -endif() -if (uring) - set(hasuring define) -else() - set(hasuring undef) -endif() -if (geom) - set(hasgeom define) -else() - set(hasgeom undef) -endif() - CHECK_CXX_SOURCE_COMPILES(" inline __attribute__((always_inline)) bool TestBit(unsigned long f) { return f != 0; }; int main() { return TestBit(0); }" found_attribute_always_inline) -if(found_attribute_always_inline) - set(has_found_attribute_always_inline define) -else() - set(has_found_attribute_always_inline undef) -endif() CHECK_CXX_SOURCE_COMPILES(" inline __attribute__((noinline)) bool TestBit(unsigned long f) { return f != 0; }; int main() { return TestBit(0); }" has_found_attribute_noinline) -if(has_found_attribute_noinline) - set(has_found_attribute_noinline define) -else() - set(has_found_attribute_noinline undef) -endif() -# The hardware interference size must be stable across all TUs in a ROOT build, so we need to save it in RConfigure.hxx +# The hardware interference size must be stable across all TUs in a ROOT build, so we need to save it in RConfigure.h # Since it can vary for different compilers or tune settings, we cannot base the ABI on a value that might change, # even be different between compiler and interpreter, or when ROOT is compiled on a different machine. # For older CMake and when cross compiling, we simply fall back to 64 @@ -562,7 +399,84 @@ add_custom_target(ensure_build_tree_marker ALL DEPENDS "${build_tree_marker}" ) -configure_file(${PROJECT_SOURCE_DIR}/config/RConfigure.in ginclude/RConfigure.h NEWLINE_STYLE UNIX) +add_library(ROOTdefs INTERFACE) +# Note: if this is modified, modify also RConfigure.h.in for backward compatibility +if (gnuinstall) + target_compile_definitions(ROOTdefs INTERFACE + ROOTPREFIX=${prefix} + ROOTBINDIR=${bindir} + ROOTLIBDIR=${libdir} + ROOTETCDIR=${etcdir} + ROOTDATADIR=${datadir} + ROOTDOCDIR=${docdir} + ROOTMACRODIR=${macrodir} + ROOTTUTDIR=${tutdir} + ROOTSRCDIR=${srcdir} + ROOTICONPATH=${iconpath} + TTFFONTDIR=${ttffontdir} + ) +endif() + +target_compile_definitions(ROOTdefs INTERFACE + ROOT__ARCHITECTURE=${architecture} + EXTRAICONPATH=$,\"${extraiconpath}\",\"\"> + ROOT__cplusplus=${__cplusplus} + $<$:R__HAS_SETRESUID> + $<$:R__HAS_MATHMORE> + $<$:R__HAS_PTHREAD> + $<$:R__HAS_XFT> + $<$:R__HAS_CLAD> + $<$:R__HAS_COCOA> + $<$:R__HAS_VDT> + $<$:R__HAS_STD_EXPERIMENTAL_SIMD> + $<$:R__EXPERIMENTAL_SIMD_PIN_AVX_ABI> + $<$:R__USE_CXXMODULES> + $<$:R__USE_LIBCXX> + $<$:R__HAS_ATTRIBUTE_ALWAYS_INLINE> + $<$:R__HAS_ATTRIBUTE_NOINLINE> + $<$:R__USE_IMT> + $<$:R__COMPLETE_MEM_TERMINATION> + $<$:R__HAS_CEFWEB> + $<$:R__HAS_QT6WEB> + $<$:R__HAS_DAVIX> + $<$:R__HAS_CURL> + $<$:R__HAS_DATAFRAME> + $<$:R__HAS_ROOT7> + $<$:R__LESS_INCLUDES> + R__HARDWARE_INTERFERENCE_SIZE=${hardwareinterferencesize} + $<$:R__HAS_ZLIB_NG> + $<$:R__HAS_TMVACPU> + $<$:R__HAS_TMVAGPU> + $<$:R__HAS_CUDNN> + $<$:R__HAS_PYMVA> + $<$:R__HAS_URING> + $<$:R__HAS_GEOM> + $<$:-Zc:__cplusplus> +) + +file(GENERATE + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginclude/RConfigure.h + CONTENT +"#ifndef ROOT_RConfigure +#define ROOT_RConfigure + +#define $,REPLACE,=, >,\n#define > + +#if defined(__cplusplus) && (__cplusplus != ROOT__cplusplus) +# define R__STR(x) #x +# define R__XSTR(x) R__STR(x) +# pragma message(__FILE__ \": Warning: The C++ standard in this build (\" R__XSTR(__cplusplus) \") does not match ROOT configuration (\" R__XSTR(ROOT__cplusplus) \"); this might cause unexpected issues.\") +# if defined(_MSC_VER) +# pragma message(__FILE__ \": Warning: And please make sure you are using the -Zc:__cplusplus compilation flag\") +# endif +# undef R__XSTR +# undef R__STR +#endif + +#endif +" + NEWLINE_STYLE UNIX +) install(FILES ${CMAKE_BINARY_DIR}/ginclude/RConfigure.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) #---Configure and install various files---------------------------------------------------------------------- diff --git a/config/RConfigure.in b/config/RConfigure.in deleted file mode 100644 index 2b2370256b4ed..0000000000000 --- a/config/RConfigure.in +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef ROOT_RConfigure -#define ROOT_RConfigure - -/* Configurations file for @architecture@ */ - -#cmakedefine R__HAVE_CONFIG - -#ifdef R__HAVE_CONFIG -#define ROOTPREFIX "@prefix@" -#define ROOTBINDIR "@bindir@" -#define ROOTLIBDIR "@libdir@" -#define ROOTETCDIR "@etcdir@" -#define ROOTDATADIR "@datadir@" -#define ROOTDOCDIR "@docdir@" -#define ROOTMACRODIR "@macrodir@" -#define ROOTTUTDIR "@tutdir@" -#define ROOTSRCDIR "@srcdir@" -#define ROOTICONPATH "@iconpath@" -#define TTFFONTDIR "@ttffontdir@" -#endif - -#define EXTRAICONPATH "@extraiconpath@" - -#define ROOT__cplusplus @__cplusplus@ -#if defined(__cplusplus) && (__cplusplus != ROOT__cplusplus) -# if defined(_MSC_VER) -# pragma message(__FILE__ ": Warning: The C++ standard in this build does not match ROOT configuration (@__cplusplus@); this might cause unexpected issues. And please make sure you are using the -Zc:__cplusplus compilation flag") -# else -# warning "The C++ standard in this build does not match ROOT configuration (@__cplusplus@); this might cause unexpected issues" -# endif -#endif - -#@setresuid@ R__HAS_SETRESUID /**/ -#@hasmathmore@ R__HAS_MATHMORE /**/ -#@haspthread@ R__HAS_PTHREAD /**/ -#@hasxft@ R__HAS_XFT /**/ -#@hasclad@ R__HAS_CLAD /**/ -#@hascocoa@ R__HAS_COCOA /**/ -#@hasvdt@ R__HAS_VDT /**/ -#@hasstdexperimentalsimd@ R__HAS_STD_EXPERIMENTAL_SIMD /**/ -#@experimentalsimdpinavxabi@ R__EXPERIMENTAL_SIMD_PIN_AVX_ABI /**/ -#@usecxxmodules@ R__USE_CXXMODULES /**/ -#@uselibc++@ R__USE_LIBCXX /**/ -#@has_found_attribute_always_inline@ R__HAS_ATTRIBUTE_ALWAYS_INLINE /**/ -#@has_found_attribute_noinline@ R__HAS_ATTRIBUTE_NOINLINE /**/ -#@useimt@ R__USE_IMT /**/ -#@memory_term@ R__COMPLETE_MEM_TERMINATION /**/ -#@hascefweb@ R__HAS_CEFWEB /**/ -#@hasqt6webengine@ R__HAS_QT6WEB /**/ -#@hasdavix@ R__HAS_DAVIX /**/ -#@hascurl@ R__HAS_CURL /**/ -#@hasdataframe@ R__HAS_DATAFRAME /**/ -#@hasroot7@ R__HAS_ROOT7 /**/ -#@use_less_includes@ R__LESS_INCLUDES /**/ -#define R__HARDWARE_INTERFERENCE_SIZE @hardwareinterferencesize@ /*Determined at CMake configure to be stable across all TUs*/ - -#@usezlibng@ R__HAS_ZLIB_NG /**/ - -#@hastmvacpu@ R__HAS_TMVACPU /**/ -#@hastmvagpu@ R__HAS_TMVAGPU /**/ -#@hastmvacudnn@ R__HAS_CUDNN /**/ -#@haspymva@ R__HAS_PYMVA /**/ - -#@hasuring@ R__HAS_URING /**/ - -#@hasgeom@ R__HAS_GEOM /**/ - -#endif From d4261a0163ef16f84bd5e8b51c295091a15472b8 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Sun, 6 Sep 2026 00:20:39 +0200 Subject: [PATCH 2/4] [cmake] fix define redefinition via header guards --- cmake/modules/RootConfiguration.cmake | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/cmake/modules/RootConfiguration.cmake b/cmake/modules/RootConfiguration.cmake index 88ed02d007ff8..bd33b441969f1 100644 --- a/cmake/modules/RootConfiguration.cmake +++ b/cmake/modules/RootConfiguration.cmake @@ -399,10 +399,9 @@ add_custom_target(ensure_build_tree_marker ALL DEPENDS "${build_tree_marker}" ) -add_library(ROOTdefs INTERFACE) -# Note: if this is modified, modify also RConfigure.h.in for backward compatibility +add_library(RConfigureDefs INTERFACE) # temporary target, do not link against it, just for bw-compatible header generation RConfigure.h if (gnuinstall) - target_compile_definitions(ROOTdefs INTERFACE + target_compile_definitions(RConfigureDefs INTERFACE ROOTPREFIX=${prefix} ROOTBINDIR=${bindir} ROOTLIBDIR=${libdir} @@ -417,7 +416,7 @@ if (gnuinstall) ) endif() -target_compile_definitions(ROOTdefs INTERFACE +target_compile_definitions(RConfigureDefs INTERFACE ROOT__ARCHITECTURE=${architecture} EXTRAICONPATH=$,\"${extraiconpath}\",\"\"> ROOT__cplusplus=${__cplusplus} @@ -460,8 +459,11 @@ file(GENERATE "#ifndef ROOT_RConfigure #define ROOT_RConfigure -#define $,REPLACE,=, >,\n#define > +#define $,REPLACE,=, >,\n#define > +#endif +#ifndef ROOT_RConfigure_w +#define ROOT_RConfigure_w #if defined(__cplusplus) && (__cplusplus != ROOT__cplusplus) # define R__STR(x) #x # define R__XSTR(x) R__STR(x) @@ -472,13 +474,20 @@ file(GENERATE # undef R__XSTR # undef R__STR #endif - #endif " NEWLINE_STYLE UNIX ) install(FILES ${CMAKE_BINARY_DIR}/ginclude/RConfigure.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +# Public target interface against which to link +add_library(ROOTdefs INTERFACE) +target_compile_definitions(ROOTdefs INTERFACE +ROOT_RConfigure # so that including the mirror header RConfigure.h is inocuous if linking against this target +) +target_link_libraries(ROOTdefs INTERFACE RConfigureDefs) + + #---Configure and install various files---------------------------------------------------------------------- execute_Process(COMMAND hostname OUTPUT_VARIABLE BuildNodeInfo OUTPUT_STRIP_TRAILING_WHITESPACE ) From 9838ed6927c6cc9ce488dbb61a4756d905ef1b11 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Mon, 7 Sep 2026 17:16:09 +0200 Subject: [PATCH 3/4] [RConfig] simplify and move to CMake as builtin def module --- cmake/modules/RootBuildOptions.cmake | 3 + cmake/modules/RootConfiguration.cmake | 399 +++++++++++++++++++++++++- cmake/modules/SetROOTVersion.cmake | 29 +- core/foundation/inc/ROOT/RVersion.hxx | 48 ---- 4 files changed, 406 insertions(+), 73 deletions(-) delete mode 100644 core/foundation/inc/ROOT/RVersion.hxx diff --git a/cmake/modules/RootBuildOptions.cmake b/cmake/modules/RootBuildOptions.cmake index be3b19988076d..6457ee3e99d97 100644 --- a/cmake/modules/RootBuildOptions.cmake +++ b/cmake/modules/RootBuildOptions.cmake @@ -198,6 +198,9 @@ option(testing "Enable testing with CTest" OFF) option(asan "Build ROOT with address sanitizer instrumentation (see core/sanitizer for details)" OFF) option(_wheel_build "ROOT is being packaged as a wheel, do not install .dist-info metadata" OFF) +option(ENABLE_BASKET_ALLOC_TIME_TRACKING "Setting this define causes ROOT to keep statistics about memory buffer allocation time within the TTree. Given that this is a 'hot-path', we provide a mechanism for enabling / disabling this at compile time by developers; default is disabled." OFF) +mark_as_advanced(ENABLE_BASKET_ALLOC_TIME_TRACKING) + set(gcctoolchain "" CACHE PATH "Set path to GCC toolchain used to build llvm/clang") if(all AND minimal) diff --git a/cmake/modules/RootConfiguration.cmake b/cmake/modules/RootConfiguration.cmake index bd33b441969f1..52395caa2bf33 100644 --- a/cmake/modules/RootConfiguration.cmake +++ b/cmake/modules/RootConfiguration.cmake @@ -399,6 +399,10 @@ add_custom_target(ensure_build_tree_marker ALL DEPENDS "${build_tree_marker}" ) +include(CheckSymbolExists) +include(CheckCXXCompilerFlag) +include(CheckSourceCompiles) + add_library(RConfigureDefs INTERFACE) # temporary target, do not link against it, just for bw-compatible header generation RConfigure.h if (gnuinstall) target_compile_definitions(RConfigureDefs INTERFACE @@ -480,12 +484,405 @@ file(GENERATE ) install(FILES ${CMAKE_BINARY_DIR}/ginclude/RConfigure.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +# RVersion.hxx +add_library(RVersionDefs INTERFACE) # temporary target, do not link against it, just for bw-compatible header generation +target_compile_definitions(RVersionDefs INTERFACE + ROOT_VERSION_MAJOR=${ROOT_MAJOR_VERSION} + ROOT_VERSION_MINOR=${ROOT_MINOR_VERSION} + ROOT_VERSION_PATCH=${ROOT_PATCH_VERSION} + ROOT_RELEASE_DATE="${ROOT_RELEASE_DATE}" + ROOT_RELEASE_TIME="00:00:00" # not updated anymore +) +file(GENERATE + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginclude/ROOT/RVersion.hxx + CONTENT +"#ifndef ROOT_RVERSION_HXX +#define ROOT_RVERSION_HXX + +#define $,REPLACE,=, >,\n#define > +#endif // ROOT_RVERSION_HXX + +#ifndef #ifndef ROOT_RVERSION_HXX_m +#define ROOT_RVERSION_HXX_m +/* Don't change the lines below. */ + +/* + * These macros can be used in the following way: + * + * #if ROOT_VERSION_CODE >= ROOT_VERSION(6,32,4) + * #include + * #else + * #include + * #endif + * +*/ + +#define ROOT_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +#define ROOT_VERSION_CODE ROOT_VERSION(ROOT_VERSION_MAJOR, ROOT_VERSION_MINOR, ROOT_VERSION_PATCH) + +#define R__VERS_QUOTE1_MAJOR(P) #P +#define R__VERS_QUOTE_MAJOR(P) R__VERS_QUOTE1_MAJOR(P) + + +#if ROOT_VERSION_MINOR < 10 +#define R__VERS_QUOTE1_MINOR(P) \"0\" #P +#else +#define R__VERS_QUOTE1_MINOR(P) #P +#endif +#define R__VERS_QUOTE_MINOR(P) R__VERS_QUOTE1_MINOR(P) + +#if ROOT_VERSION_PATCH < 10 +#define R__VERS_QUOTE1_PATCH(P) \"0\" #P +#else +#define R__VERS_QUOTE1_PATCH(P) #P +#endif +#define R__VERS_QUOTE_PATCH(P) R__VERS_QUOTE1_PATCH(P) + +#define ROOT_RELEASE R__VERS_QUOTE_MAJOR(ROOT_VERSION_MAJOR) \ + \".\" R__VERS_QUOTE_MINOR(ROOT_VERSION_MINOR) \ + \".\" R__VERS_QUOTE_PATCH(ROOT_VERSION_PATCH) +#endif // ROOT_RVERSION_HXX +" + NEWLINE_STYLE UNIX +) + +# ----- RConfig.hxx +check_cxx_compiler_flag("-fmodules" HAS_MODULES) + +# Machines +# TODO all this part can be easily simplified by using native CMake system name checks +check_source_compiles(CXX " +#if !defined(__hpux) +#error \"This is not HP-UX\" +#endif +int main() { return 0; } +" HAS_HPUX) +check_source_compiles(CXX " +#if !defined(__LP64__) || !defined(__hpux) +#error This is not HP-UX LP64 +#endif +int main() { return 0; } +" HAS_LP64) +check_source_compiles(CXX " +#if !defined(__hpux) +#error \"This is not HP-UX\" +#endif +int main() { return 0; } +" HAS_HPUX) +check_source_compiles(CXX " +#if defined(__linux) || defined(__linux__) || (defined(__CYGWIN__) && defined(__GNUC__)) +# ifdef linux +#error \"This does not need Linux\" +# endif +#else +#error \"This is not Linux\" +#endif +int main() { return 0; } +" NEEDS_LINUX) +check_source_compiles(CXX " +#if !defined(__linux) && defined(__linux__) && !defined(linux) && !(defined(__CYGWIN__) && defined(__GNUC__)) +#error \"This is not Linux\" +#endif +int main() { return 0; } +" IS_LINUX) +check_source_compiles(CXX " +#if !defined(__CYGWIN__) || !defined(__GNUC__) +#error \"This is not wingcc\" +#endif +int main() { return 0; } +" HAS_WINGCC) +check_source_compiles(CXX " +#if defined(__sun) && !(defined(linux) || defined(__FCC_VERSION)) && defined(__SVR4) +#else +#error \"This is not Solaris\" +#endif +int main() { return 0; } +" HAS_SOLARIS) +check_source_compiles(CXX " +#if defined(__sun) && !(defined(linux) || defined(__FCC_VERSION)) && !defined(__SVR4) +#else +#error \"This is not Sun\" +#endif +int main() { return 0; } +" HAS_SUN) +check_symbol_exists(siglongjmp "setjmp.h" HAVE_SIGLONGJMP) +check_symbol_exists(lstat64 "sys/stat.h;sys/types.h" HAVE_LSTAT64) +check_source_compiles(CXX " +#if (!defined(__linux) && !defined(__linux__) && !defined(linux)) || defined(_LARGEFILE64_SOURCE) +#error \"This does not need _LARGEFILE64_SOURCE\" +#endif +int main() { return 0; } +" NEEDS_LARGEFILE64) +check_symbol_exists(strlcpy "string.h" HAS_STRLCPY) +check_symbol_exists(strcasecmp "strings.h;string.h" HAS_STRCASECMP) +check_source_compiles(CXX " +#if (!defined(__linux) && !defined(__linux__) && !defined(linux)) || !defined(i386) || defined(__i486__) +#error \"This does not need i486\" +#endif +int main() { return 0; } +" NEEDS_I486) +check_source_compiles(CXX " +#if defined(_INCLUDE_LONGLONG) || !defined(__HP_aCC) +#error \"This does not need longlong\" +#endif +int main() { return 0; } +" NEEDS_INC_LONGLONG) +check_source_compiles(CXX " +#if defined(WIN32) || !defined(_WIN32) +#error \"This does not need WIN32\" +#endif +int main() { return 0; } +" NEEDS_WIN32) +check_source_compiles(CXX " +#if defined(WIN64) || !defined(_WIN64) +#error \"This does not need WIN64\" +#endif +int main() { return 0; } +" NEEDS_WIN64) + +add_library(RConfigDefs INTERFACE) # temporary target, do not link against it, just for bw-compatible header generation +target_compile_definitions(RConfigDefs INTERFACE + $<$:R__CXXMODULES> + R__USE_SHADOW_CLASS + R__ANSISTREAM + R_SSTREAM + R__NULLPTR + # In comments below potential simplifications using native CMake + $<$:R__HPUX> + $<$:R__WINGCC> # $<$,$>:linux;R__WINGCC> + $<$:R__SOLARIS> # CMAKE_SYSTEM_NAME STREQUAL "SunOS" + $<$:R__SUN> # CMAKE_SYSTEM_NAME STREQUAL "SunOS" + $<$:R__UNIX> + $<$:R__LINUX> + $<$:linux> + $<$:R__SEEK64> + $<$:NEED_SIGJMP> + $<$:R__BYTESWAP> + $<$:R__B64> + $<$:_LARGEFILE64_SOURCE> + $<$:HAS_STRLCPY=1> # TODO move this just to Clib and remove from global defs + $<$:__i486__> + $<$,$>:R__HURD;f2cFortran> + $<$:R__FBSD> + $<$:R__OBSD> + $<$:R__MACOSX> + $<$:R__HIUX> + $<$>:NEED_STRCASECMP> # could be moved to a private implementation detail into TString.cxx + $<$,$>:R__LYNXOS> + # $<$:R__HIDDEN=__attribute__((__visibility__(\"hidden\")))>> # Not used + # $<$,$>:R__INTEL_COMPILER> # Not used + $<$:R__ACC;R__TMPLTSTREAM> + $<$:_INCLUDE_LONGLONG> + $<$:R__WIN32> # R__ACCESS_IN_SYMBOL not used + $<$:WIN32> + $<$,$>:R__WIN64> # R__x86_64__ not used + $<$:WIN64> + $<$:SC;R__SC> + $<$,$>>:MSDOS> # TODO move to Zlib private impreventation detail + $<$:R__VISUAL_CPLUSPLUS> + $<$,$,13.1>>:R__NO_CLASS_TEMPLATE_SPECIALIZATION> + $<$,$,18.0>>:R__NO_ATOMIC_FUNCTION_POINTER> + $<$:R__TRACK_BASKET_ALLOC_TIME=1> +) +file(GENERATE + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginclude/ROOT/RConfig.hxx + CONTENT +" +#ifndef ROOT_RConfig_h +#define ROOT_RConfig_h +#include +#include +#endif + +#ifndef ROOT_RConfig +#define ROOT_RConfig + +#define $,REPLACE,=, >,\n#define > +#endif + +#ifndef ROOT_RConfig_m +#define ROOT_RConfig_m +# define _NAME1_(name) name +# define _NAME2_(name1,name2) name1##name2 +# define _NAME3_(name1,name2,name3) name1##name2##name3 + + /* stringizing */ +# define _QUOTE_(name) #name +#define _R_QUOTEVAL_(string) _QUOTE_(string) +/* produce an identifier that is almost unique inside a file */ +# define _R__JOIN_(X,Y) _NAME2_(X,Y) +# define _R__JOIN3_(F,X,Y) _NAME3_(F,X,Y) +# define _R__UNIQUE_DICT_(X) _R__JOIN3_(R__DICTIONARY_FILENAME,X,__LINE__) +# define _R__UNIQUE_(X) _R__JOIN_(X,__LINE__) +#endif + +#ifndef ROOT_RConfig_w +#define ROOT_RConfig_w + +#if defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) +# if (__GNUC__ == 5 && (__GNUC_MINOR__ == 1 || __GNUC_MINOR__ == 2)) || defined(R__NO_DEPRECATION) +/* GCC 5.1, 5.2: false positives due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=15269 + or deprecation turned off */ +# define _R__DEPRECATED_LATER(REASON) +# else +# define _R__DEPRECATED_LATER(REASON) __attribute__((deprecated(REASON))) +# endif +#elif defined(_MSC_VER) && !defined(R__NO_DEPRECATION) +# define _R__DEPRECATED_LATER(REASON) __pragma(deprecated(REASON)) +#else +/* Deprecation not supported for this compiler. */ +# define _R__DEPRECATED_LATER(REASON) +#endif + +#ifdef R__WIN32 +#define _R_DEPRECATED_REMOVE_NOW(REASON) +#else +#define _R_DEPRECATED_REMOVE_NOW(REASON) __attribute__((REMOVE_THIS_NOW)) +#endif + +/* USE AS `R__DEPRECATED(6,42, \"Not threadsafe; use TFoo::Bar().\")` + To be removed by 6.42 */ +#if ROOT_VERSION_CODE < ROOT_VERSION(6, 41, 2) +#define _R__DEPRECATED_642(REASON) _R__DEPRECATED_LATER(REASON) +#else +#define _R__DEPRECATED_642(REASON) _R_DEPRECATED_REMOVE_NOW(REASON) +#endif + +#if ROOT_VERSION_CODE <= ROOT_VERSION(6, 43, 0) +#define _R__DEPRECATED_644(REASON) _R__DEPRECATED_LATER(REASON) +#else +#define _R__DEPRECATED_644(REASON) _R_DEPRECATED_REMOVE_NOW(REASON) +#endif + +#if ROOT_VERSION_CODE <= ROOT_VERSION(6, 45, 0) +#define _R__DEPRECATED_646(REASON) _R__DEPRECATED_LATER(REASON) +#else +#define _R__DEPRECATED_646(REASON) _R_DEPRECATED_REMOVE_NOW(REASON) +#endif + +/* USE AS `R__DEPRECATED(7,00, \"Not threadsafe; use TFoo::Bar().\")` + To be removed by 7.00 */ +#if ROOT_VERSION_CODE < ROOT_VERSION(6,99,0) +# define _R__DEPRECATED_700(REASON) _R__DEPRECATED_LATER(REASON) +#else +# define _R__DEPRECATED_700(REASON) _R_DEPRECATED_REMOVE_NOW(REASON) +#endif + +/* Spell as R__DEPRECATED(6,04, \"Not threadsafe; use TFoo::Bar().\") */ +#define R__DEPRECATED(MAJOR, MINOR, REASON) \ + _R__JOIN3_(_R__DEPRECATED_,MAJOR,MINOR)(\"will be removed in ROOT v\" #MAJOR \".\" #MINOR \": \" REASON) + +/* Mechanisms to advise users to avoid legacy functions and classes that will not be removed */ +#if defined R__SUGGEST_NEW_INTERFACE +# define R__SUGGEST_ALTERNATIVE(ALTERNATIVE) \ + _R__DEPRECATED_LATER(\"There is a superior alternative: \" ALTERNATIVE) +#else +# define R__SUGGEST_ALTERNATIVE(ALTERNATIVE) +#endif + +#define R__ALWAYS_SUGGEST_ALTERNATIVE(ALTERNATIVE) \ + _R__DEPRECATED_LATER(\"There is a superior alternative: \" ALTERNATIVE) + +/*---- misc ------------------------------------------------------------------*/ + +#ifdef R__GNU +# define SafeDelete(p) { if (p) { delete p; p = nullptr; } } +#else +# define SafeDelete(p) { delete p; p = nullptr; } +#endif + +#ifdef __FAST_MATH__ +#define R__FAST_MATH +#endif + +#if (__GNUC__ >= 7) +#define R__DO_PRAGMA(x) _Pragma (#x) +# define R__INTENTIONALLY_UNINIT_BEGIN \ + R__DO_PRAGMA(GCC diagnostic push) \ + R__DO_PRAGMA(GCC diagnostic ignored \"-Wmaybe-uninitialized\") \ + R__DO_PRAGMA(GCC diagnostic ignored \"-Wuninitialized\") +# define R__INTENTIONALLY_UNINIT_END \ + R__DO_PRAGMA(GCC diagnostic pop) +#else +# define R__INTENTIONALLY_UNINIT_BEGIN +# define R__INTENTIONALLY_UNINIT_END + +#endif + +#ifdef R__HAS_ATTRIBUTE_ALWAYS_INLINE +#define R__ALWAYS_INLINE inline __attribute__((always_inline)) +#else +#if defined(_MSC_VER) +#define R__ALWAYS_INLINE __forceinline +#else +#define R__ALWAYS_INLINE inline +#endif +#endif + +// See also https://nemequ.github.io/hedley/api-reference.html#HEDLEY_NEVER_INLINE +// for other platforms. +#ifdef R__HAS_ATTRIBUTE_NOINLINE +#define R__NEVER_INLINE inline __attribute__((noinline)) +#else +#if defined(_MSC_VER) +#define R__NEVER_INLINE inline __declspec(noinline) +#else +#define R__NEVER_INLINE inline +#endif +#endif + +/*---- unlikely / likely expressions -----------------------------------------*/ +// These are meant to use in cases like: +// if (R__unlikely(expression)) { ... } +// in performance-critical sections. R__unlikely / R__likely provide hints to +// the compiler code generation to heavily optimize one side of a conditional, +// causing the other branch to have a heavy performance cost. +// +// It is best to use this for conditionals that test for rare error cases or +// backward compatibility code. + +#if (__GNUC__ >= 3) || defined(__INTEL_COMPILER) +#if !defined(R__unlikely) + #define R__unlikely(expr) __builtin_expect(!!(expr), 0) +#endif +#if !defined(R__likely) + #define R__likely(expr) __builtin_expect(!!(expr), 1) +#endif +#else + #define R__unlikely(expr) expr + #define R__likely(expr) expr +#endif + +#ifdef __HP_aCC +# if __HP_aCC <= 015000 +#error \"ROOT requires proper support for C++17 or higher\" +# endif +#endif + +#if defined(_MSC_VER) +# if (_MSC_VER < 1910) +# error \"ROOT requires Visual Studio 2017 or higher.\" +#else +#if defined(__cplusplus) && (__cplusplus < 201703L) +#error \"ROOT requires support for C++17 or higher.\" +# if defined(__GNUC__) || defined(__clang__) +#error \"Pass `-std=c++17` as compiler argument.\" +# endif +# endif +#endif + +#endif +" + NEWLINE_STYLE UNIX +) + # Public target interface against which to link add_library(ROOTdefs INTERFACE) target_compile_definitions(ROOTdefs INTERFACE ROOT_RConfigure # so that including the mirror header RConfigure.h is inocuous if linking against this target +ROOT_RVERSION_HXX ) -target_link_libraries(ROOTdefs INTERFACE RConfigureDefs) +target_link_libraries(ROOTdefs INTERFACE RConfigureDefs RVersionDefs RConfigDefs) #---Configure and install various files---------------------------------------------------------------------- diff --git a/cmake/modules/SetROOTVersion.cmake b/cmake/modules/SetROOTVersion.cmake index 36ecc17aca9ee..5179ba586b58b 100644 --- a/cmake/modules/SetROOTVersion.cmake +++ b/cmake/modules/SetROOTVersion.cmake @@ -14,29 +14,6 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR) -function(SET_VERSION_FROM_FILE) - # See https://stackoverflow.com/questions/47066115/cmake-get-version-from-multiline-text-file - file(READ "${CMAKE_SOURCE_DIR}/core/foundation/inc/ROOT/RVersion.hxx" versionstr) - string(REGEX MATCH "#define ROOT_VERSION_MAJOR ([0-9]*)" _ ${versionstr}) - set(ROOT_MAJOR_VERSION ${CMAKE_MATCH_1}) - string(REGEX MATCH "#define ROOT_VERSION_MINOR ([0-9]*)" _ ${versionstr}) - if (CMAKE_MATCH_1 LESS 10) - set(ROOT_MINOR_VERSION "0${CMAKE_MATCH_1}") - else() - set(ROOT_MINOR_VERSION ${CMAKE_MATCH_1}) - endif() - string(REGEX MATCH "#define ROOT_VERSION_PATCH ([0-9]*)" _ ${versionstr}) - if (CMAKE_MATCH_1 LESS 10) - set(ROOT_PATCH_VERSION "0${CMAKE_MATCH_1}") - else() - set(ROOT_PATCH_VERSION ${CMAKE_MATCH_1}) - endif() - - set(ROOT_MAJOR_VERSION "${ROOT_MAJOR_VERSION}" PARENT_SCOPE) - set(ROOT_MINOR_VERSION "${ROOT_MINOR_VERSION}" PARENT_SCOPE) - set(ROOT_PATCH_VERSION "${ROOT_PATCH_VERSION}" PARENT_SCOPE) -endfunction() - function(SET_ROOT_VERSION) if(Git_FOUND AND EXISTS ${CMAKE_SOURCE_DIR}/.git) execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_SOURCE_DIR}/.git describe --all @@ -48,7 +25,10 @@ function(SET_ROOT_VERSION) set(GIT_DESCRIBE_ERRCODE "NoGit") endif() - SET_VERSION_FROM_FILE() + set(ROOT_MAJOR_VERSION 6) + set(ROOT_MINOR_VERSION 41) + set(ROOT_PATCH_VERSION 1) # When changing the version number here, never add leading zeroes! + set(ROOT_RELEASE_DATE "Apr 23 2026") set(ROOT_VERSION "${ROOT_MAJOR_VERSION}.${ROOT_MINOR_VERSION}.${ROOT_PATCH_VERSION}") set(ROOT_FULL_VERSION "${ROOT_VERSION}") @@ -97,6 +77,7 @@ function(SET_ROOT_VERSION) set(ROOT_MAJOR_VERSION "${ROOT_MAJOR_VERSION}" PARENT_SCOPE) set(ROOT_MINOR_VERSION "${ROOT_MINOR_VERSION}" PARENT_SCOPE) set(ROOT_PATCH_VERSION "${ROOT_PATCH_VERSION}" PARENT_SCOPE) + set(ROOT_RELEASE_DATE ${ROOT_RELEASE_DATE} PARENT_SCOPE) set(ROOT_VERSION "${ROOT_VERSION}" PARENT_SCOPE) set(ROOT_FULL_VERSION "${ROOT_FULL_VERSION}" PARENT_SCOPE) set(GIT_DESCRIBE_ALWAYS "${GIT_DESCRIBE_ALWAYS}" PARENT_SCOPE) diff --git a/core/foundation/inc/ROOT/RVersion.hxx b/core/foundation/inc/ROOT/RVersion.hxx deleted file mode 100644 index 2f23b7c43bf71..0000000000000 --- a/core/foundation/inc/ROOT/RVersion.hxx +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef ROOT_RVERSION_HXX -#define ROOT_RVERSION_HXX - -/* Update on release: */ -#define ROOT_VERSION_MAJOR 6 -#define ROOT_VERSION_MINOR 41 -#define ROOT_VERSION_PATCH 1 // When changing the version number here, never add leading zeroes! -#define ROOT_RELEASE_DATE "Apr 23 2026" - -/* Don't change the lines below. */ - -/* - * These macros can be used in the following way: - * - * #if ROOT_VERSION_CODE >= ROOT_VERSION(6,32,4) - * #include - * #else - * #include - * #endif - * -*/ - -#define ROOT_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#define ROOT_VERSION_CODE ROOT_VERSION(ROOT_VERSION_MAJOR, ROOT_VERSION_MINOR, ROOT_VERSION_PATCH) - -#define R__VERS_QUOTE1_MAJOR(P) #P -#define R__VERS_QUOTE_MAJOR(P) R__VERS_QUOTE1_MAJOR(P) - - -#if ROOT_VERSION_MINOR < 10 -#define R__VERS_QUOTE1_MINOR(P) "0" #P -#else -#define R__VERS_QUOTE1_MINOR(P) #P -#endif -#define R__VERS_QUOTE_MINOR(P) R__VERS_QUOTE1_MINOR(P) - -#if ROOT_VERSION_PATCH < 10 -#define R__VERS_QUOTE1_PATCH(P) "0" #P -#else -#define R__VERS_QUOTE1_PATCH(P) #P -#endif -#define R__VERS_QUOTE_PATCH(P) R__VERS_QUOTE1_PATCH(P) - -#define ROOT_RELEASE R__VERS_QUOTE_MAJOR(ROOT_VERSION_MAJOR) \ - "." R__VERS_QUOTE_MINOR(ROOT_VERSION_MINOR) \ - "." R__VERS_QUOTE_PATCH(ROOT_VERSION_PATCH) - -#endif // ROOT_RVERSION_H From 9f57ee830fffa181df2c03b23792e209293a3181 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 8 Sep 2026 17:28:47 +0200 Subject: [PATCH 4/4] Apply batched suggestions from code review from copilot sister PR pcanal Co-authored-by: ferdymercury --- cmake/modules/RootConfiguration.cmake | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/cmake/modules/RootConfiguration.cmake b/cmake/modules/RootConfiguration.cmake index 52395caa2bf33..ce7196c25e973 100644 --- a/cmake/modules/RootConfiguration.cmake +++ b/cmake/modules/RootConfiguration.cmake @@ -406,17 +406,17 @@ include(CheckSourceCompiles) add_library(RConfigureDefs INTERFACE) # temporary target, do not link against it, just for bw-compatible header generation RConfigure.h if (gnuinstall) target_compile_definitions(RConfigureDefs INTERFACE - ROOTPREFIX=${prefix} - ROOTBINDIR=${bindir} - ROOTLIBDIR=${libdir} - ROOTETCDIR=${etcdir} - ROOTDATADIR=${datadir} - ROOTDOCDIR=${docdir} - ROOTMACRODIR=${macrodir} - ROOTTUTDIR=${tutdir} - ROOTSRCDIR=${srcdir} - ROOTICONPATH=${iconpath} - TTFFONTDIR=${ttffontdir} + ROOTPREFIX="${prefix}" + ROOTBINDIR="${bindir}" + ROOTLIBDIR="${libdir}" + ROOTETCDIR="${etcdir}" + ROOTDATADIR="${datadir}" + ROOTDOCDIR="${docdir}" + ROOTMACRODIR="${macrodir}" + ROOTTUTDIR="${tutdir}" + ROOTSRCDIR="${srcdir}" + ROOTICONPATH="${iconpath}" + TTFFONTDIR="${ttffontdir}" ) endif() @@ -432,7 +432,7 @@ target_compile_definitions(RConfigureDefs INTERFACE $<$:R__HAS_COCOA> $<$:R__HAS_VDT> $<$:R__HAS_STD_EXPERIMENTAL_SIMD> - $<$:R__EXPERIMENTAL_SIMD_PIN_AVX_ABI> + $<$:R__EXPERIMENTAL_SIMD_PIN_AVX_ABI> $<$:R__USE_CXXMODULES> $<$:R__USE_LIBCXX> $<$:R__HAS_ATTRIBUTE_ALWAYS_INLINE> @@ -454,7 +454,6 @@ target_compile_definitions(RConfigureDefs INTERFACE $<$:R__HAS_PYMVA> $<$:R__HAS_URING> $<$:R__HAS_GEOM> - $<$:-Zc:__cplusplus> ) file(GENERATE @@ -879,7 +878,7 @@ file(GENERATE # Public target interface against which to link add_library(ROOTdefs INTERFACE) target_compile_definitions(ROOTdefs INTERFACE -ROOT_RConfigure # so that including the mirror header RConfigure.h is inocuous if linking against this target +ROOT_RConfigure # so that including the mirror header RConfigure.h is innocuous if linking against this target ROOT_RVERSION_HXX ) target_link_libraries(ROOTdefs INTERFACE RConfigureDefs RVersionDefs RConfigDefs)