Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions .github/workflows/PR_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
## Summary
<!-- Provide 2-3 bullet points summarizing the key changes and their purpose -->
-
-
<!-- Summarize the change and why it is needed. -->
-

## Changes
<!-- List the specific changes made, grouped by component or functionality -->
- **Component/Feature**: Description of changes
- **Another Component**: Description of changes
<!-- List the concrete code, API, or documentation changes. -->
-

## Test Plan
<!-- Checklist of tests to validate the changes -->
- [ ] Test item 1
- [ ] Test item 2
- [ ] Test item 3
<!-- List the commands run or explain why testing was not performed. -->
- [ ]

## Additional Notes
<!-- Any additional context, design decisions, or concerns for reviewers -->
## Notes
<!-- Add reviewer context only when it is needed. -->
41 changes: 41 additions & 0 deletions .github/workflows/python-dependency-guard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Python Dependency Guard

on:
pull_request:
branches: [ master ]
paths:
- "pyproject.toml"
- "uv.lock"
- "security/python-direct-deps-allowlist.txt"
- "tools/check_python_dependency_policy.py"

permissions:
contents: read

jobs:
policy:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Enforce dependency policy
run: python tools/check_python_dependency_policy.py --base-ref "origin/${{ github.base_ref }}"

dependency-review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check dependency review
uses: actions/dependency-review-action@v4
with:
fail-on-severity: high
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ pdf_images/

# Solver output
solver_snopt.out

# Python / uv
.venv/
uv.lock
*.egg-info/
__pycache__/
*.so
*.pyd
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
93 changes: 66 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ project(
HOMEPAGE_URL "https://github.com/astomodynamics/cddp-cpp"
)

include(GNUInstallDirs)

set(CMAKE_CXX_STANDARD 17) # Enforce C++17 as the minimum standard
set(CMAKE_CXX_STANDARD_REQUIRED ON) # Enforce C++17 as the minimum standard
set(ABSL_PROPAGATE_CXX_STD ON) # Enforce C++17 for absl
Expand All @@ -43,6 +45,7 @@ endif()

# Options
option(CDDP_CPP_BUILD_TESTS "Whether to build tests." ON)
option(CDDP_CPP_BUILD_EXAMPLES "Whether to build examples." ON)

# CasADi Configuration
option(CDDP_CPP_CASADI "Whether to use CasADi" OFF)
Expand Down Expand Up @@ -92,16 +95,6 @@ endif()
# Enable FetchContent for downloading dependencies
include(FetchContent)

# Matplotplusplus
FetchContent_Declare(matplotplusplus
GIT_REPOSITORY https://github.com/alandefreitas/matplotplusplus
GIT_TAG origin/master) # or whatever tag you want
FetchContent_GetProperties(matplotplusplus)
if(NOT matplotplusplus_POPULATED)
FetchContent_Populate(matplotplusplus)
add_subdirectory(${matplotplusplus_SOURCE_DIR} ${matplotplusplus_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

# autodiff
set(AUTODIFF_BUILD_TESTS OFF CACHE BOOL "Don't build autodiff tests")
set(AUTODIFF_BUILD_EXAMPLES OFF CACHE BOOL "Don't build autodiff examples")
Expand All @@ -116,6 +109,7 @@ FetchContent_MakeAvailable(autodiff)
# Googletest
if (CDDP_CPP_BUILD_TESTS)
enable_testing()
set(INSTALL_GTEST OFF CACHE BOOL "Don't install GTest alongside cddp" FORCE)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
Expand Down Expand Up @@ -172,29 +166,33 @@ set(dynamics_model_srcs
src/dynamics_model/euler_attitude.cpp
)

add_library(${PROJECT_NAME}
add_library(${PROJECT_NAME}
${cddp_core_srcs}
${dynamics_model_srcs}
)

Comment thread
astomodynamics marked this conversation as resolved.
target_link_libraries(${PROJECT_NAME}
$<IF:$<BOOL:${Eigen3_FOUND}>,Eigen3::Eigen,>
matplot
autodiff
)
# Enable position-independent code (required for Python shared library linking)
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)

target_link_libraries(${PROJECT_NAME}
PUBLIC
$<IF:$<BOOL:${Eigen3_FOUND}>,Eigen3::Eigen,>
autodiff
)

if(NOT Eigen3_FOUND)
target_include_directories(${PROJECT_NAME} PUBLIC ${EIGEN3_INCLUDE_DIRS})
endif()

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/cddp-cpp>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cddp-cpp>
)

if (CDDP_CPP_CASADI)
target_include_directories(${PROJECT_NAME} PUBLIC ${CASADI_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${CASADI_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PRIVATE ${CASADI_LIBRARIES})
endif()

# ACADOS
Expand Down Expand Up @@ -241,7 +239,7 @@ if (CDDP_CPP_ACADOS)
include_directories(${BLASFEO_INCLUDE_DIR})
include_directories(${HPIPM_INCLUDE_DIR})
link_directories(${ACADOS_LIB_DIR})
target_link_libraries(${PROJECT_NAME} ${ACADOS_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PRIVATE ${ACADOS_LIBRARIES})

# Add preprocessor definition to enable ACADOS in code
target_compile_definitions(${PROJECT_NAME} PRIVATE CDDP_CPP_ACADOS_ENABLED=1)
Expand All @@ -258,11 +256,52 @@ if (CDDP_CPP_BUILD_TESTS)
endif()

# Build examples
add_subdirectory(examples)

# Cmake compile commmand:
# $ mkdir build
# $ cd build
# $ cmake -DCDDP_CPP_BUILD_TESTS=ON -DCDDP_CPP_CASADI=ON ..
# $ make -j4
# $ make test
if (CDDP_CPP_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

# Python bindings (optional)
option(CDDP_CPP_BUILD_PYTHON "Build Python bindings" OFF)
if(CDDP_CPP_BUILD_PYTHON)
add_subdirectory(python)
endif()

# Install targets
include(CMakePackageConfigHelpers)

install(TARGETS ${PROJECT_NAME}
EXPORT cddpTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(DIRECTORY include/cddp-cpp/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cddp-cpp
FILES_MATCHING PATTERN "*.hpp"
)

install(EXPORT cddpTargets
FILE cddpTargets.cmake
NAMESPACE cddp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cddp
)

configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/cddpConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cddpConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cddp
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cddpConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/cddpConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/cddpConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cddp
)
24 changes: 9 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins
curl \
git \
wget \
libjpeg-dev \
libpng-dev \
gnuplot \
libeigen3-dev && \
rm -rf /var/lib/apt/lists/*

Expand All @@ -31,15 +28,12 @@ WORKDIR /app
COPY . /app


# # Configure and build your project
RUN rm -rf build && \
mkdir build && \
cd build && \
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCDDP_CPP_BUILD_TESTS=ON \
-DCDDP_CPP_CASADI=OFF \
-DPython_EXECUTABLE=/usr/bin/python3 \
.. && \
make -j$(nproc) && \
make test
# Configure and build the project
RUN rm -rf build && \
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCDDP_CPP_BUILD_TESTS=ON \
-DCDDP_CPP_BUILD_EXAMPLES=ON \
-DCDDP_CPP_CASADI=OFF && \
cmake --build build -j$(nproc) && \
ctest --test-dir build --output-on-failure
Loading
Loading