examples - further simplify linking

This commit is contained in:
Andrej730
2025-12-12 18:58:04 +05:00
parent b237fac4b8
commit dd683d1115
5 changed files with 18 additions and 22 deletions
+1 -1
View File
@@ -319,7 +319,7 @@ endif()
# Otherwise it will find components needed for CGAL and we might some libraries.
if(WITH_CGAL)
find_package(CGAL REQUIRED)
set(CGAL_LIBRARIES CGAL::CGAL_INTERFACE)
set(CGAL_LIBRARIES IFCOPENSHELL_CGAL)
list(APPEND GEOMETRY_KERNELS cgal)
endif()
+8 -6
View File
@@ -10,10 +10,10 @@
# Input variables could also be provided as environment variables.
#
# Output targets:
# - `CGAL::CGAL_INTERFACE`
# - `IFCOPENSHELL_CGAL`
#
if(TARGET CGAL::CGAL_INTERFACE)
if(TARGET IFCOPENSHELL_CGAL)
return()
endif()
@@ -59,9 +59,11 @@ else()
message(STATUS "CGAL: found config at '${CGAL_DIR}'.")
endif()
# Adding another `CGAL_INTERFACE` target, because we want to add compile definitions to it,
# Adding another `IFCOPENSHELL_CGAL` target, because we want to add compile definitions to it,
# but in `CGALconfig.cmake` `CGAL::CGAL` is an alias, so you can't add properties to it.
add_library(CGAL::CGAL_INTERFACE INTERFACE IMPORTED)
target_link_libraries(CGAL::CGAL_INTERFACE INTERFACE CGAL::CGAL)
target_compile_definitions(CGAL::CGAL_INTERFACE INTERFACE IFOPSH_WITH_CGAL)
add_library(IFCOPENSHELL_CGAL INTERFACE)
target_link_libraries(IFCOPENSHELL_CGAL INTERFACE CGAL::CGAL)
target_compile_definitions(IFCOPENSHELL_CGAL INTERFACE IFOPSH_WITH_CGAL)
set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_CGAL)
install(TARGETS IFCOPENSHELL_CGAL
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS})
+6 -12
View File
@@ -39,6 +39,8 @@ if(STANDALONE_PROJECT)
find_package(IfcOpenShell CONFIG REQUIRED)
set(SCHEMA_VERSIONS ${IFCOPENSHELL_SCHEMA_VERSIONS})
set(WITH_OPENCASCADE ${IFCOPENSHELL_WITH_OPENCASCADE})
else()
include_directories("${CMAKE_SOURCE_DIR}/../src")
endif()
if(SCHEMA_VERSIONS MATCHES "2x3")
@@ -62,16 +64,10 @@ if(SCHEMA_VERSIONS MATCHES "2x3")
find_package(Eigen3 CONFIG REQUIRED)
find_package(CGAL CONFIG REQUIRED)
find_package(OpenCASCADE CONFIG REQUIRED)
add_library(CGAL::CGAL_INTERFACE INTERFACE IMPORTED)
target_link_libraries(CGAL::CGAL_INTERFACE INTERFACE CGAL::CGAL)
target_link_libraries(IfcHouseInterface
INTERFACE ${OpenCASCADE_LIBRARIES} RocksDB::rocksdb
IfcOpenShell::IfcParse IfcOpenShell::geometry_serializer
)
target_link_libraries(IfcHouseInterface INTERFACE IfcOpenShell::IfcParse IfcOpenShell::geometry_serializer)
else()
target_include_directories(IfcHouseInterface INTERFACE "${CMAKE_SOURCE_DIR}/../src")
target_link_libraries(IfcHouseInterface INTERFACE ${IFCOPENSHELL_LIBRARIES} ${OpenCASCADE_LIBRARIES})
target_link_libraries(IfcHouseInterface INTERFACE IfcParse geometry_serializer)
set_target_properties(IfcOpenHouse PROPERTIES FOLDER Examples)
set_target_properties(IfcAdvancedHouse PROPERTIES FOLDER Examples)
endif()
@@ -87,11 +83,9 @@ if(SCHEMA_VERSIONS MATCHES "4x3_add2")
add_library(IfcAlignmentInterface INTERFACE)
if(STANDALONE_PROJECT)
target_link_libraries(IfcAlignment PRIVATE IfcOpenShell::IfcParse)
target_link_libraries(IfcSimplifiedAlignment PRIVATE IfcOpenShell::IfcParse)
target_link_libraries(IfcAlignmentInterface INTERFACE IfcOpenShell::IfcParse)
else()
target_include_directories(IfcAlignmentInterface INTERFACE "${CMAKE_SOURCE_DIR}/../src")
target_link_libraries(IfcAlignmentInterface INTERFACE ${IFCOPENSHELL_LIBRARIES})
target_link_libraries(IfcAlignmentInterface INTERFACE IfcParse)
set_target_properties(IfcAlignment PROPERTIES FOLDER Examples)
set_target_properties(IfcSimplifiedAlignment PROPERTIES FOLDER Examples)
endif()
+2 -2
View File
@@ -22,7 +22,7 @@ foreach(kernel ${GEOMETRY_KERNELS})
if(${kernel} STREQUAL "cgal")
find_package(CGAL REQUIRED)
target_link_libraries(${KERNEL_TARGET} CGAL::CGAL_INTERFACE)
target_link_libraries(${KERNEL_TARGET} IFCOPENSHELL_CGAL)
set_property(TARGET ${KERNEL_TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS " -DCGAL_HAS_THREADS")
set(KERNEL_TARGET_SIMPLE "${KERNEL_TARGET}_simple")
@@ -30,7 +30,7 @@ foreach(kernel ${GEOMETRY_KERNELS})
set_target_properties(${KERNEL_TARGET_SIMPLE} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIFOPSH_SIMPLE_KERNEL -DCGAL_HAS_THREADS")
list(APPEND kernel_libraries ${KERNEL_TARGET_SIMPLE})
target_link_libraries(${KERNEL_TARGET_SIMPLE} ${${KERNEL_UPPER}_LIBRARIES} Eigen3::Eigen)
target_link_libraries(${KERNEL_TARGET_SIMPLE} CGAL::CGAL_INTERFACE)
target_link_libraries(${KERNEL_TARGET_SIMPLE} IFCOPENSHELL_CGAL)
install(TARGETS ${KERNEL_TARGET_SIMPLE}
EXPORT ${IFCOPENSHELL_EXPORT_TARGETS}
)
+1 -1
View File
@@ -46,7 +46,7 @@ file(GLOB LIB_H_FILES src/*.h)
file(GLOB LIB_CPP_FILES src/svgfill.cpp src/arrange_polygons.cpp)
set(LIB_SRC_FILES ${LIB_H_FILES} ${LIB_CPP_FILES})
add_library(svgfill ${LIB_SRC_FILES})
target_link_libraries(svgfill ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} LibXml2::LibXml2 CGAL::CGAL_INTERFACE)
target_link_libraries(svgfill ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} LibXml2::LibXml2 IFCOPENSHELL_CGAL)
set_target_properties(svgfill PROPERTIES
PUBLIC_HEADER "${LIB_H_FILES}"
)