Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
os: [ubuntu-latest, windows-latest, macos-14]

Comment thread
astomodynamics marked this conversation as resolved.
steps:
- name: Check out repository
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
os: [ubuntu-latest, windows-latest, macos-14]

Comment thread
astomodynamics marked this conversation as resolved.
steps:
- name: Check out repository
Expand All @@ -57,8 +57,8 @@ jobs:
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: cp310-* cp311-* cp312-* cp313-*
CIBW_SKIP: *-musllinux_* *-win32
CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-*"
CIBW_SKIP: "*-musllinux_* *-win32"
CIBW_ARCHS_LINUX: auto64
CIBW_ARCHS_WINDOWS: auto64
CIBW_ARCHS_MACOS: auto64
Expand Down
33 changes: 23 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,33 @@ find_package(Eigen3 3.4 QUIET NO_MODULE)
# If Eigen3 is not found, fetch it and expose a proper Eigen3::Eigen target
if(NOT Eigen3_FOUND)
message(STATUS "Eigen3 not found. Downloading...")
# Fetch Eigen as header-only: SOURCE_SUBDIR points at a path with no
# CMakeLists.txt so MakeAvailable downloads the source without running
# Eigen's CMake. This avoids slow configure probes (Fortran, Qt, CUDA)
# and a target name collision with the real autodiff library.
FetchContent_Declare(
eigen
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3.4.0
SOURCE_SUBDIR _unused
)
FetchContent_MakeAvailable(eigen)

# Point Eigen3_DIR to the build directory where Eigen3Config.cmake is generated
# so that downstream find_package(Eigen3) calls (e.g., from autodiff) can find it
set(Eigen3_DIR "${eigen_BINARY_DIR}" CACHE PATH "Path to Eigen3Config.cmake" FORCE)
add_library(Eigen3::Eigen INTERFACE IMPORTED)
set_target_properties(Eigen3::Eigen PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${eigen_SOURCE_DIR}"
)

# Ensure Eigen3::Eigen target exists for direct usage
if(NOT TARGET Eigen3::Eigen)
add_library(Eigen3::Eigen INTERFACE IMPORTED)
set_target_properties(Eigen3::Eigen PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${eigen_SOURCE_DIR}"
)
endif()
# Write a minimal Eigen3Config.cmake so autodiff's find_package(Eigen3)
# finds it without needing Eigen's full configure step
file(WRITE "${eigen_BINARY_DIR}/Eigen3Config.cmake"
"set(Eigen3_FOUND TRUE)\n"
"if(NOT TARGET Eigen3::Eigen)\n"
" add_library(Eigen3::Eigen INTERFACE IMPORTED)\n"
" set_target_properties(Eigen3::Eigen PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"${eigen_SOURCE_DIR}\")\n"
"endif()\n"
)
set(Eigen3_DIR "${eigen_BINARY_DIR}" CACHE PATH "" FORCE)
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When Eigen3 isn't found, this block fetches Eigen and sets Eigen3_DIR, but it never re-runs find_package(Eigen3) (nor does it recreate the Eigen3::Eigen target). Later the project links against Eigen3::Eigen, so configuration can fail unless the FetchContent'd Eigen happens to define that target. Consider re-invoking find_package(Eigen3 CONFIG REQUIRED) after setting Eigen3_DIR (or restoring the fallback creation of Eigen3::Eigen) to guarantee the target exists.

Suggested change
set(Eigen3_DIR "${eigen_BINARY_DIR}" CACHE PATH "" FORCE)
set(Eigen3_DIR "${eigen_BINARY_DIR}" CACHE PATH "" FORCE)
find_package(Eigen3 3.4 CONFIG REQUIRED NO_MODULE)

Copilot uses AI. Check for mistakes.
endif()

if (CDDP_CPP_CASADI)
Expand Down Expand Up @@ -188,6 +197,10 @@ target_link_libraries(${PROJECT_NAME}
autodiff
)

if(MSVC)
target_compile_definitions(${PROJECT_NAME} PUBLIC _USE_MATH_DEFINES)
endif()

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