From a48f36f58c9d36d5c50f663b251a4048d8569453 Mon Sep 17 00:00:00 2001
From: Manfred Kroehnert <Manfred.Kroehnert@kit.edu>
Date: Mon, 24 Feb 2014 15:08:02 +0100
Subject: [PATCH] cmake: use include_directories() only if the required
 libraries have been found

---
 .../RobotAPI/GraspingWithTorques/CMakeLists.txt   |  7 +++++--
 source/RobotAPI/OpenHand/CMakeLists.txt           |  7 +++++--
 .../ForceTorqueObserver/CMakeLists.txt            |  8 --------
 .../applications/MotionControl/CMakeLists.txt     |  8 --------
 .../applications/MotionControlTest/CMakeLists.txt | 15 +++++----------
 .../applications/TCPControlUnit/CMakeLists.txt    | 15 +++++----------
 source/RobotAPI/core/CMakeLists.txt               |  7 +++++--
 source/RobotAPI/motioncontrol/CMakeLists.txt      |  7 +++++--
 source/RobotAPI/units/CMakeLists.txt              |  7 +++++--
 9 files changed, 35 insertions(+), 46 deletions(-)

diff --git a/source/RobotAPI/GraspingWithTorques/CMakeLists.txt b/source/RobotAPI/GraspingWithTorques/CMakeLists.txt
index 6745f8d83..3f4d1563f 100644
--- a/source/RobotAPI/GraspingWithTorques/CMakeLists.txt
+++ b/source/RobotAPI/GraspingWithTorques/CMakeLists.txt
@@ -7,8 +7,11 @@ find_package(Simox QUIET)
 armarx_build_if(Eigen3_FOUND "Eigen3 not available")
 armarx_build_if(Simox_FOUND "Simox-VirtualRobot not available")
 
-include_directories(${Eigen3_INCLUDE_DIR})
-include_directories(${Simox_INCLUDE_DIRS})
+if (Eigen3_FOUND AND Simox_FOUND)
+    include_directories(
+        ${Eigen3_INCLUDE_DIR}
+        ${Simox_INCLUDE_DIRS})
+endif()
 
 set(LIB_NAME       GraspingWithTorques)
 set(LIB_VERSION    0.1.0)
diff --git a/source/RobotAPI/OpenHand/CMakeLists.txt b/source/RobotAPI/OpenHand/CMakeLists.txt
index 3a9d3d37a..b049ee78d 100644
--- a/source/RobotAPI/OpenHand/CMakeLists.txt
+++ b/source/RobotAPI/OpenHand/CMakeLists.txt
@@ -6,8 +6,11 @@ find_package(Simox QUIET)
 armarx_build_if(Eigen3_FOUND "Eigen3 not available")
 armarx_build_if(Simox_FOUND "Simox-VirtualRobot not available")
 
-include_directories(${Eigen3_INCLUDE_DIR})
-include_directories(${Simox_INCLUDE_DIRS})
+if (Eigen3_FOUND AND Simox_FOUND)
+    include_directories(
+        ${Eigen3_INCLUDE_DIR}
+        ${Simox_INCLUDE_DIRS})
+endif()
 
 set(LIB_NAME       OpenHand)
 set(LIB_VERSION    0.1.0)
diff --git a/source/RobotAPI/applications/ForceTorqueObserver/CMakeLists.txt b/source/RobotAPI/applications/ForceTorqueObserver/CMakeLists.txt
index 8398b7002..449734e08 100755
--- a/source/RobotAPI/applications/ForceTorqueObserver/CMakeLists.txt
+++ b/source/RobotAPI/applications/ForceTorqueObserver/CMakeLists.txt
@@ -7,14 +7,6 @@ armarx_build_if(Eigen3_FOUND "Eigen3 not available")
 find_package(Simox QUIET)
 armarx_build_if(Simox_FOUND "Simox-VirtualRobot not available")
 
-# check if ArmarXCoreUnits library gets built
-# LOCATION is NOT-FOUND (equal to FALSE) if library is disabled
-GET_TARGET_PROPERTY(ArmarXCoreUnits_ENABLED ArmarXCoreUnits LOCATION)
-armarx_build_if(ArmarXCoreUnits_ENABLED "ArmarXCoreUnits library disabled")
-
-GET_TARGET_PROPERTY(ArmarXCoreObservers_ENABLED ArmarXCoreObservers LOCATION)
-armarx_build_if(ArmarXCoreObservers_ENABLED "ArmarXCoreObservers library disabled")
-
 
 set(COMPONENT_LIBS RobotAPIUnits RobotAPICore RobotAPIInterfaces  ArmarXInterfaces ArmarXCore ArmarXCoreObservers ArmarXCoreRemoteRobot)
 
