From 31c13d83f7deb99140b824fd2e173d571288f256 Mon Sep 17 00:00:00 2001
From: Florian Uhlig <f.uhlig@gsi.de>
Date: Tue, 22 Feb 2022 18:25:03 +0100
Subject: [PATCH] Install MQ startup scripts

Create MQ startup scripts to be installed already at the configuration stage
and store the in the build tree. The difference between the scripts used in
the build tree and the scripts finally installed are the hardcoded directory
information inside. In the scripts to be used inside the build directory this
links to the source and the build directories whereas it links to the
installation directory in case of the scripts which are installed.
Copy the scripts during installation to the correct directory.
Install the MQ executables in the same directory structure as in the build
directory.
---
 MQ/histoServer/CMakeLists.txt |  7 ++++--
 MQ/hitbuilder/CMakeLists.txt  | 22 ++++++++++++++++++-
 MQ/mcbm/CMakeLists.txt        | 34 +++++++++++++++++++++++------
 MQ/monitor/CMakeLists.txt     | 40 ++++++++++++++++++++++++++++++-----
 MQ/parmq/CMakeLists.txt       |  3 +++
 MQ/sink/CMakeLists.txt        | 25 ++++++++++++++++++++++
 MQ/source/CMakeLists.txt      | 28 ++++++++++++++++++++++++
 MQ/unpacker/CMakeLists.txt    | 29 +++++++++++++++++++++++++
 8 files changed, 174 insertions(+), 14 deletions(-)

diff --git a/MQ/histoServer/CMakeLists.txt b/MQ/histoServer/CMakeLists.txt
index a338e1bdab..d6c772e212 100644
--- a/MQ/histoServer/CMakeLists.txt
+++ b/MQ/histoServer/CMakeLists.txt
@@ -62,6 +62,11 @@ set(DEPENDENCIES_ALL
   ${BOOST_LIBS}
 )
 
