Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
Remove CasADi backend (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacey-sooty authored Jun 20, 2024
1 parent 4df4263 commit 3c62764
Showing 15 changed files with 6 additions and 1,029 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/build-rust.yml
Original file line number Diff line number Diff line change
@@ -13,26 +13,6 @@ jobs:
fail-fast: false
matrix:
include:
- artifact-name: Rust Native - Windows x86_64 (CasADi)
optimizer_backend: casadi
os: windows-2022
cmake-env:
cargo-build-flags:
- artifact-name: Rust Native - macOS x86_64 (CasADi)
optimizer_backend: casadi
os: macOS-14
cmake-env: CMAKE_OSX_ARCHITECTURES="x86_64"
cargo-build-flags:
- artifact-name: Rust Native - macOS arm64 (CasADi)
optimizer_backend: casadi
os: macOS-14
cmake-env: CMAKE_OSX_ARCHITECTURES="arm64"
cargo-build-flags:
- artifact-name: Rust Native - Linux x86_64 (CasADi)
optimizer_backend: casadi
os: ubuntu-24.04
cmake-env:
cargo-build-flags:
- artifact-name: Rust Native - Windows x86_64 (Sleipnir)
optimizer_backend: sleipnir
os: windows-2022
@@ -65,18 +45,6 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set to Windows GNU Rust Toolchain
if: matrix.os == 'windows-2022' && matrix.optimizer_backend == 'casadi'
run: |
rustup install 1.76-gnu
rustup default 1.76-gnu
- name: Set up MinGW
if: matrix.os == 'windows-2022' && matrix.optimizer_backend == 'casadi'
run: |
choco upgrade mingw --version=11.2.0 -y --no-progress --allow-downgrade
echo C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin >> $env:GITHUB_PATH
- name: Set up Windows aarch64 Rust compiler
if: matrix.artifact-name == 'Rust Native - Windows aarch64 (Sleipnir)'
run: rustup target install aarch64-pc-windows-msvc
23 changes: 0 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -13,23 +13,6 @@ jobs:
fail-fast: false
matrix:
include:
- artifact-name: Native - Windows (CasADi)
# FIXME: Tests give "Exit code 0xc0000135" for missing DLLs
cmake-args: "-G \"MinGW Makefiles\" -DBUILD_TESTING=OFF"
optimizer_backend: casadi
os: windows-2022
- artifact-name: Native - macOS x86_64 (CasADi)
cmake-args: -DCMAKE_OSX_ARCHITECTURES="x86_64"
optimizer_backend: casadi
os: macOS-14
- artifact-name: Native - macOS arm64 (CasADi)
cmake-args: -DCMAKE_OSX_ARCHITECTURES="arm64"
optimizer_backend: casadi
os: macOS-14
- artifact-name: Native - Linux x86_64 (CasADi)
cmake-args:
optimizer_backend: casadi
os: ubuntu-24.04
- artifact-name: Native - Windows x86_64 (Sleipnir)
# FIXME: Tests give "Exit code 0xc0000135" for missing DLLs
cmake-args: "-DCMAKE_GENERATOR_PLATFORM=x64 -DBUILD_TESTING=OFF"
@@ -55,12 +38,6 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up MinGW
if: matrix.os == 'windows-2022' && matrix.optimizer_backend == 'casadi'
run: |
choco upgrade mingw --version=11.2.0 -y --no-progress --allow-downgrade
echo C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin >> $env:GITHUB_PATH
- name: Make GCC 14 the default toolchain (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: |
2 changes: 0 additions & 2 deletions .github/workflows/lint-format.yml
Original file line number Diff line number Diff line change
@@ -102,6 +102,4 @@ jobs:
- run: cargo fmt --check

- run: cargo clippy --features casadi -- -D warnings

- run: cargo clippy --features sleipnir -- -D warnings
9 changes: 0 additions & 9 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
@@ -22,15 +22,6 @@ jobs:
- sanitizer-name: ubsan
cmake-args: "-DCMAKE_BUILD_TYPE=Ubsan"
optimizer_backend: sleipnir
- sanitizer-name: asan
cmake-args: "-DCMAKE_BUILD_TYPE=Asan"
optimizer_backend: casadi
- sanitizer-name: tsan
cmake-args: "-DCMAKE_BUILD_TYPE=Tsan"
optimizer_backend: casadi
- sanitizer-name: ubsan
cmake-args: "-DCMAKE_BUILD_TYPE=Ubsan"
optimizer_backend: casadi

name: "${{ matrix.sanitizer-name }} with ${{ matrix.optimizer_backend }}"
runs-on: ubuntu-24.04
49 changes: 3 additions & 46 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -67,11 +67,6 @@ option(BUILD_EXAMPLES "Build examples" OFF)
include(CompilerFlags)

file(GLOB_RECURSE src src/*.cpp)
if(${OPTIMIZER_BACKEND} STREQUAL "casadi")
list(FILTER src EXCLUDE REGEX "SleipnirOpti.cpp")
elseif(${OPTIMIZER_BACKEND} STREQUAL "sleipnir")
list(FILTER src EXCLUDE REGEX "CasADiOpti.cpp")
endif()
list(FILTER src EXCLUDE REGEX trajoptlibrust.cpp)

add_library(TrajoptLib ${src})
@@ -99,37 +94,10 @@ if(BUILD_TESTING)
fetchcontent_makeavailable(Catch2)
endif()

set(OPTIMIZER_BACKEND "casadi" CACHE STRING "Optimizer backend")
set_property(CACHE OPTIMIZER_BACKEND PROPERTY STRINGS casadi sleipnir)

if(${OPTIMIZER_BACKEND} STREQUAL "casadi")
message(STATUS "Using CasADi optimizer")

include(FetchCasADi)
fetch_casadi()
target_compile_definitions(TrajoptLib PRIVATE OPTIMIZER_BACKEND_CASADI)
target_include_directories(TrajoptLib SYSTEM PRIVATE ${CASADI_INCLUDEDIR})
target_link_directories(TrajoptLib PRIVATE ${CASADI_LIBDIR})
target_link_libraries(TrajoptLib PRIVATE casadi)

# Add current directory to RPATH
if(APPLE)
set_property(
TARGET TrajoptLib
APPEND
PROPERTY INSTALL_RPATH "@loader_path/../lib;@loader_path"
)
elseif(UNIX)
set_property(
TARGET TrajoptLib
APPEND
PROPERTY INSTALL_RPATH "$ORIGIN/../lib;$ORIGIN"
)
endif()
set(OPTIMIZER_BACKEND "sleipnir" CACHE STRING "Optimizer backend")
set_property(CACHE OPTIMIZER_BACKEND PROPERTY STRINGS sleipnir)

# Install CasADi libraries since FetchContent isn't setting that up properly
install(FILES ${CASADI_INSTALL_LIBS} DESTINATION ${CASADI_INSTALL_DEST})
elseif(${OPTIMIZER_BACKEND} STREQUAL "sleipnir")
if(${OPTIMIZER_BACKEND} STREQUAL "sleipnir")
message(STATUS "Using Sleipnir optimizer")

set(BUILD_TESTING_SAVE ${BUILD_TESTING})
@@ -202,17 +170,6 @@ if(BUILD_TESTING)
enable_testing()
list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras)
include(Catch)
if(
${OPTIMIZER_BACKEND} STREQUAL "casadi"
AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux"
AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU"
)
target_compile_definitions(Catch2 PUBLIC "_GLIBCXX_USE_CXX11_ABI=0")
target_compile_definitions(
Catch2WithMain
PUBLIC "_GLIBCXX_USE_CXX11_ABI=0"
)
endif()
endif()

# Build TrajoptLib tests
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@ cmake = "0.1"
[features]
default = []
sleipnir = []
casadi = []

[[example]]
name = "swerve"
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -30,7 +30,6 @@ Trajectory optimization works by mathematically formulating the problem of trave
* On macOS, install via `brew install cmake`
* [Rust](https://www.rust-lang.org/) compiler
* [Sleipnir](https://github.com/SleipnirGroup/Sleipnir) (optional backend)
* [CasADi](https://github.com/casadi/casadi) (optional backend)
* [Catch2](https://github.com/catchorg/Catch2) (tests only)

Library dependencies which aren't installed locally will be automatically downloaded and built by CMake.
@@ -47,9 +46,6 @@ cd TrajoptLib
# Configure with Sleipnir backend; automatically downloads library dependencies
cmake -B build -S . -DOPTIMIZER_BACKEND=sleipnir

# Configure with CasADi backend; automatically downloads library dependencies
cmake -B build -S . -DOPTIMIZER_BACKEND=casadi

# Build
cmake --build build

@@ -83,5 +79,4 @@ git clone git@github.com:SleipnirGroup/TrajoptLib
cd TrajoptLib

cargo build --features sleipnir # Sleipnir backend
cargo build --features casadi # CasADi backend
```
30 changes: 1 addition & 29 deletions build.rs
Original file line number Diff line number Diff line change
@@ -7,10 +7,6 @@ fn main() {
.profile("Release")
.define("BUILD_TESTING", "OFF");

if cfg!(feature = "sleipnir") && cfg!(feature = "casadi") {
panic!("Only select one optimizer backend via cargo `--features sleipnir` or `--features casadi`.");
}

if cfg!(feature = "sleipnir") {
cmake_config
.define("OPTIMIZER_BACKEND", "sleipnir")
@@ -21,28 +17,8 @@ fn main() {
.generator("Visual Studio 17 2022")
.cxxflag("/EHsc");
}
} else if cfg!(feature = "casadi") {
cmake_config.define("OPTIMIZER_BACKEND", "casadi");

if cfg!(target_os = "windows") {
cmake_config
.generator("MinGW Makefiles")
.define("CMAKE_CXX_COMPILER", "x86_64-w64-mingw32-g++")
.define("CMAKE_C_COMPILER", "x86_64-w64-mingw32-gcc")
.define(
"CMAKE_SHARED_LINKER_FLAGS",
"-static-libgcc -static-libstdc++",
)
.define("CMAKE_EXE_LINKER_FLAGS", "-static-libgcc -static-libstdc++");
} else if cfg!(target_os = "linux") {
cmake_config
.define("CMAKE_CXX_COMPILER", "g++")
.define("CMAKE_C_COMPILER", "gcc");
}
} else {
panic!(
"Select an optimizer backend via cargo `--features sleipnir` or `--features casadi`."
);
panic!("Select an optimizer backend via cargo `--features sleipnir`.");
}

let cmake_dest = cmake_config.build();
@@ -55,10 +31,6 @@ fn main() {
.include(format!("{}/include", cmake_dest.display()))
.std("c++20");

if cfg!(feature = "casadi") && cfg!(target_os = "linux") {
bridge_build.define("_GLIBCXX_USE_CXX11_ABI", "0");
}

bridge_build.compile("trajoptrust");

println!(
11 changes: 0 additions & 11 deletions cmake/modules/CompilerFlags.cmake
Original file line number Diff line number Diff line change
@@ -4,17 +4,6 @@ macro(compiler_flags target)
${target}
PRIVATE -Wall -pedantic -Wextra -Werror -Wno-unused-parameter
)

if(
${OPTIMIZER_BACKEND} STREQUAL "casadi"
AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux"
AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU"
)
target_compile_definitions(
${target}
PRIVATE _GLIBCXX_USE_CXX11_ABI=0
)
endif()
else()
# Suppress the following warnings:
# * C4244: lossy conversion
114 changes: 0 additions & 114 deletions cmake/modules/FetchCasADi.cmake

This file was deleted.

Loading

0 comments on commit 3c62764

Please sign in to comment.