From c23d4bd4569fdd07afc14489b9a4a612791dd4e2 Mon Sep 17 00:00:00 2001
From: Fabian Reister <fabian.reister@kit.edu>
Date: Tue, 26 Mar 2024 08:32:03 +0100
Subject: [PATCH] modernizing cmakelists (Simox and Eigen usage)

---
 .../DSObstacleAvoidance/CMakeLists.txt        |  4 +--
 .../DynamicObstacleManager/CMakeLists.txt     | 11 ++-----
 .../aron/codegeneration/test/CMakeLists.txt   | 30 ++++++-------------
 source/RobotAPI/libraries/core/CMakeLists.txt | 14 ++++-----
 4 files changed, 18 insertions(+), 41 deletions(-)

diff --git a/source/RobotAPI/components/DSObstacleAvoidance/CMakeLists.txt b/source/RobotAPI/components/DSObstacleAvoidance/CMakeLists.txt
index 4eb4b16a3..37675a4f2 100644
--- a/source/RobotAPI/components/DSObstacleAvoidance/CMakeLists.txt
+++ b/source/RobotAPI/components/DSObstacleAvoidance/CMakeLists.txt
@@ -11,9 +11,6 @@ endif()
 
 find_package(Simox QUIET)
 armarx_build_if(Simox_FOUND "Simox not available")
-if(Simox_FOUND)
-    include_directories(${Simox_INCLUDE_DIR})
-endif()
 
 find_package(PythonLibs 3.6 QUIET)
 armarx_build_if(PYTHONLIBS_FOUND "Python libs not available")
@@ -26,6 +23,7 @@ set(COMPONENT_LIBS
     RobotAPIComponentPlugins
     RobotAPIInterfaces
     dynamic_obstacle_avoidance
+    Simox::SimoxUtility
 )
 
 set(SOURCES DSObstacleAvoidance.cpp)
diff --git a/source/RobotAPI/components/DynamicObstacleManager/CMakeLists.txt b/source/RobotAPI/components/DynamicObstacleManager/CMakeLists.txt
index 7136f05db..abcd773ce 100644
--- a/source/RobotAPI/components/DynamicObstacleManager/CMakeLists.txt
+++ b/source/RobotAPI/components/DynamicObstacleManager/CMakeLists.txt
@@ -3,15 +3,9 @@ armarx_component_set_name("DynamicObstacleManager")
 
 find_package(Eigen3 QUIET)
 armarx_build_if(Eigen3_FOUND "Eigen3 not available")
-if(Eigen3_FOUND)
-    include_directories(${Eigen3_INCLUDE_DIR})
-endif()
 
 find_package(Simox ${ArmarX_Simox_VERSION} QUIET)
 armarx_build_if(Simox_FOUND "Simox ${ArmarX_Simox_VERSION} or later not available")
-if (Simox_FOUND)
-    include_directories(${Simox_INCLUDE_DIRS})
-endif()
 
 find_package(OpenCV QUIET)
 armarx_build_if(OpenCV_FOUND "OpenCV not available")
