cgal.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. if(TARGET CGAL::CGAL)
  2. return()
  3. endif()
  4. message(STATUS "Third-party: creating target 'CGAL::CGAL'")
  5. include(FetchContent)
  6. FetchContent_Declare(
  7. cgal
  8. URL https://github.com/CGAL/cgal/releases/download/v5.4/CGAL-5.4-library.tar.xz
  9. URL_MD5 996f7ee9ba1553edac60debb115699cd
  10. )
  11. FetchContent_GetProperties(cgal)
  12. if(cgal_POPULATED)
  13. return()
  14. endif()
  15. FetchContent_Populate(cgal)
  16. function(cgal_import_target)
  17. macro(ignore_package NAME VERSION_NUM)
  18. include(CMakePackageConfigHelpers)
  19. file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/${NAME}Config.cmake "")
  20. write_basic_package_version_file(
  21. ${CMAKE_CURRENT_BINARY_DIR}/${NAME}/${NAME}ConfigVersion.cmake
  22. VERSION ${VERSION_NUM}
  23. COMPATIBILITY AnyNewerVersion
  24. )
  25. set(${NAME}_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NAME} CACHE PATH "")
  26. set(${NAME}_ROOT ${CMAKE_CURRENT_BINARY_DIR}/${NAME} CACHE PATH "")
  27. endmacro()
  28. include(gmp)
  29. include(mpfr)
  30. include(boost)
  31. ignore_package(GMP 5.0.1)
  32. set(GMP_INCLUDE_DIR ${gmp_INCLUDE_DIR})
  33. set(GMP_LIBRARIES gmp::gmp)
  34. set(GMPXX_INCLUDE_DIR ${GMP_INCLUDE_DIR})
  35. set(GMPXX_LIBRARIES ${GMP_LIBRARIES})
  36. ignore_package(MPFR 3.0.0)
  37. set(MPFR_INCLUDE_DIR "")
  38. set(MPFR_LIBRARIES mpfr::mpfr)
  39. ignore_package(Boost 1.71.0)
  40. set(Boost_INCLUDE_DIRS "")
  41. set(Boost_LIBRARIES Boost::thread Boost::system)
  42. # Prefer Config mode before Module mode to prevent CGAL from loading its own FindXXX.cmake
  43. set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
  44. # https://stackoverflow.com/a/71714947/148668
  45. set(CGAL_DATA_DIR "unspecified")
  46. find_package(CGAL CONFIG COMPONENTS Core PATHS ${cgal_SOURCE_DIR} NO_DEFAULT_PATH)
  47. endfunction()
  48. cgal_import_target()