cmake: Link Eigen3 only against targets needing it

This commit is contained in:
Esteban DUGUEPEROUX
2025-11-30 17:06:52 +01:00
committed by Andrej730
parent 9807c2bedf
commit 2e5d87b5d7
4 changed files with 10 additions and 8 deletions
-4
View File
@@ -449,10 +449,6 @@ else()
endif() endif()
endif(MSVC) endif(MSVC)
find_package(Eigen3 REQUIRED)
link_libraries(Eigen3::Eigen)
include_directories(${INCLUDE_DIRECTORIES} ${OPENCOLLADA_INCLUDE_DIRS} include_directories(${INCLUDE_DIRECTORIES} ${OPENCOLLADA_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR} ${JSON_INCLUDE_DIR} ${HDF5_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR} ${JSON_INCLUDE_DIR} ${HDF5_INCLUDE_DIR}
${CGAL_INCLUDE_DIR} ${GMP_INCLUDE_DIR} ${MPFR_INCLUDE_DIR} ${USD_INCLUDE_DIR} ${CGAL_INCLUDE_DIR} ${GMP_INCLUDE_DIR} ${MPFR_INCLUDE_DIR} ${USD_INCLUDE_DIR}
+2
View File
@@ -20,6 +20,8 @@ if(UNIX)
find_package(Threads) find_package(Threads)
endif() endif()
find_package(Eigen3 REQUIRED)
if(WASM_BUILD) if(WASM_BUILD)
target_link_libraries(IfcGeom ${kernel_libraries} ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT} "Eigen3::Eigen") target_link_libraries(IfcGeom ${kernel_libraries} ${mapping_libraries} ${CMAKE_THREAD_LIBS_INIT} "Eigen3::Eigen")
else() else()
+3 -1
View File
@@ -1,3 +1,5 @@
find_package(Eigen3 REQUIRED)
foreach(kernel ${GEOMETRY_KERNELS}) foreach(kernel ${GEOMETRY_KERNELS})
string(TOUPPER ${kernel} KERNEL_UPPER) string(TOUPPER ${kernel} KERNEL_UPPER)
file(GLOB IFCGEOM_H_FILES ${kernel}/*.h) file(GLOB IFCGEOM_H_FILES ${kernel}/*.h)
@@ -9,7 +11,7 @@ foreach(kernel ${GEOMETRY_KERNELS})
add_library(${KERNEL_TARGET} OBJECT ${IFCGEOM_FILES}) add_library(${KERNEL_TARGET} OBJECT ${IFCGEOM_FILES})
set_property(TARGET ${KERNEL_TARGET} APPEND PROPERTY COMPILE_FLAGS "-DIFC_GEOM_EXPORTS") set_property(TARGET ${KERNEL_TARGET} APPEND PROPERTY COMPILE_FLAGS "-DIFC_GEOM_EXPORTS")
list(APPEND kernel_libraries ${KERNEL_TARGET}) list(APPEND kernel_libraries ${KERNEL_TARGET})
target_link_libraries(${KERNEL_TARGET} ${${KERNEL_UPPER}_LIBRARIES}) target_link_libraries(${KERNEL_TARGET} ${${KERNEL_UPPER}_LIBRARIES} Eigen3::Eigen)
install(TARGETS ${KERNEL_TARGET}) install(TARGETS ${KERNEL_TARGET})
+3 -1
View File
@@ -1,3 +1,5 @@
find_package(Eigen3 REQUIRED)
foreach(schema ${SCHEMA_VERSIONS}) foreach(schema ${SCHEMA_VERSIONS})
file(GLOB IFCGEOM_I_FILES *.i) file(GLOB IFCGEOM_I_FILES *.i)
file(GLOB IFCGEOM_H_FILES *.h) file(GLOB IFCGEOM_H_FILES *.h)
@@ -6,7 +8,7 @@ foreach(schema ${SCHEMA_VERSIONS})
add_library(geometry_mapping_ifc${schema} OBJECT ${IFCGEOM_FILES}) add_library(geometry_mapping_ifc${schema} OBJECT ${IFCGEOM_FILES})
set_target_properties(geometry_mapping_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}") set_target_properties(geometry_mapping_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}")
target_link_libraries(geometry_mapping_ifc${schema} IfcParse) target_link_libraries(geometry_mapping_ifc${schema} IfcParse Eigen3::Eigen)
list(APPEND mapping_libraries geometry_mapping_ifc${schema}) list(APPEND mapping_libraries geometry_mapping_ifc${schema})