@@ -90,16 +90,24 @@ macro(DCMTK_ADD_LIBRARY LIBRARY)
9090        set_target_properties (${LIBRARY}${DCMTK_LIBRARY_SUFFIX}  PROPERTIES COMPILE_DEFINITIONS  "${LIBRARY} _EXPORTS" )
9191    endif ()
9292
93+     get_filename_component (DCMTK_ADD_LIBRARY_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR} "  PATH )
94+     target_include_directories (${LIBRARY}${DCMTK_LIBRARY_SUFFIX}  PUBLIC 
95+       $<BUILD_INTERFACE:${DCMTK_ADD_LIBRARY_PARENT_DIR} /include >
96+       $<INSTALL_INTERFACE:include >
97+     )
98+ 
9399    if (NOT  BUILD_SINGLE_SHARED_LIBRARY)
94100        # Remember export target for writing it to build tree later 
95101        set_property (GLOBAL  APPEND  PROPERTY DCMTK_LIBRARY_TARGETS ${LIBRARY}${DCMTK_LIBRARY_SUFFIX} )
102+         target_link_libraries (DCMTK INTERFACE  ${LIBRARY}${DCMTK_LIBRARY_SUFFIX} )
96103
97104        # Declare installation files 
98105        install (TARGETS ${LIBRARY}${DCMTK_LIBRARY_SUFFIX} 
99106          EXPORT  DCMTKTargets
100107          RUNTIME DESTINATION  "${CMAKE_INSTALL_BINDIR} "  COMPONENT  bin
101108          LIBRARY DESTINATION  "${CMAKE_INSTALL_LIBDIR} "  COMPONENT  shlib
102-           ARCHIVE DESTINATION  "${CMAKE_INSTALL_LIBDIR} "  COMPONENT  lib)
109+           ARCHIVE DESTINATION  "${CMAKE_INSTALL_LIBDIR} "  COMPONENT  lib
110+         )
103111    endif ()
104112endmacro ()
105113
@@ -186,3 +194,52 @@ function(DCMTK_UPPER_BOUND LIST COMP VAR)
186194  endforeach ()
187195  set ("${VAR} "  ${N}  PARENT_SCOPE)
188196endfunction ()
197+ 
198+ function (DCMTK_CREATE_INSTALL_EXPORTS)
199+     # DCMTKTargets.cmake will contain list of executables and libraries produced 
200+     # DCMTKConfigVersion.cmake will contain DCMTK version information 
201+     # DCMTKConfig.cmake will contain options used to build DCMTK 
202+     # 
203+     # All three files are created within the build tree's main directory (handled in 
204+     # CMake/GenerateCMakeExports.cmake, and are installed to locations (OS-specific 
205+     # under the main install dir (handled directly below). 
206+ 
207+     # Only create fully-fledged CMake export files if we have the related commands 
208+     include ("${DCMTK_MACROS_DIR} /CheckCMakeCommandExists.cmake" )
209+     include (CMakePackageConfigHelpers OPTIONAL )
210+     CHECK_CMAKE_COMMAND_EXISTS("CONFIGURE_PACKAGE_CONFIG_FILE" )
211+     CHECK_CMAKE_COMMAND_EXISTS("WRITE_BASIC_PACKAGE_VERSION_FILE" )
212+ 
213+     if (HAVE_CONFIGURE_PACKAGE_CONFIG_FILE AND  HAVE_WRITE_BASIC_PACKAGE_VERSION_FILE)
214+ 
215+       # Create and configure CMake export files 
216+       include ("${DCMTK_MACROS_DIR} /GenerateCMakeExports.cmake" )
217+ 
218+       # ${DCMTK_INSTALL_CONFIG} and ${DCMTK_CONFIG_VERSION} are 
219+       # defined within CMake/GenerateCMakeExports.cmake. 
220+       # Install DCMTKTargets.cmake to install tree 
221+       install (EXPORT DCMTKTargets FILE DCMTKTargets.cmake NAMESPACE DCMTK::
222+               DESTINATION  "${DCMTK_INSTALL_CMKDIR} "  COMPONENT  cmake)
223+ 
224+       # Install DCMTKConfig.cmake and DCMTKConfigVersion.cmake 
225+       install (FILES  "${DCMTK_INSTALL_CONFIG} "  "${DCMTK_CONFIG_VERSION} " 
226+               DESTINATION  "${DCMTK_INSTALL_CMKDIR} "  COMPONENT  cmake)
227+ 
228+     else ()
229+ 
230+       # Warning that we use old "configure_file" command 
231+       message (STATUS  "Warning: Using old configure_file() mechanism to produce DCMTKConfig.cmake" )
232+ 
233+       # Actually configure file 
234+       configure_file ("${DCMTK_MACROS_DIR} /DCMTKConfig.old_cmake.in" 
235+                      "${DCMTK_BINARY_DIR} /DCMTKConfig.cmake"  @ONLY)
236+ 
237+       # Install DCMTKConfig.cmake and DCMTKConfigVersion.cmake 
238+       install (FILES  "${DCMTK_BINARY_DIR} /DCMTKConfig.cmake"  "${DCMTK_BINARY_DIR} /DCMTKConfigVersion.cmake" 
239+               DESTINATION  "${DCMTK_INSTALL_CMKDIR} " 
240+               COMPONENT  cmake)
241+ 
242+     endif ()
243+ endfunction ()
244+ 
245+ set (DCMTK_MACROS_DIR "${CMAKE_CURRENT_LIST_DIR} "  CACHE  INTERNAL  "" )
0 commit comments