Files
IfcOpenShell/cmake/FindCGAL.cmake
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

65 lines
2.3 KiB
CMake
Raw Normal View History

2025-11-20 16:55:19 +05:00
#
# Input variables:
# - `CGAL_INCLUDE_DIR`
# - `CGAL_LIBRARY_DIR`
# - `GMP_INCLUDE_DIR`
# - `GMP_LIBRARY_DIR`
# - `MPFR_INCLUDE_DIR`
# - `MPFR_LIBRARY_DIR`
# If input variables are not specified, try to find HDF5 config.
# Input variables could also be provided as environment variables.
#
# Output targets:
2025-12-11 16:00:48 +05:00
# - `CGAL::CGAL_INTERFACE`
2025-11-20 16:55:19 +05:00
#
2025-12-11 16:00:48 +05:00
if(TARGET CGAL::CGAL_INTERFACE)
return()
endif()
2025-11-20 16:55:19 +05:00
UNIFY_ENVVARS_AND_CACHE(CGAL_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(CGAL_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(GMP_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(GMP_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(MPFR_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(MPFR_LIBRARY_DIR)
if(CGAL_INCLUDE_DIR)
find_library(libGMP NAMES gmp mpir PATHS ${GMP_LIBRARY_DIR} NO_DEFAULT_PATH)
find_library(libMPFR NAMES mpfr PATHS ${MPFR_LIBRARY_DIR} NO_DEFAULT_PATH)
if(NOT libGMP)
message(FATAL_ERROR "Unable to find GMP library files, aborting")
endif()
if(NOT libMPFR)
message(FATAL_ERROR "Unable to find MPFR library files, aborting")
endif()
add_library(CGAL::CGAL INTERFACE IMPORTED)
target_include_directories(CGAL::CGAL INTERFACE "${CGAL_INCLUDE_DIR}")
target_include_directories(CGAL::CGAL INTERFACE "${GMP_INCLUDE_DIR}" "${MPFR_INCLUDE_DIR}")
target_link_libraries(CGAL::CGAL INTERFACE "${libMPFR}" "${libGMP}")
else()
2025-11-20 16:55:19 +05:00
# CGAL is not respecting default Boost_USE_STATIC_LIBS value
# and sometiems it's getting in the way.
if(NOT DEFINED Boost_USE_STATIC_LIBS)
set(CGAL_Boost_USE_STATIC_LIBS OFF)
else()
set(CGAL_Boost_USE_STATIC_LIBS "${Boost_USE_STATIC_LIBS}")
endif()
find_package(CGAL CONFIG)
2025-12-04 19:15:41 +01:00
if(NOT CGAL_FOUND)
2025-11-20 16:55:19 +05:00
message(
FATAL_ERROR
"CGAL_SUPPORT enabled, but CGAL_INCLUDE_DIR wasn't provided and CGAL package couldn't be found."
)
endif()
message(STATUS "CGAL: found config at '${CGAL_DIR}'.")
endif()
2025-12-11 16:00:48 +05:00
# 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)
2025-11-20 16:55:19 +05:00
set(SWIG_DEFINES ${SWIG_DEFINES} -DIFOPSH_WITH_CGAL)