From a203b11a35bc3827752b477ef8878872dbe35c37 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Mon, 9 Sep 2024 13:26:40 -0400 Subject: [PATCH 1/2] Automatically include all JANA helper macros when including JANA project --- cmake/JANAConfig.cmake.in | 5 +++++ cmake/MakeConfig.cmake | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/cmake/JANAConfig.cmake.in b/cmake/JANAConfig.cmake.in index e1d395366..d62492012 100644 --- a/cmake/JANAConfig.cmake.in +++ b/cmake/JANAConfig.cmake.in @@ -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") + diff --git a/cmake/MakeConfig.cmake b/cmake/MakeConfig.cmake index 8fafad0de..aba0927c9 100644 --- a/cmake/MakeConfig.cmake +++ b/cmake/MakeConfig.cmake @@ -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") From 15fa877241776267f8c7ec6aad5178357be27b95 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Mon, 9 Sep 2024 13:27:10 -0400 Subject: [PATCH 2/2] add_jana_plugin supports linking to shared libJANA --- cmake/AddJanaPlugin.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/AddJanaPlugin.cmake b/cmake/AddJanaPlugin.cmake index c302f54e5..36705f38d 100644 --- a/cmake/AddJanaPlugin.cmake +++ b/cmake/AddJanaPlugin.cmake @@ -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/*") @@ -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)