From 89f2018a4044b89dd5d49f327abb6fef5b9e2abb Mon Sep 17 00:00:00 2001
From: Francois Keith <keith@lirmm.fr>
Date: Sat, 14 Jul 2012 00:13:04 +0200
Subject: [PATCH] The dependency in hrp2 is now optional.

The code can now compile without.
---
 CMakeLists.txt             | 10 +++++-----
 src/CMakeLists.txt         | 25 +++++++++++++++++--------
 unitTesting/CMakeLists.txt |  4 +++-
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index da9e10c..5b0e956 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,11 +41,11 @@ SETUP_PROJECT()
 ADD_REQUIRED_DEPENDENCY("jrl-mal >= 1.9.0")
 
 ADD_REQUIRED_DEPENDENCY("jrl-dynamics >= 1.19.0")
-ADD_REQUIRED_DEPENDENCY("hrp2-dynamics >= 1.5.0")
-ADD_REQUIRED_DEPENDENCY("hrp2-10-optimized >= 1.0.1")
+ADD_OPTIONAL_DEPENDENCY("hrp2-dynamics >= 1.5.0")
+ADD_OPTIONAL_DEPENDENCY("hrp2-10-optimized >= 1.0.1")
 
-ADD_REQUIRED_DEPENDENCY("hrp2-10 >= 1.0.1")
-ADD_REQUIRED_DEPENDENCY("hrp2-14 >= 1.8")
+ADD_OPTIONAL_DEPENDENCY("hrp2-10 >= 1.0.1")
+ADD_OPTIONAL_DEPENDENCY("hrp2-14 >= 1.8")
 
 ADD_REQUIRED_DEPENDENCY("dynamic-graph >= 2.5.0")
 ADD_REQUIRED_DEPENDENCY("sot-core >= 2.5")
@@ -90,4 +90,4 @@ ADD_SUBDIRECTORY(doc)
 ADD_SUBDIRECTORY(unitTesting)
 
 SETUP_PROJECT_FINALIZE()
-SETUP_PROJECT_CPACK()
\ No newline at end of file
+SETUP_PROJECT_CPACK()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a2bff00..2a30117 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -29,9 +29,11 @@ ENDIF(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
 SET(integrator-force-rk4_plugins_dependencies integrator-force)
 SET(integrator-force-exact_plugins_dependencies integrator-force)
 
-SET(dynamic-hrp2_plugins_dependencies dynamic)
-SET(dynamic-hrp2_10_plugins_dependencies dynamic)
-SET(dynamic-hrp2_10_old_plugins_dependencies dynamic)
+IF(HRP2_DYNAMICS_FOUND)
+  SET(dynamic-hrp2_plugins_dependencies dynamic)
+  SET(dynamic-hrp2_10_plugins_dependencies dynamic)
+  SET(dynamic-hrp2_10_old_plugins_dependencies dynamic)
+ENDIF(HRP2_DYNAMICS_FOUND)
 
 FOREACH(lib ${libs})
   ADD_LIBRARY(${lib} SHARED ${lib}.cpp)
@@ -48,10 +50,12 @@ FOREACH(lib ${libs})
   TARGET_LINK_LIBRARIES(${lib} ${Boost_LIBRARIES})
 
   PKG_CONFIG_USE_DEPENDENCY(${lib} jrl-dynamics)
-  PKG_CONFIG_USE_DEPENDENCY(${lib} hrp2-dynamics)
   PKG_CONFIG_USE_DEPENDENCY(${lib} sot-core)
   PKG_CONFIG_USE_DEPENDENCY(${lib} dynamic-graph)
   PKG_CONFIG_USE_DEPENDENCY(${lib} jrl-mal)
+  IF(HRP2_DYNAMICS_FOUND)
+    PKG_CONFIG_USE_DEPENDENCY(${lib} hrp2-dynamics)
+  ENDIF(HRP2_DYNAMICS_FOUND)
 
   INSTALL(TARGETS ${lib} DESTINATION lib/plugin)
   # build python submodule
@@ -64,10 +68,7 @@ FOREACH(lib ${libs})
 ENDFOREACH(lib)
 
 # Install empty __init__.py files in intermediate directories.
-CONFIG_FILES(dynamic_graph/sot/dynamics/hrp2.py)
-
 INSTALL(FILES
-  ${CMAKE_CURRENT_BINARY_DIR}/dynamic_graph/sot/dynamics/hrp2.py
   ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/dynamics/__init__.py
   ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/dynamics/humanoid_robot.py
   ${CMAKE_CURRENT_SOURCE_DIR}/dynamic_graph/sot/dynamics/parser.py
@@ -76,7 +77,15 @@ INSTALL(FILES
   DESTINATION ${PYTHON_SITELIB}/dynamic_graph/sot/dynamics
   )
 
-PKG_CONFIG_USE_DEPENDENCY(dynamic-hrp2 hrp2-dynamics)
+IF(HRP2_DYNAMICS_FOUND)
+  CONFIG_FILES(dynamic_graph/sot/dynamics/hrp2.py)
+  INSTALL(FILES
+    ${CMAKE_CURRENT_BINARY_DIR}/dynamic_graph/sot/dynamics/hrp2.py
+    DESTINATION ${PYTHON_SITELIB}/dynamic_graph/sot/dynamics
+  )
+
+  PKG_CONFIG_USE_DEPENDENCY(dynamic-hrp2 hrp2-dynamics)
+ENDIF(HRP2_DYNAMICS_FOUND)
 
 IF(${HRP2_10_OPTIMIZED_FOUND})
   PKG_CONFIG_USE_DEPENDENCY(dynamic-hrp2_10 hrp2-10-optimized)
diff --git a/unitTesting/CMakeLists.txt b/unitTesting/CMakeLists.txt
index 74327c1..55c6cb9 100644
--- a/unitTesting/CMakeLists.txt
+++ b/unitTesting/CMakeLists.txt
@@ -53,10 +53,12 @@ FOREACH(test ${tests})
     )
 
   PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} jrl-dynamics)
-  PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} hrp2-dynamics)
   PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} sot-core)
   PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} dynamic-graph)
   PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} jrl-mal)
+  IF(HRP2_DYNAMICS_FOUND)
+    PKG_CONFIG_USE_DEPENDENCY(${EXECUTABLE_NAME} hrp2-dynamics)
+  ENDIF(HRP2_DYNAMICS_FOUND)
 
 
   IF(${test}_plugins_dependencies)
-- 
GitLab