Permalink
Browse files

CMake for qpOASES (#94)

* Give qpOASES its own CMakeLists

* Add math library to qpOASES

* disable rpath in qpOASES

* test octave cache

* try fixing relocation error

* debugging travis..

* Trying fix weird error where only 1 build fails

* add cache also to my remote

* further travis debugging

* Add test for clang

* Install qpOASES the proper way

* Revive unit tests

* Cleanup build output

* Fix python and matlab finding

* include qpOASES as subdirectory instead of external project

* add PIC

* Only run test if MATLAB is present

* Add c99 to examples

* Include qpDUNES as subdir

* Remove Test build type

* Remove some more flags
  • Loading branch information...
roversch committed Jun 14, 2017
1 parent 4b30102 commit 2e772b59a123e46fcf26006368eb5d7702c06872
View
@@ -0,0 +1,11 @@
#!/bin/bash
# http://stackoverflow.com/questions/151677/tool-for-adding-license-headers-to-source-files
DIRECTORY=$*
for i in $DIRECTORY # or whatever other pattern...
do
if ! grep -q MERCHANTABILITY $i
then
cat COPYING $i >$i.new && mv $i.new $i
echo $i
fi
done
View
@@ -5,10 +5,10 @@ python:
- 3.5
env:
- CXX="g++-6" CC="gcc-6" SWIG_PYTHON=1 SWIG_MATLAB=0 # no MATLAB support for gcc>=5
- CXX="g++-5" CC="gcc-5" SWIG_PYTHON=1 SWIG_MATLAB=0
- CXX="g++-4.9" CC="gcc-4.9" SWIG_PYTHON=1 SWIG_MATLAB=1 COVERAGE="lcov"
- CXX="clang++-3.7" CC="clang-3.7" SWIG_PYTHON=1 SWIG_MATLAB=1
- CXX="g++-6" CC="gcc-6" SWIG_PYTHON=ON SWIG_MATLAB=OFF # no MATLAB support for gcc>=5
- CXX="g++-5" CC="gcc-5" SWIG_PYTHON=ON SWIG_MATLAB=OFF
- CXX="g++-4.9" CC="gcc-4.9" SWIG_PYTHON=ON SWIG_MATLAB=ON COVERAGE="lcov"
- CXX="clang++-3.7" CC="clang-3.7" SWIG_PYTHON=ON SWIG_MATLAB=ON
addons:
apt:
@@ -40,26 +40,22 @@ install:
before_script:
- set -e
- mkdir -p /home/travis/octave_download/
- pushd /home/travis/octave_download/
- mkdir -p /home/travis/octave_download
- pushd /home/travis/octave_download
- wget http://packages.octave.org/download/optim-1.5.2.tar.gz
- wget http://packages.octave.org/download/struct-1.0.14.tar.gz
- popd
- ls -la /home/travis/octave_download
script:
- cmake -E make_directory build
- cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Test -DSWIG_MATLAB=$SWIG_MATLAB -DSWIG_PYTHON=$SWIG_PYTHON -DCOVERAGE=$COVERAGE ..
- cmake --build build --clean-first
- cmake -E chdir build cmake -DCMAKE_BUILD_TYPE=Debug -DUNIT_TESTS=ON -DSWIG_MATLAB=$SWIG_MATLAB -DSWIG_PYTHON=$SWIG_PYTHON -DCOVERAGE=$COVERAGE ..
- cmake --build build --target install
- cmake --build build --target lint
- cmake --build build --target acados_coverage || echo "Coverage report not generated"
- cmake -E chdir build ctest --output-on-failure
- cmake --build build --target test
- cmake -E chdir build cmake -D CMAKE_BUILD_TYPE=Release ..
- cmake --build build --clean-first
- cmake -E chdir build cmake -D CMAKE_BUILD_TYPE=Debug ..
- cmake --build build --clean-first
#- pushd experimental/dang/esp32
#- ./test_all_linux.sh
after_success:
- pushd ${TRAVIS_BUILD_DIR}/build/test
View
@@ -21,69 +21,45 @@ cmake_minimum_required(VERSION 3.2)
project(acados LANGUAGES C CXX)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
set(CMAKE_SKIP_RPATH TRUE) # Seems necessary for Mac OSX
set(CMAKE_VERBOSE_MAKEFILE OFF)
# Set default compile flags for GCC
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Werror -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -fPIC")
endif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
# Set up build type
if(NOT CMAKE_BUILD_TYPE)
message("\n-- No build type chosen. Valid build types are:"
"\n Release (default), Debug, Test, NoExternalLibs")
set(CMAKE_BUILD_TYPE Release)
endif()
message("\n\n --- Configuring acados with build type: ${CMAKE_BUILD_TYPE} ---\n\n")
if(CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES NoExternalLibs)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -funroll-loops -fdiagnostics-show-option")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -funroll-loops -fdiagnostics-show-option")
set(CMAKE_BUILD_TYPE Release
CACHE STRING "No build type chosen. Valid build types are: \
Release (default), None, Debug, NoExternalLibs, RelWithDebInfo, MinSizeRel." FORCE)
endif()
message(STATUS "Build type is ${CMAKE_BUILD_TYPE}")
if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DDEBUG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wno-unused-function -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wno-unused-function -Wno-unused-parameter")
endif()
if(CMAKE_BUILD_TYPE MATCHES Test)
enable_testing(true)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif()
enable_testing(true)
# Set install and executable output directories
# Set install directories
if(NOT ACADOS_INSTALL_DIR)
set(ACADOS_INSTALL_DIR "$ENV{HOME}/local")
endif()
set(CMAKE_INSTALL_PREFIX ${ACADOS_INSTALL_DIR})
set(LIBRARY_OUTPUT_PATH "${CMAKE_INSTALL_PREFIX}/lib")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
message(STATUS "acados will be installed in ${CMAKE_INSTALL_PREFIX}")
set(CMAKE_INSTALL_PREFIX ${ACADOS_INSTALL_DIR}
CACHE STRING "Install path prefix, prepended onto install directories." FORCE)
set(CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}/share")
message(STATUS "Installation directory is ${CMAKE_INSTALL_PREFIX}")
# Configure external libraries
set(EXTERNAL_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external)
add_subdirectory(${EXTERNAL_SRC_DIR})
# Configure acados
set(ACADOS_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/acados)
add_subdirectory(acados)
# Add examples
set(EXAMPLES_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/examples)
add_subdirectory(${EXAMPLES_SRC_DIR})
add_subdirectory(examples)
# Configure SWIG interface
if(NOT CMAKE_BUILD_TYPE MATCHES NoExternalLibs)
add_subdirectory(swig)
endif()
# Generate test data and configure unit tests
if(CMAKE_BUILD_TYPE MATCHES Test)
if(UNIT_TESTS)
add_subdirectory(test)
endif()
View
19 COPYING
@@ -0,0 +1,19 @@
#
# This file is part of acados.
#
# acados is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# acados is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with acados; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
#
View
@@ -17,40 +17,42 @@
#
#
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Werror -fdiagnostics-show-option")
elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -WX")
endif()
# Only test acados library for coverage
if((CMAKE_BUILD_TYPE MATCHES Test) AND (COVERAGE MATCHES "lcov"))
if(COVERAGE MATCHES "lcov")
include(CodeCoverage)
setup_target_for_coverage(acados_coverage ctest coverage)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -fprofile-arcs -ftest-coverage")
endif()
# Build list with all source files to go into the acados library
file(GLOB_RECURSE ACADOS_SRC ${PROJECT_SOURCE_DIR}/acados/*.c)
file(GLOB_RECURSE ACADOS_SRC "${PROJECT_SOURCE_DIR}/acados/*.c")
# Exclude helper files
list(REMOVE_ITEM ACADOS_SRC ${PROJECT_SOURCE_DIR}/acados/ocp_qp/condensing_helper_functions.c)
list(REMOVE_ITEM ACADOS_SRC "${PROJECT_SOURCE_DIR}/acados/ocp_qp/condensing_helper_functions.c")
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/external/OOQP)
list(REMOVE_ITEM ACADOS_SRC ${PROJECT_SOURCE_DIR}/acados/ocp_qp/ocp_qp_ooqp.c)
list(REMOVE_ITEM ACADOS_SRC "${PROJECT_SOURCE_DIR}/acados/ocp_qp/ocp_qp_ooqp.c")
endif()
# Define acados library
add_library(acados STATIC ${ACADOS_SRC})
target_include_directories(acados
PUBLIC
"${ACADOS_SRC_DIR}/.."
"${EXTERNAL_SRC_DIR}"
"${EXTERNAL_SRC_DIR}/qpDUNES-dev/include/"
"${EXTERNAL_SRC_DIR}/qpOASES/include/"
)
target_link_libraries(acados
PRIVATE
qpoases
hpmpc
blasfeo
qpdunes
m
)
"${CMAKE_CURRENT_SOURCE_DIR}/.." # for include "acados/..."
"${EXTERNAL_SRC_DIR}")
target_link_libraries(acados PUBLIC qpOASES_e hpmpc blasfeo qpdunes)
if(CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(acados PRIVATE DEBUG)
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/external/OOQP AND NOT CMAKE_BUILD_TYPE MATCHES NoExternalLibs)
target_compile_definitions(acados PRIVATE OOQP)
@@ -63,8 +65,7 @@ if(EXISTS ${PROJECT_SOURCE_DIR}/external/OOQP AND NOT CMAKE_BUILD_TYPE MATCHES N
ma27
blas
${FORTRAN_LIBRARY}
m
)
m)
endif()
if(COVERAGE MATCHES "lcov")
@@ -14,11 +14,13 @@ endif()
ExternalProject_Add(
blasfeo_project
CONFIGURE_COMMAND ""
CONFIGURE_COMMAND make clean
SOURCE_DIR "${PROJECT_SOURCE_DIR}/external/blasfeo"
BUILD_IN_SOURCE 1
BUILD_COMMAND make clean && make static_library -j 2 TARGET=${BLASFEO_TARGET} LA=${BLASFEO_LA}
INSTALL_COMMAND cmake -E echo "Skipping install"
BUILD_COMMAND make static_library -j 2 TARGET=${BLASFEO_TARGET} LA=${BLASFEO_LA}
INSTALL_COMMAND ""
LOG_CONFIGURE 1 # suppress output
LOG_BUILD 1
)
ExternalProject_Get_Property(blasfeo_project source_dir)
@@ -13,11 +13,13 @@ ExternalProject_Add(
hpmpc_project
DEPENDS blasfeo
CONFIGURE_COMMAND ""
CONFIGURE_COMMAND make clean
SOURCE_DIR "${PROJECT_SOURCE_DIR}/external/hpmpc"
BUILD_IN_SOURCE 1
BUILD_COMMAND make clean && make static_library -j 2 TARGET=${HPMPC_TARGET} BLASFEO_PATH=${HPMPC_BLASFEO_PATH}
BUILD_COMMAND make static_library -j 2 TARGET=${HPMPC_TARGET} BLASFEO_PATH=${HPMPC_BLASFEO_PATH}
INSTALL_COMMAND ""
LOG_CONFIGURE 1 # suppress output
LOG_BUILD 1
)
ExternalProject_Get_Property(hpmpc_project source_dir)
@@ -8,6 +8,8 @@ ExternalProject_Add(
BUILD_IN_SOURCE 1
BUILD_COMMAND make
INSTALL_COMMAND ""
LOG_CONFIGURE 1 # suppress output
LOG_BUILD 1
)
ExternalProject_Add_Step(ma27_project cp_lib
@@ -19,6 +19,8 @@ ExternalProject_Add(
BUILD_IN_SOURCE 1
BUILD_COMMAND make
INSTALL_COMMAND ""
LOG_CONFIGURE 1 # suppress output
LOG_BUILD 1
)
ExternalProject_Get_Property(ooqp_project source_dir)
@@ -8,6 +8,8 @@ ExternalProject_Add(
CONFIGURE_COMMAND cmake ..
BUILD_COMMAND make
INSTALL_COMMAND ""
LOG_CONFIGURE 1 # suppress output
LOG_BUILD 1
)
ExternalProject_Get_Property(qpdunes_project source_dir)
@@ -5,12 +5,11 @@ ExternalProject_Add(
CONFIGURE_COMMAND ""
SOURCE_DIR "${PROJECT_SOURCE_DIR}/external/qpOASES"
BUILD_IN_SOURCE 1
BUILD_COMMAND make
BINARY_DIR "${PROJECT_SOURCE_DIR}/external/qpOASES/build"
CONFIGURE_COMMAND cmake -D CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} ..
BUILD_COMMAND cmake --build .
# INSTALL_COMMAND cmake --build . --target install
INSTALL_COMMAND ""
LOG_CONFIGURE 1 # suppress output
LOG_BUILD 1
)
ExternalProject_Get_Property(qpoases_project source_dir)
add_library(qpoases STATIC IMPORTED GLOBAL)
add_dependencies(qpoases qpoases_project)
set_property(TARGET qpoases PROPERTY IMPORTED_LOCATION "${source_dir}/bin/libqpOASES_e.a")
Oops, something went wrong.

0 comments on commit 2e772b5

Please sign in to comment.