Skip to content

Commit

Permalink
Merge pull request JeffersonLab#11 from hansenjo/fix-root-libnew
Browse files Browse the repository at this point in the history
Check the ROOT version, and disable the TMapFile if the libNew is not properly supported.  We will need to use an older ROOT to test the realtime systems.
  • Loading branch information
paulmking authored Apr 1, 2024
2 parents e86f040 + 23e9fc8 commit 0692b13
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
16 changes: 14 additions & 2 deletions Analysis/src/QwRootFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ QwRootFile::QwRootFile(const TString& run_label)
// Process the configuration options
ProcessOptions(gQwOptions);

#ifdef QW_ENABLE_MAPFILE
// Check for the memory-mapped file flag
if (fEnableMapFile) {

Expand All @@ -43,8 +44,9 @@ QwRootFile::QwRootFile(const TString& run_label)
QwMessage << "================== RealTime Producer Memory Map File =================" << QwLog::endl;
fMapFile->Print();
QwMessage << "======================================================================" << QwLog::endl;

} else {
} else
#endif
{

TString rootfilename = fRootFileDir;
TString hostname = gSystem -> HostName();
Expand Down Expand Up @@ -249,6 +251,16 @@ void QwRootFile::ProcessOptions(QwOptions &options)

// Option 'mapfile' to enable memory-mapped ROOT file
fEnableMapFile = options.GetValue<bool>("enable-mapfile");
#ifndef QW_ENABLE_MAPFILE
if( fEnableMapFile ) {
QwMessage << QwLog::endl;
QwWarning << "QwRootFile::ProcessOptions: "
<< "The 'enable-mapfile' flag is not supported by the ROOT "
"version with which this app is built. Disabling it."
<< QwLog::endl;
fEnableMapFile = false;
}
#endif
fUseTemporaryFile = options.GetValue<bool>("write-temporary-rootfiles");

// Options 'disable-trees' and 'disable-histos' for disabling
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ target_compile_options(${PROJECT_NAME}
${${PROJECT_NAME_UC}_DIAG_FLAGS_LIST}
)

if(${CMAKE_CXX_STANDARD} LESS 17)
target_compile_definitions(${PROJECT_NAME} PUBLIC QW_ENABLE_MAPFILE)
endif()

target_link_libraries(${PROJECT_NAME}
PRIVATE
evio
Expand Down
16 changes: 9 additions & 7 deletions cmake/modules/CMakeEnv.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ endfunction(get_target_definitions)
#----------------------------------------------------------------------------
# Set project's CXX level if no "-std=xxx" flag given in CXX_FLAGS
macro(set_cxx_std CXX_FLAGS)
string(REGEX MATCH "(^| +)-std=([^ ]*)" std_flag "${CXX_FLAGS}")
if(NOT CMAKE_MATCH_COUNT GREATER 1)
if(DEFINED ROOT_VERSION AND NOT ${ROOT_VERSION} VERSION_LESS 6)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS FALSE)
endif()
string(REGEX MATCH "(^| +)-std=([^ ]*)\\+\\+(..)" std_flag "${CXX_FLAGS}")
if(CMAKE_MATCH_COUNT EQUAL 3)
set(CMAKE_CXX_STANDARD ${CMAKE_MATCH_3})
elseif(DEFINED ROOT_VERSION AND NOT ${ROOT_VERSION} VERSION_LESS 6)
set(CMAKE_CXX_STANDARD 11)
endif()
if(CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS FALSE)
endif()
unset(std_flag)
endmacro(set_cxx_std)
Expand Down
19 changes: 18 additions & 1 deletion cmake/modules/FindROOT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ separate_arguments(ROOT_CXXFLAG_LIST)
separate_arguments(ROOT_LIB_FLAGS)
string(REPLACE "-l" "" ROOT_LIB_FLAGS "${ROOT_LIB_FLAGS}")

# libNew is currently broken with C++17 or higher. See
# https://root-forum.cern.ch/t/aborting-with-std-align-val-t-is-not-implemented-yet-rhel-9-2/55989/17
string(REGEX MATCH "(^| +)-std=([^ ]*)\\+\\+(..)" _cxx_std "${ROOT_CXX_FLAGS}")
set(uselibnew TRUE)
if(CMAKE_MATCH_COUNT EQUAL 3)
if(${CMAKE_MATCH_3} GREATER_EQUAL 17)
set(uselibnew FALSE)
endif()
elseif(${CMAKE_CXX_STANDARD} GREATER_EQUAL 17)
set(uselibnew FALSE)
endif()
unset(_cxx_std)

# Find absolute paths to the core libraries plus any requested components
set(ROOT_LIBRARIES)
set(targetlist)
Expand All @@ -136,10 +149,14 @@ foreach(_lib IN LISTS ROOT_FIND_COMPONENTS ROOT_LIB_FLAGS)
)
list(APPEND ROOT_LIBRARIES ${ROOT_${_lib}_LIBRARY})
list(REMOVE_ITEM ROOT_FIND_COMPONENTS ${_lib})
list(APPEND targetlist ROOT::${_lib})
if(NOT "${_lib}" STREQUAL "New" OR uselibnew)
list(APPEND targetlist ROOT::${_lib})
endif()
endif()
endif()
endforeach()
unset(uselibnew)

if(ROOT_LIBRARIES)
list(REMOVE_DUPLICATES ROOT_LIBRARIES)
endif()
Expand Down
File renamed without changes.

0 comments on commit 0692b13

Please sign in to comment.