From b178c8fa441ee7ddfa2395e5414c76a2cf363e14 Mon Sep 17 00:00:00 2001
From: Frank Gaede <frank.gaede@desy.de>
Date: Tue, 14 May 2013 10:55:49 +0000
Subject: [PATCH]  - add example libraries and rootmap files to install target

---
 CMakeLists.txt                      |  1 +
 DDCore/CMakeLists.txt               |  3 ++-
 DDExamples/AlignDet/CMakeLists.txt  |  9 +++++++++
 DDExamples/CLICSiD/CMakeLists.txt   |  9 +++++++++
 DDExamples/ILDExDet/CMakeLists.txt  |  9 +++++++++
 DDExamples/ILDExSimu/CMakeLists.txt |  1 -
 DDG4/CMakeLists.txt                 | 13 +++++++++++++
 cmake/DD4hep.cmake                  | 11 ++++++++++-
 8 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6447fa650..0707d3605 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,3 +66,4 @@ endif()
 configure_file(cmake/thisdd4hep.csh thisdd4hep.csh @ONLY)
 configure_file(cmake/thisdd4hep.sh  thisdd4hep.sh @ONLY)
 
+
diff --git a/DDCore/CMakeLists.txt b/DDCore/CMakeLists.txt
index 9bb72f0c7..7148aa176 100644
--- a/DDCore/CMakeLists.txt
+++ b/DDCore/CMakeLists.txt
@@ -27,7 +27,7 @@ add_library(DD4hepPlugins SHARED ${plugin_sources})
 target_link_libraries(DD4hepPlugins ${ROOT_LIBRARIES} ${XML_LIBRARIES} DD4hepCore Geom Reflex ${libraries})
 #---Rootmap generation--------------------------------------------------------------
 dd4hep_generate_rootmap(DD4hepPlugins)
-
+#dd4hep_install_library(DD4hepPlugins)
 
 
 #--- install target-------------------------------------
@@ -40,5 +40,6 @@ install(TARGETS DD4hepCore DD4hepPlugins
   RUNTIME DESTINATION bin
   LIBRARY DESTINATION lib
   )
+
 # to do: add corresponding uninstall...
 #-------------------------------------------------------
