FindDraco.cmake 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Finddraco
  2. #
  3. # Locates draco and sets the following variables:
  4. #
  5. # draco_FOUND
  6. # draco_INCLUDE_DIRS
  7. # draco_LIBARY_DIRS
  8. # draco_LIBRARIES
  9. # draco_VERSION_STRING
  10. #
  11. # draco_FOUND is set to YES only when all other variables are successfully
  12. # configured.
  13. unset(draco_FOUND)
  14. unset(draco_INCLUDE_DIRS)
  15. unset(draco_LIBRARY_DIRS)
  16. unset(draco_LIBRARIES)
  17. unset(draco_VERSION_STRING)
  18. mark_as_advanced(draco_FOUND)
  19. mark_as_advanced(draco_INCLUDE_DIRS)
  20. mark_as_advanced(draco_LIBRARY_DIRS)
  21. mark_as_advanced(draco_LIBRARIES)
  22. mark_as_advanced(draco_VERSION_STRING)
  23. set(draco_version_file_no_prefix "draco/src/draco/core/draco_version.h")
  24. # Set draco_INCLUDE_DIRS
  25. find_path(draco_INCLUDE_DIRS NAMES "${draco_version_file_no_prefix}")
  26. # Extract the version string from draco_version.h.
  27. if (draco_INCLUDE_DIRS)
  28. set(draco_version_file
  29. "${draco_INCLUDE_DIRS}/draco/src/draco/core/draco_version.h")
  30. file(STRINGS "${draco_version_file}" draco_version
  31. REGEX "kdracoVersion")
  32. list(GET draco_version 0 draco_version)
  33. string(REPLACE "static const char kdracoVersion[] = " "" draco_version
  34. "${draco_version}")
  35. string(REPLACE ";" "" draco_version "${draco_version}")
  36. string(REPLACE "\"" "" draco_version "${draco_version}")
  37. set(draco_VERSION_STRING ${draco_version})
  38. endif ()
  39. # Find the library.
  40. if (BUILD_SHARED_LIBS)
  41. find_library(draco_LIBRARIES NAMES draco.dll libdraco.dylib libdraco.so)
  42. else ()
  43. find_library(draco_LIBRARIES NAMES draco.lib libdraco.a)
  44. endif ()
  45. # Store path to library.
  46. get_filename_component(draco_LIBRARY_DIRS ${draco_LIBRARIES} DIRECTORY)
  47. if (draco_INCLUDE_DIRS AND draco_LIBRARY_DIRS AND draco_LIBRARIES AND
  48. draco_VERSION_STRING)
  49. set(draco_FOUND YES)
  50. endif ()