diff --git a/source/RobotAPI/applications/MotionControl/CMakeLists.txt b/source/RobotAPI/applications/MotionControl/CMakeLists.txt
index b7bf1b6df..65c7ee082 100755
--- a/source/RobotAPI/applications/MotionControl/CMakeLists.txt
+++ b/source/RobotAPI/applications/MotionControl/CMakeLists.txt
@@ -7,14 +7,6 @@ armarx_build_if(Eigen3_FOUND "Eigen3 not available")
 find_package(Simox QUIET)
 armarx_build_if(Simox_FOUND "Simox-VirtualRobot not available")
 
-# check if ArmarXCoreUnits library gets built
-# LOCATION is NOT-FOUND (equal to FALSE) if library is disabled
-GET_TARGET_PROPERTY(ArmarXCoreUnits_ENABLED ArmarXCoreUnits LOCATION)
-armarx_build_if(ArmarXCoreUnits_ENABLED "ArmarXCoreUnits library disabled")
-
-GET_TARGET_PROPERTY(ArmarXCoreObservers_ENABLED ArmarXCoreObservers LOCATION)
-armarx_build_if(ArmarXCoreObservers_ENABLED "ArmarXCoreObservers library disabled")
-
 
 set(COMPONENT_LIBS MotionControl RobotAPICore ArmarXInterfaces ArmarXCore ArmarXCoreObservers ArmarXCoreRobotStateComponent ArmarXCoreStatechart ArmarXCoreOperations)
 
diff --git a/source/RobotAPI/applications/MotionControlTest/CMakeLists.txt b/source/RobotAPI/applications/MotionControlTest/CMakeLists.txt
index ce7392449..1d9334a52 100644
--- a/source/RobotAPI/applications/MotionControlTest/CMakeLists.txt
+++ b/source/RobotAPI/applications/MotionControlTest/CMakeLists.txt
@@ -7,17 +7,12 @@ armarx_build_if(Eigen3_FOUND "Eigen3 not available")
 find_package(Simox QUIET)
 armarx_build_if(Simox_FOUND "Simox-VirtualRobot not available")
 
-# check if ArmarXCoreUnits library gets built
-# LOCATION is NOT-FOUND (equal to FALSE) if library is disabled
-GET_TARGET_PROPERTY(ArmarXCoreUnits_ENABLED ArmarXCoreUnits LOCATION)
-armarx_build_if(ArmarXCoreUnits_ENABLED "ArmarXCoreUnits library disabled")
+if (Eigen3_FOUND AND Simox_FOUND)
+    include_directories(
+        ${Eigen3_INCLUDE_DIR}
+        ${Simox_INCLUDE_DIRS})
+endif()
 
-GET_TARGET_PROPERTY(ArmarXCoreObservers_ENABLED ArmarXCoreObservers LOCATION)
-armarx_build_if(ArmarXCoreObservers_ENABLED "ArmarXCoreObservers library disabled")
-
-
-include_directories(${Eigen3_INCLUDE_DIR})
-include_directories(${Simox_INCLUDE_DIRS})
 set(COMPONENT_LIBS MotionControl RobotAPICore ArmarXInterfaces ArmarXCore ArmarXCoreObservers ArmarXCoreRobotStateComponent ArmarXCoreStatechart ArmarXCoreOperations ${Simox_LIBRARIES})
 
 set(SOURCES main.cpp MotionControlTestApp.h)
diff --git a/source/RobotAPI/applications/TCPControlUnit/CMakeLists.txt b/source/RobotAPI/applications/TCPControlUnit/CMakeLists.txt
index 492c1aded..c914803ce 100755
--- a/source/RobotAPI/applications/TCPControlUnit/CMakeLists.txt
+++ b/source/RobotAPI/applications/TCPControlUnit/CMakeLists.txt
@@ -7,17 +7,12 @@ armarx_build_if(Eigen3_FOUND "Eigen3 not available")
 find_package(Simox QUIET)
 armarx_build_if(Simox_FOUND "Simox-VirtualRobot not available")
 
