From 1dafbc7b8b5dc8cb0cb71ca5625e35ac664752b4 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 2 Aug 2024 00:32:35 -0400 Subject: [PATCH 01/23] Fix PodioExampleDatamodel generation & install This addresses issue #329 --- .gitignore | 5 --- src/examples/PodioExample/CMakeLists.txt | 33 ++++++++++++------- src/examples/PodioExample/DatamodelGlue.h | 8 ++--- .../PodioExample/ExampleClusterFactory.cc | 4 +-- .../PodioExample/ExampleClusterFactory.h | 2 +- src/examples/PodioExample/PodioExample.cc | 4 +-- .../PodioExample/PodioExampleSource.cc | 2 +- src/programs/perf_tests/PodioStressTest.h | 4 +-- .../unit_tests/Components/PodioTests.cc | 2 +- 9 files changed, 34 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 0b4376270..e8356938f 100644 --- a/.gitignore +++ b/.gitignore @@ -65,9 +65,4 @@ cmake-build*/ .cache compile_commands.json -# PODIO generated artifacts -src/examples/PodioExample/datamodel/* -src/examples/PodioExample/src/* -src/examples/PodioExample/podio_generated_files.cmake -podio_build/ diff --git a/src/examples/PodioExample/CMakeLists.txt b/src/examples/PodioExample/CMakeLists.txt index c77838a52..9e29d1be0 100644 --- a/src/examples/PodioExample/CMakeLists.txt +++ b/src/examples/PodioExample/CMakeLists.txt @@ -9,25 +9,34 @@ set(PodioExample_SOURCES if (USE_PODIO) - foreach( _conf ${CMAKE_CONFIGURATION_TYPES} ) - string(TOUPPER ${_conf} _conf ) - set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${_conf} ${CMAKE_CURRENT_BINARY_DIR} ) - set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${_conf} ${CMAKE_CURRENT_BINARY_DIR} ) - set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${_conf} ${CMAKE_CURRENT_BINARY_DIR} ) - endforeach() - PODIO_GENERATE_DATAMODEL(datamodel layout.yaml DATAMODEL_HEADERS DATAMODEL_SOURCES IO_BACKEND_HANDLERS ROOT) - PODIO_ADD_DATAMODEL_CORE_LIB(PodioExampleDatamodel "${DATAMODEL_HEADERS}" "${DATAMODEL_SOURCES}") - PODIO_ADD_ROOT_IO_DICT(PodioExampleDatamodelDict PodioExampleDatamodel "${DATAMODEL_HEADERS}" src/selection.xml) + PODIO_GENERATE_DATAMODEL(PodioExampleDatamodel layout.yaml headers sources + IO_BACKEND_HANDLERS ROOT + OUTPUT_FOLDER ${CMAKE_CURRENT_BINARY_DIR} + ) + + PODIO_ADD_DATAMODEL_CORE_LIB(PodioExampleDatamodel "${headers}" "${sources}" + OUTPUT_FOLDER ${CMAKE_CURRENT_BINARY_DIR}) + + PODIO_ADD_ROOT_IO_DICT(PodioExampleDatamodelDict PodioExampleDatamodel "${headers}" + ${CMAKE_CURRENT_BINARY_DIR}/src/selection.xml) find_package(podio REQUIRED) add_executable(PodioExample ${PodioExample_SOURCES}) - target_include_directories(PodioExample PUBLIC .) - target_link_libraries(PodioExample jana2 podio::podio PodioExampleDatamodel PodioExampleDatamodelDict podio::podioRootIO) + target_link_libraries(PodioExample + jana2 PodioExampleDatamodel PodioExampleDatamodelDict podio::podioRootIO) + set_target_properties(PodioExample PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) install(TARGETS PodioExample DESTINATION bin) - install(TARGETS PodioExampleDatamodel DESTINATION lib) + + install(TARGETS PodioExampleDatamodel + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION include/PodioExampleDatamodel #include/JANA/Plugins/PodioExampleDatamodel + ) + install(TARGETS PodioExampleDatamodelDict DESTINATION lib) + + else() message(STATUS "Skipping examples/PodioExample because USE_PODIO=Off") diff --git a/src/examples/PodioExample/DatamodelGlue.h b/src/examples/PodioExample/DatamodelGlue.h index f0ae08426..a96ac9789 100644 --- a/src/examples/PodioExample/DatamodelGlue.h +++ b/src/examples/PodioExample/DatamodelGlue.h @@ -6,10 +6,10 @@ #ifndef JANA2_DATAMODELGLUE_H #define JANA2_DATAMODELGLUE_H -#include -#include -#include -#include +#include +#include +#include +#include template diff --git a/src/examples/PodioExample/ExampleClusterFactory.cc b/src/examples/PodioExample/ExampleClusterFactory.cc index c718c59e6..9e91ea83a 100644 --- a/src/examples/PodioExample/ExampleClusterFactory.cc +++ b/src/examples/PodioExample/ExampleClusterFactory.cc @@ -4,7 +4,7 @@ #include "ExampleClusterFactory.h" -#include "datamodel/ExampleHit.h" +#include "PodioExampleDatamodel/ExampleHit.h" #include ExampleClusterFactory::ExampleClusterFactory() { @@ -54,4 +54,4 @@ void ExampleClusterFactory::Process(const std::shared_ptr &event) } -// TODO: Expose collections as refs, not ptrs? \ No newline at end of file +// TODO: Expose collections as refs, not ptrs? diff --git a/src/examples/PodioExample/ExampleClusterFactory.h b/src/examples/PodioExample/ExampleClusterFactory.h index 0980c123a..39a979490 100644 --- a/src/examples/PodioExample/ExampleClusterFactory.h +++ b/src/examples/PodioExample/ExampleClusterFactory.h @@ -7,7 +7,7 @@ #define JANA2_EXAMPLECLUSTERFACTORY_H #include -#include "datamodel/ExampleCluster.h" +#include "PodioExampleDatamodel/ExampleCluster.h" #include "DatamodelGlue.h" class ExampleClusterFactory : public JFactoryPodioT { diff --git a/src/examples/PodioExample/PodioExample.cc b/src/examples/PodioExample/PodioExample.cc index 2bf703814..3980238a6 100644 --- a/src/examples/PodioExample/PodioExample.cc +++ b/src/examples/PodioExample/PodioExample.cc @@ -4,8 +4,8 @@ #include #include #include -#include "datamodel/MutableExampleHit.h" -#include "datamodel/ExampleHitCollection.h" +#include "PodioExampleDatamodel/MutableExampleHit.h" +#include "PodioExampleDatamodel/ExampleHitCollection.h" #include #include diff --git a/src/examples/PodioExample/PodioExampleSource.cc b/src/examples/PodioExample/PodioExampleSource.cc index 751dca681..66c5f5e4f 100644 --- a/src/examples/PodioExample/PodioExampleSource.cc +++ b/src/examples/PodioExample/PodioExampleSource.cc @@ -4,7 +4,7 @@ #include "PodioExampleSource.h" -#include +#include std::unique_ptr PodioExampleSource::NextFrame(int event_index, int &event_number, int &run_number) { diff --git a/src/programs/perf_tests/PodioStressTest.h b/src/programs/perf_tests/PodioStressTest.h index f2cddce7c..8ad2ee9df 100644 --- a/src/programs/perf_tests/PodioStressTest.h +++ b/src/programs/perf_tests/PodioStressTest.h @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include diff --git a/src/programs/unit_tests/Components/PodioTests.cc b/src/programs/unit_tests/Components/PodioTests.cc index 184e596fb..9fdcd4099 100644 --- a/src/programs/unit_tests/Components/PodioTests.cc +++ b/src/programs/unit_tests/Components/PodioTests.cc @@ -2,7 +2,7 @@ #include #include -#include +#include #include // Hopefully this won't be necessary in the future #include From 419fb565774669747da352fc3ac96e10cfdeb7a4 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 2 Aug 2024 02:47:50 -0400 Subject: [PATCH 02/23] Isolate plugin install directories - Plugin libraries install to lib/JANA/plugins/ - Plugin headers install to include/JANA/plugins/$PLUGIN_NAME Addresses issue #136 --- .gitignore | 1 - src/examples/DstExample/CMakeLists.txt | 2 +- src/examples/EventGroupExample/CMakeLists.txt | 4 ++-- .../InteractiveStreamingExample/CMakeLists.txt | 4 ++-- src/examples/MetadataExample/CMakeLists.txt | 2 +- src/examples/PodioExample/CMakeLists.txt | 6 +++--- .../RootDatamodelExample/CMakeLists.txt | 6 +++--- src/examples/StreamingExample/CMakeLists.txt | 2 +- src/examples/TimesliceExample/CMakeLists.txt | 2 +- src/examples/Tutorial/CMakeLists.txt | 2 +- src/plugins/JTest/CMakeLists.txt | 4 ++-- src/plugins/janacontrol/src/CMakeLists.txt | 2 +- src/plugins/janadot/CMakeLists.txt | 4 ++-- src/plugins/janarate/CMakeLists.txt | 4 ++-- src/plugins/janaview/CMakeLists.txt | 18 +++++++++--------- src/plugins/regressiontest/CMakeLists.txt | 4 ++-- 16 files changed, 33 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index e8356938f..472e36011 100644 --- a/.gitignore +++ b/.gitignore @@ -52,7 +52,6 @@ Makefile /bin/ /include/ /lib/ -/plugins/ # Doxygen generated files docs/html/* diff --git a/src/examples/DstExample/CMakeLists.txt b/src/examples/DstExample/CMakeLists.txt index d4902359a..be2f2ccfd 100644 --- a/src/examples/DstExample/CMakeLists.txt +++ b/src/examples/DstExample/CMakeLists.txt @@ -16,5 +16,5 @@ add_library(DstExample_plugin SHARED ${DstExample_PLUGIN_SOURCES}) target_include_directories(DstExample_plugin PUBLIC ${JANA_INCLUDE_DIR}) target_link_libraries(DstExample_plugin jana2) set_target_properties(DstExample_plugin PROPERTIES PREFIX "" OUTPUT_NAME "DstExample" SUFFIX ".so") -install(TARGETS DstExample_plugin DESTINATION plugins) +install(TARGETS DstExample_plugin DESTINATION lib/JANA/plugins) diff --git a/src/examples/EventGroupExample/CMakeLists.txt b/src/examples/EventGroupExample/CMakeLists.txt index 9cdafddb4..68df85fed 100644 --- a/src/examples/EventGroupExample/CMakeLists.txt +++ b/src/examples/EventGroupExample/CMakeLists.txt @@ -12,8 +12,8 @@ add_library(EventGroupExample_plugin SHARED ${EventGroupExample_SOURCES}) target_include_directories(EventGroupExample_plugin PUBLIC ${JANA_INCLUDE_DIRS}) target_link_libraries(EventGroupExample_plugin jana2 ${JANA_LIBRARIES}) -set_target_properties(EventGroupExample_plugin PROPERTIES PREFIX "" SUFFIX ".so") +set_target_properties(EventGroupExample_plugin PROPERTIES PREFIX "" OUTPUT_NAME "EventGroupExample" SUFFIX ".so") -install(TARGETS EventGroupExample_plugin DESTINATION ${CMAKE_INSTALL_PREFIX}/plugins) +install(TARGETS EventGroupExample_plugin DESTINATION lib/JANA/plugins) diff --git a/src/examples/InteractiveStreamingExample/CMakeLists.txt b/src/examples/InteractiveStreamingExample/CMakeLists.txt index 26e6ec3c3..a68b772ef 100644 --- a/src/examples/InteractiveStreamingExample/CMakeLists.txt +++ b/src/examples/InteractiveStreamingExample/CMakeLists.txt @@ -23,10 +23,10 @@ if (${USE_ROOT} AND ${USE_ZEROMQ}) target_include_directories(streamDet PUBLIC ${ROOT_INCLUDE_DIRS} ${ZeroMQ_INCLUDE_DIRS}) target_link_libraries(streamDet jana2 ${ZeroMQ_LIBRARIES} ${ROOT_LIBRARIES}) set_target_properties(streamDet PROPERTIES PREFIX "" SUFFIX ".so") - install(TARGETS streamDet DESTINATION plugins) + install(TARGETS streamDet DESTINATION lib/JANA/plugins) file(GLOB my_headers "*.h*") - install(FILES ${my_headers} DESTINATION include/streamDet) + install(FILES ${my_headers} DESTINATION include/JANA/plugins/streamDet) else() message(STATUS "Skipping examples/InteractiveStreamingExample because USE_ROOT=Off or USE_ZEROMQ=Off") diff --git a/src/examples/MetadataExample/CMakeLists.txt b/src/examples/MetadataExample/CMakeLists.txt index 757224d93..b48c95311 100644 --- a/src/examples/MetadataExample/CMakeLists.txt +++ b/src/examples/MetadataExample/CMakeLists.txt @@ -16,5 +16,5 @@ add_library(MetadataExample_plugin SHARED ${MetadataExample_PLUGIN_SOURCES}) target_include_directories(MetadataExample_plugin PUBLIC ${JANA_INCLUDE_DIR}) target_link_libraries(MetadataExample_plugin jana2) set_target_properties(MetadataExample_plugin PROPERTIES PREFIX "" OUTPUT_NAME "MetadataExample" SUFFIX ".so") -install(TARGETS MetadataExample_plugin DESTINATION plugins) +install(TARGETS MetadataExample_plugin DESTINATION lib/JANA/plugins) diff --git a/src/examples/PodioExample/CMakeLists.txt b/src/examples/PodioExample/CMakeLists.txt index 9e29d1be0..83b606240 100644 --- a/src/examples/PodioExample/CMakeLists.txt +++ b/src/examples/PodioExample/CMakeLists.txt @@ -30,11 +30,11 @@ if (USE_PODIO) install(TARGETS PodioExample DESTINATION bin) install(TARGETS PodioExampleDatamodel - LIBRARY DESTINATION lib - PUBLIC_HEADER DESTINATION include/PodioExampleDatamodel #include/JANA/Plugins/PodioExampleDatamodel + LIBRARY DESTINATION lib/JANA/plugins + PUBLIC_HEADER DESTINATION include/JANA/plugins/PodioExampleDatamodel ) - install(TARGETS PodioExampleDatamodelDict DESTINATION lib) + install(TARGETS PodioExampleDatamodelDict DESTINATION lib/JANA/plugins) else() diff --git a/src/examples/RootDatamodelExample/CMakeLists.txt b/src/examples/RootDatamodelExample/CMakeLists.txt index e170f771e..244df4ed5 100644 --- a/src/examples/RootDatamodelExample/CMakeLists.txt +++ b/src/examples/RootDatamodelExample/CMakeLists.txt @@ -37,13 +37,13 @@ if(${USE_ROOT}) target_link_libraries(RootDatamodelExample_plugin jana2) target_link_libraries(RootDatamodelExample_plugin ${ROOT_LIBRARIES}) set_target_properties(RootDatamodelExample_plugin PROPERTIES PREFIX "" OUTPUT_NAME "JTestRoot" SUFFIX ".so") - install(TARGETS RootDatamodelExample_plugin DESTINATION plugins) + install(TARGETS RootDatamodelExample_plugin DESTINATION lib/JANA/plugins) message(STATUS "Installing ROOT PCM files: ${my_pcms}") - install(FILES ${my_pcms} DESTINATION plugins) + install(FILES ${my_pcms} DESTINATION lib/JANA/plugins) file(GLOB my_headers "*.h*") - install(FILES ${my_headers} DESTINATION include/RootDatamodelExample) + install(FILES ${my_headers} DESTINATION include/JANA/plugins/RootDatamodelExample) else() message(STATUS "Skipping plugins/RootDatamodelExample because USE_ROOT=Off") diff --git a/src/examples/StreamingExample/CMakeLists.txt b/src/examples/StreamingExample/CMakeLists.txt index dd2a806a0..a84e2da13 100644 --- a/src/examples/StreamingExample/CMakeLists.txt +++ b/src/examples/StreamingExample/CMakeLists.txt @@ -15,7 +15,7 @@ if (USE_ZEROMQ) target_include_directories(StreamingExample_plugin PUBLIC ${ZeroMQ_INCLUDE_DIRS}) target_link_libraries(StreamingExample_plugin jana2 ${ZeroMQ_LIBRARIES}) set_target_properties(StreamingExample_plugin PROPERTIES PREFIX "" SUFFIX ".so") - install(TARGETS StreamingExample_plugin DESTINATION plugins) + install(TARGETS StreamingExample_plugin DESTINATION lib/JANA/plugins) else() message(STATUS "Skipping examples/StreamingExample because USE_ZEROMQ=Off") diff --git a/src/examples/TimesliceExample/CMakeLists.txt b/src/examples/TimesliceExample/CMakeLists.txt index 13b886b0c..4091c8fe0 100644 --- a/src/examples/TimesliceExample/CMakeLists.txt +++ b/src/examples/TimesliceExample/CMakeLists.txt @@ -9,7 +9,7 @@ if (USE_PODIO) add_library(TimesliceExample SHARED ${TimesliceExample_SOURCES}) target_link_libraries(TimesliceExample PodioExampleDatamodel PodioExampleDatamodelDict podio::podioRootIO) set_target_properties(TimesliceExample PROPERTIES PREFIX "" SUFFIX ".so" OUTPUT_NAME "TimesliceExample") - install(TARGETS TimesliceExample DESTINATION plugins) + install(TARGETS TimesliceExample DESTINATION lib/JANA/plugins) else() message(STATUS "Skipping examples/TimesliceExample because USE_PODIO=Off") diff --git a/src/examples/Tutorial/CMakeLists.txt b/src/examples/Tutorial/CMakeLists.txt index 7e146f4d5..03bc25bb1 100644 --- a/src/examples/Tutorial/CMakeLists.txt +++ b/src/examples/Tutorial/CMakeLists.txt @@ -16,5 +16,5 @@ add_library(Tutorial_plugin SHARED ${Tutorial_PLUGIN_SOURCES}) target_link_libraries(Tutorial_plugin jana2) set_target_properties(Tutorial_plugin PROPERTIES PREFIX "" OUTPUT_NAME "Tutorial" SUFFIX ".so") -install(TARGETS Tutorial_plugin DESTINATION plugins) +install(TARGETS Tutorial_plugin DESTINATION lib/JANA/plugins) diff --git a/src/plugins/JTest/CMakeLists.txt b/src/plugins/JTest/CMakeLists.txt index 00362d81b..ee031a4e5 100644 --- a/src/plugins/JTest/CMakeLists.txt +++ b/src/plugins/JTest/CMakeLists.txt @@ -12,7 +12,7 @@ add_library(jtest SHARED find_package(Threads REQUIRED) target_link_libraries(jtest Threads::Threads) set_target_properties(jtest PROPERTIES PREFIX "" OUTPUT_NAME "JTest" SUFFIX ".so") -install(TARGETS jtest DESTINATION plugins) +install(TARGETS jtest DESTINATION lib/JANA/plugins) file(GLOB my_headers "*.h*") -install(FILES ${my_headers} DESTINATION include/JTest) +install(FILES ${my_headers} DESTINATION include/JANA/plugins/JTest) diff --git a/src/plugins/janacontrol/src/CMakeLists.txt b/src/plugins/janacontrol/src/CMakeLists.txt index 68da47396..b9be580f3 100644 --- a/src/plugins/janacontrol/src/CMakeLists.txt +++ b/src/plugins/janacontrol/src/CMakeLists.txt @@ -17,7 +17,7 @@ if (${USE_ZEROMQ}) target_include_directories(janacontrol_plugin PUBLIC ${JANA_INCLUDE_DIR} ${ZeroMQ_INCLUDE_DIRS}) target_link_libraries(janacontrol_plugin jana2 Threads::Threads ${ZeroMQ_LIBRARIES}) set_target_properties(janacontrol_plugin PROPERTIES PREFIX "" OUTPUT_NAME "janacontrol" SUFFIX ".so") - install(TARGETS janacontrol_plugin DESTINATION plugins) + install(TARGETS janacontrol_plugin DESTINATION lib/JANA/plugins) else() message(STATUS "Skipping plugins/janacontrol because USE_ZEROMQ=Off") diff --git a/src/plugins/janadot/CMakeLists.txt b/src/plugins/janadot/CMakeLists.txt index 8863514dc..ea9d0c73d 100644 --- a/src/plugins/janadot/CMakeLists.txt +++ b/src/plugins/janadot/CMakeLists.txt @@ -3,7 +3,7 @@ add_library(janadot SHARED JEventProcessorJANADOT.cc) find_package(Threads REQUIRED) target_link_libraries(janadot Threads::Threads) set_target_properties(janadot PROPERTIES PREFIX "" OUTPUT_NAME "janadot" SUFFIX ".so") -install(TARGETS janadot DESTINATION plugins) +install(TARGETS janadot DESTINATION lib/JANA/plugins) file(GLOB my_headers "*.h*") -install(FILES ${my_headers} DESTINATION include/janadot) +install(FILES ${my_headers} DESTINATION include/JANA/plugins/janadot) diff --git a/src/plugins/janarate/CMakeLists.txt b/src/plugins/janarate/CMakeLists.txt index 8096965f8..a676548b5 100644 --- a/src/plugins/janarate/CMakeLists.txt +++ b/src/plugins/janarate/CMakeLists.txt @@ -5,10 +5,10 @@ if (${USE_ROOT}) target_include_directories(janarate PUBLIC ${ROOT_INCLUDE_DIRS}) target_link_libraries(janarate jana2 ${ROOT_LIBRARIES}) set_target_properties(janarate PROPERTIES PREFIX "" SUFFIX ".so") - install(TARGETS janarate DESTINATION plugins) + install(TARGETS janarate DESTINATION lib/JANA/plugins) file(GLOB my_headers "*.h*") - install(FILES ${my_headers} DESTINATION include/janarate) + install(FILES ${my_headers} DESTINATION include/JANA/plugins/janarate) else() message(STATUS "Skipping plugins/janarate because USE_ROOT=Off") diff --git a/src/plugins/janaview/CMakeLists.txt b/src/plugins/janaview/CMakeLists.txt index 2f3cbc48f..886cafac0 100644 --- a/src/plugins/janaview/CMakeLists.txt +++ b/src/plugins/janaview/CMakeLists.txt @@ -6,11 +6,11 @@ if(USE_ROOT) ROOT_GENERATE_DICTIONARY(G__jv_mainframe jv_mainframe.h) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -add_library(janaview SHARED - JEventProcessor_janaview.cc - jv_mainframe.cc - G__jv_mainframe.cxx - ) + add_library(janaview SHARED + JEventProcessor_janaview.cc + jv_mainframe.cc + G__jv_mainframe.cxx + ) find_package(Threads REQUIRED) target_include_directories(janaview PUBLIC ${ROOT_INCLUDE_DIRS}) @@ -18,12 +18,12 @@ add_library(janaview SHARED target_link_libraries(janaview Threads::Threads) target_link_libraries(janaview ${ROOT_LIBRARIES}) set_target_properties(janaview PROPERTIES PREFIX "" OUTPUT_NAME "janaview" SUFFIX ".so") - install(TARGETS janaview DESTINATION plugins) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjv_mainframe_rdict.pcm DESTINATION plugins) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjv_mainframe.rootmap DESTINATION plugins) + install(TARGETS janaview DESTINATION lib/JANA/plugins) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjv_mainframe_rdict.pcm DESTINATION lib/JANA/plugins) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjv_mainframe.rootmap DESTINATION lib/JANA/plugins) file(GLOB my_headers "*.h*") - install(FILES ${my_headers} DESTINATION include/janaview) + install(FILES ${my_headers} DESTINATION include/JANA/plugins/janaview) else() message(STATUS "Skipping plugins/janaview because USE_ROOT=Off") diff --git a/src/plugins/regressiontest/CMakeLists.txt b/src/plugins/regressiontest/CMakeLists.txt index 37c784e8a..a3b09865e 100644 --- a/src/plugins/regressiontest/CMakeLists.txt +++ b/src/plugins/regressiontest/CMakeLists.txt @@ -3,7 +3,7 @@ add_library(regressiontest SHARED JEventProcessor_regressiontest.cc) find_package(Threads REQUIRED) target_link_libraries(regressiontest Threads::Threads) set_target_properties(regressiontest PROPERTIES PREFIX "" OUTPUT_NAME "regressiontest" SUFFIX ".so") -install(TARGETS regressiontest DESTINATION plugins) +install(TARGETS regressiontest DESTINATION lib/JANA/plugins) file(GLOB my_headers "*.h*") -install(FILES ${my_headers} DESTINATION include/regressiontest) +install(FILES ${my_headers} DESTINATION include/JANA/plugins/regressiontest) From c8c961490a55b64c50abe16c815677a4b6899fa6 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 2 Aug 2024 02:57:08 -0400 Subject: [PATCH 03/23] Update JPluginLoader search paths --- src/libraries/JANA/Services/JPluginLoader.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/JANA/Services/JPluginLoader.cc b/src/libraries/JANA/Services/JPluginLoader.cc index 70169d0a5..76dae3421 100644 --- a/src/libraries/JANA/Services/JPluginLoader.cc +++ b/src/libraries/JANA/Services/JPluginLoader.cc @@ -76,7 +76,7 @@ void JPluginLoader::resolve_plugin_paths() { // 4. Next we look in the plugin directories relative to $JANA_HOME if (const char* jana_home = getenv("JANA_HOME")) { - add_plugin_path(std::string(jana_home) + "/plugins/JANA"); // In case we did a system install and want to avoid conflicts. + add_plugin_path(std::string(jana_home) + "/lib/JANA/plugins"); // In case we did a system install and want to avoid conflicts. add_plugin_path(std::string(jana_home) + "/plugins"); } @@ -86,7 +86,7 @@ void JPluginLoader::resolve_plugin_paths() { // but we can't guarantee that because the user can set JANA_HOME to be anything they want. // It would be nice if nothing in the JANA codebase itself relied on JANA_HOME, although we // won't be removing it anytime soon because of build_scripts. - add_plugin_path(JVersion::GetInstallDir() + "/plugins"); + add_plugin_path(JVersion::GetInstallDir() + "/lib/JANA/plugins"); } From 8e16f9f96267a0e4ab97d9e66d30e75316bbfb64 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 2 Aug 2024 03:17:31 -0400 Subject: [PATCH 04/23] Vendored headers installed to include/JANA/external --- scripts/jana-generate.py | 4 ++-- src/programs/unit_tests/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/jana-generate.py b/scripts/jana-generate.py index 21b76c163..18380a6ec 100755 --- a/scripts/jana-generate.py +++ b/scripts/jana-generate.py @@ -936,7 +936,7 @@ def build_plugin_test(plugin_name, copy_catch_hpp=True, dir="."): if copy_catch_hpp: files_to_copy = {"catch.hpp": {"sourcedir": "src/external", - "installdir": "include/external", + "installdir": "include/JANA/external", "destname": dir+"/catch.hpp"}} copy_from_source_dir(files_to_copy) @@ -960,7 +960,7 @@ def build_jeventprocessor_test(processor_name, is_mini=True, copy_catch_hpp=True if copy_catch_hpp: files_to_copy = {"catch.hpp": {"sourcedir": "src/external", - "installdir": "include/external", + "installdir": "include/JANA/external", "destname": dir+"/catch.hpp"}} copy_from_source_dir(files_to_copy) diff --git a/src/programs/unit_tests/CMakeLists.txt b/src/programs/unit_tests/CMakeLists.txt index 22532dd17..67e27e0eb 100644 --- a/src/programs/unit_tests/CMakeLists.txt +++ b/src/programs/unit_tests/CMakeLists.txt @@ -60,4 +60,4 @@ if (${USE_PODIO}) endif() install(TARGETS jana-unit-tests DESTINATION bin) -install(FILES ../../external/catch.hpp DESTINATION include/external) +install(FILES ../../external/catch.hpp DESTINATION include/JANA/external) From a8e5d8d0d02ccda46fdb63b63b6e88dbb49031ea Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Sat, 3 Aug 2024 01:09:48 -0400 Subject: [PATCH 05/23] Fix LD_LIBRARY_PATH on docker CI workflow Eventually we should put this in the rpath if possible --- .github/workflows/ccpp-docker.yml | 34 ++++++++++--------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ccpp-docker.yml b/.github/workflows/ccpp-docker.yml index 09d7cf131..ad52102a8 100644 --- a/.github/workflows/ccpp-docker.yml +++ b/.github/workflows/ccpp-docker.yml @@ -18,47 +18,35 @@ jobs: - uses: actions/checkout@v4 - - name: cmake + - name: build run: | - mkdir -p $GITHUB_WORKSPACE/build - cd $GITHUB_WORKSPACE/build - cmake ../ -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/Linux \ + cmake -S . -B build -DCMAKE_INSTALL_PREFIX=`pwd` \ -DUSE_PYTHON=ON \ -DUSE_ROOT=ON \ -DUSE_PODIO=ON \ -DUSE_XERCES=ON \ - -DXercesC_DIR=/usr \ -DUSE_ZEROMQ=ON \ + -DXercesC_DIR=/usr \ -Dpodio_DIR=/app/podio/install/lib/cmake/podio/ - - name: make - run: | - cd $GITHUB_WORKSPACE/build - make - - name: make install - run: | - cd $GITHUB_WORKSPACE/build - make install + cmake --build build --target install - name: JTest run: | echo "--- Running JTest plugin -----------------------" - export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/Linux/plugins - $GITHUB_WORKSPACE/Linux/bin/jana -PPLUGINS=JTest -Pjana:nevents=100 + $GITHUB_WORKSPACE/bin/jana -PPLUGINS=JTest -Pjana:nevents=100 - name: jana-unit-tests run: | echo "--- Running jana-unit-tests ------------------------------" - export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/Linux/plugins - $GITHUB_WORKSPACE/Linux/bin/jana-unit-tests + export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/lib/JANA/plugins:$LD_LIBRARY_PATH + $GITHUB_WORKSPACE/bin/jana-unit-tests - name: TimesliceExample with simple (physics event) topology run: | echo "--- Running TimesliceExample with simple topology ------------------------------" - export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/Linux/plugins - export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/Linux/lib:/app/podio/install/lib:$LD_LIBRARY_PATH - $GITHUB_WORKSPACE/Linux/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=100 events.root + export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/lib/JANA/plugins:/app/podio/install/lib:$LD_LIBRARY_PATH + $GITHUB_WORKSPACE/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=100 events.root - name: TimesliceExample with complex (timeslice) topology run: | echo "--- Running TimesliceExample with complex topology ------------------------------" - export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/Linux/plugins - export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/Linux/lib:/app/podio/install/lib:$LD_LIBRARY_PATH - $GITHUB_WORKSPACE/Linux/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=100 timeslices.root + export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/lib/JANA/plugins:/app/podio/install/lib:$LD_LIBRARY_PATH + $GITHUB_WORKSPACE/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=100 timeslices.root From b2fb89f80c7dc354676244efe3755d39da7ce620 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Mon, 5 Aug 2024 12:48:11 -0400 Subject: [PATCH 06/23] Pull JANAConfig.cmake generation out of src/libraries/JANA --- CMakeLists.txt | 1 + .../JANA => cmake}/JANAConfig.cmake.in | 0 cmake/MakeConfig.cmake | 164 +++--------------- cmake/MakeJanaThis.cmake | 153 ++++++++++++++++ src/libraries/JANA/CMakeLists.txt | 26 --- 5 files changed, 175 insertions(+), 169 deletions(-) rename {src/libraries/JANA => cmake}/JANAConfig.cmake.in (100%) create mode 100644 cmake/MakeJanaThis.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d0d20eac..c3fac469c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,4 +217,5 @@ 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/MakeJanaThis.cmake) include(${CMAKE_SOURCE_DIR}/cmake/MakeJVersionH.cmake) diff --git a/src/libraries/JANA/JANAConfig.cmake.in b/cmake/JANAConfig.cmake.in similarity index 100% rename from src/libraries/JANA/JANAConfig.cmake.in rename to cmake/JANAConfig.cmake.in diff --git a/cmake/MakeConfig.cmake b/cmake/MakeConfig.cmake index 9335c34a9..d1fcce1c6 100644 --- a/cmake/MakeConfig.cmake +++ b/cmake/MakeConfig.cmake @@ -1,153 +1,31 @@ -# -# This is used in the generation of the files: -# jana-config -# jana-this.sh -# jana-this.csh -# -# The primary role of this file is to set cmake variables based on the -# output of running various 3rd party tools meant to help with your -# build system. For example, it runs root-config --cflags and puts the -# results in the ROOTCFLAGS cmake variable. That variable is then used -# in generating the jana-config script so that it can report those flags -# for use when building against this version of JANA. -# -# In addition, some variables such as JANA2_HAVE_ROOT are set which can be used -# in preprocessor directives to conditionally compile code depending on -# whether the 3rd party package is present. -# -set(JANA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) -execute_process(COMMAND SBMS/osrelease.pl - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE BMS_OSNAME - OUTPUT_STRIP_TRAILING_WHITESPACE) +include(CMakePackageConfigHelpers) +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/JANAConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/JANAConfig.cmake" + INSTALL_DESTINATION "lib/cmake/JANA" +) -# ROOT -if(${USE_ROOT}) - if(DEFINED ENV{ROOTSYS}) - set(JANA2_HAVE_ROOT 1) - set(ROOTSYS $ENV{ROOTSYS}) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/cmake/JANAConfigVersion.cmake" + VERSION ${PACKAGE_VERSION} + COMPATIBILITY AnyNewerVersion +) - execute_process(COMMAND $ENV{ROOTSYS}/bin/root-config --cflags - OUTPUT_VARIABLE ROOTCFLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE) +install(EXPORT jana2_targets + FILE "JANATargets.cmake" + NAMESPACE JANA:: + DESTINATION "lib/cmake/JANA") - 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() +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/JANAConfig.cmake" + DESTINATION "lib/cmake/JANA") -# XERCESC -# n.b. this is hard-coded for now to assume XERCES 3 -if(${USE_XERCES}) - if(DEFINED ENV{XERCESCROOT}) - set(JANA2_HAVE_XERCES 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) - 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() +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/JANAConfigVersion.cmake" + DESTINATION "lib/cmake/JANA") -# cMsg -# n.b. I don't believe this will be needed in JANA2 -#if(DEFINED ENV{CMSGROOT}) -# set(HAVE_CMSG 1) -# set(CMSG_CPPFLAGS "-I${CMSGROOT}/include") -# set(CMSG_LDFLAGS "-L${CMSGROOT}/lib") -# set(CMSG_LIBS "-lcmsg -lcmsgxx -lcmsgRegex") -#else() -# set(HAVE_CMSG 0) -#endif() +#install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddExternalPlugin.cmake" +# DESTINATION "lib/cmake/JANA") -# CCDB -if(DEFINED ENV{CCDB_HOME}) - set(HAVE_CCDB 1) - set(CCDB_HOME $ENV{CCDB_HOME}) - set(CCDB_CPPFLAGS "-I${CCDB_HOME}/include") - set(CCDB_LDFLAGS "-L${CCDB_HOME}/lib") - set(CCDB_LIBS "-lccdb") -else() - set(HAVE_CCDB 0) -endif() -# MySQL -# TODO: Strange that MySQL does not provide a FindMySQL.cmake. There seem to be plenty out there though and we should maybe adopt one to replace the following -execute_process(COMMAND which mysql_config - OUTPUT_VARIABLE MYSQL_FOUND - OUTPUT_STRIP_TRAILING_WHITESPACE) -if(MYSQL_FOUND) - set(HAVE_MYSQL 1) - set(JANA2_MYSQL_CONFIG ${MYSQL_FOUND}) - execute_process(COMMAND mysql_config --cflags - OUTPUT_VARIABLE MYSQL_CFLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process(COMMAND mysql_config --libs - OUTPUT_VARIABLE MYSQL_LDFLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process(COMMAND mysql_config --version - OUTPUT_VARIABLE MYSQL_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process(COMMAND mysql_config --variable=pkglibdir - OUTPUT_VARIABLE MYSQL_PKGLIBDIR - OUTPUT_STRIP_TRAILING_WHITESPACE) -else() - set(HAVE_MYSQL 0) -endif() - -# CURL -execute_process(COMMAND "which curl-config 2> /dev/null" - OUTPUT_VARIABLE CURL_FOUND - OUTPUT_STRIP_TRAILING_WHITESPACE) - -if(CURL_FOUND) - set(HAVE_CURL 1) - set(JANA2_CURL_CONFIG ${CURL_FOUND}) - execute_process(COMMAND curl-config --cflags - OUTPUT_VARIABLE CURL_CFLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process(COMMAND curl-config --libs - OUTPUT_VARIABLE CURL_LDFLAGS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - execute_process(COMMAND curl-config --prefix - OUTPUT_VARIABLE CURL_ROOT - OUTPUT_STRIP_TRAILING_WHITESPACE) -else() - set(HAVE_CURL 0) -endif() - -configure_file(scripts/jana-config.in jana-config @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}/jana-this.sh DESTINATION bin) -install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jana-this.csh DESTINATION bin) diff --git a/cmake/MakeJanaThis.cmake b/cmake/MakeJanaThis.cmake new file mode 100644 index 000000000..9335c34a9 --- /dev/null +++ b/cmake/MakeJanaThis.cmake @@ -0,0 +1,153 @@ +# +# This is used in the generation of the files: +# jana-config +# jana-this.sh +# jana-this.csh +# +# The primary role of this file is to set cmake variables based on the +# output of running various 3rd party tools meant to help with your +# build system. For example, it runs root-config --cflags and puts the +# results in the ROOTCFLAGS cmake variable. That variable is then used +# in generating the jana-config script so that it can report those flags +# for use when building against this version of JANA. +# +# In addition, some variables such as JANA2_HAVE_ROOT are set which can be used +# in preprocessor directives to conditionally compile code depending on +# whether the 3rd party package is present. +# + +set(JANA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) + +execute_process(COMMAND SBMS/osrelease.pl + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE BMS_OSNAME + OUTPUT_STRIP_TRAILING_WHITESPACE) + +# ROOT +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(${USE_XERCES}) + if(DEFINED ENV{XERCESCROOT}) + set(JANA2_HAVE_XERCES 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) + 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 +# n.b. I don't believe this will be needed in JANA2 +#if(DEFINED ENV{CMSGROOT}) +# set(HAVE_CMSG 1) +# set(CMSG_CPPFLAGS "-I${CMSGROOT}/include") +# set(CMSG_LDFLAGS "-L${CMSGROOT}/lib") +# set(CMSG_LIBS "-lcmsg -lcmsgxx -lcmsgRegex") +#else() +# set(HAVE_CMSG 0) +#endif() + + +# CCDB +if(DEFINED ENV{CCDB_HOME}) + set(HAVE_CCDB 1) + set(CCDB_HOME $ENV{CCDB_HOME}) + set(CCDB_CPPFLAGS "-I${CCDB_HOME}/include") + set(CCDB_LDFLAGS "-L${CCDB_HOME}/lib") + set(CCDB_LIBS "-lccdb") +else() + set(HAVE_CCDB 0) +endif() + +# MySQL +# TODO: Strange that MySQL does not provide a FindMySQL.cmake. There seem to be plenty out there though and we should maybe adopt one to replace the following +execute_process(COMMAND which mysql_config + OUTPUT_VARIABLE MYSQL_FOUND + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(MYSQL_FOUND) + set(HAVE_MYSQL 1) + set(JANA2_MYSQL_CONFIG ${MYSQL_FOUND}) + execute_process(COMMAND mysql_config --cflags + OUTPUT_VARIABLE MYSQL_CFLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process(COMMAND mysql_config --libs + OUTPUT_VARIABLE MYSQL_LDFLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process(COMMAND mysql_config --version + OUTPUT_VARIABLE MYSQL_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process(COMMAND mysql_config --variable=pkglibdir + OUTPUT_VARIABLE MYSQL_PKGLIBDIR + OUTPUT_STRIP_TRAILING_WHITESPACE) +else() + set(HAVE_MYSQL 0) +endif() + +# CURL +execute_process(COMMAND "which curl-config 2> /dev/null" + OUTPUT_VARIABLE CURL_FOUND + OUTPUT_STRIP_TRAILING_WHITESPACE) + +if(CURL_FOUND) + set(HAVE_CURL 1) + set(JANA2_CURL_CONFIG ${CURL_FOUND}) + execute_process(COMMAND curl-config --cflags + OUTPUT_VARIABLE CURL_CFLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process(COMMAND curl-config --libs + OUTPUT_VARIABLE CURL_LDFLAGS + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process(COMMAND curl-config --prefix + OUTPUT_VARIABLE CURL_ROOT + OUTPUT_STRIP_TRAILING_WHITESPACE) +else() + set(HAVE_CURL 0) +endif() + +configure_file(scripts/jana-config.in jana-config @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}/jana-this.sh DESTINATION bin) +install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jana-this.csh DESTINATION bin) diff --git a/src/libraries/JANA/CMakeLists.txt b/src/libraries/JANA/CMakeLists.txt index 3909bc6c7..552d7eeab 100644 --- a/src/libraries/JANA/CMakeLists.txt +++ b/src/libraries/JANA/CMakeLists.txt @@ -195,32 +195,6 @@ else() endif() -# Install JANATargets.cmake -install(EXPORT jana2_targets FILE JANATargets.cmake NAMESPACE JANA:: DESTINATION lib/cmake/JANA) - -# Generate JANAConfig.cmake, pointing it to JANATargets -include(CMakePackageConfigHelpers) -configure_package_config_file( - "JANAConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/JANAConfig.cmake" - INSTALL_DESTINATION "lib/cmake/JANA" -) - -# Generate JANAConfigVersion.cmake -write_basic_package_version_file( - JANAConfigVersion.cmake - VERSION ${PACKAGE_VERSION} - COMPATIBILITY AnyNewerVersion -) - -# Install JANAConfig.cmake and JANAConfigVersion.cmake -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/JANAConfig.cmake" DESTINATION "lib/cmake/JANA") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/JANAConfigVersion.cmake" DESTINATION "lib/cmake/JANA") - - -# Export targets so that outside projects can use them - - # Install "public" header files file(GLOB jana_headers "*.h*") From 7e110267c8404695704177a4a096f43eee4f7c1c Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Mon, 5 Aug 2024 12:51:09 -0400 Subject: [PATCH 07/23] Install cmake files to $PREFIX/lib/JANA/cmake This is for consistency with installing plugins, etc. This is also on CMake's search path, so there should be no effect downstream. --- cmake/MakeConfig.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/MakeConfig.cmake b/cmake/MakeConfig.cmake index d1fcce1c6..d0797e25c 100644 --- a/cmake/MakeConfig.cmake +++ b/cmake/MakeConfig.cmake @@ -4,7 +4,7 @@ include(CMakePackageConfigHelpers) configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/JANAConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake/JANAConfig.cmake" - INSTALL_DESTINATION "lib/cmake/JANA" + INSTALL_DESTINATION "lib/JANA/cmake" ) write_basic_package_version_file( @@ -16,16 +16,16 @@ write_basic_package_version_file( install(EXPORT jana2_targets FILE "JANATargets.cmake" NAMESPACE JANA:: - DESTINATION "lib/cmake/JANA") + DESTINATION "lib/JANA/cmake") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/JANAConfig.cmake" - DESTINATION "lib/cmake/JANA") + DESTINATION "lib/JANA/cmake") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/JANAConfigVersion.cmake" - DESTINATION "lib/cmake/JANA") + DESTINATION "lib/JANA/cmake") #install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddExternalPlugin.cmake" -# DESTINATION "lib/cmake/JANA") +# DESTINATION "lib/JANA/cmake") From d33a99441c4c8bab7a1325af5d4963a8600850b8 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Mon, 5 Aug 2024 13:50:15 -0400 Subject: [PATCH 08/23] Vendored catch2 dependency is now a CMake target --- CMakeLists.txt | 4 ++-- src/examples/UnitTestingExample/CMakeLists.txt | 4 +--- src/external/CMakeLists.txt | 16 ++++++++++++++++ src/programs/unit_tests/CMakeLists.txt | 4 ++-- 4 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 src/external/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index c3fac469c..2f5cd22f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,7 +195,6 @@ 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 @@ -203,19 +202,20 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") add_link_options(-undefined dynamic_lookup) endif() +add_subdirectory(src/external) add_subdirectory(src/libraries/JANA) add_subdirectory(src/examples) add_subdirectory(src/plugins) add_subdirectory(src/programs/jana) add_subdirectory(src/programs/unit_tests) add_subdirectory(src/programs/perf_tests) - 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/MakeJanaThis.cmake) include(${CMAKE_SOURCE_DIR}/cmake/MakeJVersionH.cmake) diff --git a/src/examples/UnitTestingExample/CMakeLists.txt b/src/examples/UnitTestingExample/CMakeLists.txt index 410efbc2b..5288c932e 100644 --- a/src/examples/UnitTestingExample/CMakeLists.txt +++ b/src/examples/UnitTestingExample/CMakeLists.txt @@ -5,9 +5,7 @@ set (UnitTestingExample_SOURCES add_executable(UnitTestingExample ${UnitTestingExample_SOURCES}) -# Need to be able to find catch.hpp -target_include_directories(UnitTestingExample PRIVATE ${CMAKE_SOURCE_DIR}/src/external) -target_link_libraries(UnitTestingExample Tutorial_plugin jana2) +target_link_libraries(UnitTestingExample Tutorial_plugin jana2 VendoredCatch2) set_target_properties(UnitTestingExample PROPERTIES PREFIX "" OUTPUT_NAME "UnitTestingExample") install(TARGETS UnitTestingExample DESTINATION bin) diff --git a/src/external/CMakeLists.txt b/src/external/CMakeLists.txt new file mode 100644 index 000000000..65205f701 --- /dev/null +++ b/src/external/CMakeLists.txt @@ -0,0 +1,16 @@ + +add_library(VendoredCatch2 INTERFACE) + +target_include_directories(VendoredCatch2 INTERFACE + $ + $ +) + +install(FILES catch.hpp + DESTINATION include/JANA/external) + +install(TARGETS VendoredCatch2 + EXPORT jana2_targets + DESTINATION include/JANA/external) + + diff --git a/src/programs/unit_tests/CMakeLists.txt b/src/programs/unit_tests/CMakeLists.txt index 67e27e0eb..72029c29c 100644 --- a/src/programs/unit_tests/CMakeLists.txt +++ b/src/programs/unit_tests/CMakeLists.txt @@ -51,7 +51,7 @@ endif() add_executable(jana-unit-tests ${TEST_SOURCES}) find_package(Threads REQUIRED) target_include_directories(jana-unit-tests PUBLIC .) -target_link_libraries(jana-unit-tests jana2) +target_link_libraries(jana-unit-tests jana2 VendoredCatch2) if (${USE_PODIO}) # Pull in the data model from examples/PodioExample. @@ -60,4 +60,4 @@ if (${USE_PODIO}) endif() install(TARGETS jana-unit-tests DESTINATION bin) -install(FILES ../../external/catch.hpp DESTINATION include/JANA/external) + From 74530b7b9324b2c0d7831d2d1b1cc2b8fb5578de Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Mon, 5 Aug 2024 15:39:34 -0400 Subject: [PATCH 09/23] Introduce add_jana_plugin() macro --- CMakeLists.txt | 5 +- cmake/AddExternalPlugin.cmake | 65 +++++++++++++++++++ cmake/AddInternalPlugin.cmake | 60 +++++++++++++++++ cmake/MakeConfig.cmake | 4 +- src/examples/DstExample/CMakeLists.txt | 21 ++---- src/examples/EventGroupExample/CMakeLists.txt | 20 ++---- .../CMakeLists.txt | 34 ++++------ src/examples/MetadataExample/CMakeLists.txt | 21 ++---- .../RootDatamodelExample/CMakeLists.txt | 44 ++++++------- src/examples/StreamingExample/CMakeLists.txt | 22 ++++--- src/examples/TimesliceExample/CMakeLists.txt | 10 +-- src/examples/Tutorial/CMakeLists.txt | 30 ++++----- .../UnitTestingExample/CMakeLists.txt | 3 +- src/plugins/JTest/CMakeLists.txt | 21 ++---- src/plugins/janacontrol/tests/CMakeLists.txt | 1 - src/plugins/janadot/CMakeLists.txt | 9 +-- src/plugins/janarate/CMakeLists.txt | 10 ++- src/plugins/janaview/CMakeLists.txt | 31 ++++----- src/plugins/regressiontest/CMakeLists.txt | 11 ++-- 19 files changed, 242 insertions(+), 180 deletions(-) create mode 100644 cmake/AddExternalPlugin.cmake create mode 100644 cmake/AddInternalPlugin.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f5cd22f9..ff2519134 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ endif() # TODO: detector MacOS and set MACOSX_RPATH to TRUE set( CMAKE_SKIP_BUILD_RPATH FALSE ) set( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE ) -set( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" ) +set( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib/JANA/plugins" ) set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE ) # Generate a compilation database, e.g. for IDE autocompletion @@ -202,6 +202,9 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") add_link_options(-undefined dynamic_lookup) endif() +include(CTest) +include(cmake/AddInternalPlugin.cmake) + add_subdirectory(src/external) add_subdirectory(src/libraries/JANA) add_subdirectory(src/examples) diff --git a/cmake/AddExternalPlugin.cmake b/cmake/AddExternalPlugin.cmake new file mode 100644 index 000000000..3c435f5b4 --- /dev/null +++ b/cmake/AddExternalPlugin.cmake @@ -0,0 +1,65 @@ + +macro(add_jana_plugin plugin_name) + + # Parse remaining arguments + set(options) + set(oneValueArgs) + set(multiValueArgs SOURCES PUBLIC_HEADER TESTS) + + cmake_parse_arguments(PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Figure out install namespacce + if (NOT DEFINED INSTALL_NAMESPACE) + set(INSTALL_NAMESPACE ${PROJECT_NAME} CACHE STRING "Project-specific namespace for installation paths, e.g. /lib/PROJECT_NAMESPACE/plugins") + endif() + + # Set up target + add_library(${plugin_name} SHARED ${PLUGIN_SOURCES}) + + set_target_properties(${plugin_name} PROPERTIES + EXPORT_NAME ${plugin_name} + PREFIX "" + SUFFIX ".so" + SKIP_BUILD_RPATH FALSE + BUILD_WITH_INSTALL_RPATH FALSE + INSTALL_RPATH_USE_LINK_PATH TRUE + INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/${INSTALL_NAMESPACE}/plugins" + ) + + target_link_libraries(${plugin_name} PUBLIC JANA::jana2_static_lib) + + # Handle public headers + if (PLUGIN_PUBLIC_HEADER) + set_target_properties(${plugin_name} PROPERTIES + PUBLIC_HEADER "${PLUGIN_PUBLIC_HEADER}" + ) + target_include_directories(${plugin_name} + PUBLIC + $ + $ + ) + endif() + + # Install target + install(TARGETS ${plugin_name} + EXPORT jana2_targets + PUBLIC_HEADER DESTINATION include/${INSTALL_NAMESPACE}/plugins/${plugin_name} + LIBRARY DESTINATION lib/${INSTALL_NAMESPACE}/plugins + ) + + # Handle tests + if (PLUGIN_TESTS) + add_executable(${plugin_name}_tests ${PLUGIN_TESTS}) + target_link_libraries(${plugin_name}_tests PRIVATE ${plugin_name} VendoredCatch2) + set_target_properties(${plugin_name}_tests PROPERTIES + SKIP_BUILD_RPATH FALSE + BUILD_WITH_INSTALL_RPATH FALSE + INSTALL_RPATH_USE_LINK_PATH TRUE + INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/${INSTALL_NAMESPACE}/plugins" + ) + install(TARGETS ${plugin_name}_tests RUNTIME DESTINATION bin) + add_test(NAME ${plugin_name}_tests COMMAND ${CMAKE_INSTALL_PREFIX}/bin/${plugin_name}_tests) + endif() +endmacro() + + diff --git a/cmake/AddInternalPlugin.cmake b/cmake/AddInternalPlugin.cmake new file mode 100644 index 000000000..92e30b621 --- /dev/null +++ b/cmake/AddInternalPlugin.cmake @@ -0,0 +1,60 @@ + +macro(add_jana_plugin plugin_name) + + # Parse remaining arguments + set(options) + set(oneValueArgs) + set(multiValueArgs SOURCES PUBLIC_HEADER TESTS) + + cmake_parse_arguments(PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # Set up target + add_library(${plugin_name} SHARED ${PLUGIN_SOURCES}) + + set_target_properties(${plugin_name} PROPERTIES + EXPORT_NAME ${plugin_name} + PREFIX "" + SUFFIX ".so" + SKIP_BUILD_RPATH FALSE + BUILD_WITH_INSTALL_RPATH FALSE + INSTALL_RPATH_USE_LINK_PATH TRUE + INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/JANA/plugins" + ) + + target_link_libraries(${plugin_name} PUBLIC jana2_static_lib) + + # Handle public headers + if (PLUGIN_PUBLIC_HEADER) + set_target_properties(${plugin_name} PROPERTIES + PUBLIC_HEADER "${PLUGIN_PUBLIC_HEADER}" + ) + target_include_directories(${plugin_name} + PUBLIC + $ + $ + ) + endif() + + # Install target + install(TARGETS ${plugin_name} + EXPORT ParentTargets + PUBLIC_HEADER DESTINATION include/JANA/plugins/${plugin_name} + LIBRARY DESTINATION lib/JANA/plugins + ) + + # Handle tests + if (PLUGIN_TESTS) + add_executable(${plugin_name}_tests ${PLUGIN_TESTS}) + target_link_libraries(${plugin_name}_tests PRIVATE ${plugin_name} VendoredCatch2) + set_target_properties(${plugin_name}_tests PROPERTIES + SKIP_BUILD_RPATH FALSE + BUILD_WITH_INSTALL_RPATH FALSE + INSTALL_RPATH_USE_LINK_PATH TRUE + INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/JANA/plugins" + ) + install(TARGETS ${plugin_name}_tests RUNTIME DESTINATION bin) + add_test(NAME ${plugin_name}_tests COMMAND ${CMAKE_INSTALL_PREFIX}/bin/jana-${plugin_name}-tests) + endif() +endmacro() + + diff --git a/cmake/MakeConfig.cmake b/cmake/MakeConfig.cmake index d0797e25c..667df19b9 100644 --- a/cmake/MakeConfig.cmake +++ b/cmake/MakeConfig.cmake @@ -24,8 +24,8 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/JANAConfig.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/JANAConfigVersion.cmake" DESTINATION "lib/JANA/cmake") -#install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddExternalPlugin.cmake" -# DESTINATION "lib/JANA/cmake") +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddExternalPlugin.cmake" + DESTINATION "lib/JANA/cmake") diff --git a/src/examples/DstExample/CMakeLists.txt b/src/examples/DstExample/CMakeLists.txt index be2f2ccfd..947bbd263 100644 --- a/src/examples/DstExample/CMakeLists.txt +++ b/src/examples/DstExample/CMakeLists.txt @@ -1,20 +1,9 @@ +file(GLOB DSTExample_SOURCES "*.c*") +file(GLOB DSTExample_HEADERS "*.h*") -set (DstExample_PLUGIN_SOURCES - DstExample.cc - DstExampleSource.cc - DstExampleSource.h - DstExampleProcessor.cc - DstExampleProcessor.h - DstExampleFactory.cc - DstExampleFactory.h - DataObjects.h - ) +add_jana_plugin(DstExample + SOURCES ${DSTExample_SOURCES} + PUBLIC_HEADER ${DSTExample_HEADERS}) -add_library(DstExample_plugin SHARED ${DstExample_PLUGIN_SOURCES}) - -target_include_directories(DstExample_plugin PUBLIC ${JANA_INCLUDE_DIR}) -target_link_libraries(DstExample_plugin jana2) -set_target_properties(DstExample_plugin PROPERTIES PREFIX "" OUTPUT_NAME "DstExample" SUFFIX ".so") -install(TARGETS DstExample_plugin DESTINATION lib/JANA/plugins) diff --git a/src/examples/EventGroupExample/CMakeLists.txt b/src/examples/EventGroupExample/CMakeLists.txt index 68df85fed..cec9efb86 100644 --- a/src/examples/EventGroupExample/CMakeLists.txt +++ b/src/examples/EventGroupExample/CMakeLists.txt @@ -1,19 +1,9 @@ -# JExample 7 plugin -set(EventGroupExample_SOURCES SHARED - BlockingGroupedEventSource.h - EventGroupExamplePlugin.cc - GroupedEventProcessor.h - GroupedEventSource.h - TridasEvent.h -) +file(GLOB EventGroupExample_SOURCES "*.c*") +file(GLOB EventGroupExample_HEADERS "*.h*") -add_library(EventGroupExample_plugin SHARED ${EventGroupExample_SOURCES}) - -target_include_directories(EventGroupExample_plugin PUBLIC ${JANA_INCLUDE_DIRS}) -target_link_libraries(EventGroupExample_plugin jana2 ${JANA_LIBRARIES}) -set_target_properties(EventGroupExample_plugin PROPERTIES PREFIX "" OUTPUT_NAME "EventGroupExample" SUFFIX ".so") - -install(TARGETS EventGroupExample_plugin DESTINATION lib/JANA/plugins) +add_jana_plugin(EventGroupExample + SOURCES ${EventGroupExample_SOURCES} + PUBLIC_HEADER ${EventGroupExample_HEADERS}) diff --git a/src/examples/InteractiveStreamingExample/CMakeLists.txt b/src/examples/InteractiveStreamingExample/CMakeLists.txt index a68b772ef..fd7cb3f01 100644 --- a/src/examples/InteractiveStreamingExample/CMakeLists.txt +++ b/src/examples/InteractiveStreamingExample/CMakeLists.txt @@ -4,30 +4,18 @@ if (${USE_ROOT} AND ${USE_ZEROMQ}) find_package(ZeroMQ REQUIRED) find_package(ROOT REQUIRED) - set(STREAMDET_SOURCES - InteractiveStreamingExample.cc - MonitoringProcessor.cc - MonitoringProcessor.h - RootProcessor.cc - RootProcessor.h - DecodeDASSource.cc - DecodeDASSource.h - JFactoryGenerator_streamDet.h - ZmqTransport.h - INDRAMessage.h - ADCSample.h - ADCSampleFactory.h - ) - - add_library(streamDet SHARED ${STREAMDET_SOURCES}) - target_include_directories(streamDet PUBLIC ${ROOT_INCLUDE_DIRS} ${ZeroMQ_INCLUDE_DIRS}) - target_link_libraries(streamDet jana2 ${ZeroMQ_LIBRARIES} ${ROOT_LIBRARIES}) - set_target_properties(streamDet PROPERTIES PREFIX "" SUFFIX ".so") - install(TARGETS streamDet DESTINATION lib/JANA/plugins) - - file(GLOB my_headers "*.h*") - install(FILES ${my_headers} DESTINATION include/JANA/plugins/streamDet) + file(GLOB InteractiveStreamingExample_SOURCES "*.c*") + file(GLOB InteractiveStreamingExample_HEADERS "*.h*") + + add_jana_plugin(InteractiveStreamingExample + SOURCES ${InteractiveStreamingExample_SOURCES} + PUBLIC_HEADER ${InteractiveStreamingExample_HEADERS}) + + target_include_directories(InteractiveStreamingExample PUBLIC ${ROOT_INCLUDE_DIRS} ${ZeroMQ_INCLUDE_DIRS}) + target_link_libraries(InteractiveStreamingExample jana2_shared_lib ${ZeroMQ_LIBRARIES} ${ROOT_LIBRARIES}) else() + message(STATUS "Skipping examples/InteractiveStreamingExample because USE_ROOT=Off or USE_ZEROMQ=Off") + endif() diff --git a/src/examples/MetadataExample/CMakeLists.txt b/src/examples/MetadataExample/CMakeLists.txt index b48c95311..fd30e5467 100644 --- a/src/examples/MetadataExample/CMakeLists.txt +++ b/src/examples/MetadataExample/CMakeLists.txt @@ -1,20 +1,9 @@ +file(GLOB MetadataExample_SOURCES "*.c*") +file(GLOB MetadataExample_HEADERS "*.h*") -set (MetadataExample_PLUGIN_SOURCES - MetadataExample.cc - MetadataAggregator.cc - MetadataAggregator.h - Track.h - TrackSmearingFactory.cc - TrackSmearingFactory.h - RandomTrackSource.cc - RandomTrackSource.h - ) +add_jana_plugin(MetadataExample + SOURCES ${MetadataExample_SOURCES} + PUBLIC_HEADER ${MetadataExample_HEADERS}) -add_library(MetadataExample_plugin SHARED ${MetadataExample_PLUGIN_SOURCES}) - -target_include_directories(MetadataExample_plugin PUBLIC ${JANA_INCLUDE_DIR}) -target_link_libraries(MetadataExample_plugin jana2) -set_target_properties(MetadataExample_plugin PROPERTIES PREFIX "" OUTPUT_NAME "MetadataExample" SUFFIX ".so") -install(TARGETS MetadataExample_plugin DESTINATION lib/JANA/plugins) diff --git a/src/examples/RootDatamodelExample/CMakeLists.txt b/src/examples/RootDatamodelExample/CMakeLists.txt index 244df4ed5..e34cd0580 100644 --- a/src/examples/RootDatamodelExample/CMakeLists.txt +++ b/src/examples/RootDatamodelExample/CMakeLists.txt @@ -18,33 +18,31 @@ if(${USE_ROOT}) list(APPEND my_pcms ${CMAKE_CURRENT_BINARY_DIR}/lib${CLASS}_rdict.pcm ) endforeach() - set (RootDatamodelExample_PLUGIN_SOURCES - RootDatamodelExample.cc - JTestRootEventSource.cc - JTestRootEventSource.h - JFactory_Cluster.cc - JFactory_Cluster.h - JTestRootProcessor.cc - JTestRootProcessor.h - Hit.h - Cluster.h - G__Hit.cxx - G__Cluster.cxx - ) - - add_library(RootDatamodelExample_plugin SHARED ${RootDatamodelExample_PLUGIN_SOURCES}) - 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}) - set_target_properties(RootDatamodelExample_plugin PROPERTIES PREFIX "" OUTPUT_NAME "JTestRoot" SUFFIX ".so") - install(TARGETS RootDatamodelExample_plugin DESTINATION lib/JANA/plugins) + set (RootDataModelExample_HEADERS + Hit.h + Cluster.h + JFactory_Cluster.h + JTestRootEventSource.h + JTestRootProcessor.h) + + set (RootDatamodelExample_SOURCES + RootDatamodelExample.cc + JTestRootEventSource.cc + JFactory_Cluster.cc + JTestRootProcessor.cc + G__Hit.cxx + G__Cluster.cxx) + + add_jana_plugin(RootDataModelExample + SOURCES ${RootDatamodelExample_SOURCES} + PUBLIC_HEADER ${RootDataModelExample_HEADERS}) + + target_include_directories(RootDatamodelExample PUBLIC ${ROOT_INCLUDE_DIRS}) + target_link_libraries(RootDatamodelExample PUBLIC ${ROOT_LIBRARIES}) message(STATUS "Installing ROOT PCM files: ${my_pcms}") install(FILES ${my_pcms} DESTINATION lib/JANA/plugins) - file(GLOB my_headers "*.h*") - install(FILES ${my_headers} DESTINATION include/JANA/plugins/RootDatamodelExample) - else() message(STATUS "Skipping plugins/RootDatamodelExample because USE_ROOT=Off") diff --git a/src/examples/StreamingExample/CMakeLists.txt b/src/examples/StreamingExample/CMakeLists.txt index a84e2da13..922e8a834 100644 --- a/src/examples/StreamingExample/CMakeLists.txt +++ b/src/examples/StreamingExample/CMakeLists.txt @@ -1,22 +1,26 @@ # JExample 7 plugin -set(StreamingExample_SOURCES SHARED - ZmqMain.cc +set(StreamingExample_SOURCES + ZmqMain.cc) + +set(StreamingExample_HEADERS ZmqTransport.h ReadoutMessageAuto.h AHit.h AHitAnomalyDetector.h - AHitParser.h - ) + AHitParser.h) if (USE_ZEROMQ) find_package(ZeroMQ REQUIRED) - add_library(StreamingExample_plugin SHARED ${StreamingExample_SOURCES}) - target_include_directories(StreamingExample_plugin PUBLIC ${ZeroMQ_INCLUDE_DIRS}) - target_link_libraries(StreamingExample_plugin jana2 ${ZeroMQ_LIBRARIES}) - set_target_properties(StreamingExample_plugin PROPERTIES PREFIX "" SUFFIX ".so") - install(TARGETS StreamingExample_plugin DESTINATION lib/JANA/plugins) + add_jana_plugin(StreamingExample + SOURCES ${StreamingExample_SOURCES} + PUBLIC_HEADER ${StreamingExample_HEADERS}) + + target_include_directories(StreamingExample PUBLIC ${ZeroMQ_INCLUDE_DIRS}) + target_link_libraries(StreamingExample jana2 ${ZeroMQ_LIBRARIES}) + else() + message(STATUS "Skipping examples/StreamingExample because USE_ZEROMQ=Off") endif() diff --git a/src/examples/TimesliceExample/CMakeLists.txt b/src/examples/TimesliceExample/CMakeLists.txt index 4091c8fe0..d541985ca 100644 --- a/src/examples/TimesliceExample/CMakeLists.txt +++ b/src/examples/TimesliceExample/CMakeLists.txt @@ -1,15 +1,11 @@ if (USE_PODIO) - set (TimesliceExample_SOURCES - TimesliceExample.cc - CollectionTabulators.cc - ) - add_library(TimesliceExample SHARED ${TimesliceExample_SOURCES}) + add_jana_plugin(TimesliceExample + SOURCES TimesliceExample.cc CollectionTabulators.cc) + target_link_libraries(TimesliceExample PodioExampleDatamodel PodioExampleDatamodelDict podio::podioRootIO) - set_target_properties(TimesliceExample PROPERTIES PREFIX "" SUFFIX ".so" OUTPUT_NAME "TimesliceExample") - install(TARGETS TimesliceExample DESTINATION lib/JANA/plugins) else() message(STATUS "Skipping examples/TimesliceExample because USE_PODIO=Off") diff --git a/src/examples/Tutorial/CMakeLists.txt b/src/examples/Tutorial/CMakeLists.txt index 03bc25bb1..b4a1383aa 100644 --- a/src/examples/Tutorial/CMakeLists.txt +++ b/src/examples/Tutorial/CMakeLists.txt @@ -1,20 +1,20 @@ -set (Tutorial_PLUGIN_SOURCES - Tutorial.cc - TutorialProcessor.cc - TutorialProcessor.h - RandomSource.cc - RandomSource.h - Hit.h - Cluster.h - SimpleClusterFactory.cc - SimpleClusterFactory.h - ) +set (Tutorial_SOURCES + Tutorial.cc + RandomSource.cc + TutorialProcessor.cc + SimpleClusterFactory.cc) -add_library(Tutorial_plugin SHARED ${Tutorial_PLUGIN_SOURCES}) +set (Tutorial_HEADERS + TutorialProcessor.h + RandomSource.h + Hit.h + Cluster.h + SimpleClusterFactory.h) + +add_jana_plugin(Tutorial + SOURCES ${Tutorial_SOURCES} + PUBLIC_HEADER ${Tutorial_HEADERS}) -target_link_libraries(Tutorial_plugin jana2) -set_target_properties(Tutorial_plugin PROPERTIES PREFIX "" OUTPUT_NAME "Tutorial" SUFFIX ".so") -install(TARGETS Tutorial_plugin DESTINATION lib/JANA/plugins) diff --git a/src/examples/UnitTestingExample/CMakeLists.txt b/src/examples/UnitTestingExample/CMakeLists.txt index 5288c932e..e84b95a0b 100644 --- a/src/examples/UnitTestingExample/CMakeLists.txt +++ b/src/examples/UnitTestingExample/CMakeLists.txt @@ -5,7 +5,6 @@ set (UnitTestingExample_SOURCES add_executable(UnitTestingExample ${UnitTestingExample_SOURCES}) - -target_link_libraries(UnitTestingExample Tutorial_plugin jana2 VendoredCatch2) +target_link_libraries(UnitTestingExample Tutorial VendoredCatch2) set_target_properties(UnitTestingExample PROPERTIES PREFIX "" OUTPUT_NAME "UnitTestingExample") install(TARGETS UnitTestingExample DESTINATION bin) diff --git a/src/plugins/JTest/CMakeLists.txt b/src/plugins/JTest/CMakeLists.txt index ee031a4e5..1ce83432c 100644 --- a/src/plugins/JTest/CMakeLists.txt +++ b/src/plugins/JTest/CMakeLists.txt @@ -1,18 +1,9 @@ -add_library(jtest SHARED - JTestMain.cc - JTestDataObjects.h - JTestParser.h - JTestDisentangler.h - JTestTracker.h - JTestPlotter.h - JTestCalibrationService.h - ) + +file(GLOB JTEST_HEADERS "*.h*") + +add_jana_plugin(JTest SOURCES JTestMain.cc PUBLIC_HEADER ${JTEST_HEADERS}) find_package(Threads REQUIRED) -target_link_libraries(jtest Threads::Threads) -set_target_properties(jtest PROPERTIES PREFIX "" OUTPUT_NAME "JTest" SUFFIX ".so") -install(TARGETS jtest DESTINATION lib/JANA/plugins) - -file(GLOB my_headers "*.h*") -install(FILES ${my_headers} DESTINATION include/JANA/plugins/JTest) +target_link_libraries(JTest PUBLIC Threads::Threads) + diff --git a/src/plugins/janacontrol/tests/CMakeLists.txt b/src/plugins/janacontrol/tests/CMakeLists.txt index 4de206361..ed26d351d 100644 --- a/src/plugins/janacontrol/tests/CMakeLists.txt +++ b/src/plugins/janacontrol/tests/CMakeLists.txt @@ -16,7 +16,6 @@ target_include_directories(janacontrol_plugin_tests PUBLIC ../src) target_include_directories(janacontrol_plugin_tests PUBLIC ${JANA_INCLUDE_DIR}) target_link_libraries(janacontrol_plugin_tests janacontrol) -#target_link_libraries(janacontrol_plugin_tests ${JANA_LIBRARY}) target_link_libraries(janacontrol_plugin_tests jana2) target_link_libraries(janacontrol_plugin_tests Threads::Threads) diff --git a/src/plugins/janadot/CMakeLists.txt b/src/plugins/janadot/CMakeLists.txt index ea9d0c73d..6176687f0 100644 --- a/src/plugins/janadot/CMakeLists.txt +++ b/src/plugins/janadot/CMakeLists.txt @@ -1,9 +1,6 @@ -add_library(janadot SHARED JEventProcessorJANADOT.cc) +file(GLOB JANADOT_HEADERS "*.h*") +add_jana_plugin(janadot SOURCES JEventProcessorJANADOT.cc PUBLIC_HEADER ${JANADOT_HEADERS}) find_package(Threads REQUIRED) -target_link_libraries(janadot Threads::Threads) -set_target_properties(janadot PROPERTIES PREFIX "" OUTPUT_NAME "janadot" SUFFIX ".so") -install(TARGETS janadot DESTINATION lib/JANA/plugins) +target_link_libraries(janadot PUBLIC Threads::Threads) -file(GLOB my_headers "*.h*") -install(FILES ${my_headers} DESTINATION include/JANA/plugins/janadot) diff --git a/src/plugins/janarate/CMakeLists.txt b/src/plugins/janarate/CMakeLists.txt index a676548b5..2b542796a 100644 --- a/src/plugins/janarate/CMakeLists.txt +++ b/src/plugins/janarate/CMakeLists.txt @@ -1,14 +1,12 @@ if (${USE_ROOT}) - add_library(janarate SHARED JEventProcessorJANARATE.cc) + + file(GLOB JTEST_HEADERS "*.h*") + add_jana_plugin(janarate SOURCES JEventProcessorJANARATE.cc PUBLIC_HEADER ${JTEST_HEADERS}) + target_include_directories(janarate PUBLIC ${ROOT_INCLUDE_DIRS}) target_link_libraries(janarate jana2 ${ROOT_LIBRARIES}) - set_target_properties(janarate PROPERTIES PREFIX "" SUFFIX ".so") - install(TARGETS janarate DESTINATION lib/JANA/plugins) - - file(GLOB my_headers "*.h*") - install(FILES ${my_headers} DESTINATION include/JANA/plugins/janarate) else() message(STATUS "Skipping plugins/janarate because USE_ROOT=Off") diff --git a/src/plugins/janaview/CMakeLists.txt b/src/plugins/janaview/CMakeLists.txt index 886cafac0..1d0d4fcc9 100644 --- a/src/plugins/janaview/CMakeLists.txt +++ b/src/plugins/janaview/CMakeLists.txt @@ -1,31 +1,28 @@ if(USE_ROOT) - find_package(ROOT REQUIRED COMPONENTS Gui Core RIO Net Hist Graf Graf3d Gpad Tree Rint Postscript Matrix Physics MathCore Thread MultiProc) + find_package(ROOT REQUIRED COMPONENTS Gui Core RIO Net Hist Graf Graf3d Gpad Tree Rint Postscript Matrix Physics MathCore Thread MultiProc) ROOT_GENERATE_DICTIONARY(G__jv_mainframe jv_mainframe.h) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - add_library(janaview SHARED - JEventProcessor_janaview.cc - jv_mainframe.cc - G__jv_mainframe.cxx - ) + file(GLOB JANAVIEW_HEADERS "*.h*") + + add_jana_plugin(janaview + SOURCES JEventProcessor_janaview.cc jv_mainframe.cc G__jv_mainframe.cxx + PUBLIC_HEADER ${JANAVIEW_HEADERS} + ) - find_package(Threads REQUIRED) target_include_directories(janaview PUBLIC ${ROOT_INCLUDE_DIRS}) - target_link_libraries(janaview jana2) - target_link_libraries(janaview Threads::Threads) - target_link_libraries(janaview ${ROOT_LIBRARIES}) - set_target_properties(janaview PROPERTIES PREFIX "" OUTPUT_NAME "janaview" SUFFIX ".so") - install(TARGETS janaview DESTINATION lib/JANA/plugins) + target_link_libraries(janaview PUBLIC ${ROOT_LIBRARIES}) + + find_package(Threads REQUIRED) + target_link_libraries(janaview PUBLIC Threads::Threads) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjv_mainframe_rdict.pcm DESTINATION lib/JANA/plugins) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjv_mainframe.rootmap DESTINATION lib/JANA/plugins) - - file(GLOB my_headers "*.h*") - install(FILES ${my_headers} DESTINATION include/JANA/plugins/janaview) else() -message(STATUS "Skipping plugins/janaview because USE_ROOT=Off") + + message(STATUS "Skipping plugins/janaview because USE_ROOT=Off") endif() # ROOT_FOUND diff --git a/src/plugins/regressiontest/CMakeLists.txt b/src/plugins/regressiontest/CMakeLists.txt index a3b09865e..a6dc0489d 100644 --- a/src/plugins/regressiontest/CMakeLists.txt +++ b/src/plugins/regressiontest/CMakeLists.txt @@ -1,9 +1,8 @@ -add_library(regressiontest SHARED JEventProcessor_regressiontest.cc) +add_jana_plugin(regressiontest + SOURCES JEventProcessor_regressiontest.cc + PUBLIC_HEADER JEventProcessor_regressiontest.h) + find_package(Threads REQUIRED) -target_link_libraries(regressiontest Threads::Threads) -set_target_properties(regressiontest PROPERTIES PREFIX "" OUTPUT_NAME "regressiontest" SUFFIX ".so") -install(TARGETS regressiontest DESTINATION lib/JANA/plugins) +target_link_libraries(regressiontest PUBLIC Threads::Threads) -file(GLOB my_headers "*.h*") -install(FILES ${my_headers} DESTINATION include/JANA/plugins/regressiontest) From 7fb01a8c5517650b4b60b313694209f94f4cf595 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Tue, 6 Aug 2024 14:37:12 -0400 Subject: [PATCH 10/23] Update janacontrol to use new testing concept --- .../CMakeLists.txt | 2 +- .../RootDatamodelExample/CMakeLists.txt | 6 ++-- src/examples/StreamingExample/CMakeLists.txt | 2 +- src/examples/TimesliceExample/CMakeLists.txt | 2 +- src/plugins/janacontrol/CMakeLists.txt | 35 +++++++++++++++++-- .../{src => }/JControlEventProcessor.cc | 2 +- .../{src => }/JControlEventProcessor.h | 0 .../janacontrol/{src => }/JControlZMQ.cc | 0 .../janacontrol/{src => }/JControlZMQ.h | 0 src/plugins/janacontrol/{src => }/janaJSON.h | 0 .../janacontrol/{src => }/janacontrol.cc | 0 ...tegrationTests.cc => janacontrol_tests.cc} | 12 ++++--- src/plugins/janacontrol/src/CMakeLists.txt | 26 -------------- src/plugins/janacontrol/tests/CMakeLists.txt | 23 ------------ src/plugins/janacontrol/tests/TestsMain.cc | 8 ----- src/plugins/janarate/CMakeLists.txt | 2 +- 16 files changed, 49 insertions(+), 71 deletions(-) rename src/plugins/janacontrol/{src => }/JControlEventProcessor.cc (98%) rename src/plugins/janacontrol/{src => }/JControlEventProcessor.h (100%) rename src/plugins/janacontrol/{src => }/JControlZMQ.cc (100%) rename src/plugins/janacontrol/{src => }/JControlZMQ.h (100%) rename src/plugins/janacontrol/{src => }/janaJSON.h (100%) rename src/plugins/janacontrol/{src => }/janacontrol.cc (100%) rename src/plugins/janacontrol/{tests/IntegrationTests.cc => janacontrol_tests.cc} (74%) delete mode 100644 src/plugins/janacontrol/src/CMakeLists.txt delete mode 100644 src/plugins/janacontrol/tests/CMakeLists.txt delete mode 100644 src/plugins/janacontrol/tests/TestsMain.cc diff --git a/src/examples/InteractiveStreamingExample/CMakeLists.txt b/src/examples/InteractiveStreamingExample/CMakeLists.txt index fd7cb3f01..2f12c0213 100644 --- a/src/examples/InteractiveStreamingExample/CMakeLists.txt +++ b/src/examples/InteractiveStreamingExample/CMakeLists.txt @@ -12,7 +12,7 @@ if (${USE_ROOT} AND ${USE_ZEROMQ}) PUBLIC_HEADER ${InteractiveStreamingExample_HEADERS}) target_include_directories(InteractiveStreamingExample PUBLIC ${ROOT_INCLUDE_DIRS} ${ZeroMQ_INCLUDE_DIRS}) - target_link_libraries(InteractiveStreamingExample jana2_shared_lib ${ZeroMQ_LIBRARIES} ${ROOT_LIBRARIES}) + target_link_libraries(InteractiveStreamingExample PUBLIC ${ZeroMQ_LIBRARIES} ${ROOT_LIBRARIES}) else() diff --git a/src/examples/RootDatamodelExample/CMakeLists.txt b/src/examples/RootDatamodelExample/CMakeLists.txt index e34cd0580..94823e227 100644 --- a/src/examples/RootDatamodelExample/CMakeLists.txt +++ b/src/examples/RootDatamodelExample/CMakeLists.txt @@ -18,7 +18,7 @@ if(${USE_ROOT}) list(APPEND my_pcms ${CMAKE_CURRENT_BINARY_DIR}/lib${CLASS}_rdict.pcm ) endforeach() - set (RootDataModelExample_HEADERS + set (RootDatamodelExample_HEADERS Hit.h Cluster.h JFactory_Cluster.h @@ -33,9 +33,9 @@ if(${USE_ROOT}) G__Hit.cxx G__Cluster.cxx) - add_jana_plugin(RootDataModelExample + add_jana_plugin(RootDatamodelExample SOURCES ${RootDatamodelExample_SOURCES} - PUBLIC_HEADER ${RootDataModelExample_HEADERS}) + PUBLIC_HEADER ${RootDatamodelExample_HEADERS}) target_include_directories(RootDatamodelExample PUBLIC ${ROOT_INCLUDE_DIRS}) target_link_libraries(RootDatamodelExample PUBLIC ${ROOT_LIBRARIES}) diff --git a/src/examples/StreamingExample/CMakeLists.txt b/src/examples/StreamingExample/CMakeLists.txt index 922e8a834..3ba3e8946 100644 --- a/src/examples/StreamingExample/CMakeLists.txt +++ b/src/examples/StreamingExample/CMakeLists.txt @@ -17,7 +17,7 @@ if (USE_ZEROMQ) PUBLIC_HEADER ${StreamingExample_HEADERS}) target_include_directories(StreamingExample PUBLIC ${ZeroMQ_INCLUDE_DIRS}) - target_link_libraries(StreamingExample jana2 ${ZeroMQ_LIBRARIES}) + target_link_libraries(StreamingExample PUBLIC ${ZeroMQ_LIBRARIES}) else() diff --git a/src/examples/TimesliceExample/CMakeLists.txt b/src/examples/TimesliceExample/CMakeLists.txt index d541985ca..a79020dd3 100644 --- a/src/examples/TimesliceExample/CMakeLists.txt +++ b/src/examples/TimesliceExample/CMakeLists.txt @@ -5,7 +5,7 @@ if (USE_PODIO) add_jana_plugin(TimesliceExample SOURCES TimesliceExample.cc CollectionTabulators.cc) - target_link_libraries(TimesliceExample PodioExampleDatamodel PodioExampleDatamodelDict podio::podioRootIO) + target_link_libraries(TimesliceExample PUBLIC PodioExampleDatamodel PodioExampleDatamodelDict podio::podioRootIO) else() message(STATUS "Skipping examples/TimesliceExample because USE_PODIO=Off") diff --git a/src/plugins/janacontrol/CMakeLists.txt b/src/plugins/janacontrol/CMakeLists.txt index c9987ea9e..1619f2801 100644 --- a/src/plugins/janacontrol/CMakeLists.txt +++ b/src/plugins/janacontrol/CMakeLists.txt @@ -1,4 +1,35 @@ -add_subdirectory(src) -#add_subdirectory(tests) +if (${USE_ZEROMQ}) + + find_package(ZeroMQ REQUIRED) + find_package(Threads REQUIRED) + + set (janacontrol_PLUGIN_SOURCES + janacontrol.cc + JControlZMQ.cc + JControlEventProcessor.cc) + + set (janacontrol_PLUGIN_HEADERS + JControlZMQ.h + JControlEventProcessor.h) + + set (janacontrol_PLUGIN_TESTS + janacontrol_tests.cc + ) + + add_jana_plugin(janacontrol + SOURCES ${janacontrol_PLUGIN_SOURCES} + PUBLIC_HEADER ${janacontrol_PLUGIN_HEADERS} + TESTS ${janacontrol_PLUGIN_TESTS}) + + target_include_directories(janacontrol PUBLIC ${ZeroMQ_INCLUDE_DIRS}) + target_link_libraries(janacontrol PUBLIC ${ZeroMQ_LIBRARIES}) + target_include_directories(janacontrol_tests PUBLIC ${ZeroMQ_INCLUDE_DIRS}) + target_link_libraries(janacontrol_tests PUBLIC ${ZeroMQ_LIBRARIES}) + +else() + message(STATUS "Skipping plugins/janacontrol because USE_ZEROMQ=Off") + +endif() + diff --git a/src/plugins/janacontrol/src/JControlEventProcessor.cc b/src/plugins/janacontrol/JControlEventProcessor.cc similarity index 98% rename from src/plugins/janacontrol/src/JControlEventProcessor.cc rename to src/plugins/janacontrol/JControlEventProcessor.cc index 856624dd1..fd1d9f1fd 100644 --- a/src/plugins/janacontrol/src/JControlEventProcessor.cc +++ b/src/plugins/janacontrol/JControlEventProcessor.cc @@ -66,7 +66,7 @@ void JControlEventProcessor::Finish() { //------------------------------------------------------------- void JControlEventProcessor::SetDebugMode(bool debug_mode){ _debug_mode = debug_mode; - GetApplication()->SetTimeoutEnabled( !_debug_mode ); // TODO: Add a GetTimeoutEnabled() to JApplication + GetApplication()->SetTimeoutEnabled( !_debug_mode ); } //------------------------------------------------------------- diff --git a/src/plugins/janacontrol/src/JControlEventProcessor.h b/src/plugins/janacontrol/JControlEventProcessor.h similarity index 100% rename from src/plugins/janacontrol/src/JControlEventProcessor.h rename to src/plugins/janacontrol/JControlEventProcessor.h diff --git a/src/plugins/janacontrol/src/JControlZMQ.cc b/src/plugins/janacontrol/JControlZMQ.cc similarity index 100% rename from src/plugins/janacontrol/src/JControlZMQ.cc rename to src/plugins/janacontrol/JControlZMQ.cc diff --git a/src/plugins/janacontrol/src/JControlZMQ.h b/src/plugins/janacontrol/JControlZMQ.h similarity index 100% rename from src/plugins/janacontrol/src/JControlZMQ.h rename to src/plugins/janacontrol/JControlZMQ.h diff --git a/src/plugins/janacontrol/src/janaJSON.h b/src/plugins/janacontrol/janaJSON.h similarity index 100% rename from src/plugins/janacontrol/src/janaJSON.h rename to src/plugins/janacontrol/janaJSON.h diff --git a/src/plugins/janacontrol/src/janacontrol.cc b/src/plugins/janacontrol/janacontrol.cc similarity index 100% rename from src/plugins/janacontrol/src/janacontrol.cc rename to src/plugins/janacontrol/janacontrol.cc diff --git a/src/plugins/janacontrol/tests/IntegrationTests.cc b/src/plugins/janacontrol/janacontrol_tests.cc similarity index 74% rename from src/plugins/janacontrol/tests/IntegrationTests.cc rename to src/plugins/janacontrol/janacontrol_tests.cc index 5919725e8..a00aefc4f 100644 --- a/src/plugins/janacontrol/tests/IntegrationTests.cc +++ b/src/plugins/janacontrol/janacontrol_tests.cc @@ -1,23 +1,27 @@ - // Copyright 2020, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. +// This is the entry point for our test suite executable. +// Catch2 will take over from here. +#define CATCH_CONFIG_MAIN #include "catch.hpp" #include #include +#include "JControlEventProcessor.h" // This is where you can assemble various components and verify that when put together, they // do what you'd expect. This means you can skip the laborious mixing and matching of plugins and configurations, // and have everything run automatically inside one executable. -TEST_CASE("IntegrationTests") { +TEST_CASE("JANAControlIntegrationTests") { auto app = new JApplication; - + // Create and register components - // app->Add(new janacontrolProcessor); + app->AddPlugin("JTest"); + app->Add(new JControlEventProcessor); // Set test parameters app->SetParameterValue("nevents", 10); diff --git a/src/plugins/janacontrol/src/CMakeLists.txt b/src/plugins/janacontrol/src/CMakeLists.txt deleted file mode 100644 index b9be580f3..000000000 --- a/src/plugins/janacontrol/src/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ - -if (${USE_ZEROMQ}) - - set (janacontrol_PLUGIN_SOURCES - janacontrol.cc - JControlZMQ.cc - JControlZMQ.h - JControlEventProcessor.cc - JControlEventProcessor.h - ) - - find_package(ZeroMQ REQUIRED) - find_package(Threads REQUIRED) - - add_library(janacontrol_plugin SHARED ${janacontrol_PLUGIN_SOURCES}) - - target_include_directories(janacontrol_plugin PUBLIC ${JANA_INCLUDE_DIR} ${ZeroMQ_INCLUDE_DIRS}) - target_link_libraries(janacontrol_plugin jana2 Threads::Threads ${ZeroMQ_LIBRARIES}) - set_target_properties(janacontrol_plugin PROPERTIES PREFIX "" OUTPUT_NAME "janacontrol" SUFFIX ".so") - install(TARGETS janacontrol_plugin DESTINATION lib/JANA/plugins) - -else() - message(STATUS "Skipping plugins/janacontrol because USE_ZEROMQ=Off") - -endif() - diff --git a/src/plugins/janacontrol/tests/CMakeLists.txt b/src/plugins/janacontrol/tests/CMakeLists.txt deleted file mode 100644 index ed26d351d..000000000 --- a/src/plugins/janacontrol/tests/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ - - -set (janacontrol_PLUGIN_TESTS_SOURCES - TestsMain.cc - IntegrationTests.cc - # Add component tests here - ) - -add_executable(janacontrol_plugin_tests ${janacontrol_PLUGIN_TESTS_SOURCES}) - -#find_package(JANA REQUIRED) -find_package(Threads REQUIRED) - - -target_include_directories(janacontrol_plugin_tests PUBLIC ../src) -target_include_directories(janacontrol_plugin_tests PUBLIC ${JANA_INCLUDE_DIR}) - -target_link_libraries(janacontrol_plugin_tests janacontrol) -target_link_libraries(janacontrol_plugin_tests jana2) -target_link_libraries(janacontrol_plugin_tests Threads::Threads) - -install(TARGETS janacontrol_plugin_tests DESTINATION bin) - diff --git a/src/plugins/janacontrol/tests/TestsMain.cc b/src/plugins/janacontrol/tests/TestsMain.cc deleted file mode 100644 index 32408e13c..000000000 --- a/src/plugins/janacontrol/tests/TestsMain.cc +++ /dev/null @@ -1,8 +0,0 @@ - - -// This is the entry point for our test suite executable. -// Catch2 will take over from here. - -#define CATCH_CONFIG_MAIN -#include "catch.hpp" - diff --git a/src/plugins/janarate/CMakeLists.txt b/src/plugins/janarate/CMakeLists.txt index 2b542796a..c524d8c48 100644 --- a/src/plugins/janarate/CMakeLists.txt +++ b/src/plugins/janarate/CMakeLists.txt @@ -6,7 +6,7 @@ if (${USE_ROOT}) add_jana_plugin(janarate SOURCES JEventProcessorJANARATE.cc PUBLIC_HEADER ${JTEST_HEADERS}) target_include_directories(janarate PUBLIC ${ROOT_INCLUDE_DIRS}) - target_link_libraries(janarate jana2 ${ROOT_LIBRARIES}) + target_link_libraries(janarate PUBLIC ${ROOT_LIBRARIES}) else() message(STATUS "Skipping plugins/janarate because USE_ROOT=Off") From 4959240439e75c2bda72bc926b36b5ccdcef09f3 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Mon, 5 Aug 2024 21:10:28 -0400 Subject: [PATCH 11/23] Update janapy --- src/python/plugins/janapy/CMakeLists.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/python/plugins/janapy/CMakeLists.txt b/src/python/plugins/janapy/CMakeLists.txt index f615959fb..45cf0e751 100644 --- a/src/python/plugins/janapy/CMakeLists.txt +++ b/src/python/plugins/janapy/CMakeLists.txt @@ -1,13 +1,12 @@ # See https://pybind11.readthedocs.io/en/stable/faq.html#someclass-declared-with-greater-visibility-than-the-type-of-its-field-someclass-member-wattributes -add_library(janapy_plugin SHARED janapy_plugin.cc) -target_compile_options(janapy_plugin PRIVATE "-fvisibility=hidden") -target_include_directories(janapy_plugin PRIVATE ${PYTHON_INCLUDE_DIRS} ${pybind11_INCLUDE_DIRS} ../../common) -target_link_libraries(janapy_plugin PRIVATE ${PYTHON_LIBRARIES} pybind11::embed) +add_jana_plugin(janapy SOURCES janapy_plugin.cc) + +target_compile_options(janapy PRIVATE "-fvisibility=hidden") +target_include_directories(janapy PRIVATE ${PYTHON_INCLUDE_DIRS} ${pybind11_INCLUDE_DIRS} ../../common) +target_link_libraries(janapy PRIVATE ${PYTHON_LIBRARIES} pybind11::embed) -set_target_properties(janapy_plugin PROPERTIES PREFIX "" SUFFIX ".so" LIBRARY_OUTPUT_NAME "janapy") -install(TARGETS janapy_plugin DESTINATION plugins) From ec0959eb6170ae6f1ffdaa5f969fdd5133e4596b Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Tue, 6 Aug 2024 14:47:57 -0400 Subject: [PATCH 12/23] Fix warning in JTablePrinter --- src/libraries/JANA/Utils/JTablePrinter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/JANA/Utils/JTablePrinter.cc b/src/libraries/JANA/Utils/JTablePrinter.cc index 02e298f54..8087fe9ea 100644 --- a/src/libraries/JANA/Utils/JTablePrinter.cc +++ b/src/libraries/JANA/Utils/JTablePrinter.cc @@ -166,7 +166,7 @@ void JTablePrinter::Render(std::ostream& os) const { } // Print rows - for (size_t row = 0; row < current_row; ++row) { + for (int row = 0; row < current_row; ++row) { std::vector> lines; size_t line_count = 1; for (const auto& col : columns) { From acab1ac6450a7834f4f977ab06289b2e87b4d53d Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Tue, 6 Aug 2024 16:56:04 -0400 Subject: [PATCH 13/23] Introduce add_jana_test macro --- CMakeLists.txt | 1 + cmake/AddJanaTest.cmake | 27 +++++++++++++++++++ .../UnitTestingExample/CMakeLists.txt | 8 +----- src/programs/perf_tests/CMakeLists.txt | 14 ++-------- src/programs/unit_tests/CMakeLists.txt | 14 +++------- 5 files changed, 35 insertions(+), 29 deletions(-) create mode 100644 cmake/AddJanaTest.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ff2519134..ba9871546 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,6 +204,7 @@ endif() include(CTest) include(cmake/AddInternalPlugin.cmake) +include(cmake/AddJanaTest.cmake) add_subdirectory(src/external) add_subdirectory(src/libraries/JANA) diff --git a/cmake/AddJanaTest.cmake b/cmake/AddJanaTest.cmake new file mode 100644 index 000000000..76f5b49f0 --- /dev/null +++ b/cmake/AddJanaTest.cmake @@ -0,0 +1,27 @@ + +macro(add_jana_test test_target_name) + + cmake_parse_arguments(JANATEST "" "" "SOURCES" ${ARGN}) + + if (NOT JANATEST_SOURCES) + file(GLOB JANATEST_SOURCES "*.c*") + endif() + + # Set up target + add_executable(${test_target_name} ${JANATEST_SOURCES}) + + target_link_libraries(${test_target_name} PRIVATE jana2_static_lib VendoredCatch2) + + set_target_properties(${test_target_name} PROPERTIES + SKIP_BUILD_RPATH FALSE + BUILD_WITH_INSTALL_RPATH FALSE + INSTALL_RPATH_USE_LINK_PATH TRUE + INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/JANA/plugins") + + install(TARGETS ${test_target_name} RUNTIME DESTINATION bin/JANA/tests) + + add_test(NAME ${test_target_name} COMMAND ${CMAKE_INSTALL_PREFIX}/bin/JANA/tests/${test_target_name}) + +endmacro() + + diff --git a/src/examples/UnitTestingExample/CMakeLists.txt b/src/examples/UnitTestingExample/CMakeLists.txt index e84b95a0b..84fc87e87 100644 --- a/src/examples/UnitTestingExample/CMakeLists.txt +++ b/src/examples/UnitTestingExample/CMakeLists.txt @@ -1,10 +1,4 @@ -set (UnitTestingExample_SOURCES - SimpleClusterFactoryTests.cc - ) +add_jana_test(UnitTestingExample SOURCES SimpleClusterFactoryTests.cc) -add_executable(UnitTestingExample ${UnitTestingExample_SOURCES}) -target_link_libraries(UnitTestingExample Tutorial VendoredCatch2) -set_target_properties(UnitTestingExample PROPERTIES PREFIX "" OUTPUT_NAME "UnitTestingExample") -install(TARGETS UnitTestingExample DESTINATION bin) diff --git a/src/programs/perf_tests/CMakeLists.txt b/src/programs/perf_tests/CMakeLists.txt index 8efa6c964..558516bbd 100644 --- a/src/programs/perf_tests/CMakeLists.txt +++ b/src/programs/perf_tests/CMakeLists.txt @@ -1,23 +1,13 @@ -set(PERF_TEST_SOURCES - PerfTests.cc - ) -add_executable(jana-perf-tests ${PERF_TEST_SOURCES}) -find_package(Threads REQUIRED) -target_include_directories(jana-perf-tests PUBLIC .) -target_link_libraries(jana-perf-tests jana2 Threads::Threads) +add_jana_test(jana-perf-tests) if (USE_PODIO) find_package(podio REQUIRED) - target_link_libraries(jana-perf-tests podio::podio PodioExampleDatamodel PodioExampleDatamodelDict podio::podioRootIO) - set_target_properties(jana-perf-tests PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) + target_link_libraries(jana-perf-tests PRIVATE podio::podio PodioExampleDatamodel PodioExampleDatamodelDict podio::podioRootIO) else() message(STATUS "jana-perf-tests compiled without PODIO stress test because USE_PODIO=Off") endif() - - -install(TARGETS jana-perf-tests DESTINATION bin) diff --git a/src/programs/unit_tests/CMakeLists.txt b/src/programs/unit_tests/CMakeLists.txt index 72029c29c..7ae7f6915 100644 --- a/src/programs/unit_tests/CMakeLists.txt +++ b/src/programs/unit_tests/CMakeLists.txt @@ -43,21 +43,15 @@ set(TEST_SOURCES ) if (${USE_PODIO}) - list(APPEND TEST_SOURCES - Components/PodioTests.cc - ) + list(APPEND TEST_SOURCES Components/PodioTests.cc) endif() -add_executable(jana-unit-tests ${TEST_SOURCES}) -find_package(Threads REQUIRED) -target_include_directories(jana-unit-tests PUBLIC .) -target_link_libraries(jana-unit-tests jana2 VendoredCatch2) +add_jana_test(jana-unit-tests SOURCES ${TEST_SOURCES}) if (${USE_PODIO}) # Pull in the data model from examples/PodioExample. - # We don't want to have two separate toy data models in the JANA codebase - target_link_libraries(jana-unit-tests PodioExampleDatamodel PodioExampleDatamodelDict) + # We don't want to have multiple separate toy data models in the JANA codebase + target_link_libraries(jana-unit-tests PRIVATE PodioExampleDatamodel PodioExampleDatamodelDict) endif() -install(TARGETS jana-unit-tests DESTINATION bin) From a823fae772aff0b58d899e9fe65fc063476d2a3d Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Wed, 7 Aug 2024 01:09:44 -0400 Subject: [PATCH 14/23] Add CTest tests for examples --- src/examples/DstExample/CMakeLists.txt | 4 +++- src/examples/EventGroupExample/CMakeLists.txt | 3 +++ src/examples/MetadataExample/CMakeLists.txt | 4 ++++ src/examples/PodioExample/CMakeLists.txt | 4 ++++ src/examples/PodioExample/PodioExample.cc | 7 ++++++- .../RootDatamodelExample/CMakeLists.txt | 6 ++++++ src/examples/StreamingExample/CMakeLists.txt | 5 +++++ src/examples/SubeventCUDAExample/CMakeLists.txt | 17 ++++++++++++----- src/examples/SubeventExample/CMakeLists.txt | 11 +++++------ src/examples/TimesliceExample/CMakeLists.txt | 7 +++++++ src/examples/Tutorial/CMakeLists.txt | 4 ++++ src/examples/UnitTestingExample/CMakeLists.txt | 4 ++-- src/plugins/JTest/CMakeLists.txt | 3 +++ src/plugins/janadot/CMakeLists.txt | 11 +++++++++-- src/programs/perf_tests/CMakeLists.txt | 1 + 15 files changed, 74 insertions(+), 17 deletions(-) diff --git a/src/examples/DstExample/CMakeLists.txt b/src/examples/DstExample/CMakeLists.txt index 947bbd263..8387be7dd 100644 --- a/src/examples/DstExample/CMakeLists.txt +++ b/src/examples/DstExample/CMakeLists.txt @@ -6,4 +6,6 @@ add_jana_plugin(DstExample SOURCES ${DSTExample_SOURCES} PUBLIC_HEADER ${DSTExample_HEADERS}) - +add_test( + NAME jana-example-dst-tests + COMMAND jana -Pplugins=DstExample) diff --git a/src/examples/EventGroupExample/CMakeLists.txt b/src/examples/EventGroupExample/CMakeLists.txt index cec9efb86..2fd2817c0 100644 --- a/src/examples/EventGroupExample/CMakeLists.txt +++ b/src/examples/EventGroupExample/CMakeLists.txt @@ -6,4 +6,7 @@ add_jana_plugin(EventGroupExample SOURCES ${EventGroupExample_SOURCES} PUBLIC_HEADER ${EventGroupExample_HEADERS}) +add_test(NAME jana-example-eventgroup-tests + COMMAND jana -Pplugins=EventGroupExample) +set_tests_properties(jana-example-eventgroup-tests PROPERTIES DISABLED TRUE) diff --git a/src/examples/MetadataExample/CMakeLists.txt b/src/examples/MetadataExample/CMakeLists.txt index fd30e5467..cebdb2315 100644 --- a/src/examples/MetadataExample/CMakeLists.txt +++ b/src/examples/MetadataExample/CMakeLists.txt @@ -6,4 +6,8 @@ add_jana_plugin(MetadataExample SOURCES ${MetadataExample_SOURCES} PUBLIC_HEADER ${MetadataExample_HEADERS}) +add_test(NAME jana-example-metadata-tests + COMMAND jana -Pplugins=MetadataExample) +set_tests_properties(jana-example-metadata-tests + PROPERTIES DISABLED TRUE) diff --git a/src/examples/PodioExample/CMakeLists.txt b/src/examples/PodioExample/CMakeLists.txt index 83b606240..9bc536aea 100644 --- a/src/examples/PodioExample/CMakeLists.txt +++ b/src/examples/PodioExample/CMakeLists.txt @@ -36,6 +36,10 @@ if (USE_PODIO) install(TARGETS PodioExampleDatamodelDict DESTINATION lib/JANA/plugins) + add_test(NAME jana-example-podio-tests + COMMAND PodioExample) + + set_tests_properties(jana-example-podio-tests PROPERTIES DISABLED TRUE) else() message(STATUS "Skipping examples/PodioExample because USE_PODIO=Off") diff --git a/src/examples/PodioExample/PodioExample.cc b/src/examples/PodioExample/PodioExample.cc index 3980238a6..af906bb5e 100644 --- a/src/examples/PodioExample/PodioExample.cc +++ b/src/examples/PodioExample/PodioExample.cc @@ -1,7 +1,6 @@ // Copyright 2023, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. -#include #include #include #include "PodioExampleDatamodel/MutableExampleHit.h" @@ -18,6 +17,9 @@ #include "ExampleClusterFactory.h" #include "ExampleMultifactory.h" +#include +#include + void create_hits_file() { @@ -63,9 +65,11 @@ void verify_clusters_file() { auto event0 = podio::Frame(reader.readEntry("events", 0)); std::cout << "Event 0: Expected 2 clusters, got " << event0.get("clusters")->size() << std::endl; + assert(event0.get("clusters")->size() == 2); auto event1 = podio::Frame(reader.readEntry("events", 1)); std::cout << "Event 1: Expected 3 clusters, got " << event1.get("clusters")->size() << std::endl; + assert(event1.get("clusters")->size() == 1); } @@ -83,5 +87,6 @@ int main() { verify_clusters_file(); + return app.GetExitCode(); } diff --git a/src/examples/RootDatamodelExample/CMakeLists.txt b/src/examples/RootDatamodelExample/CMakeLists.txt index 94823e227..2ca2e4fc8 100644 --- a/src/examples/RootDatamodelExample/CMakeLists.txt +++ b/src/examples/RootDatamodelExample/CMakeLists.txt @@ -42,7 +42,13 @@ if(${USE_ROOT}) message(STATUS "Installing ROOT PCM files: ${my_pcms}") install(FILES ${my_pcms} DESTINATION lib/JANA/plugins) + + add_test(NAME jana-example-rootdatamodel-tests + COMMAND jana -Pplugins=RootDatamodelExample -Pjana:nevents=10) + set_tests_properties(jana-example-rootdatamodel-tests + PROPERTIES DISABLED TRUE) + else() message(STATUS "Skipping plugins/RootDatamodelExample because USE_ROOT=Off") diff --git a/src/examples/StreamingExample/CMakeLists.txt b/src/examples/StreamingExample/CMakeLists.txt index 3ba3e8946..44fd4323a 100644 --- a/src/examples/StreamingExample/CMakeLists.txt +++ b/src/examples/StreamingExample/CMakeLists.txt @@ -19,6 +19,11 @@ if (USE_ZEROMQ) target_include_directories(StreamingExample PUBLIC ${ZeroMQ_INCLUDE_DIRS}) target_link_libraries(StreamingExample PUBLIC ${ZeroMQ_LIBRARIES}) + add_test(NAME jana-example-streaming-tests + COMMAND jana -Pplugins=StreamingExample) + + set_tests_properties(jana-example-streaming-tests PROPERTIES DISABLED TRUE) + else() message(STATUS "Skipping examples/StreamingExample because USE_ZEROMQ=Off") diff --git a/src/examples/SubeventCUDAExample/CMakeLists.txt b/src/examples/SubeventCUDAExample/CMakeLists.txt index 44a9116f7..c3ee3f7e4 100644 --- a/src/examples/SubeventCUDAExample/CMakeLists.txt +++ b/src/examples/SubeventCUDAExample/CMakeLists.txt @@ -1,18 +1,25 @@ -set(SubeventCUDAExample_SOURCES - SubeventCUDAExample.cu - ) if (USE_CUDA) find_package(CUDA REQUIRED) enable_language(CUDA) + set(SubeventCUDAExample_SOURCES + SubeventCUDAExample.cu) + add_executable(SubeventCUDAExample ${SubeventCUDAExample_SOURCES}) target_link_libraries(SubeventCUDAExample jana2) - set_target_properties(SubeventCUDAExample PROPERTIES PREFIX "" OUTPUT_NAME "SubeventCUDAExample" - CUDA_ARCHITECTURES "75;80") + + set_target_properties(SubeventCUDAExample PROPERTIES + PREFIX "" + OUTPUT_NAME "SubeventCUDAExample" + CUDA_ARCHITECTURES "75;80") + install(TARGETS SubeventCUDAExample DESTINATION bin) + add_test(NAME jana-example-subevent-cuda-tests + COMMAND SubeventCUDAExample) + else() message(STATUS "Skipping examples/SubeventCUDAExample because USE_CUDA=Off") diff --git a/src/examples/SubeventExample/CMakeLists.txt b/src/examples/SubeventExample/CMakeLists.txt index 088ac2927..351a260f9 100644 --- a/src/examples/SubeventExample/CMakeLists.txt +++ b/src/examples/SubeventExample/CMakeLists.txt @@ -1,13 +1,12 @@ -set (SubeventExample_SOURCES - SubeventExample.cc - ) - -add_executable(SubeventExample ${SubeventExample_SOURCES}) - +add_executable(SubeventExample SubeventExample.cc) target_link_libraries(SubeventExample jana2) set_target_properties(SubeventExample PROPERTIES PREFIX "" OUTPUT_NAME "SubeventExample") install(TARGETS SubeventExample DESTINATION bin) +add_test(NAME jana-example-subevent-tests + COMMAND SubeventExample) + +set_tests_properties(jana-example-subevent-tests PROPERTIES DISABLED TRUE) diff --git a/src/examples/TimesliceExample/CMakeLists.txt b/src/examples/TimesliceExample/CMakeLists.txt index a79020dd3..c9e2faaca 100644 --- a/src/examples/TimesliceExample/CMakeLists.txt +++ b/src/examples/TimesliceExample/CMakeLists.txt @@ -7,7 +7,14 @@ if (USE_PODIO) target_link_libraries(TimesliceExample PUBLIC PodioExampleDatamodel PodioExampleDatamodelDict podio::podioRootIO) + add_test(NAME jana-example-timeslices-simple-tests + COMMAND jana -Pplugins=TimesliceExample -Pjana:nevents=10 events.root) + + add_test(NAME jana-example-timeslices-complex-tests + COMMAND jana -Pplugins=TimesliceExample -Pjana:nevents=10 timeslices.root) + else() message(STATUS "Skipping examples/TimesliceExample because USE_PODIO=Off") endif() + diff --git a/src/examples/Tutorial/CMakeLists.txt b/src/examples/Tutorial/CMakeLists.txt index b4a1383aa..093edd9f1 100644 --- a/src/examples/Tutorial/CMakeLists.txt +++ b/src/examples/Tutorial/CMakeLists.txt @@ -17,4 +17,8 @@ add_jana_plugin(Tutorial SOURCES ${Tutorial_SOURCES} PUBLIC_HEADER ${Tutorial_HEADERS}) +add_test(NAME jana-example-tutorial-tests + COMMAND jana -Pplugins=Tutorial) + +set_tests_properties(jana-example-tutorial-tests PROPERTIES DISABLED TRUE) diff --git a/src/examples/UnitTestingExample/CMakeLists.txt b/src/examples/UnitTestingExample/CMakeLists.txt index 84fc87e87..446f2b962 100644 --- a/src/examples/UnitTestingExample/CMakeLists.txt +++ b/src/examples/UnitTestingExample/CMakeLists.txt @@ -1,4 +1,4 @@ -add_jana_test(UnitTestingExample SOURCES SimpleClusterFactoryTests.cc) - +add_jana_test(jana-example-unit-tests SOURCES SimpleClusterFactoryTests.cc) +target_link_libraries(jana-example-unit-tests PUBLIC Tutorial) diff --git a/src/plugins/JTest/CMakeLists.txt b/src/plugins/JTest/CMakeLists.txt index 1ce83432c..cfcfcb406 100644 --- a/src/plugins/JTest/CMakeLists.txt +++ b/src/plugins/JTest/CMakeLists.txt @@ -4,6 +4,9 @@ file(GLOB JTEST_HEADERS "*.h*") add_jana_plugin(JTest SOURCES JTestMain.cc PUBLIC_HEADER ${JTEST_HEADERS}) +add_test(NAME jana-plugin-jtest-tests + COMMAND jana -Pplugins=JTest -Pjana:nevents=100) + find_package(Threads REQUIRED) target_link_libraries(JTest PUBLIC Threads::Threads) diff --git a/src/plugins/janadot/CMakeLists.txt b/src/plugins/janadot/CMakeLists.txt index 6176687f0..7428f8797 100644 --- a/src/plugins/janadot/CMakeLists.txt +++ b/src/plugins/janadot/CMakeLists.txt @@ -1,6 +1,13 @@ -file(GLOB JANADOT_HEADERS "*.h*") -add_jana_plugin(janadot SOURCES JEventProcessorJANADOT.cc PUBLIC_HEADER ${JANADOT_HEADERS}) +add_jana_plugin(janadot + SOURCES JEventProcessorJANADOT.cc + PUBLIC_HEADER JEventProcessorJANADOT.h) + find_package(Threads REQUIRED) target_link_libraries(janadot PUBLIC Threads::Threads) +add_test(NAME jana-plugin-janadot-tests + COMMAND jana -Pplugins=JTest,janadot -Pjana:nevents=10) + +# TODO: Test that file is not empty! + diff --git a/src/programs/perf_tests/CMakeLists.txt b/src/programs/perf_tests/CMakeLists.txt index 558516bbd..d12240f1f 100644 --- a/src/programs/perf_tests/CMakeLists.txt +++ b/src/programs/perf_tests/CMakeLists.txt @@ -1,6 +1,7 @@ add_jana_test(jana-perf-tests) +set_tests_properties(jana-perf-tests PROPERTIES DISABLED TRUE) if (USE_PODIO) find_package(podio REQUIRED) From bf80259b82a98c7b86f34f27c6d8d3cc8c204f2d Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Wed, 7 Aug 2024 14:26:59 -0400 Subject: [PATCH 15/23] CI workflows use ctest suite --- .github/workflows/ccpp-docker.yml | 15 ++++----------- .github/workflows/ccpp-linux.yml | 4 ++-- src/plugins/JTest/CMakeLists.txt | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ccpp-docker.yml b/.github/workflows/ccpp-docker.yml index ad52102a8..3addd8d68 100644 --- a/.github/workflows/ccpp-docker.yml +++ b/.github/workflows/ccpp-docker.yml @@ -12,12 +12,8 @@ jobs: runs-on: ubuntu-latest container: image: nbrei/jana2_env_everything_except_cuda - - # Build Docker container and run the entrypoint.sh script in it steps: - - uses: actions/checkout@v4 - - name: build run: | cmake -S . -B build -DCMAKE_INSTALL_PREFIX=`pwd` \ @@ -32,21 +28,18 @@ jobs: - name: JTest run: | echo "--- Running JTest plugin -----------------------" - $GITHUB_WORKSPACE/bin/jana -PPLUGINS=JTest -Pjana:nevents=100 + ctest --test-dir build -R jana-plugin-jtest-tests - name: jana-unit-tests run: | echo "--- Running jana-unit-tests ------------------------------" - export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/lib/JANA/plugins:$LD_LIBRARY_PATH - $GITHUB_WORKSPACE/bin/jana-unit-tests + ctest --test-dir build -R jana-unit-tests - name: TimesliceExample with simple (physics event) topology run: | echo "--- Running TimesliceExample with simple topology ------------------------------" - export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/lib/JANA/plugins:/app/podio/install/lib:$LD_LIBRARY_PATH - $GITHUB_WORKSPACE/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=100 events.root + ctest --test-dir build -R jana-example-timeslices-simple-tests - name: TimesliceExample with complex (timeslice) topology run: | echo "--- Running TimesliceExample with complex topology ------------------------------" - export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/lib/JANA/plugins:/app/podio/install/lib:$LD_LIBRARY_PATH - $GITHUB_WORKSPACE/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=100 timeslices.root + ctest --test-dir build -R jana-example-timeslices-simple-tests diff --git a/.github/workflows/ccpp-linux.yml b/.github/workflows/ccpp-linux.yml index 9e39dc8fd..4fd338027 100644 --- a/.github/workflows/ccpp-linux.yml +++ b/.github/workflows/ccpp-linux.yml @@ -47,8 +47,8 @@ jobs: run: | export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/Linux/plugins echo "--- Running JTest plugin -----------------------" - $GITHUB_WORKSPACE/Linux/bin/jana -PPLUGINS=JTest -Pjana:nevents=100 + ctest --test-dir build -R jana-plugin-jtest-tests - name: jana-unit-tests run: | echo "--- Running jana-unit-tests ------------------------------" - $GITHUB_WORKSPACE/Linux/bin/jana-unit-tests + ctest --test-dir build -R jana-unit-tests diff --git a/src/plugins/JTest/CMakeLists.txt b/src/plugins/JTest/CMakeLists.txt index cfcfcb406..a2f5eebe6 100644 --- a/src/plugins/JTest/CMakeLists.txt +++ b/src/plugins/JTest/CMakeLists.txt @@ -5,7 +5,7 @@ file(GLOB JTEST_HEADERS "*.h*") add_jana_plugin(JTest SOURCES JTestMain.cc PUBLIC_HEADER ${JTEST_HEADERS}) add_test(NAME jana-plugin-jtest-tests - COMMAND jana -Pplugins=JTest -Pjana:nevents=100) + COMMAND jana -Pplugins=JTest -Pjana:nevents=20) find_package(Threads REQUIRED) target_link_libraries(JTest PUBLIC Threads::Threads) From 9168ba334232005969f0d7f08ab3c49b1e0111d5 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 8 Aug 2024 01:43:39 -0400 Subject: [PATCH 16/23] Tests install to $PREFIX/bin again --- .github/workflows/ccpp-docker.yml | 8 ++++---- cmake/AddJanaTest.cmake | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ccpp-docker.yml b/.github/workflows/ccpp-docker.yml index 3addd8d68..92e361e95 100644 --- a/.github/workflows/ccpp-docker.yml +++ b/.github/workflows/ccpp-docker.yml @@ -28,18 +28,18 @@ jobs: - name: JTest run: | echo "--- Running JTest plugin -----------------------" - ctest --test-dir build -R jana-plugin-jtest-tests + ctest --test-dir build -R jana-plugin-jtest-tests --rerun-failed --output-on-failure - name: jana-unit-tests run: | echo "--- Running jana-unit-tests ------------------------------" - ctest --test-dir build -R jana-unit-tests + ctest --test-dir build -R jana-unit-tests --rerun-failed --output-on-failure - name: TimesliceExample with simple (physics event) topology run: | echo "--- Running TimesliceExample with simple topology ------------------------------" - ctest --test-dir build -R jana-example-timeslices-simple-tests + ctest --test-dir build -R jana-example-timeslices-simple-tests --rerun-failed --output-on-failure - name: TimesliceExample with complex (timeslice) topology run: | echo "--- Running TimesliceExample with complex topology ------------------------------" - ctest --test-dir build -R jana-example-timeslices-simple-tests + ctest --test-dir build -R jana-example-timeslices-simple-tests --rerun-failed --output-on-failure diff --git a/cmake/AddJanaTest.cmake b/cmake/AddJanaTest.cmake index 76f5b49f0..633ec0b3e 100644 --- a/cmake/AddJanaTest.cmake +++ b/cmake/AddJanaTest.cmake @@ -18,9 +18,9 @@ macro(add_jana_test test_target_name) INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/JANA/plugins") - install(TARGETS ${test_target_name} RUNTIME DESTINATION bin/JANA/tests) + install(TARGETS ${test_target_name} RUNTIME DESTINATION bin) - add_test(NAME ${test_target_name} COMMAND ${CMAKE_INSTALL_PREFIX}/bin/JANA/tests/${test_target_name}) + add_test(NAME ${test_target_name} COMMAND ${CMAKE_INSTALL_PREFIX}/bin/${test_target_name}) endmacro() From b7827a602cdb7a015d018d766b1752bbd0bd61d3 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 8 Aug 2024 02:05:33 -0400 Subject: [PATCH 17/23] Set build rpath to install rpath so that plugins run from build dir --- .github/workflows/ccpp-docker.yml | 22 +++++++++++++------- cmake/AddInternalPlugin.cmake | 4 ++-- src/examples/TimesliceExample/CMakeLists.txt | 4 ++-- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ccpp-docker.yml b/.github/workflows/ccpp-docker.yml index 92e361e95..d6327ea56 100644 --- a/.github/workflows/ccpp-docker.yml +++ b/.github/workflows/ccpp-docker.yml @@ -25,21 +25,27 @@ jobs: -DXercesC_DIR=/usr \ -Dpodio_DIR=/app/podio/install/lib/cmake/podio/ cmake --build build --target install + - name: Examine dynamic linking + run: | + echo "ldd bin/jana" + ldd bin/jana + echo "ldd bin/libJANA.so" + ldd lib/libJANA.so + echo "bin/jana rpath" + objdump -x bin/jana | grep PATH + echo "lib/libJANA.so rpath" + objdump -x lib/libJANA.so | grep PATH - name: JTest run: | - echo "--- Running JTest plugin -----------------------" - ctest --test-dir build -R jana-plugin-jtest-tests --rerun-failed --output-on-failure + ctest --test-dir build --output-on-failure -R jana-plugin-jtest-tests - name: jana-unit-tests run: | - echo "--- Running jana-unit-tests ------------------------------" - ctest --test-dir build -R jana-unit-tests --rerun-failed --output-on-failure + ctest --test-dir build --output-on-failure -R jana-unit-tests - name: TimesliceExample with simple (physics event) topology run: | - echo "--- Running TimesliceExample with simple topology ------------------------------" - ctest --test-dir build -R jana-example-timeslices-simple-tests --rerun-failed --output-on-failure + ctest --test-dir build --output-on-failure -R jana-example-timeslices-simple-tests - name: TimesliceExample with complex (timeslice) topology run: | - echo "--- Running TimesliceExample with complex topology ------------------------------" - ctest --test-dir build -R jana-example-timeslices-simple-tests --rerun-failed --output-on-failure + ctest --test-dir build --output-on-failure -R jana-example-timeslices-complex-tests diff --git a/cmake/AddInternalPlugin.cmake b/cmake/AddInternalPlugin.cmake index 92e30b621..de32d1f0a 100644 --- a/cmake/AddInternalPlugin.cmake +++ b/cmake/AddInternalPlugin.cmake @@ -16,7 +16,7 @@ macro(add_jana_plugin plugin_name) PREFIX "" SUFFIX ".so" SKIP_BUILD_RPATH FALSE - BUILD_WITH_INSTALL_RPATH FALSE + BUILD_WITH_INSTALL_RPATH TRUE INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/JANA/plugins" ) @@ -48,7 +48,7 @@ macro(add_jana_plugin plugin_name) target_link_libraries(${plugin_name}_tests PRIVATE ${plugin_name} VendoredCatch2) set_target_properties(${plugin_name}_tests PROPERTIES SKIP_BUILD_RPATH FALSE - BUILD_WITH_INSTALL_RPATH FALSE + BUILD_WITH_INSTALL_RPATH TRUE INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/JANA/plugins" ) diff --git a/src/examples/TimesliceExample/CMakeLists.txt b/src/examples/TimesliceExample/CMakeLists.txt index c9e2faaca..8abb80d09 100644 --- a/src/examples/TimesliceExample/CMakeLists.txt +++ b/src/examples/TimesliceExample/CMakeLists.txt @@ -8,10 +8,10 @@ if (USE_PODIO) target_link_libraries(TimesliceExample PUBLIC PodioExampleDatamodel PodioExampleDatamodelDict podio::podioRootIO) add_test(NAME jana-example-timeslices-simple-tests - COMMAND jana -Pplugins=TimesliceExample -Pjana:nevents=10 events.root) + COMMAND ${CMAKE_INSTALL_PREFIX}/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=10 events.root) add_test(NAME jana-example-timeslices-complex-tests - COMMAND jana -Pplugins=TimesliceExample -Pjana:nevents=10 timeslices.root) + COMMAND ${CMAKE_INSTALL_PREFIX}/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=10 timeslices.root) else() message(STATUS "Skipping examples/TimesliceExample because USE_PODIO=Off") From eb0fa4542193863e4323aea555639035cd24dfd5 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 8 Aug 2024 14:25:56 -0400 Subject: [PATCH 18/23] Fix PodioExample --- src/examples/PodioExample/CMakeLists.txt | 4 +++- src/examples/PodioExample/PodioExample.cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/examples/PodioExample/CMakeLists.txt b/src/examples/PodioExample/CMakeLists.txt index 9bc536aea..03c6b137c 100644 --- a/src/examples/PodioExample/CMakeLists.txt +++ b/src/examples/PodioExample/CMakeLists.txt @@ -33,8 +33,10 @@ if (USE_PODIO) LIBRARY DESTINATION lib/JANA/plugins PUBLIC_HEADER DESTINATION include/JANA/plugins/PodioExampleDatamodel ) - + install(TARGETS PodioExampleDatamodelDict DESTINATION lib/JANA/plugins) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PodioExampleDatamodelDictDict.rootmap DESTINATION lib/JANA/plugins) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libPodioExampleDatamodelDict_rdict.pcm DESTINATION lib/JANA/plugins) add_test(NAME jana-example-podio-tests COMMAND PodioExample) diff --git a/src/examples/PodioExample/PodioExample.cc b/src/examples/PodioExample/PodioExample.cc index af906bb5e..4b9c88bc8 100644 --- a/src/examples/PodioExample/PodioExample.cc +++ b/src/examples/PodioExample/PodioExample.cc @@ -69,7 +69,7 @@ void verify_clusters_file() { auto event1 = podio::Frame(reader.readEntry("events", 1)); std::cout << "Event 1: Expected 3 clusters, got " << event1.get("clusters")->size() << std::endl; - assert(event1.get("clusters")->size() == 1); + assert(event1.get("clusters")->size() == 3); } From 79667d2198793e6d3e45830a3d0068bbd43e59dc Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 8 Aug 2024 16:23:23 -0400 Subject: [PATCH 19/23] CI: Fix LD_LIBRARY_PATH on eic-shell --- .github/workflows/ccpp-docker.yml | 4 ++++ .github/workflows/eicshell.yml | 28 +++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ccpp-docker.yml b/.github/workflows/ccpp-docker.yml index d6327ea56..574361ffb 100644 --- a/.github/workflows/ccpp-docker.yml +++ b/.github/workflows/ccpp-docker.yml @@ -35,6 +35,10 @@ jobs: objdump -x bin/jana | grep PATH echo "lib/libJANA.so rpath" objdump -x lib/libJANA.so | grep PATH + echo "lib/JANA/plugins/TimesliceExample.so" + objdump -x lib/JANA/plugins/TimesliceExample.so | grep PATH + echo "bin/PodioExample" + objdump -x bin/PodioExample | grep PATH - name: JTest run: | ctest --test-dir build --output-on-failure -R jana-plugin-jtest-tests diff --git a/.github/workflows/eicshell.yml b/.github/workflows/eicshell.yml index 0747c04c5..15247740b 100644 --- a/.github/workflows/eicshell.yml +++ b/.github/workflows/eicshell.yml @@ -39,6 +39,24 @@ jobs: run: | cd $GITHUB_WORKSPACE/build make -j4 install + + - name: Examine dynamic linking + run: | + export JANA_HOME=$GITHUB_WORKSPACE + export JANA_PLUGIN_PATH=$JANA_HOME/plugins + export LD_LIBRARY_PATH=$JANA_HOME/lib:$JANA_HOME/lib/JANA/plugins:$LD_LIBRARY_PATH + echo "ldd bin/jana" + ldd bin/jana + echo "ldd bin/libJANA.so" + ldd lib/libJANA.so + echo "bin/jana rpath" + objdump -x bin/jana | grep PATH + echo "lib/libJANA.so rpath" + objdump -x lib/libJANA.so | grep PATH + echo "lib/JANA/plugins/TimesliceExample.so" + objdump -x lib/JANA/plugins/TimesliceExample.so | grep PATH + echo "bin/PodioExample" + objdump -x bin/PodioExample | grep PATH - name: Run JTest plugin with 100 events uses: eic/run-cvmfs-osg-eic-shell@main @@ -47,7 +65,7 @@ jobs: run: | export JANA_HOME=$GITHUB_WORKSPACE export JANA_PLUGIN_PATH=$JANA_HOME/plugins - export LD_LIBRARY_PATH=$JANA_HOME/lib:$LD_LIBRARY_PATH + export LD_LIBRARY_PATH=$JANA_HOME/lib:$JANA_HOME/lib/JANA/plugins:$LD_LIBRARY_PATH $GITHUB_WORKSPACE/bin/jana -Pplugins=JTest -Pjana:nevents=100 - name: Run jana-unit-tests @@ -57,7 +75,7 @@ jobs: run: | export JANA_HOME=$GITHUB_WORKSPACE export JANA_PLUGIN_PATH=$JANA_HOME/plugins - export LD_LIBRARY_PATH=$JANA_HOME/lib:$LD_LIBRARY_PATH + export LD_LIBRARY_PATH=$JANA_HOME/lib:$JANA_HOME/lib/JANA/plugins:$LD_LIBRARY_PATH $GITHUB_WORKSPACE/bin/jana-unit-tests - name: Run TimesliceExample with simple (physics event) topology @@ -68,7 +86,7 @@ jobs: echo "--- Running TimesliceExample with simple topology ------------------------------" export JANA_HOME=$GITHUB_WORKSPACE export JANA_PLUGIN_PATH=$JANA_HOME/plugins - export LD_LIBRARY_PATH=$JANA_HOME/lib:$LD_LIBRARY_PATH + export LD_LIBRARY_PATH=$JANA_HOME/lib:$JANA_HOME/lib/JANA/plugins:$LD_LIBRARY_PATH $GITHUB_WORKSPACE/bin/jana \ -Pplugins=TimesliceExample \ -Pjana:nevents=100 \ @@ -82,7 +100,7 @@ jobs: echo "--- Running TimesliceExample with simple topology ------------------------------" export JANA_HOME=$GITHUB_WORKSPACE export JANA_PLUGIN_PATH=$JANA_HOME/plugins - export LD_LIBRARY_PATH=$JANA_HOME/lib:$LD_LIBRARY_PATH + export LD_LIBRARY_PATH=$JANA_HOME/lib:$JANA_HOME/lib/JANA/plugins:$LD_LIBRARY_PATH $GITHUB_WORKSPACE/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=100 timeslices.root @@ -120,7 +138,7 @@ jobs: run: | echo "--- Running EICrecon ---" export JANA_HOME=$GITHUB_WORKSPACE - export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/../EICrecon/lib:$JANA_HOME/lib:$LD_LIBRARY_PATH export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/../EICrecon/lib/EICrecon/plugins + export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/../EICrecon/lib:$JANA_HOME/lib:$JANA_HOME/lib/JANA/plugins:$LD_LIBRARY_PATH ../EICrecon/bin/eicrecon sim_e_1GeV_20GeV_craterlake.edm4hep.root From b4e877b82b31bd9290a51b5a5108ff5bc8cd2463 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 8 Aug 2024 18:00:42 -0400 Subject: [PATCH 20/23] CI: Add podio back to LD_LIBRARY_PATH Even though podio is in the RPath, Cling won't look there when hunting for libpodio's dictionaries --- .github/workflows/ccpp-docker.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ccpp-docker.yml b/.github/workflows/ccpp-docker.yml index 574361ffb..716092016 100644 --- a/.github/workflows/ccpp-docker.yml +++ b/.github/workflows/ccpp-docker.yml @@ -41,15 +41,21 @@ jobs: objdump -x bin/PodioExample | grep PATH - name: JTest run: | + export LD_LIBRARY_PATH=/app/podio/install/lib:$LD_LIBRARY_PATH + # Note that podio needs to be on the LD_LIBRARY_PATH, not merely someone's RPath, because + # Cling needs to be able to find the libpodioDict* ctest --test-dir build --output-on-failure -R jana-plugin-jtest-tests - name: jana-unit-tests run: | + export LD_LIBRARY_PATH=/app/podio/install/lib:$LD_LIBRARY_PATH ctest --test-dir build --output-on-failure -R jana-unit-tests - name: TimesliceExample with simple (physics event) topology run: | + export LD_LIBRARY_PATH=/app/podio/install/lib:$LD_LIBRARY_PATH ctest --test-dir build --output-on-failure -R jana-example-timeslices-simple-tests - name: TimesliceExample with complex (timeslice) topology run: | + export LD_LIBRARY_PATH=/app/podio/install/lib:$LD_LIBRARY_PATH ctest --test-dir build --output-on-failure -R jana-example-timeslices-complex-tests From cbb3b9baad1058c080f119055c891f74b4bc9112 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 9 Aug 2024 12:12:59 -0400 Subject: [PATCH 21/23] CMake add_jana_plugin() supports glob matching --- cmake/AddInternalPlugin.cmake | 27 +++++++++++++++++++ src/examples/DstExample/CMakeLists.txt | 6 +---- src/examples/EventGroupExample/CMakeLists.txt | 6 +---- src/examples/MetadataExample/CMakeLists.txt | 6 +---- src/examples/StreamingExample/CMakeLists.txt | 15 +---------- src/examples/TimesliceExample/CMakeLists.txt | 3 +-- src/examples/Tutorial/CMakeLists.txt | 17 +----------- .../UnitTestingExample/CMakeLists.txt | 2 +- src/plugins/JTest/CMakeLists.txt | 4 +-- src/plugins/janadot/CMakeLists.txt | 4 +-- src/plugins/janarate/CMakeLists.txt | 3 +-- 11 files changed, 37 insertions(+), 56 deletions(-) diff --git a/cmake/AddInternalPlugin.cmake b/cmake/AddInternalPlugin.cmake index de32d1f0a..ab1b8113d 100644 --- a/cmake/AddInternalPlugin.cmake +++ b/cmake/AddInternalPlugin.cmake @@ -8,6 +8,33 @@ macro(add_jana_plugin plugin_name) cmake_parse_arguments(PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if (NOT PLUGIN_SOURCES AND NOT PLUGIN_PUBLIC_HEADER AND NOT PLUGIN_TESTS) + # If no arguments provided, glob everything + file(GLOB HEADERS_IN_SUBDIR "include/*") + file(GLOB SOURCES_IN_SUBDIR "src/*") + file(GLOB TESTS_IN_SUBDIR "test*/*") + file(GLOB HEADERS_IN_CWD "*.h*") + set(SOURCES_IN_CWD) + set(TESTS_IN_CWD) + + file(GLOB ALL_SOURCES_IN_CWD "*.c*") + foreach(file IN LISTS ALL_SOURCES_IN_CWD) + string(TOLOWER "${file}" file_lower) + if(NOT file_lower MATCHES ".*/test[^/]*$|.*test$|.*tests$") + list(APPEND SOURCES_IN_CWD ${file}) + else() + list(APPEND TESTS_IN_CWD ${file}) + endif() + endforeach() + + set(PLUGIN_SOURCES ${SOURCES_IN_CWD} ${SOURCES_IN_SUBDIR}) + set(PLUGIN_PUBLIC_HEADER ${HEADERS_IN_CWD} ${HEADERS_IN_SUBDIR}) + set(PLUGIN_TESTS ${TESTS_IN_CWD} ${TESTS_IN_SUBDIR}) + message(STATUS "Plugin ${plugin_name}: found sources: ${PLUGIN_SOURCES}") + message(STATUS "Plugin ${plugin_name}: found headers: ${PLUGIN_PUBLIC_HEADER}") + message(STATUS "Plugin ${plugin_name}: found tests: ${PLUGIN_TESTS}") + endif() + # Set up target add_library(${plugin_name} SHARED ${PLUGIN_SOURCES}) diff --git a/src/examples/DstExample/CMakeLists.txt b/src/examples/DstExample/CMakeLists.txt index 8387be7dd..47bb1a3f9 100644 --- a/src/examples/DstExample/CMakeLists.txt +++ b/src/examples/DstExample/CMakeLists.txt @@ -1,10 +1,6 @@ -file(GLOB DSTExample_SOURCES "*.c*") -file(GLOB DSTExample_HEADERS "*.h*") -add_jana_plugin(DstExample - SOURCES ${DSTExample_SOURCES} - PUBLIC_HEADER ${DSTExample_HEADERS}) +add_jana_plugin(DstExample) add_test( NAME jana-example-dst-tests diff --git a/src/examples/EventGroupExample/CMakeLists.txt b/src/examples/EventGroupExample/CMakeLists.txt index 2fd2817c0..8b761b3aa 100644 --- a/src/examples/EventGroupExample/CMakeLists.txt +++ b/src/examples/EventGroupExample/CMakeLists.txt @@ -1,10 +1,6 @@ -file(GLOB EventGroupExample_SOURCES "*.c*") -file(GLOB EventGroupExample_HEADERS "*.h*") -add_jana_plugin(EventGroupExample - SOURCES ${EventGroupExample_SOURCES} - PUBLIC_HEADER ${EventGroupExample_HEADERS}) +add_jana_plugin(EventGroupExample) add_test(NAME jana-example-eventgroup-tests COMMAND jana -Pplugins=EventGroupExample) diff --git a/src/examples/MetadataExample/CMakeLists.txt b/src/examples/MetadataExample/CMakeLists.txt index cebdb2315..67da55203 100644 --- a/src/examples/MetadataExample/CMakeLists.txt +++ b/src/examples/MetadataExample/CMakeLists.txt @@ -1,10 +1,6 @@ -file(GLOB MetadataExample_SOURCES "*.c*") -file(GLOB MetadataExample_HEADERS "*.h*") -add_jana_plugin(MetadataExample - SOURCES ${MetadataExample_SOURCES} - PUBLIC_HEADER ${MetadataExample_HEADERS}) +add_jana_plugin(MetadataExample) add_test(NAME jana-example-metadata-tests COMMAND jana -Pplugins=MetadataExample) diff --git a/src/examples/StreamingExample/CMakeLists.txt b/src/examples/StreamingExample/CMakeLists.txt index 44fd4323a..042ed265c 100644 --- a/src/examples/StreamingExample/CMakeLists.txt +++ b/src/examples/StreamingExample/CMakeLists.txt @@ -1,21 +1,8 @@ -# JExample 7 plugin - -set(StreamingExample_SOURCES - ZmqMain.cc) - -set(StreamingExample_HEADERS - ZmqTransport.h - ReadoutMessageAuto.h - AHit.h - AHitAnomalyDetector.h - AHitParser.h) if (USE_ZEROMQ) find_package(ZeroMQ REQUIRED) - add_jana_plugin(StreamingExample - SOURCES ${StreamingExample_SOURCES} - PUBLIC_HEADER ${StreamingExample_HEADERS}) + add_jana_plugin(StreamingExample) target_include_directories(StreamingExample PUBLIC ${ZeroMQ_INCLUDE_DIRS}) target_link_libraries(StreamingExample PUBLIC ${ZeroMQ_LIBRARIES}) diff --git a/src/examples/TimesliceExample/CMakeLists.txt b/src/examples/TimesliceExample/CMakeLists.txt index 8abb80d09..e3bc209b4 100644 --- a/src/examples/TimesliceExample/CMakeLists.txt +++ b/src/examples/TimesliceExample/CMakeLists.txt @@ -2,8 +2,7 @@ if (USE_PODIO) - add_jana_plugin(TimesliceExample - SOURCES TimesliceExample.cc CollectionTabulators.cc) + add_jana_plugin(TimesliceExample) target_link_libraries(TimesliceExample PUBLIC PodioExampleDatamodel PodioExampleDatamodelDict podio::podioRootIO) diff --git a/src/examples/Tutorial/CMakeLists.txt b/src/examples/Tutorial/CMakeLists.txt index 093edd9f1..93c115f98 100644 --- a/src/examples/Tutorial/CMakeLists.txt +++ b/src/examples/Tutorial/CMakeLists.txt @@ -1,21 +1,6 @@ -set (Tutorial_SOURCES - Tutorial.cc - RandomSource.cc - TutorialProcessor.cc - SimpleClusterFactory.cc) - -set (Tutorial_HEADERS - TutorialProcessor.h - RandomSource.h - Hit.h - Cluster.h - SimpleClusterFactory.h) - -add_jana_plugin(Tutorial - SOURCES ${Tutorial_SOURCES} - PUBLIC_HEADER ${Tutorial_HEADERS}) +add_jana_plugin(Tutorial) add_test(NAME jana-example-tutorial-tests COMMAND jana -Pplugins=Tutorial) diff --git a/src/examples/UnitTestingExample/CMakeLists.txt b/src/examples/UnitTestingExample/CMakeLists.txt index 446f2b962..a48488a53 100644 --- a/src/examples/UnitTestingExample/CMakeLists.txt +++ b/src/examples/UnitTestingExample/CMakeLists.txt @@ -1,4 +1,4 @@ -add_jana_test(jana-example-unit-tests SOURCES SimpleClusterFactoryTests.cc) +add_jana_test(jana-example-unit-tests) target_link_libraries(jana-example-unit-tests PUBLIC Tutorial) diff --git a/src/plugins/JTest/CMakeLists.txt b/src/plugins/JTest/CMakeLists.txt index a2f5eebe6..7587211d9 100644 --- a/src/plugins/JTest/CMakeLists.txt +++ b/src/plugins/JTest/CMakeLists.txt @@ -1,8 +1,6 @@ -file(GLOB JTEST_HEADERS "*.h*") - -add_jana_plugin(JTest SOURCES JTestMain.cc PUBLIC_HEADER ${JTEST_HEADERS}) +add_jana_plugin(JTest) add_test(NAME jana-plugin-jtest-tests COMMAND jana -Pplugins=JTest -Pjana:nevents=20) diff --git a/src/plugins/janadot/CMakeLists.txt b/src/plugins/janadot/CMakeLists.txt index 7428f8797..526627eca 100644 --- a/src/plugins/janadot/CMakeLists.txt +++ b/src/plugins/janadot/CMakeLists.txt @@ -1,7 +1,5 @@ -add_jana_plugin(janadot - SOURCES JEventProcessorJANADOT.cc - PUBLIC_HEADER JEventProcessorJANADOT.h) +add_jana_plugin(janadot) find_package(Threads REQUIRED) target_link_libraries(janadot PUBLIC Threads::Threads) diff --git a/src/plugins/janarate/CMakeLists.txt b/src/plugins/janarate/CMakeLists.txt index c524d8c48..b0f7be996 100644 --- a/src/plugins/janarate/CMakeLists.txt +++ b/src/plugins/janarate/CMakeLists.txt @@ -2,8 +2,7 @@ if (${USE_ROOT}) - file(GLOB JTEST_HEADERS "*.h*") - add_jana_plugin(janarate SOURCES JEventProcessorJANARATE.cc PUBLIC_HEADER ${JTEST_HEADERS}) + add_jana_plugin(janarate) target_include_directories(janarate PUBLIC ${ROOT_INCLUDE_DIRS}) target_link_libraries(janarate PUBLIC ${ROOT_LIBRARIES}) From 335623266c778123aeb1182572f23420d328d9ae Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 9 Aug 2024 12:39:09 -0400 Subject: [PATCH 22/23] CMake add_jana_plugin() works both internally and externally --- CMakeLists.txt | 2 +- cmake/AddExternalPlugin.cmake | 65 ------------------- ...ternalPlugin.cmake => AddJanaPlugin.cmake} | 38 +++++++---- cmake/MakeConfig.cmake | 2 +- src/examples/PodioExample/CMakeLists.txt | 6 +- 5 files changed, 34 insertions(+), 79 deletions(-) delete mode 100644 cmake/AddExternalPlugin.cmake rename cmake/{AddInternalPlugin.cmake => AddJanaPlugin.cmake} (67%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba9871546..b170b1d29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,7 +203,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif() include(CTest) -include(cmake/AddInternalPlugin.cmake) +include(cmake/AddJanaPlugin.cmake) include(cmake/AddJanaTest.cmake) add_subdirectory(src/external) diff --git a/cmake/AddExternalPlugin.cmake b/cmake/AddExternalPlugin.cmake deleted file mode 100644 index 3c435f5b4..000000000 --- a/cmake/AddExternalPlugin.cmake +++ /dev/null @@ -1,65 +0,0 @@ - -macro(add_jana_plugin plugin_name) - - # Parse remaining arguments - set(options) - set(oneValueArgs) - set(multiValueArgs SOURCES PUBLIC_HEADER TESTS) - - cmake_parse_arguments(PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - # Figure out install namespacce - if (NOT DEFINED INSTALL_NAMESPACE) - set(INSTALL_NAMESPACE ${PROJECT_NAME} CACHE STRING "Project-specific namespace for installation paths, e.g. /lib/PROJECT_NAMESPACE/plugins") - endif() - - # Set up target - add_library(${plugin_name} SHARED ${PLUGIN_SOURCES}) - - set_target_properties(${plugin_name} PROPERTIES - EXPORT_NAME ${plugin_name} - PREFIX "" - SUFFIX ".so" - SKIP_BUILD_RPATH FALSE - BUILD_WITH_INSTALL_RPATH FALSE - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/${INSTALL_NAMESPACE}/plugins" - ) - - target_link_libraries(${plugin_name} PUBLIC JANA::jana2_static_lib) - - # Handle public headers - if (PLUGIN_PUBLIC_HEADER) - set_target_properties(${plugin_name} PROPERTIES - PUBLIC_HEADER "${PLUGIN_PUBLIC_HEADER}" - ) - target_include_directories(${plugin_name} - PUBLIC - $ - $ - ) - endif() - - # Install target - install(TARGETS ${plugin_name} - EXPORT jana2_targets - PUBLIC_HEADER DESTINATION include/${INSTALL_NAMESPACE}/plugins/${plugin_name} - LIBRARY DESTINATION lib/${INSTALL_NAMESPACE}/plugins - ) - - # Handle tests - if (PLUGIN_TESTS) - add_executable(${plugin_name}_tests ${PLUGIN_TESTS}) - target_link_libraries(${plugin_name}_tests PRIVATE ${plugin_name} VendoredCatch2) - set_target_properties(${plugin_name}_tests PROPERTIES - SKIP_BUILD_RPATH FALSE - BUILD_WITH_INSTALL_RPATH FALSE - INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/${INSTALL_NAMESPACE}/plugins" - ) - install(TARGETS ${plugin_name}_tests RUNTIME DESTINATION bin) - add_test(NAME ${plugin_name}_tests COMMAND ${CMAKE_INSTALL_PREFIX}/bin/${plugin_name}_tests) - endif() -endmacro() - - diff --git a/cmake/AddInternalPlugin.cmake b/cmake/AddJanaPlugin.cmake similarity index 67% rename from cmake/AddInternalPlugin.cmake rename to cmake/AddJanaPlugin.cmake index ab1b8113d..c302f54e5 100644 --- a/cmake/AddInternalPlugin.cmake +++ b/cmake/AddJanaPlugin.cmake @@ -3,7 +3,7 @@ macro(add_jana_plugin plugin_name) # Parse remaining arguments set(options) - set(oneValueArgs) + set(oneValueArgs EXPORT) set(multiValueArgs SOURCES PUBLIC_HEADER TESTS) cmake_parse_arguments(PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -35,6 +35,22 @@ macro(add_jana_plugin plugin_name) message(STATUS "Plugin ${plugin_name}: found tests: ${PLUGIN_TESTS}") endif() + if (${PROJECT_NAME} STREQUAL "jana2") + # This is an internal plugin + set(INSTALL_NAMESPACE "JANA") + set(JANA_NAMESPACE "") + if (NOT PLUGIN_EXPORT) + set(PLUGIN_EXPORT "jana2_targets") + endif() + else() + # This is an external plugin + # Figure out install namespace, which _might_ be different than PROJECT_NAME + if (NOT DEFINED INSTALL_NAMESPACE) + set(INSTALL_NAMESPACE ${PROJECT_NAME} CACHE STRING "Project-specific namespace for installation paths, e.g. /lib/PROJECT_NAMESPACE/plugins") + endif() + set(JANA_NAMESPACE "JANA::") + endif() + # Set up target add_library(${plugin_name} SHARED ${PLUGIN_SOURCES}) @@ -45,10 +61,10 @@ macro(add_jana_plugin plugin_name) SKIP_BUILD_RPATH FALSE BUILD_WITH_INSTALL_RPATH TRUE INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/JANA/plugins" + INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/${INSTALL_NAMESPACE}/plugins" ) - target_link_libraries(${plugin_name} PUBLIC jana2_static_lib) + target_link_libraries(${plugin_name} PUBLIC "${JANA_NAMESPACE}jana2_static_lib") # Handle public headers if (PLUGIN_PUBLIC_HEADER) @@ -58,29 +74,29 @@ macro(add_jana_plugin plugin_name) target_include_directories(${plugin_name} PUBLIC $ - $ + $ ) endif() # Install target install(TARGETS ${plugin_name} - EXPORT ParentTargets - PUBLIC_HEADER DESTINATION include/JANA/plugins/${plugin_name} - LIBRARY DESTINATION lib/JANA/plugins + EXPORT ${PLUGIN_EXPORT} + PUBLIC_HEADER DESTINATION include/${INSTALL_NAMESPACE}/plugins/${plugin_name} + LIBRARY DESTINATION lib/${INSTALL_NAMESPACE}/plugins ) # Handle tests if (PLUGIN_TESTS) add_executable(${plugin_name}_tests ${PLUGIN_TESTS}) - target_link_libraries(${plugin_name}_tests PRIVATE ${plugin_name} VendoredCatch2) + target_link_libraries(${plugin_name}_tests PRIVATE ${plugin_name} "${JANA_NAMESPACE}VendoredCatch2") set_target_properties(${plugin_name}_tests PROPERTIES SKIP_BUILD_RPATH FALSE BUILD_WITH_INSTALL_RPATH TRUE INSTALL_RPATH_USE_LINK_PATH TRUE - INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/JANA/plugins" + INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/${INSTALL_NAMESPACE}/plugins" ) - install(TARGETS ${plugin_name}_tests RUNTIME DESTINATION bin) - add_test(NAME ${plugin_name}_tests COMMAND ${CMAKE_INSTALL_PREFIX}/bin/jana-${plugin_name}-tests) + #install(TARGETS ${plugin_name}_tests RUNTIME DESTINATION bin) + add_test(NAME ${plugin_name}_tests COMMAND ${plugin_name}_tests) endif() endmacro() diff --git a/cmake/MakeConfig.cmake b/cmake/MakeConfig.cmake index 667df19b9..8fafad0de 100644 --- a/cmake/MakeConfig.cmake +++ b/cmake/MakeConfig.cmake @@ -24,7 +24,7 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/JANAConfig.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/JANAConfigVersion.cmake" DESTINATION "lib/JANA/cmake") -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddExternalPlugin.cmake" +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddJanaPlugin.cmake" DESTINATION "lib/JANA/cmake") diff --git a/src/examples/PodioExample/CMakeLists.txt b/src/examples/PodioExample/CMakeLists.txt index 03c6b137c..f42a34e09 100644 --- a/src/examples/PodioExample/CMakeLists.txt +++ b/src/examples/PodioExample/CMakeLists.txt @@ -30,11 +30,15 @@ if (USE_PODIO) install(TARGETS PodioExample DESTINATION bin) install(TARGETS PodioExampleDatamodel + EXPORT jana2_targets LIBRARY DESTINATION lib/JANA/plugins PUBLIC_HEADER DESTINATION include/JANA/plugins/PodioExampleDatamodel ) - install(TARGETS PodioExampleDatamodelDict DESTINATION lib/JANA/plugins) + install(TARGETS PodioExampleDatamodelDict + EXPORT jana2_targets + DESTINATION lib/JANA/plugins) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PodioExampleDatamodelDictDict.rootmap DESTINATION lib/JANA/plugins) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libPodioExampleDatamodelDict_rdict.pcm DESTINATION lib/JANA/plugins) From d095d4885f4394d49b3877ef5213cfb0647abc88 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 9 Aug 2024 12:44:54 -0400 Subject: [PATCH 23/23] Prune plugin dependencies that should be inherited instead --- .../InteractiveStreamingExample/CMakeLists.txt | 4 ++-- src/libraries/JANA/CMakeLists.txt | 18 +++++++++--------- src/plugins/JTest/CMakeLists.txt | 2 -- src/plugins/janarate/CMakeLists.txt | 3 --- src/plugins/janaview/CMakeLists.txt | 6 ------ src/plugins/regressiontest/CMakeLists.txt | 2 -- 6 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/examples/InteractiveStreamingExample/CMakeLists.txt b/src/examples/InteractiveStreamingExample/CMakeLists.txt index 2f12c0213..8b58400d6 100644 --- a/src/examples/InteractiveStreamingExample/CMakeLists.txt +++ b/src/examples/InteractiveStreamingExample/CMakeLists.txt @@ -11,8 +11,8 @@ if (${USE_ROOT} AND ${USE_ZEROMQ}) SOURCES ${InteractiveStreamingExample_SOURCES} PUBLIC_HEADER ${InteractiveStreamingExample_HEADERS}) - target_include_directories(InteractiveStreamingExample PUBLIC ${ROOT_INCLUDE_DIRS} ${ZeroMQ_INCLUDE_DIRS}) - target_link_libraries(InteractiveStreamingExample PUBLIC ${ZeroMQ_LIBRARIES} ${ROOT_LIBRARIES}) + target_include_directories(InteractiveStreamingExample PUBLIC ${ZeroMQ_INCLUDE_DIRS}) + target_link_libraries(InteractiveStreamingExample PUBLIC ${ZeroMQ_LIBRARIES}) else() diff --git a/src/libraries/JANA/CMakeLists.txt b/src/libraries/JANA/CMakeLists.txt index 552d7eeab..e7c59008a 100644 --- a/src/libraries/JANA/CMakeLists.txt +++ b/src/libraries/JANA/CMakeLists.txt @@ -149,12 +149,12 @@ add_library(jana2 OBJECT ${JANA2_SOURCES}) find_package(Threads REQUIRED) set(THREADS_PREFER_PTHREAD_FLAG ON) -target_link_libraries(jana2 ${CMAKE_DL_LIBS} Threads::Threads) +target_link_libraries(jana2 PUBLIC ${CMAKE_DL_LIBS} Threads::Threads) if (${USE_PODIO}) - target_link_libraries(jana2 podio::podio podio::podioRootIO ${ROOT_LIBRARIES}) + target_link_libraries(jana2 PUBLIC podio::podio podio::podioRootIO ${ROOT_LIBRARIES}) elseif (${USE_ROOT}) - target_link_libraries(jana2 ${ROOT_LIBRARIES}) + target_link_libraries(jana2 PUBLIC ${ROOT_LIBRARIES}) endif() @@ -163,12 +163,12 @@ add_library(jana2_static_lib STATIC $) set_target_properties(jana2_static_lib PROPERTIES PREFIX "lib" OUTPUT_NAME "JANA") target_include_directories(jana2_static_lib PUBLIC $) -target_link_libraries(jana2_static_lib ${CMAKE_DL_LIBS} Threads::Threads) +target_link_libraries(jana2_static_lib PUBLIC ${CMAKE_DL_LIBS} Threads::Threads) if (${USE_PODIO}) - target_link_libraries(jana2_static_lib podio::podio podio::podioRootIO ${ROOT_LIBRARIES}) + target_link_libraries(jana2_static_lib PUBLIC podio::podio podio::podioRootIO ${ROOT_LIBRARIES}) elseif (${USE_ROOT}) - target_link_libraries(jana2_static_lib ${ROOT_LIBRARIES}) + target_link_libraries(jana2_static_lib PUBLIC ${ROOT_LIBRARIES}) endif() install(TARGETS jana2_static_lib EXPORT jana2_targets DESTINATION lib) @@ -180,12 +180,12 @@ if (BUILD_SHARED_LIBS) set_target_properties(jana2_shared_lib PROPERTIES PREFIX "lib" OUTPUT_NAME "JANA") target_include_directories(jana2_shared_lib PUBLIC $) - target_link_libraries(jana2_shared_lib ${CMAKE_DL_LIBS} Threads::Threads) + target_link_libraries(jana2_shared_lib PUBLIC ${CMAKE_DL_LIBS} Threads::Threads) if (${USE_PODIO}) - target_link_libraries(jana2_shared_lib podio::podio podio::podioRootIO ${ROOT_LIBRARIES}) + target_link_libraries(jana2_shared_lib PUBLIC podio::podio podio::podioRootIO ${ROOT_LIBRARIES}) elseif (${USE_ROOT}) - target_link_libraries(jana2_shared_lib ${ROOT_LIBRARIES}) + target_link_libraries(jana2_shared_lib PUBLIC ${ROOT_LIBRARIES}) endif() install(TARGETS jana2_shared_lib EXPORT jana2_targets DESTINATION lib) diff --git a/src/plugins/JTest/CMakeLists.txt b/src/plugins/JTest/CMakeLists.txt index 7587211d9..069998b5a 100644 --- a/src/plugins/JTest/CMakeLists.txt +++ b/src/plugins/JTest/CMakeLists.txt @@ -5,6 +5,4 @@ add_jana_plugin(JTest) add_test(NAME jana-plugin-jtest-tests COMMAND jana -Pplugins=JTest -Pjana:nevents=20) -find_package(Threads REQUIRED) -target_link_libraries(JTest PUBLIC Threads::Threads) diff --git a/src/plugins/janarate/CMakeLists.txt b/src/plugins/janarate/CMakeLists.txt index b0f7be996..813bed96b 100644 --- a/src/plugins/janarate/CMakeLists.txt +++ b/src/plugins/janarate/CMakeLists.txt @@ -4,9 +4,6 @@ if (${USE_ROOT}) add_jana_plugin(janarate) - target_include_directories(janarate PUBLIC ${ROOT_INCLUDE_DIRS}) - target_link_libraries(janarate PUBLIC ${ROOT_LIBRARIES}) - else() message(STATUS "Skipping plugins/janarate because USE_ROOT=Off") diff --git a/src/plugins/janaview/CMakeLists.txt b/src/plugins/janaview/CMakeLists.txt index 1d0d4fcc9..5a1c5943a 100644 --- a/src/plugins/janaview/CMakeLists.txt +++ b/src/plugins/janaview/CMakeLists.txt @@ -12,12 +12,6 @@ if(USE_ROOT) PUBLIC_HEADER ${JANAVIEW_HEADERS} ) - target_include_directories(janaview PUBLIC ${ROOT_INCLUDE_DIRS}) - target_link_libraries(janaview PUBLIC ${ROOT_LIBRARIES}) - - find_package(Threads REQUIRED) - target_link_libraries(janaview PUBLIC Threads::Threads) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjv_mainframe_rdict.pcm DESTINATION lib/JANA/plugins) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjv_mainframe.rootmap DESTINATION lib/JANA/plugins) diff --git a/src/plugins/regressiontest/CMakeLists.txt b/src/plugins/regressiontest/CMakeLists.txt index a6dc0489d..d74e52382 100644 --- a/src/plugins/regressiontest/CMakeLists.txt +++ b/src/plugins/regressiontest/CMakeLists.txt @@ -3,6 +3,4 @@ add_jana_plugin(regressiontest SOURCES JEventProcessor_regressiontest.cc PUBLIC_HEADER JEventProcessor_regressiontest.h) -find_package(Threads REQUIRED) -target_link_libraries(regressiontest PUBLIC Threads::Threads)