\ No newline at end of file
diff --git a/DDExamples/AlignDet/CMakeLists.txt b/DDExamples/AlignDet/CMakeLists.txt
index 0ba9efc6f..dc7b5ad4b 100644
--- a/DDExamples/AlignDet/CMakeLists.txt
+++ b/DDExamples/AlignDet/CMakeLists.txt
@@ -11,3 +11,12 @@ file(GLOB sources src/*.cpp)
 add_library(Aligntest SHARED ${sources})
 target_link_libraries(Aligntest DD4hepCore ${ROOT_LIBRARIES} Rint Reflex)
 dd4hep_generate_rootmap(Aligntest)
+
+#--- install target-------------------------------------
+
+install(TARGETS Aligntest
+  RUNTIME DESTINATION bin
+  LIBRARY DESTINATION lib
+  )
+# to do: add corresponding uninstall...
+#-------------------------------------------------------
\ No newline at end of file
diff --git a/DDExamples/CLICSiD/CMakeLists.txt b/DDExamples/CLICSiD/CMakeLists.txt
index 7095c6a73..1341cc89b 100644
--- a/DDExamples/CLICSiD/CMakeLists.txt
+++ b/DDExamples/CLICSiD/CMakeLists.txt
@@ -10,3 +10,12 @@ include(DD4hep_XML_setup)
 add_library(CLICSiD SHARED ${sources})
 target_link_libraries(CLICSiD DD4hepCore ${ROOT_LIBRARIES})
 dd4hep_generate_rootmap(CLICSiD)
+
+#--- install target-------------------------------------
+
+install(TARGETS CLICSiD
+  RUNTIME DESTINATION bin
+  LIBRARY DESTINATION lib
+  )
+# to do: add corresponding uninstall...
+#-------------------------------------------------------
\ No newline at end of file
diff --git a/DDExamples/ILDExDet/CMakeLists.txt b/DDExamples/ILDExDet/CMakeLists.txt
index e0e2899b6..b23220274 100644
--- a/DDExamples/ILDExDet/CMakeLists.txt
+++ b/DDExamples/ILDExDet/CMakeLists.txt
@@ -62,3 +62,12 @@ add_library(ILDEx SHARED ${sources})
 target_link_libraries(ILDEx DD4hepCore  ${LCIO_LIBRARIES})
 #---Rootmap generation--------------------------------------------------------------
 dd4hep_generate_rootmap(ILDEx)
+
+#--- install target-------------------------------------
+
+install(TARGETS ILDEx
+  RUNTIME DESTINATION bin
+  LIBRARY DESTINATION lib
+  )
+# to do: add corresponding uninstall...
+#-------------------------------------------------------
\ No newline at end of file
diff --git a/DDExamples/ILDExSimu/CMakeLists.txt b/DDExamples/ILDExSimu/CMakeLists.txt
index 8820b078b..05836d38d 100644
--- a/DDExamples/ILDExSimu/CMakeLists.txt
+++ b/DDExamples/ILDExSimu/CMakeLists.txt
@@ -22,4 +22,3 @@ include_directories( ${CMAKE_SOURCE_DIR}/DDCore/include
 file(GLOB sources src/*.cpp)
 add_executable(ILDExSimu ILDExSimu.cpp ${sources})
 target_link_libraries(ILDExSimu DD4hepCore DD4hepG4 ILDEx ${Geant4_LIBRARIES} ${LCIO_LIBRARIES})
-
diff --git a/DDG4/CMakeLists.txt b/DDG4/CMakeLists.txt
index 35ea94cac..47c2f2722 100644
--- a/DDG4/CMakeLists.txt
+++ b/DDG4/CMakeLists.txt
@@ -23,3 +23,16 @@ endif()
 add_library(DD4hepG4 SHARED ${sources})
 target_link_libraries(DD4hepG4 DD4hepCore ${ROOT_LIBRARIES} Reflex ${Geant4_LIBRARIES})
 dd4hep_generate_rootmap(DD4hepG4)
+
+#--- install target-------------------------------------
+
+install(DIRECTORY include/DDG4
+  DESTINATION include
+  PATTERN ".svn" EXCLUDE )
+
+install(TARGETS DD4hepG4
+  RUNTIME DESTINATION bin
+  LIBRARY DESTINATION lib
+  )
+# to do: add corresponding uninstall...
+#-------------------------------------------------------
\ No newline at end of file
diff --git a/cmake/DD4hep.cmake b/cmake/DD4hep.cmake
index d013076ba..dec0e2c55 100644
--- a/cmake/DD4hep.cmake
+++ b/cmake/DD4hep.cmake
@@ -13,6 +13,11 @@ function(dd4hep_generate_rootmap library)
 		             ${ROOT_genmap_CMD} -i ${libname} -o ${rootmapfile}
                      DEPENDS ${library})
   add_custom_target(${library}Rootmap ALL DEPENDS ${rootmapfile})
+
+  install(FILES ${LIBRARY_OUTPUT_PATH}/${rootmapfile}
+    DESTINATION lib
+    )
+
   # Notify the project level target
   #gaudi_merge_files_append(Rootmap ${library}Rootmap ${CMAKE_CURRENT_BINARY_DIR}/${library}.rootmap)
 endfunction()
@@ -25,7 +30,11 @@ endfunction()
 #---------------------------------------------------------------------------------------------------
 function(dd4hep_install_library library)
   set(installfile ${library}.install)
-  set(libname ${CMAKE_SHARED_MODULE_PREFIX}${library}${CMAKE_SHARED_MODULE_SUFFIX})
+
+  set(rootmapfile ${CMAKE_SHARED_MODULE_PREFIX}${library}.rootmap)
+
+   set(libname ${CMAKE_SHARED_MODULE_PREFIX}${library}${CMAKE_SHARED_MODULE_SUFFIX})
+
   add_custom_command(OUTPUT ${rootmapfile}
                      COMMAND echo
 		             ${library} ${LIBRARY_OUTPUT_DIR}
-- 
GitLab