Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CMake helper macros available to external projects #364

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")

Loading