From 60592bc98f4b9bc13672fd3372ef03982e366d75 Mon Sep 17 00:00:00 2001
From: chantrait <teddy.chantrait@cea.fr>
Date: Mon, 27 Feb 2023 12:24:03 +0100
Subject: [PATCH] Change the way Costo is imported

---
 CMakeLists.txt           | 32 +++++++++++++++++++-------------
 src/utils/CMakeLists.txt | 12 +-----------
 src/utils/Messenger.hpp  |  2 +-
 3 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index dea40d11b..3f15fc266 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -157,6 +157,23 @@ else()
   endif()
 endif()
 
+#------------------------------------------------------
+# Search for Costo
+
+find_package(Costo 0.0.1 COMPONENTS CPO)
+
+if(NOT Costo_FOUND)
+  MESSAGE( "Cant find Costo")
+else()
+  MESSAGE("COSTO ${Costo_LIBRARIES}")
+  MESSAGE("COSTO ${Costo_LIBRARY_DIR}")
+  MESSAGE("COSTO ${Costo_INCLUDE_DIR}")
+  include_directories(SYSTEM ${Costo_INCLUDE_DIR})
+  link_directories(${Costo_LIBRARY_DIR})
+endif()
+
+
+
 #------------------------------------------------------
 # Check for PETSc
 # defaults use PETSc
@@ -563,18 +580,7 @@ endif()
 link_libraries("-rdynamic")
 
 # ------------------- Source files --------------------
-set(COSTO_INSTALL_DIR "/home/chantraitt/softs/04-costo/install/depot_git")
-
-# add_library(costo SHARED IMPORTED) # or STATIC instead of SHARED
-# set_target_properties(costo PROPERTIES
-#   IMPORTED_LOCATION "${COSTO_INSTALL_DIR}/lib/libcosto.so"
-#   INTERFACE_INCLUDE_DIRECTORIES "${COSTO_INSTALL_DIR}/includes"
-#   )
-add_library(CPO SHARED IMPORTED) # or STATIC instead of SHARED
-set_target_properties(CPO PROPERTIES
-  IMPORTED_LOCATION "${COSTO_INSTALL_DIR}/lib/libCPO.so"
-  INTERFACE_INCLUDE_DIRECTORIES "${COSTO_INSTALL_DIR}/includes"
-  )
+
 
 # Pugs binary
 add_executable(
@@ -607,7 +613,7 @@ target_link_libraries(
   ${OPENMP_LINK_FLAGS}
   ${PUGS_STD_LINK_FLAGS}
   stdc++fs
-  CPO
+  ${Costo_LIBRARIES}
   )
 
 # -------------------- Documentation --------------------
diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt
index 244634e41..ddc38d41f 100644
--- a/src/utils/CMakeLists.txt
+++ b/src/utils/CMakeLists.txt
@@ -21,21 +21,11 @@ add_library(
   Socket.cpp
   )
 
-set(COSTO_INSTALL_DIR "/home/chantraitt/softs/04-costo/install/depot_git")
-add_library(CPO SHARED IMPORTED) # or STATIC instead of SHARED
-set_target_properties(CPO PROPERTIES
-  IMPORTED_LOCATION ${COSTO_INSTALL_DIR}/lib/libCPO.so
-  INTERFACE_INCLUDE_DIRECTORIES "${COSTO_INSTALL_DIR}/includes"
-  )
-
-target_include_directories(PugsUtils
-  PUBLIC "${COSTO_INSTALL_DIR}/includes/utils"
-)
   target_link_libraries(
   PugsUtils
   ${PETSC_LIBRARIES}
   ${SLEPC_LIBRARIES}
-  CPO
+  ${Costo_LIBRARIES}
 )
 
 # --------------- get git revision info ---------------
diff --git a/src/utils/Messenger.hpp b/src/utils/Messenger.hpp
index d617aefdb..414911405 100644
--- a/src/utils/Messenger.hpp
+++ b/src/utils/Messenger.hpp
@@ -16,7 +16,7 @@
 #include <mpi.h>
 #endif   // PUGS_HAS_MPI
 
-#include "/home/chantraitt/softs/04-costo/install/depot_git/includes/CPO/couplingObjects.h"
+#include <CPO/couplingObjects.h>
 #include <utils/CommunicatorManager.hpp>
 #include <utils/Exceptions.hpp>
 #include <utils/PugsTraits.hpp>
-- 
GitLab