diff --git a/CMakeLists.txt b/CMakeLists.txt index f248d10bf..908dfb121 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,14 +70,22 @@ option(USE_CUDA "Compile CUDA-involved examples (Needed for examples/SubeventCUD option(USE_PODIO "Compile with PODIO support" OFF) option(BUILD_SHARED_LIBS "Build into both shared and static libs." ON) +if (${USE_PODIO}) + find_package(podio REQUIRED) + set(JANA2_HAVE_PODIO 1) + set(USE_ROOT ON) + include_directories(SYSTEM ${podio_INCLUDE_DIR}) +else() + set(JANA2_HAVE_PODIO 0) +endif() + if (${USE_ROOT}) if((NOT DEFINED ROOT_DIR) AND (DEFINED ENV{ROOTSYS})) set(ROOT_DIR $ENV{ROOTSYS}/cmake) endif() find_package(ROOT REQUIRED) - include(${ROOT_USE_FILE}) - add_compile_definitions(JANA2_HAVE_ROOT) + set(JANA2_HAVE_ROOT 1) include_directories(${ROOT_INCLUDE_DIRS}) link_libraries(${ROOT_LIBRARIES}) execute_process( @@ -90,6 +98,8 @@ if (${USE_ROOT}) "Specify the C++ standard used to compile ROOT with e.g. -DCMAKE_CXX_STANDARD=17. " "Check the root-config output above for cxx flags.") endif() +else() + set(JANA2_HAVE_ROOT 0) endif() if (${USE_ZEROMQ}) @@ -101,10 +111,11 @@ if (${USE_XERCES}) set(XercesC_DIR $ENV{XERCESCROOT}) endif() find_package(XercesC REQUIRED) - add_compile_definitions(JANA2_HAVE_XERCES) - add_compile_definitions(XERCES3) + set(JANA2_HAVE_XERCES 1) include_directories(${XercesC_INCLUDE_DIRS}) link_libraries(${XercesC_LIBRARIES}) +else() + set(JANA2_HAVE_XERCES 0) endif() if (${USE_ASAN}) @@ -121,11 +132,6 @@ if (${USE_CUDA}) find_package(CUDA REQUIRED) endif() -if (${USE_PODIO}) - find_package(podio REQUIRED) - add_compile_definitions(JANA2_HAVE_PODIO) - include_directories(SYSTEM ${podio_INCLUDE_DIR}) -endif() #--------- # Report back to the user what we've discovered @@ -188,6 +194,7 @@ message(STATUS "-----------------------") include_directories(src/libraries) # So that everyone can find the JANA header files include_directories(src/external) # So that everyone can find our vendorized header-old libraries +include_directories(${CMAKE_CURRENT_BINARY_DIR}/src/libraries) # So that everyone can find JVersion.h # This is needed on macos to allow plugins to link without resolving all JANA symbols until runtime if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") @@ -208,3 +215,4 @@ add_subdirectory(src/python) install(DIRECTORY scripts/ DESTINATION bin FILES_MATCHING PATTERN "jana-*.py" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE) include(${CMAKE_SOURCE_DIR}/cmake/MakeConfig.cmake) +include(${CMAKE_SOURCE_DIR}/cmake/MakeJVersionH.cmake) diff --git a/cmake/MakeConfig.cmake b/cmake/MakeConfig.cmake index 4ec1a0b18..9335c34a9 100644 --- a/cmake/MakeConfig.cmake +++ b/cmake/MakeConfig.cmake @@ -1,7 +1,6 @@ # # This is used in the generation of the files: # jana-config -# jana_config.h # jana-this.sh # jana-this.csh # @@ -25,46 +24,51 @@ execute_process(COMMAND SBMS/osrelease.pl OUTPUT_STRIP_TRAILING_WHITESPACE) # ROOT -if(DEFINED ENV{ROOTSYS}) - set(JANA2_HAVE_ROOT 1) - set(ROOTSYS $ENV{ROOTSYS}) - - execute_process(COMMAND $ENV{ROOTSYS}/bin/root-config --cflags - OUTPUT_VARIABLE ROOTCFLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process(COMMAND $ENV{ROOTSYS}/bin/root-config --glibs - OUTPUT_VARIABLE ROOTGLIBS - OUTPUT_STRIP_TRAILING_WHITESPACE) -else() +if(${USE_ROOT}) + if(DEFINED ENV{ROOTSYS}) + set(JANA2_HAVE_ROOT 1) + set(ROOTSYS $ENV{ROOTSYS}) + + execute_process(COMMAND $ENV{ROOTSYS}/bin/root-config --cflags + OUTPUT_VARIABLE ROOTCFLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process(COMMAND $ENV{ROOTSYS}/bin/root-config --glibs + OUTPUT_VARIABLE ROOTGLIBS + OUTPUT_STRIP_TRAILING_WHITESPACE) + else() # message(STATUS "Did not find ROOT") + set(JANA2_HAVE_ROOT 0) + endif() +else() set(JANA2_HAVE_ROOT 0) endif() # XERCESC # n.b. this is hard-coded for now to assume XERCES 3 -if(DEFINED ENV{XERCESCROOT}) - set(JANA2_HAVE_XERCES 1) - set(XERCES3 1) - set(XERCESCROOT $ENV{XERCESCROOT}) - set(XERCES_CPPFLAGS "-I${XERCESCROOT}/include/xercesc") - set(XERCES_LIBS "-lxerces-c") - if( NOT $XERCESCROOT EQUAL "/usr" ) - set(XERCES_CPPFLAGS "${XERCES_CPPFLAGS} -I${XERCESCROOT}/include") - set(XERCES_LDFLAGS "-L${XERCESCROOT}/lib") - endif() -else() - find_package(XercesC) - if(XercesC_FOUND) +if(${USE_XERCES}) + if(DEFINED ENV{XERCESCROOT}) set(JANA2_HAVE_XERCES 1) - set(XERCES3 1) - get_filename_component(XERCESCROOT "${XercesC_INCLUDE_DIRS}" DIRECTORY) - set(XERCES_CPPFLAGS "-I${XercesC_INCLUDE_DIRS} -I${XercesC_INCLUDE_DIRS}/xercesc") - set(XERCES_LIBS "${XercesC_LIBRARIES}") + set(XERCESCROOT $ENV{XERCESCROOT}) + set(XERCES_CPPFLAGS "-I${XERCESCROOT}/include/xercesc") + set(XERCES_LIBS "-lxerces-c") + if( NOT $XERCESCROOT EQUAL "/usr" ) + set(XERCES_CPPFLAGS "${XERCES_CPPFLAGS} -I${XERCESCROOT}/include") + set(XERCES_LDFLAGS "-L${XERCESCROOT}/lib") + endif() else() - set(JANA2_HAVE_XERCES 0) - set(XERCES3 0) + find_package(XercesC) + if(XercesC_FOUND) + set(JANA2_HAVE_XERCES 1) + get_filename_component(XERCESCROOT "${XercesC_INCLUDE_DIRS}" DIRECTORY) + set(XERCES_CPPFLAGS "-I${XercesC_INCLUDE_DIRS} -I${XercesC_INCLUDE_DIRS}/xercesc") + set(XERCES_LIBS "${XercesC_LIBRARIES}") + else() + set(JANA2_HAVE_XERCES 0) + endif() endif() +else() + set(JANA2_HAVE_XERCES 0) endif() # cMsg @@ -140,15 +144,10 @@ else() set(HAVE_CURL 0) endif() -# TODO: FindNuma.cmake -set(HAVE_NUMA 0) - configure_file(scripts/jana-config.in jana-config @ONLY) -configure_file(scripts/jana_config.h.in src/libraries/JANA/jana_config.h @ONLY) configure_file(scripts/jana-this.sh.in jana-this.sh @ONLY) configure_file(scripts/jana-this.csh.in jana-this.csh @ONLY) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jana-config DESTINATION bin) -install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/src/libraries/JANA/jana_config.h DESTINATION include/JANA) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jana-this.sh DESTINATION bin) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jana-this.csh DESTINATION bin) diff --git a/src/libraries/JANA/CLI/CMakeLists.txt b/cmake/MakeJVersionH.cmake similarity index 91% rename from src/libraries/JANA/CLI/CMakeLists.txt rename to cmake/MakeJVersionH.cmake index 7fc6b2fc2..8b3f7ad38 100644 --- a/src/libraries/JANA/CLI/CMakeLists.txt +++ b/cmake/MakeJVersionH.cmake @@ -68,6 +68,6 @@ else() endif() message(STATUS "Generating JVersion.h") -configure_file(JVersion.h.in JVersion.h) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/JVersion.h DESTINATION include/JANA/CLI) +configure_file(src/libraries/JANA/JVersion.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/libraries/JANA/JVersion.h @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libraries/JANA/JVersion.h DESTINATION include/JANA) diff --git a/scripts/jana_config.h.in b/scripts/jana_config.h.in deleted file mode 100644 index 7f9525c13..000000000 --- a/scripts/jana_config.h.in +++ /dev/null @@ -1,10 +0,0 @@ -// -// This file was generated by CMake (see cmake/make_config.cmake) -// - -#define JANA2_HAVE_ROOT @JANA2_HAVE_ROOT@ -#define JANA2_HAVE_XERCES @JANA2_HAVE_XERCES@ -#define XERCES3 @XERCES3@ -#define HAVE_CCDB @HAVE_CCDB@ -#define HAVE_NUMA @HAVE_NUMA@ - diff --git a/src/examples/RootDatamodelExample/CMakeLists.txt b/src/examples/RootDatamodelExample/CMakeLists.txt index 131b412f8..e170f771e 100644 --- a/src/examples/RootDatamodelExample/CMakeLists.txt +++ b/src/examples/RootDatamodelExample/CMakeLists.txt @@ -1,7 +1,6 @@ if(${USE_ROOT}) find_package(ROOT REQUIRED) - include(${ROOT_USE_FILE}) # Generate ROOT dictionaries for each of our ROOT object types # The foreach statement below should end with a list of classes @@ -34,7 +33,6 @@ if(${USE_ROOT}) ) add_library(RootDatamodelExample_plugin SHARED ${RootDatamodelExample_PLUGIN_SOURCES}) - target_compile_definitions(RootDatamodelExample_plugin PUBLIC JANA2_HAVE_ROOT) target_include_directories(RootDatamodelExample_plugin PUBLIC ${JANA_INCLUDE_DIR} ${ROOT_INCLUDE_DIRS}) target_link_libraries(RootDatamodelExample_plugin jana2) target_link_libraries(RootDatamodelExample_plugin ${ROOT_LIBRARIES}) diff --git a/src/libraries/JANA/CLI/JMain.cc b/src/libraries/JANA/CLI/JMain.cc index 81373643a..d28085c3a 100644 --- a/src/libraries/JANA/CLI/JMain.cc +++ b/src/libraries/JANA/CLI/JMain.cc @@ -4,16 +4,10 @@ #include "JMain.h" -#include +#include #include #include -// The values of JVERSION_COMMIT_HASH and JVERSION_COMMIT_DATE -// are #defined in JVersion.h.in so cmake can set them. -const std::string JVersion::last_commit_hash = JVERSION_COMMIT_HASH; -const std::string JVersion::last_commit_date = JVERSION_COMMIT_DATE; -const std::string JVersion::installdir = CMAKE_INSTALL_PREFIX; - namespace jana { diff --git a/src/libraries/JANA/CLI/JVersion.h b/src/libraries/JANA/CLI/JVersion.h new file mode 100644 index 000000000..10a0d697a --- /dev/null +++ b/src/libraries/JANA/CLI/JVersion.h @@ -0,0 +1,8 @@ +#pragma once + +// We are moving JVersion.h out of CLI. +// In the future, use #include instead. + +#include + + diff --git a/src/libraries/JANA/CMakeLists.txt b/src/libraries/JANA/CMakeLists.txt index 8f06c4a15..89390b67d 100644 --- a/src/libraries/JANA/CMakeLists.txt +++ b/src/libraries/JANA/CMakeLists.txt @@ -1,6 +1,4 @@ -# For now all the CMakeLists in 'CLI' does is generate and install JVersion.h -add_subdirectory(CLI) # Everything else happens below set(JANA2_SOURCES @@ -127,8 +125,6 @@ set(JANA2_SOURCES Compatibility/JGeometry.h Compatibility/JGeometryManager.cc Compatibility/JGeometryManager.h - Compatibility/JGeometryMYSQL.cc - Compatibility/JGeometryMYSQL.h Compatibility/JGeometryXML.cc Compatibility/JGeometryXML.h Compatibility/md5.c @@ -152,14 +148,11 @@ add_library(jana2 OBJECT ${JANA2_SOURCES}) find_package(Threads REQUIRED) set(THREADS_PREFER_PTHREAD_FLAG ON) -target_include_directories(jana2 PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/..) -# So that we can find the generated JVersion.h before install target_link_libraries(jana2 ${CMAKE_DL_LIBS} Threads::Threads) + if (${USE_PODIO}) - target_compile_definitions(jana2 PUBLIC JANA2_HAVE_PODIO=1 JANA2_HAVE_ROOT=1) target_link_libraries(jana2 podio::podio podio::podioRootIO ${ROOT_LIBRARIES}) elseif (${USE_ROOT}) - target_compile_definitions(jana2 PUBLIC JANA2_HAVE_ROOT=1) target_link_libraries(jana2 ${ROOT_LIBRARIES}) endif() @@ -172,10 +165,8 @@ target_include_directories(jana2_static_lib PUBLIC $) target_link_libraries(jana2_static_lib ${CMAKE_DL_LIBS} Threads::Threads) if (${USE_PODIO}) - target_compile_definitions(jana2_static_lib PUBLIC JANA2_HAVE_PODIO=1 JANA2_HAVE_ROOT=1) target_link_libraries(jana2_static_lib podio::podio podio::podioRootIO ${ROOT_LIBRARIES}) elseif (${USE_ROOT}) - target_compile_definitions(jana2_static_lib PUBLIC JANA2_HAVE_ROOT=1) target_link_libraries(jana2_static_lib ${ROOT_LIBRARIES}) endif() install(TARGETS jana2_static_lib EXPORT jana2_targets DESTINATION lib) @@ -191,10 +182,8 @@ if (BUILD_SHARED_LIBS) target_link_libraries(jana2_shared_lib ${CMAKE_DL_LIBS} Threads::Threads) if (${USE_PODIO}) - target_compile_definitions(jana2_shared_lib PUBLIC JANA2_HAVE_PODIO=1 JANA2_HAVE_ROOT=1) target_link_libraries(jana2_shared_lib podio::podio podio::podioRootIO ${ROOT_LIBRARIES}) elseif (${USE_ROOT}) - target_compile_definitions(jana2_shared_lib PUBLIC JANA2_HAVE_ROOT=1) target_link_libraries(jana2_shared_lib ${ROOT_LIBRARIES}) endif() diff --git a/src/libraries/JANA/Compatibility/JGeometryMYSQL.cc b/src/libraries/JANA/Compatibility/JGeometryMYSQL.cc deleted file mode 100644 index 12676b7bf..000000000 --- a/src/libraries/JANA/Compatibility/JGeometryMYSQL.cc +++ /dev/null @@ -1,67 +0,0 @@ -// $Id$ -// -// File: JGeometryMYSQL.cc -// Created: Wed May 7 16:21:37 EDT 2008 -// Creator: davidl (on Darwin swire-d95.jlab.org 8.11.1 i386) -// - -#include "JGeometryMYSQL.h" - -//--------------------------------- -// JGeometryMYSQL (Constructor) -//--------------------------------- -JGeometryMYSQL::JGeometryMYSQL(string url, int run, string context):JGeometry(url,run,context) -{ - -} - -//--------------------------------- -// ~JGeometryMYSQL (Destructor) -//--------------------------------- -JGeometryMYSQL::~JGeometryMYSQL() -{ - -} - -//--------------------------------- -// Get -//--------------------------------- -bool JGeometryMYSQL::Get(string /*path*/, string &/*sval*/) -{ - - // Looks like we failed to find the requested item. Let the caller know. - return false; -} - -//--------------------------------- -// Get -//--------------------------------- -bool JGeometryMYSQL::Get(string /*path*/, map &/*svals*/) -{ - // Looks like we failed to find the requested item. Let the caller know. - return false; -} - -//--------------------------------- -// GetMultiple -//--------------------------------- -bool JGeometryMYSQL::GetMultiple(string /*xpath*/, vector &/*vsval*/) -{ - return false; -} - -//--------------------------------- -// GetMultiple -//--------------------------------- -bool JGeometryMYSQL::GetMultiple(string /*xpath*/, vector >&/*vsvals*/) -{ - return false; -} - -//--------------------------------- -// GetXPaths -//--------------------------------- -void JGeometryMYSQL::GetXPaths(vector &/*paths*/, ATTR_LEVEL_t /*level*/, const string &/*filter*/) -{ - -} diff --git a/src/libraries/JANA/Compatibility/JGeometryMYSQL.h b/src/libraries/JANA/Compatibility/JGeometryMYSQL.h deleted file mode 100644 index e25857b86..000000000 --- a/src/libraries/JANA/Compatibility/JGeometryMYSQL.h +++ /dev/null @@ -1,33 +0,0 @@ -// $Id$ -// -// File: JGeometryMYSQL.h -// Created: Wed May 7 16:21:37 EDT 2008 -// Creator: davidl (on Darwin swire-d95.jlab.org 8.11.1 i386) -// - -#pragma once -#include -#include -//#include - - -class JGeometryMYSQL:public JGeometry{ - public: - JGeometryMYSQL(string url, int run, string context="default"); - virtual ~JGeometryMYSQL(); - - bool Get(string xpath, string &sval); - bool Get(string xpath, map &svals); - bool GetMultiple(string xpath, vector &vsval); - bool GetMultiple(string xpath, vector >&vsvals); - void GetXPaths(vector &xpaths, ATTR_LEVEL_t level, const string &filter=""); - - protected: - - - private: - JGeometryMYSQL(); - -}; - - diff --git a/src/libraries/JANA/Compatibility/JGeometryManager.cc b/src/libraries/JANA/Compatibility/JGeometryManager.cc index 9e3cb576c..e8b2b2651 100644 --- a/src/libraries/JANA/Compatibility/JGeometryManager.cc +++ b/src/libraries/JANA/Compatibility/JGeometryManager.cc @@ -7,7 +7,6 @@ #include #include -#include JGeometry *JGeometryManager::GetJGeometry(unsigned int run_number) { @@ -53,9 +52,11 @@ JGeometry *JGeometryManager::GetJGeometry(unsigned int run_number) { if (url_str.find("xmlfile://") == 0 || url_str.find("ccdb://") == 0) { g = new JGeometryXML(string(url), run_number, context); } + /* else if (url_str.find("mysql:") == 0) { g = new JGeometryMYSQL(string(url), run_number, context); } + */ if (g) { geometries.push_back(g); } diff --git a/src/libraries/JANA/Compatibility/JGeometryXML.cc b/src/libraries/JANA/Compatibility/JGeometryXML.cc index a9bbae502..459b37e67 100644 --- a/src/libraries/JANA/Compatibility/JGeometryXML.cc +++ b/src/libraries/JANA/Compatibility/JGeometryXML.cc @@ -19,26 +19,6 @@ using namespace std; #include "JGeometryXML.h" #if JANA2_HAVE_XERCES - -#if XERCES3 -// XERCES 3 - -#else -// XERCES 2 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif - using namespace xercesc; #endif @@ -181,18 +161,12 @@ void JGeometryXML::Init(string xmlfile, string xml) XMLPlatformUtils::Initialize(); // Instantiate the DOM parser. -#if XERCES3 parser = new XercesDOMParser(); parser->setCreateEntityReferenceNodes(false); parser->setValidationScheme(XercesDOMParser::Val_Always); parser->setValidationSchemaFullChecking(true); parser->setDoSchema(true); parser->setDoNamespaces(true); // optional -#else - static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull }; - DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(gLS); - parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0); -#endif // Create an error handler and install it JGeometryXML::ErrorHandler errorHandler; @@ -208,30 +182,19 @@ void JGeometryXML::Init(string xmlfile, string xml) // Parse top-level file allowing entity resolver to handle lower levels if( xml != "" ){ // --- Read lower levels from Calib DB -#if XERCES3 xercesc::MemBufInputSource myxml_buf((const unsigned char*)xml.c_str(), xml.size(), "myxml (in memory)"); parser->parse(myxml_buf); md5_checksum = myEntityResolver.GetMD5_checksum(); -#else - jerr << "XML string (as opposed to file) parsing not supported with xerces2" << endl; - exit(-1); -#endif }else{ // --- Read top and lower levels from files -#if XERCES3 parser->parse(xmlfile.c_str()); md5_checksum = myEntityResolver.GetMD5_checksum(); -#else - doc = parser->parseURI(xmlfile.c_str()); -#endif } // Process xml string -#if XERCES3 // Get full DOM doc = parser->getDocument(); -#endif valid_xmlfile = true; @@ -998,11 +961,7 @@ JGeometryXML::EntityResolver::~EntityResolver() //---------------------------------- // resolveEntity //---------------------------------- -#if XERCES3 xercesc::InputSource* JGeometryXML::EntityResolver::resolveEntity(const XMLCh* const publicId, const XMLCh* const systemId) -#else -xercesc::DOMInputSource* JGeometryXML::EntityResolver::resolveEntity(const XMLCh* const publicId, const XMLCh* const systemId, const XMLCh* const baseURI) -#endif { /// This method gets called from the xerces parser each time it /// opens a file (except for the top-level file). For each of these, diff --git a/src/libraries/JANA/Compatibility/JGeometryXML.h b/src/libraries/JANA/Compatibility/JGeometryXML.h index 1e2cc4885..0a0eacb7c 100644 --- a/src/libraries/JANA/Compatibility/JGeometryXML.h +++ b/src/libraries/JANA/Compatibility/JGeometryXML.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include @@ -20,9 +20,6 @@ #if JANA2_HAVE_XERCES #if !defined(__CINT__) && !defined(__CLING__) - -#if XERCES3 - // XERCES3 #include #include @@ -30,18 +27,6 @@ #include #include #include -#else - -// XERCES2 -#include -#include -#include -#include -#include -#include -#include - -#endif #else // __CINT__ __CLING__ namespace xercesc{ @@ -118,11 +103,7 @@ class JGeometryXML:public JGeometry{ }; -#if XERCES3 xercesc::XercesDOMParser *parser; -#else // XERCES3 - xercesc::DOMBuilder *parser; -#endif // XERCES3 xercesc::DOMDocument *doc; void AddNodeToList(xercesc::DOMNode* start, string start_path, vector &xpaths, JGeometry::ATTR_LEVEL_t level); @@ -133,11 +114,7 @@ class JGeometryXML:public JGeometry{ static void GetAttributes(xercesc::DOMNode* node, map &attributes); // Error handler callback class -#if XERCES3 class ErrorHandler : public xercesc::ErrorHandler -#else // XERCES3 - class ErrorHandler : public xercesc::DOMErrorHandler -#endif // XERCES3 { public: // Constructors and Destructor @@ -147,11 +124,9 @@ class JGeometryXML:public JGeometry{ void resetErrors(){} // Purely virtual methods -#if XERCES3 void warning(const xercesc::SAXParseException& /*exc*/){} void error(const xercesc::SAXParseException& /*exc*/){} void fatalError(const xercesc::SAXParseException& /*exc*/){} -#endif // XERCES3 private : // Unimplemented constructors and operators @@ -162,20 +137,12 @@ class JGeometryXML:public JGeometry{ // A simple entity resolver to keep track of files being // included from the top-level XML file so a full MD5 sum // can be made -#if XERCES3 class EntityResolver : public xercesc::EntityResolver -#else - class EntityResolver : public xercesc::DOMEntityResolver -#endif // XERCES3 { public: EntityResolver(const std::string &xmlFile, JCalibration *jcalib); ~EntityResolver(); -#if XERCES3 xercesc::InputSource* resolveEntity(const XMLCh* const publicId, const XMLCh* const systemId); -#else // XERCES3 - xercesc::DOMInputSource* resolveEntity(const XMLCh* const publicId, const XMLCh* const systemId, const XMLCh* const baseURI); -#endif // XERCES3 std::vector GetXMLFilenames(void); diff --git a/src/libraries/JANA/JEvent.h b/src/libraries/JANA/JEvent.h index 628bc45c7..ef0134bc7 100644 --- a/src/libraries/JANA/JEvent.h +++ b/src/libraries/JANA/JEvent.h @@ -10,11 +10,14 @@ #include #include +#include + #include #include #include #include #include +#include #include #include @@ -22,9 +25,8 @@ #include #include #include -#include "JANA/Utils/JInspector.h" -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO #include namespace podio { class CollectionBase; @@ -51,7 +53,7 @@ class JEvent : public std::enable_shared_from_this void SetFactorySet(JFactorySet* aFactorySet) { delete mFactorySet; mFactorySet = aFactorySet; -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO // Maintain the index of PODIO factories for (JFactory* factory : mFactorySet->GetAllFactories()) { if (dynamic_cast(factory) != nullptr) { @@ -97,7 +99,7 @@ class JEvent : public std::enable_shared_from_this template JFactoryT* Insert(const std::vector& items, const std::string& tag = "") const; // PODIO -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO std::vector GetAllCollectionNames() const; const podio::CollectionBase* GetCollectionBase(std::string name, bool throw_on_missing=true) const; template const typename JFactoryPodioT::CollectionT* GetCollection(std::string name, bool throw_on_missing=true) const; @@ -210,7 +212,7 @@ class JEvent : public std::enable_shared_from_this -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO std::map mPodioFactories; #endif }; @@ -504,7 +506,7 @@ JFactoryT* JEvent::GetSingle(const T* &t, const char *tag, bool exception_if_ return fac; } -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO inline std::vector JEvent::GetAllCollectionNames() const { std::vector keys; diff --git a/src/libraries/JANA/JFactoryT.h b/src/libraries/JANA/JFactoryT.h index a97f6f605..7151ee841 100644 --- a/src/libraries/JANA/JFactoryT.h +++ b/src/libraries/JANA/JFactoryT.h @@ -10,9 +10,10 @@ #include #include #include +#include #include -#ifdef JANA2_HAVE_ROOT +#if JANA2_HAVE_ROOT #include #endif @@ -35,7 +36,7 @@ class JFactoryT : public JFactory { JFactoryT(const std::string& aName, const std::string& aTag) __attribute__ ((deprecated)) : JFactory(aName, aTag) { EnableGetAs(); EnableGetAs( std::is_convertible() ); // Automatically add JObject if this can be converted to it -#ifdef JANA2_HAVE_ROOT +#if JANA2_HAVE_ROOT EnableGetAs( std::is_convertible() ); // Automatically add TObject if this can be converted to it #endif } @@ -43,7 +44,7 @@ class JFactoryT : public JFactory { JFactoryT(const std::string& aName) __attribute__ ((deprecated)) : JFactory(aName, "") { EnableGetAs(); EnableGetAs( std::is_convertible() ); // Automatically add JObject if this can be converted to it -#ifdef JANA2_HAVE_ROOT +#if JANA2_HAVE_ROOT EnableGetAs( std::is_convertible() ); // Automatically add TObject if this can be converted to it #endif } @@ -51,7 +52,7 @@ class JFactoryT : public JFactory { JFactoryT() : JFactory(JTypeInfo::demangle(), ""){ EnableGetAs(); EnableGetAs( std::is_convertible() ); // Automatically add JObject if this can be converted to it -#ifdef JANA2_HAVE_ROOT +#if JANA2_HAVE_ROOT EnableGetAs( std::is_convertible() ); // Automatically add TObject if this can be converted to it #endif } diff --git a/src/libraries/JANA/JMultifactory.cc b/src/libraries/JANA/JMultifactory.cc index 0e8fb4237..a36f4c66d 100644 --- a/src/libraries/JANA/JMultifactory.cc +++ b/src/libraries/JANA/JMultifactory.cc @@ -10,7 +10,7 @@ void JMultifactory::Execute(const std::shared_ptr& event) { std::lock_guard lock(m_mutex); -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO if (mNeedPodio) { mPodioFrame = GetOrCreateFrame(event); } diff --git a/src/libraries/JANA/JMultifactory.h b/src/libraries/JANA/JMultifactory.h index fe4c2b454..df5be8672 100644 --- a/src/libraries/JANA/JMultifactory.h +++ b/src/libraries/JANA/JMultifactory.h @@ -8,8 +8,9 @@ #include #include #include +#include -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO #include #include "JANA/Podio/JFactoryPodioT.h" #endif @@ -35,7 +36,7 @@ class JMultifactoryHelper : public JFactoryT{ }; -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO // TODO: This redundancy goes away if we merge JFactoryPodioT with JFactoryT template class JMultifactoryHelperPodio : public JFactoryPodioT{ @@ -70,7 +71,7 @@ class JMultifactory : public jana::omni::JComponent, // This can be used for parameter and collection name prefixing, though at a higher level std::string mFactoryName; // So we can propagate this to the JMultifactoryHelpers, so we can have useful error messages -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO bool mNeedPodio = false; // Whether we need to retrieve the podio::Frame podio::Frame* mPodioFrame = nullptr; // To provide the podio::Frame to SetPodioData, SetCollection #endif @@ -97,7 +98,7 @@ class JMultifactory : public jana::omni::JComponent, template void SetData(std::string tag, std::vector data); -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO template void DeclarePodioOutput(std::string tag, bool owns_data=true); @@ -158,7 +159,7 @@ void JMultifactory::SetData(std::string tag, std::vector data) { ex.plugin_name = m_plugin_name; throw ex; } -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO // This may or may not be a Podio factory. We find out if it is, and if so, set the frame before calling Set(). auto* typed = dynamic_cast(helper); if (typed != nullptr) { @@ -169,7 +170,7 @@ void JMultifactory::SetData(std::string tag, std::vector data) { } -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO template void JMultifactory::DeclarePodioOutput(std::string tag, bool owns_data) { @@ -245,7 +246,7 @@ void JMultifactoryHelper::Process(const std::shared_ptr &event) mMultiFactory->Execute(event); } -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO template void JMultifactoryHelperPodio::Process(const std::shared_ptr &event) { mMultiFactory->SetApplication(this->GetApplication()); diff --git a/src/libraries/JANA/CLI/JVersion.h.in b/src/libraries/JANA/JVersion.h.in similarity index 72% rename from src/libraries/JANA/CLI/JVersion.h.in rename to src/libraries/JANA/JVersion.h.in index cb6a3c695..8745a8834 100644 --- a/src/libraries/JANA/CLI/JVersion.h.in +++ b/src/libraries/JANA/JVersion.h.in @@ -5,14 +5,21 @@ #pragma once #include +#define JANA2_HAVE_PODIO @JANA2_HAVE_PODIO@ +#define JANA2_HAVE_ROOT @JANA2_HAVE_ROOT@ +#define JANA2_HAVE_XERCES @JANA2_HAVE_XERCES@ + + struct JVersion { static const int major = @jana2_VERSION_MAJOR@; static const int minor = @jana2_VERSION_MINOR@; static const int patch = @jana2_VERSION_PATCH@; - static const std::string last_commit_hash; - static const std::string last_commit_date; - static const std::string installdir; + + inline static const std::string last_commit_hash = "@JVERSION_COMMIT_HASH@"; + inline static const std::string last_commit_date = "@JVERSION_COMMIT_DATE@"; + inline static const std::string installdir = "@CMAKE_INSTALL_PREFIX@"; + static const bool is_unknown = @JVERSION_UNKNOWN@; static const bool is_release = @JVERSION_RELEASE@; static const bool is_modified = @JVERSION_MODIFIED@; @@ -23,9 +30,12 @@ struct JVersion { static std::string GetCommitHash() { return last_commit_hash; } static std::string GetCommitDate() { return last_commit_date; } - static std::string GetInstallDir() { return installdir; } + static bool HasPodio() { return JANA2_HAVE_PODIO; } + static bool HasROOT() { return JANA2_HAVE_ROOT; } + static bool HasXerces() { return JANA2_HAVE_XERCES; } + static std::string GetVersion() { std::stringstream ss; ss << major << "." << minor << "." << patch; @@ -46,10 +56,5 @@ struct JVersion { } }; -// These are defined here to allow cmake to set them but are -// actually used in JMain.cc. -#define JVERSION_COMMIT_HASH "@JVERSION_COMMIT_HASH@" -#define JVERSION_COMMIT_DATE "@JVERSION_COMMIT_DATE@" -#define CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" diff --git a/src/libraries/JANA/Omni/JHasInputs.h b/src/libraries/JANA/Omni/JHasInputs.h index 94508807a..71912b0fd 100644 --- a/src/libraries/JANA/Omni/JHasInputs.h +++ b/src/libraries/JANA/Omni/JHasInputs.h @@ -127,7 +127,7 @@ struct JHasInputs { } }; -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO template class PodioInput : public InputBase { diff --git a/src/libraries/JANA/Omni/JHasOutputs.h b/src/libraries/JANA/Omni/JHasOutputs.h index eca931a18..27fc59cb9 100644 --- a/src/libraries/JANA/Omni/JHasOutputs.h +++ b/src/libraries/JANA/Omni/JHasOutputs.h @@ -51,7 +51,7 @@ struct JHasOutputs { }; -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO template class PodioOutput : public OutputBase { diff --git a/src/libraries/JANA/Omni/JOmniFactory.h b/src/libraries/JANA/Omni/JOmniFactory.h index cf495562b..e001910a7 100644 --- a/src/libraries/JANA/Omni/JOmniFactory.h +++ b/src/libraries/JANA/Omni/JOmniFactory.h @@ -10,9 +10,10 @@ * which might be changed by user parameters. */ +#include #include +#include #include -#include #include #include @@ -69,7 +70,7 @@ class JOmniFactory : public JMultifactory, public jana::omni::JHasInputs { }; -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO template class PodioOutput : public OutputBase { diff --git a/src/libraries/JANA/Podio/JPodioTypeHelpers.h b/src/libraries/JANA/Podio/JPodioTypeHelpers.h index 7c1b8e3d0..c5f3b05f0 100644 --- a/src/libraries/JANA/Podio/JPodioTypeHelpers.h +++ b/src/libraries/JANA/Podio/JPodioTypeHelpers.h @@ -7,10 +7,11 @@ #include #include +#include /// These allow us to have both a PODIO-enabled and a PODIO-free definition of certain key structures and functions. -#ifdef JANA2_HAVE_PODIO +#if JANA2_HAVE_PODIO // Sadly, this will only work with C++17 or higher, and for now JANA still supports C++14 (when not using PODIO) template @@ -34,5 +35,5 @@ struct is_podio::collection_t>> : std::t template static constexpr bool is_podio_v = is_podio::value; -#endif //ifdef JANA2_HAVE_PODIO +#endif //if JANA2_HAVE_PODIO diff --git a/src/libraries/JANA/Utils/JCpuInfo.cc b/src/libraries/JANA/Utils/JCpuInfo.cc index 1ea207179..3349a8b9d 100644 --- a/src/libraries/JANA/Utils/JCpuInfo.cc +++ b/src/libraries/JANA/Utils/JCpuInfo.cc @@ -19,9 +19,6 @@ #include #endif //__APPLE__ -#ifdef HAVE_NUMA -#include -#endif //HAVE_NUMA #include @@ -77,45 +74,6 @@ uint32_t GetCpuID() { } - -size_t GetNumaNodeID() { -#ifdef HAVE_NUMA - if (numa_available() == -1) { - return 0; - } else { - return numa_node_of_cpu(GetCpuID()); - } -#else //HAVE_NUMA - return 0; -#endif //HAVE_NUMA -} - -size_t GetNumaNodeID(size_t cpu_id) { -#ifdef HAVE_NUMA - if (numa_available() == -1) { - return 0; - } else { - return numa_node_of_cpu(cpu_id); - } -#else //HAVE_NUMA - (void) cpu_id; // suppress compiler warning. - return 0; -#endif //HAVE_NUMA -} - -size_t GetNumNumaNodes() { -#ifdef HAVE_NUMA - if (numa_available() == -1) { - return 1; - } else { - return numa_num_configured_nodes(); - } -#else //HAVE_NUMA - return 1; -#endif //HAVE_NUMA -} - - bool PinThreadToCpu(std::thread* thread, size_t cpu_id) { if (typeid(std::thread::native_handle_type) != typeid(pthread_t)) { diff --git a/src/libraries/JANA/Utils/JCpuInfo.h b/src/libraries/JANA/Utils/JCpuInfo.h index 004f0067f..bf9f57693 100644 --- a/src/libraries/JANA/Utils/JCpuInfo.h +++ b/src/libraries/JANA/Utils/JCpuInfo.h @@ -22,12 +22,6 @@ namespace JCpuInfo { uint32_t GetCpuID(); - size_t GetNumaNodeID(); - - size_t GetNumaNodeID(size_t cpuid); - - size_t GetNumNumaNodes(); - bool PinThreadToCpu(std::thread *thread, size_t cpu_id); } diff --git a/src/libraries/JANA/Utils/JStringification.cc b/src/libraries/JANA/Utils/JStringification.cc index dc1dc3c16..364da2fd3 100644 --- a/src/libraries/JANA/Utils/JStringification.cc +++ b/src/libraries/JANA/Utils/JStringification.cc @@ -47,7 +47,7 @@ void JStringification::GetObjectSummaries(std::map ss << "0x" << std::hex << (uint64_t)jobj << std::dec; objects[ss.str()] = summary; // key is address of object converted to string } -#ifdef JANA2_HAVE_ROOT +#if JANA2_HAVE_ROOT // For objects inheriting from TObject, we try and convert members automatically // into JObjectSummary form. This relies on dictionaries being compiled in. // (see ROOT_GENERATE_DICTIONARY for cmake files). diff --git a/src/libraries/JANA/Utils/JStringification.h b/src/libraries/JANA/Utils/JStringification.h index 7a59b476e..f85b380d6 100644 --- a/src/libraries/JANA/Utils/JStringification.h +++ b/src/libraries/JANA/Utils/JStringification.h @@ -5,7 +5,9 @@ #pragma once #include -#ifdef JANA2_HAVE_ROOT +#include + +#if JANA2_HAVE_ROOT #include #include #include @@ -41,7 +43,7 @@ class JStringification { template std::string GetAddrAsString(void *addr) const; -#ifdef JANA2_HAVE_ROOT +#if JANA2_HAVE_ROOT std::string GetRootObjectMemberAsString(const TObject *tobj, const TDataMember *memitem, std::string type) const; #endif // JANA2_HAVE_ROOT diff --git a/src/plugins/janaview/CMakeLists.txt b/src/plugins/janaview/CMakeLists.txt index 7b970db98..2f3cbc48f 100644 --- a/src/plugins/janaview/CMakeLists.txt +++ b/src/plugins/janaview/CMakeLists.txt @@ -3,7 +3,6 @@ if(USE_ROOT) find_package(ROOT REQUIRED COMPONENTS Gui Core RIO Net Hist Graf Graf3d Gpad Tree Rint Postscript Matrix Physics MathCore Thread MultiProc) - include(${ROOT_USE_FILE}) ROOT_GENERATE_DICTIONARY(G__jv_mainframe jv_mainframe.h) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/python/common/JEventProcessorPY.h b/src/python/common/JEventProcessorPY.h index 075860aef..5f935ed2c 100644 --- a/src/python/common/JEventProcessorPY.h +++ b/src/python/common/JEventProcessorPY.h @@ -20,6 +20,7 @@ // n.b. There may actually be a way to do this with one class by // manipulating the ref counter in the python object +#include #include #include @@ -29,7 +30,8 @@ using std::endl; #include namespace py = pybind11; -#ifdef JANA2_HAVE_ROOT + +#if JANA2_HAVE_ROOT #include #include #include @@ -113,7 +115,7 @@ class JEventProcessorPY { LOG_ERROR(default_cout_logger) << "Unable to find factory specified for prefetching: factory=" << p.first << " tag=" << p.second << LOG_END; }else { auto v = fac->GetAs(); -#ifdef JANA2_HAVE_ROOT +#if JANA2_HAVE_ROOT if( v.empty() )fac->GetAs(); #endif // JANA2_HAVE_ROOT diff --git a/src/python/modules/jana/jana_module.cc b/src/python/modules/jana/jana_module.cc index 6c17f1a86..e2ec8e238 100644 --- a/src/python/modules/jana/jana_module.cc +++ b/src/python/modules/jana/jana_module.cc @@ -4,7 +4,7 @@ #include #include -#include +#include // Something to throw that makes a nicer error message class PYTHON_MODULE_STARTUP_FAILED{public: PYTHON_MODULE_STARTUP_FAILED(){}};