-# check if ArmarXCoreUnits library gets built
-# LOCATION is NOT-FOUND (equal to FALSE) if library is disabled
-GET_TARGET_PROPERTY(ArmarXCoreUnits_ENABLED ArmarXCoreUnits LOCATION)
-armarx_build_if(ArmarXCoreUnits_ENABLED "ArmarXCoreUnits library disabled")
+if (Eigen3_FOUND AND Simox_FOUND)
+    include_directories(
+        ${Eigen3_INCLUDE_DIR}
+        ${Simox_INCLUDE_DIRS})
+endif()
 
-GET_TARGET_PROPERTY(ArmarXCoreObservers_ENABLED ArmarXCoreObservers LOCATION)
-armarx_build_if(ArmarXCoreObservers_ENABLED "ArmarXCoreObservers library disabled")
-
-
-include_directories(${Eigen3_INCLUDE_DIR})
-include_directories(${Simox_INCLUDE_DIRS})
 set(COMPONENT_LIBS RobotAPIUnits RobotAPICore RobotAPIInterfaces  ArmarXInterfaces ArmarXCore ArmarXCoreObservers ArmarXCoreRemoteRobot ${Simox_LIBRARIES})
 
 set(SOURCES main.cpp TCPControlUnitApp.h)
diff --git a/source/RobotAPI/core/CMakeLists.txt b/source/RobotAPI/core/CMakeLists.txt
index e403fbf60..fbd863514 100644
--- a/source/RobotAPI/core/CMakeLists.txt
+++ b/source/RobotAPI/core/CMakeLists.txt
@@ -7,8 +7,11 @@ find_package(Simox QUIET)
 armarx_build_if(Eigen3_FOUND "Eigen3 not available")
 armarx_build_if(Simox_FOUND "Simox-VirtualRobot not available")
 
-include_directories(${Eigen3_INCLUDE_DIR})
-include_directories(${Simox_INCLUDE_DIRS})
+if (Eigen3_FOUND AND Simox_FOUND)
+    include_directories(
+        ${Eigen3_INCLUDE_DIR}
+        ${Simox_INCLUDE_DIRS})
+endif()
 
 set(LIB_NAME       RobotAPICore)
 set(LIB_VERSION    0.1.0)
diff --git a/source/RobotAPI/motioncontrol/CMakeLists.txt b/source/RobotAPI/motioncontrol/CMakeLists.txt
index c1f092140..9abf0ef3d 100644
--- a/source/RobotAPI/motioncontrol/CMakeLists.txt
+++ b/source/RobotAPI/motioncontrol/CMakeLists.txt
@@ -7,8 +7,11 @@ find_package(Simox QUIET)
 armarx_build_if(Eigen3_FOUND "Eigen3 not available")
 armarx_build_if(Simox_FOUND "Simox-VirtualRobot not available")
 
-include_directories(${Eigen3_INCLUDE_DIR})
-include_directories(${Simox_INCLUDE_DIRS})
+if (Eigen3_FOUND AND Simox_FOUND)
+    include_directories(
+        ${Eigen3_INCLUDE_DIR}
+        ${Simox_INCLUDE_DIRS})
+endif()
 
 set(LIB_NAME       MotionControl)
 set(LIB_VERSION    0.1.0)
diff --git a/source/RobotAPI/units/CMakeLists.txt b/source/RobotAPI/units/CMakeLists.txt
index 3cb8f9450..48752665d 100755
--- a/source/RobotAPI/units/CMakeLists.txt
+++ b/source/RobotAPI/units/CMakeLists.txt
@@ -7,8 +7,11 @@ find_package(Simox QUIET)
 armarx_build_if(Eigen3_FOUND "Eigen3 not available")
 armarx_build_if(Simox_FOUND "Simox-VirtualRobot not available")
 
-include_directories(${Eigen3_INCLUDE_DIR})
-include_directories(${Simox_INCLUDE_DIRS})
+if (Eigen3_FOUND AND Simox_FOUND)
+    include_directories(
+        ${Eigen3_INCLUDE_DIR}
+        ${Simox_INCLUDE_DIRS})
+endif()
 
 set(LIB_NAME       RobotAPIUnits)
 set(LIB_VERSION    0.1.0)
-- 
GitLab