Skip to content

Commit

Permalink
Merge pull request #330 from JeffersonLab/nbrei_small_improvements
Browse files Browse the repository at this point in the history
Build system improvements
  • Loading branch information
nathanwbrei committed Aug 9, 2024
2 parents afa596e + d095d48 commit 74a7900
Show file tree
Hide file tree
Showing 53 changed files with 628 additions and 563 deletions.
57 changes: 27 additions & 30 deletions .github/workflows/ccpp-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/ccpp-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 23 additions & 5 deletions .github/workflows/eicshell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 \
Expand All @@ -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
Expand Down Expand Up @@ -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
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ Makefile
/bin/
/include/
/lib/
/plugins/

# Doxygen generated files
/docs/doxygen_build/*
Expand All @@ -64,9 +63,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/
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -195,26 +195,31 @@ message(STATUS "-----------------------")
#---------

include_directories(src/libraries) # So that everyone can find the JANA header files
include_directories(src/external) # So that everyone can find our vendorized header-old libraries
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src/libraries) # So that everyone can find JVersion.h

# This is needed on macos to allow plugins to link without resolving all JANA symbols until runtime
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
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)
103 changes: 103 additions & 0 deletions cmake/AddJanaPlugin.cmake
Original file line number Diff line number Diff line change
@@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/${INSTALL_NAMESPACE}/plugins/${plugin_name}>
)
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()


27 changes: 27 additions & 0 deletions cmake/AddJanaTest.cmake
Original file line number Diff line number Diff line change
@@ -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()


File renamed without changes.
Loading

0 comments on commit 74a7900

Please sign in to comment.