From b4d6a207245d2404f07101aded2fc9241abaf600 Mon Sep 17 00:00:00 2001 From: Connor Kurtz Date: Tue, 25 Apr 2023 07:28:28 -0700 Subject: [PATCH] Convert libraries in install script to submodules Build hpipm and blasfeo with cmake --- .gitmodules | 15 +++++++++++ C++/.gitignore | 2 +- C++/CMakeLists.txt | 5 +++- C++/External/Eigen | 1 + C++/External/Json | 1 + C++/External/blasfeo | 1 + C++/External/hpipm | 1 + C++/External/matplotlib | 1 + C++/README.md | 6 ++--- C++/install.sh | 56 ----------------------------------------- 10 files changed, 28 insertions(+), 61 deletions(-) create mode 100644 .gitmodules create mode 160000 C++/External/Eigen create mode 160000 C++/External/Json create mode 160000 C++/External/blasfeo create mode 160000 C++/External/hpipm create mode 160000 C++/External/matplotlib delete mode 100755 C++/install.sh diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f8f5f5f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,15 @@ +[submodule "C++/External/blasfeo"] + path = C++/External/blasfeo + url = https://github.com/giaf/blasfeo.git +[submodule "C++/External/hpipm"] + path = C++/External/hpipm + url = https://github.com/giaf/hpipm.git +[submodule "External/matplotlib"] + path = C++/External/matplotlib + url = https://github.com/lava/matplotlib-cpp.git +[submodule "C++/External/Eigen"] + path = C++/External/Eigen + url = https://gitlab.com/libeigen/eigen.git +[submodule "C++/External/Json"] + path = C++/External/Json + url = https://github.com/nlohmann/json.git diff --git a/C++/.gitignore b/C++/.gitignore index 6e48a56..6ae2a50 100644 --- a/C++/.gitignore +++ b/C++/.gitignore @@ -1,6 +1,6 @@ # Project specific excludes -/External/ /MPCC +/build # CMake CMakeCache.txt diff --git a/C++/CMakeLists.txt b/C++/CMakeLists.txt index 9e68a36..921a4e3 100644 --- a/C++/CMakeLists.txt +++ b/C++/CMakeLists.txt @@ -11,6 +11,9 @@ include_directories(External/matplotlib) include_directories(External/Eigen) include_directories(External/Json/include) +add_subdirectory(External/blasfeo) +add_subdirectory(External/hpipm) + add_executable(MPCC main.cpp types.cpp @@ -40,4 +43,4 @@ find_package(Python COMPONENTS Development) target_include_directories(MPCC PRIVATE ${Python_INCLUDE_DIRS}) target_link_libraries(MPCC ${Python_LIBRARIES}) -target_link_libraries(MPCC ${CMAKE_SOURCE_DIR}/External/hpipm/lib/lib/libhpipm.a ${CMAKE_SOURCE_DIR}/External/blasfeo/lib/lib/libblasfeo.a m) +target_link_libraries(MPCC hpipm blasfeo m) diff --git a/C++/External/Eigen b/C++/External/Eigen new file mode 160000 index 0000000..f6cf5dc --- /dev/null +++ b/C++/External/Eigen @@ -0,0 +1 @@ +Subproject commit f6cf5dca802d3fe82c8f5330c6c84ddfb38f5c08 diff --git a/C++/External/Json b/C++/External/Json new file mode 160000 index 0000000..6af826d --- /dev/null +++ b/C++/External/Json @@ -0,0 +1 @@ +Subproject commit 6af826d0bdb55e4b69e3ad817576745335f243ca diff --git a/C++/External/blasfeo b/C++/External/blasfeo new file mode 160000 index 0000000..ca9e5a6 --- /dev/null +++ b/C++/External/blasfeo @@ -0,0 +1 @@ +Subproject commit ca9e5a6bc8955d339e99bdb81920a9f1a1b15260 diff --git a/C++/External/hpipm b/C++/External/hpipm new file mode 160000 index 0000000..5694905 --- /dev/null +++ b/C++/External/hpipm @@ -0,0 +1 @@ +Subproject commit 56949058ad9db99eeb8fdc6b2971d127c95b51e1 diff --git a/C++/External/matplotlib b/C++/External/matplotlib new file mode 160000 index 0000000..ef0383f --- /dev/null +++ b/C++/External/matplotlib @@ -0,0 +1 @@ +Subproject commit ef0383f1315d32e0156335e10b82e90b334f6d9f diff --git a/C++/README.md b/C++/README.md index b4ca7dc..1fe6c57 100644 --- a/C++/README.md +++ b/C++/README.md @@ -40,11 +40,11 @@ Currently, only one track and car model is implemented. However, adapting the pa ## Installation -To install all the dependencies run +To download dependencies, either clone with the `--recurse-submodules` flag, or run the following after cloning: ``` -./install.sh +git submodule update --init ``` -this clones `blasfeo`, `hpipm`, `matplotlip-cpp`, `nlohmann/json`, and `eigen`, from their git repo, and safes them in a folder External. Additionally, it installs `blasfeo` and `hpipm` in the same External folder, thus no admin rights are necessary. +this clones `blasfeo`, `hpipm`, `matplotlip-cpp`, `nlohmann/json`, and `eigen`, from their git repo, and safes them in a folder External. `blasfeo` and `hpipm` are built by cmake while you are building this repository, with no admin permissions needed. Note that `matplotlib-cpp` does also require `Python-2.7` and `matplotlib`, for more details see (https://github.com/lava/matplotlib-cpp). diff --git a/C++/install.sh b/C++/install.sh deleted file mode 100755 index c00a405..0000000 --- a/C++/install.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -## Copyright 2019 Alexander Liniger - -## Licensed under the Apache License, Version 2.0 (the "License"); -## you may not use this file except in compliance with the License. -## You may obtain a copy of the License at - -## http://www.apache.org/licenses/LICENSE-2.0 - -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -########################################################################### -########################################################################### -## Install dependencies -set -e - -## clone blasfeo -repository_blasfeo="https://github.com/giaf/blasfeo.git" -localFolder_blasfeo="External/blasfeo" -git clone "$repository_blasfeo" "$localFolder_blasfeo" -## clone hpipm -repository_hpipm="https://github.com/giaf/hpipm.git" -localFolder_hpipm="External/hpipm" -git clone "$repository_hpipm" "$localFolder_hpipm" -## clone matplotlib-cpp -repository_matplotlib="https://github.com/lava/matplotlib-cpp.git" -localFolder_matplotlib="External/matplotlib" -git clone "$repository_matplotlib" "$localFolder_matplotlib" -## clone eigne -repository_eigen="https://gitlab.com/libeigen/eigen.git" -localFolder_eigen="External/Eigen" -git clone "$repository_eigen" "$localFolder_eigen" -## clone json -repository_json="https://github.com/nlohmann/json.git" -localFolder_json="External/Json" -git clone "$repository_json" "$localFolder_json" - - -cd External/blasfeo -mkdir -p build -mkdir -p lib -cd build -cmake .. -DCMAKE_INSTALL_PREFIX=$(realpath ../lib) -make -make install - -cd ../../hpipm -mkdir -p build -mkdir -p lib -cd build -cmake .. -DCMAKE_INSTALL_PREFIX=$(realpath ../lib) -DBLASFEO_PATH=$(realpath ../../blasfeo/lib) -make -make install