@@ -25,8 +19,10 @@ set(COMPONENT_LIBS
     RobotAPICore
     RobotAPIComponentPlugins
     RobotAPIInterfaces
+    Eigen3::Eigen
     ${OpenCV_LIBS}
-    ${Simox_LIBS}
+    Simox::VirtualRobot
+    # todo maybe add other simox libs
 )
 
 set(SOURCES
@@ -42,4 +38,3 @@ set(HEADERS
 armarx_add_component("${SOURCES}" "${HEADERS}")
 
 armarx_generate_and_add_component_executable()
-
diff --git a/source/RobotAPI/libraries/aron/codegeneration/test/CMakeLists.txt b/source/RobotAPI/libraries/aron/codegeneration/test/CMakeLists.txt
index 3b05caec2..9923f490f 100644
--- a/source/RobotAPI/libraries/aron/codegeneration/test/CMakeLists.txt
+++ b/source/RobotAPI/libraries/aron/codegeneration/test/CMakeLists.txt
@@ -22,12 +22,10 @@ armarx_add_test(
     TEST_FILE
         aronOperatorTest.cpp
     LIBS
-        SimoxUtility  # Simox::SimoxUtility
+        Simox::SimoxUtility
         ArmarXCore
         aron
         aroncommon
-    INCLUDE_DIRECTORIES
-        ${Simox_INCLUDE_DIR}
 )
 
 ######################
@@ -39,9 +37,10 @@ armarx_add_test(
     TEST_FILE
         aronCodeGenerationTest.cpp
     LIBS
-        SimoxUtility  # Simox::SimoxUtility
+        Simox::SimoxUtility
         ArmarXCore
         RobotAPI::aron
+        Eigen3::Eigen
     ARON_FILES
         aron/AnyTest.xml
         aron/TemplateTest.xml
@@ -62,8 +61,6 @@ armarx_add_test(
         aron/OptionalTest.xml
         aron/DtoTest.xml
     INCLUDE_DIRECTORIES
-        ${Simox_INCLUDE_DIR}
-        ${Eigen3_INCLUDE_DIR}
         ${IVT_INCLUDE_DIRS}
         ${OpenCV_INCLUDE_DIRS}
         ${PCL_INCLUDE_DIRS}
@@ -78,13 +75,11 @@ armarx_add_test(
     TEST_FILE
         aronNavigateTest.cpp
     LIBS
-        SimoxUtility  # Simox::SimoxUtility
+        Simox::SimoxUtility
         ArmarXCore
         RobotAPI::aron
     ARON_FILES
         aron/NaturalIKTest.xml
-    INCLUDE_DIRECTORIES
-        ${Simox_INCLUDE_DIR}
 )
 
 ######################
@@ -96,14 +91,12 @@ armarx_add_test(
     TEST_FILE
         aronExtendsTest.cpp
     LIBS
-        SimoxUtility  # Simox::SimoxUtility
+        Simox::SimoxUtility
         ArmarXCore
         RobotAPI::aron
     ARON_FILES
         aron/BaseClassTest.xml
         aron/DerivedClassTest.xml
-    INCLUDE_DIRECTORIES
-        ${Simox_INCLUDE_DIR}
 )
 
 ######################
@@ -115,13 +108,11 @@ armarx_add_test(
     TEST_FILE
         aronConversionTest.cpp
     LIBS
-        SimoxUtility  # Simox::SimoxUtility
+        Simox::SimoxUtility
         ArmarXCore
         RobotAPI::aron
     ARON_FILES
         aron/HumanPoseTest.xml
-    INCLUDE_DIRECTORIES
-        ${Simox_INCLUDE_DIR}
 )
 
 ######################
@@ -133,14 +124,12 @@ armarx_add_test(
     TEST_FILE
         aronJsonExportTest.cpp
     LIBS
-        SimoxUtility  # Simox::SimoxUtility
+        Simox::SimoxUtility
         ArmarXCore
         RobotAPI::aron
     ARON_FILES
         aron/OptionalTest.xml
         aron/MatrixTest.xml
-    INCLUDE_DIRECTORIES
-        ${Simox_INCLUDE_DIR}
 )
 
 ########################
@@ -152,13 +141,14 @@ armarx_add_test(
 #    TEST_FILE
 #        aronRandomizedTest.cpp
 #    LIBS
-#        SimoxUtility  # Simox::SimoxUtility
+#        Simox::SimoxUtility
 #        ArmarXCore
 #        RobotAPI::aron
 #        ivt
 #        ivtopencv
 #        ${PCL_COMMON_LIBRARIES}
 #        aronjsonconverter
+#        Eigen3::Eigen
 #    ARON_FILES
 #        aron/DictTest.xml
 #        aron/MatrixTest.xml
@@ -176,8 +166,6 @@ armarx_add_test(
 #        aron/OptionalTest.xml
 #        aron/ImageTest.xml
 #    INCLUDE_DIRECTORIES
-#        ${Simox_INCLUDE_DIR}
-#        ${Eigen3_INCLUDE_DIR}
 #        ${IVT_INCLUDE_DIRS}
 #        ${OpenCV_INCLUDE_DIRS}
 #        ${PCL_INCLUDE_DIRS}
diff --git a/source/RobotAPI/libraries/core/CMakeLists.txt b/source/RobotAPI/libraries/core/CMakeLists.txt
index 7756a2cd5..5cf0313b9 100644
--- a/source/RobotAPI/libraries/core/CMakeLists.txt
+++ b/source/RobotAPI/libraries/core/CMakeLists.txt
@@ -1,22 +1,18 @@
 armarx_set_target("RobotAPI Core Library: RobotAPICore")
 
 find_package(Eigen3 QUIET)
-find_package(Simox ${ArmarX_Simox_VERSION} QUIET)
+find_package(Simox ${ArmarX_Simox_VERSION} REQUIRED)
 
 armarx_build_if(Eigen3_FOUND "Eigen3 not available")
 armarx_build_if(Simox_FOUND "Simox-VirtualRobot not available")
 
-if (Eigen3_FOUND AND Simox_FOUND)
-    include_directories(${Simox_INCLUDE_DIRS})
-    include_directories(SYSTEM ${Eigen3_INCLUDE_DIR})
-endif()
-
 set(LIB_NAME       RobotAPICore)
 
 set(LIBS RobotAPIInterfaces ArmarXCoreObservers ArmarXCoreStatechart ArmarXCoreEigen3Variants
-    VirtualRobot
-    Saba
-    SimDynamics
+    Simox::VirtualRobot
+    # Simox::Saba
+    # Simox::SimDynamics
+    Eigen3::Eigen
     )
 
 set(LIB_FILES
-- 
GitLab