From d58ca69d9c9bfd49eb6599dfe4673b94db61f617 Mon Sep 17 00:00:00 2001
From: andreadelprete <andre.delprete@gmail.com>
Date: Mon, 6 Jun 2016 11:40:49 +0200
Subject: [PATCH] Modify CMakeLists.txt and installation instructions to use
 pkgconfig version of qpOases

---
 CMakeLists.txt      |  3 ++-
 README.md           | 22 +++++++++++++++-------
 src/CMakeLists.txt  |  7 ++++---
 test/CMakeLists.txt |  2 +-
 4 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 32cb3e2..361bc52 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,7 +61,8 @@ else()
   add_definitions(-DCLP_FOUND)
 endif()
 
-SEARCH_FOR_QPOASES()
+#SEARCH_FOR_QPOASES()
+ADD_REQUIRED_DEPENDENCY("qpOASES")
 
 add_subdirectory (src)
 add_subdirectory (test)
diff --git a/README.md b/README.md
index 4bee78e..0789d2b 100644
--- a/README.md
+++ b/README.md
@@ -35,10 +35,18 @@ You can install Eigen3 with the following command:
 ```
  sudo apt-get install libeigen3-dev
 ```
-Install qpOases from sources following the instructions on its [webpage](https://projects.coin-or.org/qpOASES).
-Note that you need to compile qpOases into a dynamic library (not a static one).
+For qpOases you have to install the pkg-config version you can find here: https://github.com/humanoid-path-planner/qpoases
+```
+git clone --recursive https://github.com/humanoid-path-planner/qpoases
+mkdir qpoases/build
+cd qpoases/build
+cmake -DCMAKE_INSTALL_PREFIX=${DEVEL_DIR}/install ..
+make install
+```
+#Alternatively, you can install qpOases from sources following the instructions on its [webpage](https://projects.coin-or.org/qpOASES).
+#Note that you need to compile qpOases into a dynamic library (not a static one).
 
-Then you can clone the repository using ssh:
+Then you can clone this repository using ssh:
 ```
 git clone --recursive git@github.com:andreadelprete/robust-equilibrium-lib.git $ROBUST_EQUI_LIB_DIR
 ```
@@ -46,17 +54,17 @@ or using http:
 ```
 git clone --recursive https://github.com/andreadelprete/robust-equilibrium-lib.git $ROBUST_EQUI_LIB_DIR
 ```
-And you can build the library using CMake:
+And you can build this library using CMake:
 ```
 mkdir $ROBUST_EQUI_LIB_DIR/build
 cd $ROBUST_EQUI_LIB_DIR/build
 cmake -DCMAKE_INSTALL_PREFIX=${DEVEL_DIR}/install ..
 make install
 ```
-Currently, CMake may have problems finding CDD and qpOases.
-If this is the case you can specify their paths manually, for instance:
+Currently, CMake may have problems finding CDD.
+If this is the case you can specify its path manually, for instance:
 ```
-cmake -DCDD_LIBRARY=/usr/lib/libcdd.so -DqpOASES_INCLUDEDIR=${QP_OASES_DIR}/include -DqpOASES_LIB=${QP_OASES_DIR}/bin/libqpOASES.so -DCMAKE_INSTALL_PREFIX=${DEVEL_DIR}/install ..
+cmake -DCDD_LIBRARY=/usr/lib/libcdd.so -DCMAKE_INSTALL_PREFIX=${DEVEL_DIR}/install ..
 ```
 
 ### Optional
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a15ab0e..a61ad75 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -4,7 +4,7 @@ include_directories("${SRC_DIR}")
 include_directories("${INCLUDE_DIR}")
 include_directories("${EIGEN3_INCLUDE_DIR}")
 include_directories("${CDD_INCLUDE_DIR}")
-include_directories("${qpOASES_INCLUDE_DIR}")
+# no need to include directories for qpOASES as it is automatically done through pkgconfig
 
 if(CLP_FOUND)
   include_directories("${CLP_INCLUDE_DIR}")
@@ -35,8 +35,9 @@ if ( MSVC )
 	SET(CMAKE_DEBUG_POSTFIX d)
 endif ( MSVC )
 
-TARGET_LINK_LIBRARIES(robust-equilibrium-lib ${CDD_LIBRARY}
-                                             ${qpOASES_LIBRARY})
+TARGET_LINK_LIBRARIES(robust-equilibrium-lib ${CDD_LIBRARY})
+PKG_CONFIG_USE_DEPENDENCY(robust-equilibrium-lib qpOASES)
+
 if(CLP_FOUND)
   TARGET_LINK_LIBRARIES(robust-equilibrium-lib ${CLP_LIBRARY}
                                                /usr/lib/libCoinUtils.so)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 55b06fa..7399b3e 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -4,7 +4,7 @@ include_directories("${SRC_DIR}")
 include_directories("${INCLUDE_DIR}")
 include_directories("${EIGEN3_INCLUDE_DIR}")
 include_directories("${CDD_INCLUDE_DIR}")
-include_directories("${qpOASES_INCLUDE_DIR}")
+# no need to include directories for qpOASES as it is automatically done through pkgconfig
 if(CLP_FOUND)
   include_directories("${CLP_INCLUDE_DIR}")
 endif()
-- 
GitLab