FindCGAL.cmake 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #
  2. # The following module is based on FindVTK.cmake
  3. #
  4. # - Find a CGAL installation or binary tree.
  5. # The following variables are set if CGAL is found. If CGAL is not
  6. # found, CGAL_FOUND is set to false.
  7. #
  8. # CGAL_FOUND - Set to true when CGAL is found.
  9. # CGAL_USE_FILE - CMake file to use CGAL.
  10. #
  11. # Construct consitent error messages for use below.
  12. set(CGAL_DIR_DESCRIPTION "directory containing CGALConfig.cmake. This is either the binary directory where CGAL was configured or PREFIX/lib/CGAL for an installation.")
  13. set(CGAL_DIR_MESSAGE "CGAL not found. Set the CGAL_DIR cmake variable or environment variable to the ${CGAL_DIR_DESCRIPTION}")
  14. set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
  15. if ( NOT CGAL_DIR )
  16. # Get the system search path as a list.
  17. if(UNIX)
  18. string(REGEX MATCHALL "[^:]+" CGAL_DIR_SEARCH1 "$ENV{PATH}")
  19. else()
  20. string(REGEX REPLACE "\\\\" "/" CGAL_DIR_SEARCH1 "$ENV{PATH}")
  21. endif()
  22. string(REGEX REPLACE "/;" ";" CGAL_DIR_SEARCH2 "${CGAL_DIR_SEARCH1}")
  23. # Construct a set of paths relative to the system search path.
  24. set(CGAL_DIR_SEARCH "")
  25. foreach(dir ${CGAL_DIR_SEARCH2})
  26. set(CGAL_DIR_SEARCH ${CGAL_DIR_SEARCH} ${dir}/../lib/CGAL )
  27. endforeach()
  28. #
  29. # Look for an installation or build tree.
  30. #
  31. find_path(CGAL_DIR CGALConfig.cmake
  32. # Look for an environment variable CGAL_DIR.
  33. $ENV{CGAL_DIR}
  34. # Look in places relative to the system executable search path.
  35. ${CGAL_DIR_SEARCH}
  36. # Look in standard UNIX install locations.
  37. /opt/local/share/CGAL/cmake
  38. /usr/local/lib/CGAL
  39. /usr/lib/CGAL
  40. # Read from the CMakeSetup registry entries. It is likely that
  41. # CGAL will have been recently built.
  42. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
  43. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
  44. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
  45. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
  46. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
  47. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
  48. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
  49. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
  50. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
  51. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
  52. # Help the user find it if we cannot.
  53. DOC "The ${CGAL_DIR_DESCRIPTION}"
  54. )
  55. endif()
  56. if ( CGAL_DIR )
  57. if ( EXISTS "${CGAL_DIR}/CGALConfig.cmake" )
  58. include( "${CGAL_DIR}/CGALConfig.cmake" )
  59. set( CGAL_FOUND TRUE )
  60. endif()
  61. endif()
  62. if(CGAL_FOUND)
  63. MESSAGE(STATUS "Found CGAL: ${CGAL_DIR}")
  64. else()
  65. if(CGAL_FIND_REQUIRED)
  66. MESSAGE(FATAL_ERROR ${CGAL_DIR_MESSAGE})
  67. else()
  68. if(NOT CGAL_FIND_QUIETLY)
  69. MESSAGE(STATUS ${CGAL_DIR_MESSAGE})
  70. endif()
  71. endif()
  72. endif()