Skip to content

Commit

Permalink
Merge pull request #364 from JeffersonLab/nbrei_jsro_improvements
Browse files Browse the repository at this point in the history
Make CMake helper macros available to external projects
  • Loading branch information
nathanwbrei authored Sep 18, 2024
2 parents cd48b50 + 15fa877 commit 01a1ea7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmake/AddJanaPlugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
macro(add_jana_plugin plugin_name)

# Parse remaining arguments
set(options)
set(options LINK_SHARED)
set(oneValueArgs EXPORT)
set(multiValueArgs SOURCES PUBLIC_HEADER TESTS)

cmake_parse_arguments(PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if (LINK_SHARED)
set(PLUGIN_JANA_LIB jana2_shared_lib)
else()
set(PLUGIN_JANA_LIB jana2_static_lib)
endif()

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/*")
Expand Down Expand Up @@ -64,7 +70,7 @@ macro(add_jana_plugin plugin_name)
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CMAKE_INSTALL_PREFIX}/lib/${INSTALL_NAMESPACE}/plugins"
)

target_link_libraries(${plugin_name} PUBLIC "${JANA_NAMESPACE}jana2_static_lib")
target_link_libraries(${plugin_name} PUBLIC "${JANA_NAMESPACE}${PLUGIN_JANA_LIB}")

# Handle public headers
if (PLUGIN_PUBLIC_HEADER)
Expand Down
5 changes: 5 additions & 0 deletions cmake/JANAConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ set(JANA_INCLUDE_DIR ${JANA_INCLUDE_DIRS})
set(JANA_LIBRARY ${JANA_LIBRARIES})
set(JANA_LIB ${JANA_LIBRARIES})

# Include JANA cmake helper macros
include("${CMAKE_CURRENT_LIST_DIR}/AddJanaPlugin.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/AddJanaLibrary.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/AddJanaTest.cmake")


4 changes: 4 additions & 0 deletions cmake/MakeConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/JANAConfigVersion.cmake"
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddJanaPlugin.cmake"
DESTINATION "lib/JANA/cmake")

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddJanaLibrary.cmake"
DESTINATION "lib/JANA/cmake")

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddJanaTest.cmake"
DESTINATION "lib/JANA/cmake")

0 comments on commit 01a1ea7

Please sign in to comment.