From 71a36147a66868757a976b89cea2a6bc1a33df21 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 11 Dec 2025 16:00:48 +0500 Subject: [PATCH] FindCGAL - another fix for 6591a6981 --- cmake/CMakeLists.txt | 2 +- cmake/FindCGAL.cmake | 10 +++++++--- src/ifcgeom/kernels/CMakeLists.txt | 4 ++-- src/svgfill/CMakeLists.txt | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index e218fcaab9..a9acf473ec 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -199,7 +199,7 @@ endforeach() if(WITH_CGAL) find_package(CGAL REQUIRED) - set(CGAL_LIBRARIES CGAL::CGAL) + set(CGAL_LIBRARIES CGAL::CGAL_INTERFACE) list(APPEND GEOMETRY_KERNELS cgal) endif() diff --git a/cmake/FindCGAL.cmake b/cmake/FindCGAL.cmake index 089a1b112f..772c315e9c 100644 --- a/cmake/FindCGAL.cmake +++ b/cmake/FindCGAL.cmake @@ -10,10 +10,10 @@ # Input variables could also be provided as environment variables. # # Output targets: -# - `CGAL::CGAL` +# - `CGAL::CGAL_INTERFACE` # -if(TARGET CGAL::CGAL) +if(TARGET CGAL::CGAL_INTERFACE) return() endif() @@ -56,5 +56,9 @@ else() message(STATUS "CGAL: found config at '${CGAL_DIR}'.") endif() -target_compile_definitions(CGAL::CGAL INTERFACE IFOPSH_WITH_CGAL) +# Adding another `CGAL_INTERFACE` 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) set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_CGAL) diff --git a/src/ifcgeom/kernels/CMakeLists.txt b/src/ifcgeom/kernels/CMakeLists.txt index 1927a1bc68..5ccb71f149 100644 --- a/src/ifcgeom/kernels/CMakeLists.txt +++ b/src/ifcgeom/kernels/CMakeLists.txt @@ -15,7 +15,7 @@ foreach(kernel ${GEOMETRY_KERNELS}) if(${kernel} STREQUAL "cgal") find_package(CGAL REQUIRED) - target_link_libraries(${KERNEL_TARGET} CGAL::CGAL) + target_link_libraries(${KERNEL_TARGET} CGAL::CGAL_INTERFACE) set_property(TARGET ${KERNEL_TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS " -DCGAL_HAS_THREADS") set(KERNEL_TARGET_SIMPLE "${KERNEL_TARGET}_simple") @@ -23,7 +23,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) + target_link_libraries(${KERNEL_TARGET_SIMPLE} CGAL::CGAL_INTERFACE) elseif(${kernel} STREQUAL "opencascade") target_link_libraries(${KERNEL_TARGET} ${OpenCASCADE_LIBRARIES}) endif() diff --git a/src/svgfill/CMakeLists.txt b/src/svgfill/CMakeLists.txt index ab557313d7..ed777d23a4 100644 --- a/src/svgfill/CMakeLists.txt +++ b/src/svgfill/CMakeLists.txt @@ -56,7 +56,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) +target_link_libraries(svgfill ${Boost_LIBRARIES} ${BCRYPT_LIBRARIES} LibXml2::LibXml2 CGAL::CGAL_INTERFACE) add_executable(svgfill_exe src/main.cpp) target_link_libraries(svgfill_exe svgfill)