fix(build): ensure Eigen3::Eigen target exists before deps_src configuration
In static builds find_package(Eigen3) is skipped, leaving Eigen3::Eigen undefined when admesh and clipper try to link against it. Add an unconditional find_package(Eigen3 CONFIG QUIET) guard in the main CMakeLists before add_subdirectory(deps_src). deps_src/eigen now simply provides the unnamespaced alias and fatals clearly if the target is missing.
This commit is contained in:
@@ -876,6 +876,13 @@ function(orcaslicer_copy_dlls target config postfix output_dlls)
|
||||
endfunction()
|
||||
|
||||
|
||||
# Ensure Eigen3::Eigen IMPORTED target exists before deps_src subdirectories
|
||||
# are configured. In static builds find_package(Eigen3) is skipped above, so
|
||||
# admesh/clipper (which link Eigen3::Eigen) would fail without this call.
|
||||
if(NOT TARGET Eigen3::Eigen)
|
||||
find_package(Eigen3 CONFIG QUIET)
|
||||
endif()
|
||||
|
||||
# libslic3r, OrcaSlicer GUI and the OrcaSlicer executable.
|
||||
add_subdirectory(deps_src)
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -1,36 +1,13 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
project(eigen)
|
||||
|
||||
# Try to find the pre-built Eigen3 installed by deps/ CMakeLists (Eigen 5.x).
|
||||
# This must succeed: libigl and admesh use Eigen 3.4+ features (e.g. Eigen::all).
|
||||
find_package(Eigen3 CONFIG QUIET)
|
||||
|
||||
if(Eigen3_FOUND OR TARGET Eigen3::Eigen)
|
||||
message(STATUS "deps_src/eigen: using pre-built Eigen3 from CMAKE_PREFIX_PATH")
|
||||
else()
|
||||
# Fall back: construct the include path from the known deps install location.
|
||||
# CMAKE_PREFIX_PATH points to deps/build/OrcaSlicer_dep/usr/local;
|
||||
# Eigen installs its headers under <prefix>/include/eigen3.
|
||||
set(_eigen_include "")
|
||||
foreach(_prefix ${CMAKE_PREFIX_PATH})
|
||||
if(EXISTS "${_prefix}/include/eigen3")
|
||||
set(_eigen_include "${_prefix}/include/eigen3")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(_eigen_include)
|
||||
message(STATUS "deps_src/eigen: using eigen3 headers from ${_eigen_include}")
|
||||
add_library(Eigen3::Eigen INTERFACE IMPORTED GLOBAL)
|
||||
set_target_properties(Eigen3::Eigen PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_eigen_include}")
|
||||
else()
|
||||
message(FATAL_ERROR "deps_src/eigen: could not locate Eigen3 headers. "
|
||||
"Ensure deps/ has been built first (cmake --build deps/build).")
|
||||
endif()
|
||||
# Eigen3::Eigen is resolved in the parent CMakeLists before add_subdirectory(deps_src)
|
||||
# via find_package(Eigen3 CONFIG). This file only creates the unnamespaced "eigen" alias.
|
||||
if(NOT TARGET Eigen3::Eigen)
|
||||
message(FATAL_ERROR "Eigen3::Eigen target not found. "
|
||||
"Ensure find_package(Eigen3 CONFIG) is called before add_subdirectory(deps_src).")
|
||||
endif()
|
||||
|
||||
# Provide unnamespaced "eigen" alias for targets that link against it directly.
|
||||
if(NOT TARGET eigen)
|
||||
add_library(eigen INTERFACE)
|
||||
target_link_libraries(eigen INTERFACE Eigen3::Eigen)
|
||||
|
||||
Reference in New Issue
Block a user