+# Set the install path within the build directory
+set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/MQ/histogramServer")
+# Set the install path within the installation directory
+set(BIN_DESTINATION bin/MQ/histogramServer)
+
 set(EXE_NAME HistoServer)
 set(SRCS CbmHistoServer.cxx runCbmHistoServer.cxx)
 set(DEPENDENCIES
@@ -76,8 +81,6 @@ set(DEPENDENCIES
 )
 GENERATE_EXECUTABLE()
 
-set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/MQ/histogramServer")
-
 set(EXE_NAME MqHistoServer)
 set(SRCS CbmMqHistoServer.cxx runCbmMqHistoServer.cxx)
 set(DEPENDENCIES
diff --git a/MQ/hitbuilder/CMakeLists.txt b/MQ/hitbuilder/CMakeLists.txt
index ba1bdaecb0..44fcefaedf 100644
--- a/MQ/hitbuilder/CMakeLists.txt
+++ b/MQ/hitbuilder/CMakeLists.txt
@@ -1,5 +1,4 @@
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQSamplerUnpackerParserverHitBuilder.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQSamplerUnpackerParserverHitBuilder.sh)
-
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQ_Mcbm.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQ_Mcbm.sh)
 
 set(INCLUDE_DIRECTORIES
@@ -38,7 +37,10 @@ set(LINK_DIRECTORIES
 
 link_directories(${LINK_DIRECTORIES})
 
+# Set the install path within the build directory
 set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/MQ/hitbuilder")
+# Set the install path within the installation directory
+set(BIN_DESTINATION bin/MQ/hitbuilder)
 
 Set(BOOST_LIBS
   ${Boost_SYSTEM_LIBRARY}
@@ -86,3 +88,21 @@ set(DEPENDENCIES
 )
 GENERATE_EXECUTABLE()
 
+# Set the correct variables for the installation
+set(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share/cbmroot)
+
+set(MY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(CMAKE_CURRENT_SOURCE_DIR ${VMCWORKDIR}/input)
+
+set(TMPDIR "${CMAKE_BINARY_DIR}")
+set(CMAKE_BINARY_DIR ${CMAKE_INSTALL_PREFIX})
+
+# Configure file for installation directory
+configure_file(${MY_SOURCE_DIR}/startMQSamplerUnpackerParserverHitBuilder.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerUnpackerParserverHitBuilder.sh)
+configure_file(${MY_SOURCE_DIR}/startMQ_Mcbm.sh.in                      ${TMPDIR}/bin/MQ/topologies/install/startMQ_Mcbm.sh)
+
+install(PROGRAMS ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerUnpackerParserverHitBuilder.sh
+                 ${TMPDIR}/bin/MQ/topologies/install/startMQ_Mcbm.sh
+        DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/MQ/topologies
+       )
+
diff --git a/MQ/mcbm/CMakeLists.txt b/MQ/mcbm/CMakeLists.txt
index adf84ff5a7..5df7e0fb21 100644
--- a/MQ/mcbm/CMakeLists.txt
+++ b/MQ/mcbm/CMakeLists.txt
@@ -74,7 +74,10 @@ set(LINK_DIRECTORIES
 
 link_directories(${LINK_DIRECTORIES})
 
+# Set the install path within the build directory
 set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/MQ/mcbm")
+# Set the install path within the installation directory
+set(BIN_DESTINATION bin/MQ/mcbm)
 
 Set(BOOST_LIBS
   ${Boost_SYSTEM_LIBRARY}
@@ -115,7 +118,6 @@ set(DEPENDENCIES
   Hist
   RHTTP
 )
-#GENERATE_LIBRARY()
 GENERATE_EXECUTABLE()
 
 set(EXE_NAME McbmMonitorPulser)
@@ -136,7 +138,6 @@ set(DEPENDENCIES
   Hist
   RHTTP
 )
-#GENERATE_LIBRARY()
 GENERATE_EXECUTABLE()
 
 set(EXE_NAME BuildRawEvents)
@@ -163,7 +164,6 @@ set(DEPENDENCIES
   Hist
   RHTTP
 )
-#GENERATE_LIBRARY()
 GENERATE_EXECUTABLE()
 
 
@@ -185,7 +185,6 @@ set(DEPENDENCIES
   Hist
   RHTTP
 )
-#GENERATE_LIBRARY()
 GENERATE_EXECUTABLE()
 
 set(EXE_NAME McbmEventSink)
@@ -207,7 +206,6 @@ set(DEPENDENCIES
   Hist
   RHTTP
 )
-#GENERATE_LIBRARY()
 GENERATE_EXECUTABLE()
 
 
@@ -311,7 +309,6 @@ set(DEPENDENCIES
   Hist
   RHTTP
 )
-#GENERATE_LIBRARY()
 GENERATE_EXECUTABLE()
 
 if (${CMAKE_CXX_STANDARD} EQUAL 17)
@@ -337,3 +334,28 @@ if (${CMAKE_CXX_STANDARD} EQUAL 17)
   GENERATE_EXECUTABLE()
 endif()
 
+# Set the correct variables for the installation
+set(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share/cbmroot)
+
+set(MY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(CMAKE_CURRENT_SOURCE_DIR ${VMCWORKDIR}/input)
+
+set(TMPDIR "${CMAKE_BINARY_DIR}")
+set(CMAKE_BINARY_DIR ${CMAKE_INSTALL_PREFIX})
+
+# Configure file for installation directory
+configure_file(${MY_SOURCE_DIR}/startMQMcbmPulserMonitor2020.sh.in   ${TMPDIR}/bin/MQ/topologies/install/startMQMcbmPulserMonitor2020.sh)
+configure_file(${MY_SOURCE_DIR}/startMQMcbmEvtBuilderWin2020.sh.in   ${TMPDIR}/bin/MQ/topologies/install/startMQMcbmEvtBuilderWin2020.sh)
+configure_file(${MY_SOURCE_DIR}/startMQBuildRawEvents.sh.in          ${TMPDIR}/bin/MQ/topologies/install/startMQBuildRawEvents.sh)
+configure_file(${MY_SOURCE_DIR}/startBuildRawEvents2021.sh.in        ${TMPDIR}/bin/MQ/topologies/install/startBuildRawEvents2021.sh)
+configure_file(${MY_SOURCE_DIR}/startBuildRawEventsCosmics2021.sh.in ${TMPDIR}/bin/MQ/topologies/install/startBuildRawEventsCosmics2021.sh)
+configure_file(${MY_SOURCE_DIR}/startEventBuilder.sh.in              ${TMPDIR}/bin/MQ/topologies/startEventBuilder.sh)
+
+install(PROGRAMS ${TMPDIR}/bin/MQ/topologies/install/startMQMcbmPulserMonitor2020.sh
+                 ${TMPDIR}/bin/MQ/topologies/install/startMQMcbmEvtBuilderWin2020.sh
+                 ${TMPDIR}/bin/MQ/topologies/install/startMQBuildRawEvents.sh
+                 ${TMPDIR}/bin/MQ/topologies/install/startBuildRawEvents2021.sh
+                 ${TMPDIR}/bin/MQ/topologies/install/startBuildRawEventsCosmics2021.sh
+                 ${TMPDIR}/bin/MQ/topologies/install/startEventBuilder.sh
+        DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/MQ/topologies
+       )
diff --git a/MQ/monitor/CMakeLists.txt b/MQ/monitor/CMakeLists.txt
index dd39732bd3..43c45b98a2 100644
--- a/MQ/monitor/CMakeLists.txt
+++ b/MQ/monitor/CMakeLists.txt
@@ -47,7 +47,10 @@ set(LINK_DIRECTORIES
 
 link_directories(${LINK_DIRECTORIES})
 
+# Set the install path within the build directory
 set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/MQ/monitor")
+# Set the install path within the installation directory
+set(BIN_DESTINATION bin/MQ/monitor)
 
 Set(BOOST_LIBS
   ${Boost_SYSTEM_LIBRARY}
@@ -90,7 +93,6 @@ set(DEPENDENCIES
   Hist
   RHTTP
 )
-#GENERATE_LIBRARY()
 GENERATE_EXECUTABLE()
 
 set(EXE_NAME TofMonitorMcbm2018)
@@ -111,7 +113,6 @@ set(DEPENDENCIES
   Hist
   RHTTP
 )
-#GENERATE_LIBRARY()
 GENERATE_EXECUTABLE()
 
 set(EXE_NAME T0MonitorReqMcbm)
@@ -132,7 +133,6 @@ set(DEPENDENCIES
   Hist
   RHTTP
 )
-#GENERATE_LIBRARY()
 GENERATE_EXECUTABLE()
 
 set(EXE_NAME TofMonitorReqMcbm)
@@ -153,7 +153,6 @@ set(DEPENDENCIES
   Hist
   RHTTP
 )
-#GENERATE_LIBRARY()
 GENERATE_EXECUTABLE()
 
 set(EXE_NAME PsdMonitorMcbm2018)
@@ -174,6 +173,37 @@ set(DEPENDENCIES
   Hist
   RHTTP
 )
-#GENERATE_LIBRARY()
 GENERATE_EXECUTABLE()
 
+# Install scripts and input file
+if(EXISTS ${VMCWORKDIR}/input/tofget4_hd2018.tsa)
+  install(FILES ${VMCWORKDIR}/input/tofget4_hd2018.tsa
+          DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cbmroot/input
+         )
+endif()
+
+# Set the correct variables for the installation
+set(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share/cbmroot)
+
+set(MY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(CMAKE_CURRENT_SOURCE_DIR ${VMCWORKDIR}/input)
+
+set(TMPDIR "${CMAKE_BINARY_DIR}")
+set(CMAKE_BINARY_DIR ${CMAKE_INSTALL_PREFIX})
+
+# Configure file for installation directory
+configure_file(${MY_SOURCE_DIR}/startMQSamplerMonitor.sh.in        ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerMonitor.sh)
+configure_file(${MY_SOURCE_DIR}/startMQSamplerT0Monitor2020.sh.in  ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerT0Monitor2020.sh)
+configure_file(${MY_SOURCE_DIR}/startMQSamplerTofMonitor2020.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerTofMonitor2020.sh)
+configure_file(${MY_SOURCE_DIR}/startMQSamplerT0Monitor2021.sh.in  ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerT0Monitor2021.sh)
+configure_file(${MY_SOURCE_DIR}/startMQSamplerTofMonitor2021.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerTofMonitor2021.sh)
+configure_file(${MY_SOURCE_DIR}/startMQSamplerPsdMonitor2021.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerPsdMonitor2021.sh)
+
+install(PROGRAMS ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerMonitor.sh
+                 ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerT0Monitor2020.sh
+                 ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerTofMonitor2020.sh
+                 ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerT0Monitor2021.sh
+                 ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerTofMonitor2021.sh
+                 ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerPsdMonitor2021.sh
+        DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/MQ/topologies
+       )
diff --git a/MQ/parmq/CMakeLists.txt b/MQ/parmq/CMakeLists.txt
index 3f6c9f8988..299ca939e2 100644
--- a/MQ/parmq/CMakeLists.txt
+++ b/MQ/parmq/CMakeLists.txt
@@ -27,7 +27,10 @@ Set(LINK_DIRECTORIES
 
 Link_Directories(${LINK_DIRECTORIES})
 
+# Set the install path within the build directory
 set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/MQ/parmq")
+# Set the install path within the installation directory
+set(BIN_DESTINATION bin/MQ/parmq)
 
 Set(BOOST_LIBS
   ${Boost_SYSTEM_LIBRARY}
diff --git a/MQ/sink/CMakeLists.txt b/MQ/sink/CMakeLists.txt
index 0a4294d30f..731189d354 100644
--- a/MQ/sink/CMakeLists.txt
+++ b/MQ/sink/CMakeLists.txt
@@ -28,7 +28,10 @@ set(LINK_DIRECTORIES
 
 link_directories(${LINK_DIRECTORIES})
 
+# Set the install path within the build directory
 set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/MQ/sink")
+# Set the install path within the installation directory
+set(BIN_DESTINATION bin/MQ/sink)
 
 Set(BOOST_LIBS
   ${Boost_SYSTEM_LIBRARY}
@@ -71,3 +74,25 @@ set(DEPENDENCIES
 )
 GENERATE_EXECUTABLE()
 
+# Install scripts and input file
+if(EXISTS ${VMCWORKDIR}/input/tofget4_hd2018.tsa)
+  install(FILES ${VMCWORKDIR}/input/tofget4_hd2018.tsa
+          DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cbmroot/input
+         )
+endif()
+
+# Set the correct variables for the installation
+set(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share/cbmroot)
+
+set(MY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(CMAKE_CURRENT_SOURCE_DIR ${VMCWORKDIR}/input)
+
+set(TMPDIR "${CMAKE_BINARY_DIR}")
+set(CMAKE_BINARY_DIR ${CMAKE_INSTALL_PREFIX})
+
+# Configure file for installation directory
+configure_file(${MY_SOURCE_DIR}/startMQSamplerSink.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerSink.sh)
+
+install(PROGRAMS ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerSink.sh
+       DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/MQ/topologies
+       )
diff --git a/MQ/source/CMakeLists.txt b/MQ/source/CMakeLists.txt
index 9b7ee9f902..3b618ce19d 100644
--- a/MQ/source/CMakeLists.txt
+++ b/MQ/source/CMakeLists.txt
@@ -42,7 +42,10 @@ set(LINK_DIRECTORIES
 
 link_directories(${LINK_DIRECTORIES})
 
+# Set the install path within the build directory
 set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/MQ/source")
+# Set the install path within the installation directory
+set(BIN_DESTINATION bin/MQ/source)
 
 Set(BOOST_LIBS
   ${Boost_SYSTEM_LIBRARY}
@@ -190,3 +193,28 @@ set(DEPENDENCIES
   RIO
 )
 GENERATE_EXECUTABLE()
+
+# Install scripts and input file
+if(EXISTS ${VMCWORKDIR}/input/tofget4_hd2018.tsa)
+  install(FILES ${VMCWORKDIR}/input/tofget4_hd2018.tsa
+          DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cbmroot/input
+         )
+endif()
+
+# Set the correct variables for the installation
+set(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share/cbmroot)
+
+set(MY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(CMAKE_CURRENT_SOURCE_DIR ${VMCWORKDIR}/input)
+
+set(TMPDIR "${CMAKE_BINARY_DIR}")
+set(CMAKE_BINARY_DIR ${CMAKE_INSTALL_PREFIX})
+
+# Configure file for installation directory
+configure_file(${MY_SOURCE_DIR}/startMQInfo.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQInfo.sh)
+configure_file(${MY_SOURCE_DIR}/startMQSampler.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSampler.sh)
+
+install(PROGRAMS ${TMPDIR}/bin/MQ/topologies/install/startMQInfo.sh
+                 ${TMPDIR}/bin/MQ/topologies/install/startMQSampler.sh
+        DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/MQ/topologies
+       )
diff --git a/MQ/unpacker/CMakeLists.txt b/MQ/unpacker/CMakeLists.txt
index 7091e5936f..0602122e18 100644
--- a/MQ/unpacker/CMakeLists.txt
+++ b/MQ/unpacker/CMakeLists.txt
@@ -83,5 +83,34 @@ set(DEPENDENCIES
   Net
   Hist
 )
+
+# set the install dir
+set(BIN_DESTINATION bin/MQ/unpacker)
 GENERATE_EXECUTABLE()
 
+# Install script and input file(s)
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/MapTofHdCosmics_v18d.par
+        DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cbmroot/input
+       )
+
+if(EXISTS ${VMCWORKDIR}/input/tofget4_hd2018.tsa)
+  install(FILES ${VMCWORKDIR}/input/tofget4_hd2018.tsa
+          DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cbmroot/input
+         )
+endif()
+
+# Set the correct variables for the installation
+set(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share/cbmroot)
+
+set(MY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(CMAKE_CURRENT_SOURCE_DIR ${VMCWORKDIR}/input)
+
+set(TMPDIR "${CMAKE_BINARY_DIR}")
+set(CMAKE_BINARY_DIR ${CMAKE_INSTALL_PREFIX})
+
+# Configure file for installation directory
+configure_file(${MY_SOURCE_DIR}/startMQSamplerUnpackerParserver.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerUnpackerParserver.sh)
+
+install(PROGRAMS ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerUnpackerParserver.sh
+        DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/MQ/topologies
+       )
-- 
GitLab