FindEmbree.cmake 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # - Find Embree library
  2. # Find the native Embree includes and library
  3. # This module defines
  4. # EMBREE_INCLUDE_DIRS, where to find rtcore.h, Set when
  5. # EMBREE_INCLUDE_DIR is found.
  6. # EMBREE_LIBRARIES, libraries to link against to use Embree.
  7. # EMBREE_ROOT_DIR, The base directory to search for Embree.
  8. # This can also be an environment variable.
  9. # EMBREEFOUND, If false, do not try to use Embree.
  10. #
  11. # also defined, but not for general use are
  12. # EMBREE_LIBRARY, where to find the Embree library.
  13. #=============================================================================
  14. # Copyright 2018 Blender Foundation.
  15. #
  16. # Distributed under the OSI-approved BSD License (the "License");
  17. # see accompanying file Copyright.txt for details.
  18. #
  19. # This software is distributed WITHOUT ANY WARRANTY; without even the
  20. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  21. # See the License for more information.
  22. #=============================================================================
  23. # If EMBREE_ROOT_DIR was defined in the environment, use it.
  24. IF(NOT EMBREE_ROOT_DIR AND NOT $ENV{EMBREE_ROOT_DIR} STREQUAL "")
  25. SET(EMBREE_ROOT_DIR $ENV{EMBREE_ROOT_DIR})
  26. ENDIF()
  27. SET(_embree_SEARCH_DIRS
  28. ${EMBREE_ROOT_DIR}
  29. /usr/local
  30. /sw # Fink
  31. /opt/local # DarwinPorts
  32. /opt/embree
  33. /opt/lib/embree
  34. )
  35. FIND_PATH(EMBREE_INCLUDE_DIR
  36. NAMES
  37. embree3/rtcore.h
  38. HINTS
  39. ${_embree_SEARCH_DIRS}
  40. PATH_SUFFIXES
  41. include
  42. )
  43. SET(_embree_FIND_COMPONENTS
  44. embree3
  45. embree_avx
  46. embree_avx2
  47. embree_sse42
  48. lexers
  49. math
  50. simd
  51. sys
  52. tasking
  53. )
  54. SET(_embree_LIBRARIES)
  55. FOREACH(COMPONENT ${_embree_FIND_COMPONENTS})
  56. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  57. FIND_LIBRARY(EMBREE_${UPPERCOMPONENT}_LIBRARY
  58. NAMES
  59. ${COMPONENT}
  60. HINTS
  61. ${_embree_SEARCH_DIRS}
  62. PATH_SUFFIXES
  63. lib64 lib
  64. )
  65. LIST(APPEND _embree_LIBRARIES "${EMBREE_${UPPERCOMPONENT}_LIBRARY}")
  66. ENDFOREACH()
  67. FIND_LIBRARY(EMBREE_LIBRARY
  68. NAMES
  69. libembree3
  70. HINTS
  71. ${_embree_SEARCH_DIRS}
  72. PATH_SUFFIXES
  73. lib64 lib
  74. )
  75. # handle the QUIETLY and REQUIRED arguments and set EMBREE_FOUND to TRUE if
  76. # all listed variables are TRUE
  77. INCLUDE(FindPackageHandleStandardArgs)
  78. FIND_PACKAGE_HANDLE_STANDARD_ARGS(EMBREE DEFAULT_MSG
  79. _embree_LIBRARIES EMBREE_INCLUDE_DIR)
  80. IF(EMBREE_FOUND)
  81. SET(EMBREE_LIBRARIES ${_embree_LIBRARIES})
  82. SET(EMBREE_INCLUDE_DIRS ${EMBREE_INCLUDE_DIR})
  83. ENDIF(EMBREE_FOUND)
  84. MARK_AS_ADVANCED(
  85. EMBREE_INCLUDE_DIR
  86. )
  87. FOREACH(COMPONENT ${_embree_FIND_COMPONENTS})
  88. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  89. MARK_AS_ADVANCED(EMBREE_${UPPERCOMPONENT}_LIBRARY)
  90. ENDFOREACH()
  91. UNSET(_embree_SEARCH_DIRS)
  92. UNSET(_embree_FIND_COMPONENTS)
  93. UNSET(_embree_LIBRARIES)