diff --git a/.github/workflows/ccpp-docker.yml b/.github/workflows/ccpp-docker.yml index 09d7cf131..716092016 100644 --- a/.github/workflows/ccpp-docker.yml +++ b/.github/workflows/ccpp-docker.yml @@ -12,53 +12,50 @@ 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: 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 + cmake --build build --target install + - name: Examine dynamic linking run: | - cd $GITHUB_WORKSPACE/build - make install + 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: JTest run: | - echo "--- Running JTest plugin -----------------------" - export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/Linux/plugins - $GITHUB_WORKSPACE/Linux/bin/jana -PPLUGINS=JTest -Pjana:nevents=100 + 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: | - echo "--- Running jana-unit-tests ------------------------------" - export JANA_PLUGIN_PATH=$GITHUB_WORKSPACE/Linux/plugins - $GITHUB_WORKSPACE/Linux/bin/jana-unit-tests + 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: | - 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=/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: | - 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=/app/podio/install/lib:$LD_LIBRARY_PATH + ctest --test-dir build --output-on-failure -R jana-example-timeslices-complex-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/.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 diff --git a/.gitignore b/.gitignore index 0b4376270..472e36011 100644 --- a/.gitignore +++ b/.gitignore @@ -52,7 +52,6 @@ Makefile /bin/ /include/ /lib/ -/plugins/ # Doxygen generated files docs/html/* @@ -65,9 +64,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/CMakeLists.txt b/CMakeLists.txt index 5d0d20eac..b170b1d29 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 @@ -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,18 +202,24 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") add_link_options(-undefined dynamic_lookup) endif() +include(CTest) +include(cmake/AddJanaPlugin.cmake) +include(cmake/AddJanaTest.cmake) + +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/cmake/AddJanaPlugin.cmake b/cmake/AddJanaPlugin.cmake new file mode 100644 index 000000000..c302f54e5 --- /dev/null +++ b/cmake/AddJanaPlugin.cmake @@ -0,0 +1,103 @@ + +macro(add_jana_plugin plugin_name) + + # Parse remaining arguments + set(options) + set(oneValueArgs EXPORT) + set(multiValueArgs SOURCES PUBLIC_HEADER TESTS) + + 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() + + 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}) + + set_target_properties(${plugin_name} PROPERTIES + EXPORT_NAME ${plugin_name} + PREFIX "" + SUFFIX ".so" + 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/${INSTALL_NAMESPACE}/plugins" + ) + + target_link_libraries(${plugin_name} PUBLIC "${JANA_NAMESPACE}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 ${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} "${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/${INSTALL_NAMESPACE}/plugins" + ) + #install(TARGETS ${plugin_name}_tests RUNTIME DESTINATION bin) + add_test(NAME ${plugin_name}_tests COMMAND ${plugin_name}_tests) + endif() +endmacro() + + diff --git a/cmake/AddJanaTest.cmake b/cmake/AddJanaTest.cmake new file mode 100644 index 000000000..633ec0b3e --- /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) + + add_test(NAME ${test_target_name} COMMAND ${CMAKE_INSTALL_PREFIX}/bin/${test_target_name}) + +endmacro() + + 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..8fafad0de 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/JANA/cmake" +) -# 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/JANA/cmake") - 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/JANA/cmake") -# 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/JANA/cmake") -# 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/AddJanaPlugin.cmake" + DESTINATION "lib/JANA/cmake") -# 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/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/examples/DstExample/CMakeLists.txt b/src/examples/DstExample/CMakeLists.txt index d4902359a..47bb1a3f9 100644 --- a/src/examples/DstExample/CMakeLists.txt +++ b/src/examples/DstExample/CMakeLists.txt @@ -1,20 +1,7 @@ -set (DstExample_PLUGIN_SOURCES - DstExample.cc - DstExampleSource.cc - DstExampleSource.h - DstExampleProcessor.cc - DstExampleProcessor.h - DstExampleFactory.cc - DstExampleFactory.h - DataObjects.h - ) - -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) +add_jana_plugin(DstExample) +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 9cdafddb4..8b761b3aa 100644 --- a/src/examples/EventGroupExample/CMakeLists.txt +++ b/src/examples/EventGroupExample/CMakeLists.txt @@ -1,19 +1,8 @@ -# JExample 7 plugin -set(EventGroupExample_SOURCES SHARED - BlockingGroupedEventSource.h - EventGroupExamplePlugin.cc - GroupedEventProcessor.h - GroupedEventSource.h - TridasEvent.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 "" SUFFIX ".so") - -install(TARGETS EventGroupExample_plugin DESTINATION ${CMAKE_INSTALL_PREFIX}/plugins) +add_jana_plugin(EventGroupExample) +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/InteractiveStreamingExample/CMakeLists.txt b/src/examples/InteractiveStreamingExample/CMakeLists.txt index 26e6ec3c3..8b58400d6 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 plugins) - - file(GLOB my_headers "*.h*") - install(FILES ${my_headers} DESTINATION include/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 ${ZeroMQ_INCLUDE_DIRS}) + target_link_libraries(InteractiveStreamingExample PUBLIC ${ZeroMQ_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 757224d93..67da55203 100644 --- a/src/examples/MetadataExample/CMakeLists.txt +++ b/src/examples/MetadataExample/CMakeLists.txt @@ -1,20 +1,9 @@ -set (MetadataExample_PLUGIN_SOURCES - MetadataExample.cc - MetadataAggregator.cc - MetadataAggregator.h - Track.h - TrackSmearingFactory.cc - TrackSmearingFactory.h - RandomTrackSource.cc - RandomTrackSource.h - ) +add_jana_plugin(MetadataExample) -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) +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 c77838a52..f42a34e09 100644 --- a/src/examples/PodioExample/CMakeLists.txt +++ b/src/examples/PodioExample/CMakeLists.txt @@ -9,25 +9,44 @@ 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 PodioExampleDatamodelDict DESTINATION lib) + + install(TARGETS PodioExampleDatamodel + EXPORT jana2_targets + LIBRARY DESTINATION lib/JANA/plugins + PUBLIC_HEADER DESTINATION include/JANA/plugins/PodioExampleDatamodel + ) + + 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) + + 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/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..4b9c88bc8 100644 --- a/src/examples/PodioExample/PodioExample.cc +++ b/src/examples/PodioExample/PodioExample.cc @@ -1,11 +1,10 @@ // Copyright 2023, Jefferson Science Associates, LLC. // Subject to the terms in the LICENSE file found in the top-level directory. -#include #include #include -#include "datamodel/MutableExampleHit.h" -#include "datamodel/ExampleHitCollection.h" +#include "PodioExampleDatamodel/MutableExampleHit.h" +#include "PodioExampleDatamodel/ExampleHitCollection.h" #include #include @@ -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() == 3); } @@ -83,5 +87,6 @@ int main() { verify_clusters_file(); + return app.GetExitCode(); } 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/examples/RootDatamodelExample/CMakeLists.txt b/src/examples/RootDatamodelExample/CMakeLists.txt index e170f771e..2ca2e4fc8 100644 --- a/src/examples/RootDatamodelExample/CMakeLists.txt +++ b/src/examples/RootDatamodelExample/CMakeLists.txt @@ -18,32 +18,36 @@ 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 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 plugins) + install(FILES ${my_pcms} DESTINATION lib/JANA/plugins) + + add_test(NAME jana-example-rootdatamodel-tests + COMMAND jana -Pplugins=RootDatamodelExample -Pjana:nevents=10) - file(GLOB my_headers "*.h*") - install(FILES ${my_headers} DESTINATION include/RootDatamodelExample) + 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 dd2a806a0..042ed265c 100644 --- a/src/examples/StreamingExample/CMakeLists.txt +++ b/src/examples/StreamingExample/CMakeLists.txt @@ -1,22 +1,18 @@ -# JExample 7 plugin - -set(StreamingExample_SOURCES SHARED - ZmqMain.cc - ZmqTransport.h - ReadoutMessageAuto.h - AHit.h - AHitAnomalyDetector.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 plugins) + + add_jana_plugin(StreamingExample) + 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") endif() 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 13b886b0c..e3bc209b4 100644 --- a/src/examples/TimesliceExample/CMakeLists.txt +++ b/src/examples/TimesliceExample/CMakeLists.txt @@ -1,17 +1,19 @@ if (USE_PODIO) - set (TimesliceExample_SOURCES - TimesliceExample.cc - CollectionTabulators.cc - ) - 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) + add_jana_plugin(TimesliceExample) + + target_link_libraries(TimesliceExample PUBLIC PodioExampleDatamodel PodioExampleDatamodelDict podio::podioRootIO) + + add_test(NAME jana-example-timeslices-simple-tests + COMMAND ${CMAKE_INSTALL_PREFIX}/bin/jana -Pplugins=TimesliceExample -Pjana:nevents=10 events.root) + + add_test(NAME jana-example-timeslices-complex-tests + COMMAND ${CMAKE_INSTALL_PREFIX}/bin/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 7e146f4d5..93c115f98 100644 --- a/src/examples/Tutorial/CMakeLists.txt +++ b/src/examples/Tutorial/CMakeLists.txt @@ -1,20 +1,9 @@ -set (Tutorial_PLUGIN_SOURCES - Tutorial.cc - TutorialProcessor.cc - TutorialProcessor.h - RandomSource.cc - RandomSource.h - Hit.h - Cluster.h - SimpleClusterFactory.cc - SimpleClusterFactory.h - ) +add_jana_plugin(Tutorial) -add_library(Tutorial_plugin SHARED ${Tutorial_PLUGIN_SOURCES}) +add_test(NAME jana-example-tutorial-tests + COMMAND jana -Pplugins=Tutorial) -target_link_libraries(Tutorial_plugin jana2) -set_target_properties(Tutorial_plugin PROPERTIES PREFIX "" OUTPUT_NAME "Tutorial" SUFFIX ".so") -install(TARGETS Tutorial_plugin DESTINATION plugins) +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 410efbc2b..a48488a53 100644 --- a/src/examples/UnitTestingExample/CMakeLists.txt +++ b/src/examples/UnitTestingExample/CMakeLists.txt @@ -1,13 +1,4 @@ -set (UnitTestingExample_SOURCES - SimpleClusterFactoryTests.cc - ) +add_jana_test(jana-example-unit-tests) +target_link_libraries(jana-example-unit-tests PUBLIC Tutorial) -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) -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/libraries/JANA/CMakeLists.txt b/src/libraries/JANA/CMakeLists.txt index 3909bc6c7..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) @@ -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*") 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"); } 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) { diff --git a/src/plugins/JTest/CMakeLists.txt b/src/plugins/JTest/CMakeLists.txt index 00362d81b..069998b5a 100644 --- a/src/plugins/JTest/CMakeLists.txt +++ b/src/plugins/JTest/CMakeLists.txt @@ -1,18 +1,8 @@ -add_library(jtest SHARED - JTestMain.cc - JTestDataObjects.h - JTestParser.h - JTestDisentangler.h - JTestTracker.h - JTestPlotter.h - JTestCalibrationService.h - ) -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) - -file(GLOB my_headers "*.h*") -install(FILES ${my_headers} DESTINATION include/JTest) +add_jana_plugin(JTest) + +add_test(NAME jana-plugin-jtest-tests + COMMAND jana -Pplugins=JTest -Pjana:nevents=20) + + 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 68da47396..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 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 4de206361..000000000 --- a/src/plugins/janacontrol/tests/CMakeLists.txt +++ /dev/null @@ -1,24 +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 ${JANA_LIBRARY}) -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/janadot/CMakeLists.txt b/src/plugins/janadot/CMakeLists.txt index 8863514dc..526627eca 100644 --- a/src/plugins/janadot/CMakeLists.txt +++ b/src/plugins/janadot/CMakeLists.txt @@ -1,9 +1,11 @@ -add_library(janadot SHARED JEventProcessorJANADOT.cc) +add_jana_plugin(janadot) + 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) +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! -file(GLOB my_headers "*.h*") -install(FILES ${my_headers} DESTINATION include/janadot) diff --git a/src/plugins/janarate/CMakeLists.txt b/src/plugins/janarate/CMakeLists.txt index 8096965f8..813bed96b 100644 --- a/src/plugins/janarate/CMakeLists.txt +++ b/src/plugins/janarate/CMakeLists.txt @@ -1,14 +1,8 @@ if (${USE_ROOT}) - add_library(janarate SHARED JEventProcessorJANARATE.cc) - 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) - - file(GLOB my_headers "*.h*") - install(FILES ${my_headers} DESTINATION include/janarate) + + add_jana_plugin(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..5a1c5943a 100644 --- a/src/plugins/janaview/CMakeLists.txt +++ b/src/plugins/janaview/CMakeLists.txt @@ -1,31 +1,22 @@ 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 - ) - - 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 plugins) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjv_mainframe_rdict.pcm DESTINATION plugins) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjv_mainframe.rootmap DESTINATION plugins) - - file(GLOB my_headers "*.h*") - install(FILES ${my_headers} DESTINATION include/janaview) + + file(GLOB JANAVIEW_HEADERS "*.h*") + + add_jana_plugin(janaview + SOURCES JEventProcessor_janaview.cc jv_mainframe.cc G__jv_mainframe.cxx + PUBLIC_HEADER ${JANAVIEW_HEADERS} + ) + + 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) 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 37c784e8a..d74e52382 100644 --- a/src/plugins/regressiontest/CMakeLists.txt +++ b/src/plugins/regressiontest/CMakeLists.txt @@ -1,9 +1,6 @@ -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) +add_jana_plugin(regressiontest + SOURCES JEventProcessor_regressiontest.cc + PUBLIC_HEADER JEventProcessor_regressiontest.h) + -file(GLOB my_headers "*.h*") -install(FILES ${my_headers} DESTINATION include/regressiontest) diff --git a/src/programs/perf_tests/CMakeLists.txt b/src/programs/perf_tests/CMakeLists.txt index 8efa6c964..d12240f1f 100644 --- a/src/programs/perf_tests/CMakeLists.txt +++ b/src/programs/perf_tests/CMakeLists.txt @@ -1,23 +1,14 @@ -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) +set_tests_properties(jana-perf-tests PROPERTIES DISABLED TRUE) 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/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/CMakeLists.txt b/src/programs/unit_tests/CMakeLists.txt index 22532dd17..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) +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) -install(FILES ../../external/catch.hpp DESTINATION include/external) + 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 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)