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) 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")