From 2697899205fe95706009366b5cb224efd087bc1e Mon Sep 17 00:00:00 2001
From: Martin Hierholzer <martin.hierholzer@desy.de>
Date: Wed, 19 Apr 2023 17:38:51 +0200
Subject: [PATCH] fix(project-template): imported targets for set_csa

---
 cmake/set_control_system_adapter.cmake | 32 +++++++++++---------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/cmake/set_control_system_adapter.cmake b/cmake/set_control_system_adapter.cmake
index e95c1a1..6d52e98 100644
--- a/cmake/set_control_system_adapter.cmake
+++ b/cmake/set_control_system_adapter.cmake
@@ -26,30 +26,26 @@
 #######################################################################################################################
 
 # Select control system adapter
-IF(ADAPTER STREQUAL "OPCUA")
+if(ADAPTER STREQUAL "OPCUA")
   message("Building against the OPC UA ControlSystemAdater")
-  add_dependency(ChimeraTK-ControlSystemAdapter-OPCUAAdapter 03.00 REQUIRED)
-  set(Adapter_LINK_FLAGS ${ChimeraTK-ControlSystemAdapter-OPCUAAdapter_LINK_FLAGS})
-  set(Adapter_LIBRARIES ${ChimeraTK-ControlSystemAdapter-OPCUAAdapter_LIBRARIES})
-ELSEIF(ADAPTER STREQUAL "DOOCS")
+  find_package(ChimeraTK-ControlSystemAdapter-OPCUAAdapter 03.00 REQUIRED)
+  add_library(ChimeraTK::SelectedAdapter ALIAS ChimeraTK::ChimeraTK-ControlSystemAdapter-OPCUAAdapter)
+elseif(ADAPTER STREQUAL "DOOCS")
   message("Building against the DOOCS ControlSystemAdater")
-  add_dependency(ChimeraTK-ControlSystemAdapter-DoocsAdapter 01.08 REQUIRED)
-  set(Adapter_LINK_FLAGS ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LINK_FLAGS})
-  set(Adapter_LIBRARIES ${ChimeraTK-ControlSystemAdapter-DoocsAdapter_LIBRARIES})
-ELSEIF(ADAPTER STREQUAL "EPICSIOC")
+  find_package(ChimeraTK-ControlSystemAdapter-DoocsAdapter 01.08 REQUIRED)
+  add_library(ChimeraTK::SelectedAdapter ALIAS ChimeraTK::ChimeraTK-ControlSystemAdapter-DoocsAdapter)
+elseif(ADAPTER STREQUAL "EPICSIOC")
   message("Building against the EPICS IOC ControlSystemAdater")
-  add_dependency(ChimeraTK-ControlSystemAdapter-EPICS-IOC-Adapter 02.00 REQUIRED)
-  set(Adapter_LINK_FLAGS ${ChimeraTK-ControlSystemAdapter-EPICS-IOC-Adapter_LINK_FLAGS})
-  set(Adapter_LIBRARIES ${ChimeraTK-ControlSystemAdapter-EPICS-IOC-Adapter_LIBRARIES})
-ELSEIF(ADAPTER STREQUAL "EPICS7IOC")
+  find_package(ChimeraTK-ControlSystemAdapter-EPICS-IOC-Adapter 02.00 REQUIRED)
+  add_library(ChimeraTK::SelectedAdapter ALIAS ChimeraTK::ChimeraTK-ControlSystemAdapter-EPICS-IOC-Adapter)
+elseif(ADAPTER STREQUAL "EPICS7IOC")
   message("Building against the EPICS ver. 7.0 IOC ControlSystemAdater")
-  add_dependency(ChimeraTK-ControlSystemAdapter-EPICS7-IOC-Adapter 02.00 REQUIRED)
-  set(Adapter_LINK_FLAGS ${ChimeraTK-ControlSystemAdapter-EPICS7-IOC-Adapter_LINK_FLAGS})
-  set(Adapter_LIBRARIES ${ChimeraTK-ControlSystemAdapter-EPICS7-IOC-Adapter_LIBRARIES})
-ELSE()
+  find_package(ChimeraTK-ControlSystemAdapter-EPICS7-IOC-Adapter 02.00 REQUIRED)
+  add_library(ChimeraTK::SelectedAdapter ALIAS ChimeraTK::ChimeraTK-ControlSystemAdapter-EPICS7-IOC-Adapter)
+else()
   message(FATAL_ERROR "Please select your ControlSystemAdapter to use by passing to the cmake command line:\n"
                       "   -DADAPTER=DOOCS to build a DOOCS server\n"
                       "   -DADAPTER=OPCUA to build an OPC UA server\n"
                       "   -DADAPTER=EPICSIOC to build an EPICS ver. 3.16 IOC\n"
                       "   -DADAPTER=EPICS7IOC to build an EPICS ver. 7.0 IOC")
-ENDIF()
+endif()
-- 
GitLab