diff OrthancServer/CMakeLists.txt @ 5357:fddb5d8d0021

Prevent the leak of the full path of the source files in the binaries
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Jul 2023 17:04:31 +0200
parents 7cb1b851f5c8
children 48b8dae6dc77
line wrap: on
line diff
--- a/OrthancServer/CMakeLists.txt	Tue Jul 04 18:39:52 2023 +0200
+++ b/OrthancServer/CMakeLists.txt	Thu Jul 06 17:04:31 2023 +0200
@@ -379,6 +379,8 @@
   ${AUTOGENERATED_SOURCES}
   )
 
+DefineSourceBasenameForTarget(CoreLibrary)
+
 add_dependencies(CoreLibrary AutogeneratedTarget)
 
 if (LIBICU_LIBRARIES)
@@ -394,8 +396,11 @@
   add_custom_command(
     COMMAND
     ${PROTOC_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Plugins/Include/orthanc/OrthancDatabasePlugin.proto --cpp_out=${AUTOGENERATED_DIR} -I${CMAKE_SOURCE_DIR}/Plugins/Include/orthanc
+    COMMAND
+    ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Resources/PreventProtobufDirectoryLeaks.py ${AUTOGENERATED_DIR}/OrthancDatabasePlugin.pb.cc
     DEPENDS
     ProtobufCompiler
+    ${CMAKE_SOURCE_DIR}/Resources/PreventProtobufDirectoryLeaks.py
     ${CMAKE_SOURCE_DIR}/Plugins/Include/orthanc/OrthancDatabasePlugin.proto
     OUTPUT
     ${AUTOGENERATED_DIR}/OrthancDatabasePlugin.pb.cc
@@ -420,6 +425,8 @@
   ${ORTHANC_SERVER_SOURCES}
   )
 
+DefineSourceBasenameForTarget(ServerLibrary)
+
 # Ensure autogenerated code is built before building ServerLibrary
 add_dependencies(ServerLibrary CoreLibrary OrthancDatabaseProtobuf)
 
@@ -428,6 +435,8 @@
   ${ORTHANC_RESOURCES}
   )
 
+DefineSourceBasenameForTarget(Orthanc)
+
 target_link_libraries(Orthanc ServerLibrary CoreLibrary ${DCMTK_LIBRARIES})
 
 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
@@ -458,6 +467,8 @@
   ${BOOST_EXTENDED_SOURCES}
   )
 
+DefineSourceBasenameForTarget(UnitTests)
+
 target_link_libraries(UnitTests
   ServerLibrary
   CoreLibrary
@@ -506,6 +517,8 @@
     ${PLUGINS_DEPENDENCIES_SOURCES}
     )
 
+  DefineSourceBasenameForTarget(PluginsDependencies)
+
   # Add the "-fPIC" option as this static library must be embedded
   # inside shared libraries (important on UNIX)
   set_target_properties(
@@ -546,6 +559,8 @@
     ${SERVE_FOLDERS_RESOURCES}
     )
 
+  DefineSourceBasenameForTarget(ServeFolders)
+
   target_link_libraries(ServeFolders PluginsDependencies)
 
   set_target_properties(
@@ -594,6 +609,8 @@
     ${MODALITY_WORKLISTS_RESOURCES}
     )
 
+  DefineSourceBasenameForTarget(ModalityWorklists)
+
   target_link_libraries(ModalityWorklists PluginsDependencies)
 
   set_target_properties(
@@ -655,7 +672,9 @@
     ${CMAKE_SOURCE_DIR}/Plugins/Samples/ConnectivityChecks/OrthancFrameworkDependencies.cpp
     ${CONNECTIVITY_CHECKS_RESOURCES}
     )
-  
+
+  DefineSourceBasenameForTarget(ConnectivityChecks)
+
   target_link_libraries(ConnectivityChecks PluginsDependencies)
   
   set_target_properties(
@@ -708,6 +727,8 @@
     ${DELAYED_DELETION_RESOURCES}
     )
   
+  DefineSourceBasenameForTarget(DelayedDeletion)
+
   target_link_libraries(DelayedDeletion PluginsDependencies)
   
   set_target_properties(
@@ -755,6 +776,8 @@
     ${HOUSEKEEPER_RESOURCES}
     )
   
+  DefineSourceBasenameForTarget(Housekeeper)
+
   target_link_libraries(Housekeeper PluginsDependencies)
   
   set_target_properties(
@@ -820,6 +843,8 @@
     ${MULTITENANT_DICOM_RESOURCES}
     )
   
+  DefineSourceBasenameForTarget(MultitenantDicom)
+
   target_link_libraries(MultitenantDicom PluginsDependencies ${DCMTK_LIBRARIES})
   
   set_target_properties(
@@ -865,6 +890,7 @@
   endif()
 
   add_executable(OrthancRecoverCompressedFile ${RECOVER_COMPRESSED_SOURCES})
+  DefineSourceBasenameForTarget(OrthancRecoverCompressedFile)
 
   target_link_libraries(OrthancRecoverCompressedFile CoreLibrary)