changeset 3233:47fbb0467a62

Build a static library to share code between the plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 15 Feb 2019 10:26:32 +0100
parents 01a5b2530b68
children 6055bea6a6dc ed6dc4ecabcb
files CMakeLists.txt
diffstat 1 files changed, 27 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Fri Feb 15 09:27:10 2019 +0100
+++ b/CMakeLists.txt	Fri Feb 15 10:26:32 2019 +0100
@@ -338,6 +338,29 @@
 
 
 #####################################################################
+## Build a static library to share code between the plugins
+#####################################################################
+
+if (ENABLE_PLUGINS AND
+    (BUILD_SERVE_FOLDERS OR BUILD_MODALITY_WORKLISTS))
+  add_library(ThirdPartyPlugins STATIC
+    ${BOOST_SOURCES}
+    ${JSONCPP_SOURCES}
+    ${LIBICONV_SOURCES}
+    ${LIBICU_SOURCES}
+    Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
+    )
+
+  # Add the "-fPIC" option as this static library must be embedded
+  # inside shared libraries (important on UNIX)
+  set_property(
+    TARGET ThirdPartyPlugins
+    PROPERTY POSITION_INDEPENDENT_CODE ON
+    )
+endif()
+
+
+#####################################################################
 ## Build the "ServeFolders" plugin
 #####################################################################
 
@@ -359,14 +382,12 @@
   endif()  
 
   add_library(ServeFolders SHARED 
-    ${BOOST_SOURCES}
-    ${JSONCPP_SOURCES}
-    ${LIBICONV_SOURCES}
     Plugins/Samples/ServeFolders/Plugin.cpp
-    Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
     ${SERVE_FOLDERS_RESOURCES}
     )
 
+  target_link_libraries(ServeFolders ThirdPartyPlugins)
+
   set_target_properties(
     ServeFolders PROPERTIES 
     VERSION ${ORTHANC_VERSION} 
@@ -404,14 +425,12 @@
   endif()
 
   add_library(ModalityWorklists SHARED 
-    ${BOOST_SOURCES}
-    ${JSONCPP_SOURCES}
-    ${LIBICONV_SOURCES}
-    Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
     Plugins/Samples/ModalityWorklists/Plugin.cpp
     ${MODALITY_WORKLISTS_RESOURCES}
     )
 
+  target_link_libraries(ModalityWorklists ThirdPartyPlugins)
+
   set_target_properties(
     ModalityWorklists PROPERTIES 
     VERSION ${ORTHANC_VERSION}