FindOpenSubdiv.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # - Find OpenSubdiv library
  2. # Find the native OpenSubdiv includes and library
  3. # This module defines
  4. # OPENSUBDIV_INCLUDE_DIRS, where to find OpenSubdiv headers, Set when
  5. # OPENSUBDIV_INCLUDE_DIR is found.
  6. # OPENSUBDIV_LIBRARIES, libraries to link against to use OpenSubdiv.
  7. # OPENSUBDIV_ROOT_DIR, the base directory to search for OpenSubdiv.
  8. # This can also be an environment variable.
  9. # OPENSUBDIV_FOUND, if false, do not try to use OpenSubdiv.
  10. #
  11. # also defined, but not for general use are
  12. # OPENSUBDIV_LIBRARY, where to find the OpenSubdiv library.
  13. #=============================================================================
  14. # Copyright 2013 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 OPENSUBDIV_ROOT_DIR was defined in the environment, use it.
  24. IF(NOT OPENSUBDIV_ROOT_DIR AND NOT $ENV{OPENSUBDIV_ROOT_DIR} STREQUAL "")
  25. SET(OPENSUBDIV_ROOT_DIR $ENV{OPENSUBDIV_ROOT_DIR})
  26. ENDIF()
  27. SET(_opensubdiv_FIND_COMPONENTS
  28. osdGPU
  29. osdCPU
  30. )
  31. SET(_opensubdiv_SEARCH_DIRS
  32. ${OPENSUBDIV_ROOT_DIR}
  33. /usr/local
  34. /sw # Fink
  35. /opt/local # DarwinPorts
  36. /opt/csw # Blastwave
  37. /opt/lib/opensubdiv
  38. /opt/lib/osd # install_deps.sh
  39. )
  40. FIND_PATH(OPENSUBDIV_INCLUDE_DIR
  41. NAMES
  42. opensubdiv/osd/mesh.h
  43. HINTS
  44. ${_opensubdiv_SEARCH_DIRS}
  45. PATH_SUFFIXES
  46. include
  47. )
  48. SET(_opensubdiv_LIBRARIES)
  49. FOREACH(COMPONENT ${_opensubdiv_FIND_COMPONENTS})
  50. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  51. FIND_LIBRARY(OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY
  52. NAMES
  53. ${COMPONENT}
  54. HINTS
  55. ${_opensubdiv_SEARCH_DIRS}
  56. PATH_SUFFIXES
  57. lib64 lib
  58. )
  59. LIST(APPEND _opensubdiv_LIBRARIES "${OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY}")
  60. ENDFOREACH()
  61. MACRO(OPENSUBDIV_CHECK_CONTROLLER
  62. controller_include_file
  63. variable_name)
  64. IF(EXISTS "${OPENSUBDIV_INCLUDE_DIR}/opensubdiv/osd/${controller_include_file}")
  65. SET(${variable_name} TRUE)
  66. ELSE()
  67. SET(${variable_name} FALSE)
  68. ENDIF()
  69. ENDMACRO()
  70. # handle the QUIETLY and REQUIRED arguments and set OPENSUBDIV_FOUND to TRUE if
  71. # all listed variables are TRUE
  72. INCLUDE(FindPackageHandleStandardArgs)
  73. FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSubdiv DEFAULT_MSG
  74. _opensubdiv_LIBRARIES OPENSUBDIV_INCLUDE_DIR)
  75. IF(OPENSUBDIV_FOUND)
  76. SET(OPENSUBDIV_LIBRARIES ${_opensubdiv_LIBRARIES})
  77. SET(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_INCLUDE_DIR})
  78. # Find available compute controllers.
  79. FIND_PACKAGE(OpenMP)
  80. IF(OPENMP_FOUND)
  81. SET(OPENSUBDIV_HAS_OPENMP TRUE)
  82. ELSE()
  83. SET(OPENSUBDIV_HAS_OPENMP FALSE)
  84. ENDIF()
  85. OPENSUBDIV_CHECK_CONTROLLER("tbbEvaluator.h" OPENSUBDIV_HAS_TBB)
  86. OPENSUBDIV_CHECK_CONTROLLER("clEvaluator.h" OPENSUBDIV_HAS_OPENCL)
  87. OPENSUBDIV_CHECK_CONTROLLER("cudaEvaluator.h" OPENSUBDIV_HAS_CUDA)
  88. OPENSUBDIV_CHECK_CONTROLLER("glXFBEvaluator.h" OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK)
  89. OPENSUBDIV_CHECK_CONTROLLER("glComputeEvaluator.h" OPENSUBDIV_HAS_GLSL_COMPUTE)
  90. ENDIF(OPENSUBDIV_FOUND)
  91. MARK_AS_ADVANCED(
  92. OPENSUBDIV_INCLUDE_DIR
  93. )
  94. FOREACH(COMPONENT ${_opensubdiv_FIND_COMPONENTS})
  95. STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
  96. MARK_AS_ADVANCED(OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY)
  97. ENDFOREACH()