draco_dependencies.cmake 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # Copyright 2022 The Draco Authors
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not
  4. # use this file except in compliance with the License. You may obtain a copy of
  5. # the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  11. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  12. # License for the specific language governing permissions and limitations under
  13. # the License.
  14. if(DRACO_CMAKE_DRACO_DEPENDENCIES_CMAKE)
  15. return()
  16. endif()
  17. set(DRACO_CMAKE_DRACO_DEPENDENCIES_CMAKE 1)
  18. include("${draco_root}/cmake/draco_variables.cmake")
  19. # Each variable holds a user specified custom path to a local copy of the
  20. # sources that belong to each project that Draco depends on. When paths are
  21. # empty the build will be generated pointing to the Draco git submodules.
  22. # Otherwise the paths specified by the user will be used in the build
  23. # configuration.
  24. # Path to the Eigen. The path must contain the Eigen directory.
  25. set(DRACO_EIGEN_PATH)
  26. draco_track_configuration_variable(DRACO_EIGEN_PATH)
  27. # Path to the gulrak/filesystem installation. The path specified must contain
  28. # the ghc subdirectory that houses the filesystem includes.
  29. set(DRACO_FILESYSTEM_PATH)
  30. draco_track_configuration_variable(DRACO_FILESYSTEM_PATH)
  31. # Path to the googletest installation. The path must be to the root of the
  32. # Googletest project directory.
  33. set(DRACO_GOOGLETEST_PATH)
  34. draco_track_configuration_variable(DRACO_GOOGLETEST_PATH)
  35. # Path to the syoyo/tinygltf installation. The path must be to the root of the
  36. # project directory.
  37. set(DRACO_TINYGLTF_PATH)
  38. draco_track_configuration_variable(DRACO_TINYGLTF_PATH)
  39. # Utility macro for killing the build due to a missing submodule directory.
  40. macro(draco_die_missing_submodule dir)
  41. message(FATAL_ERROR "${dir} missing, run git submodule update --init")
  42. endmacro()
  43. # Determines the Eigen location and updates the build configuration accordingly.
  44. macro(draco_setup_eigen)
  45. if(DRACO_EIGEN_PATH)
  46. set(eigen_path "${DRACO_EIGEN_PATH}")
  47. if(NOT IS_DIRECTORY "${eigen_path}")
  48. message(FATAL_ERROR "DRACO_EIGEN_PATH does not exist.")
  49. endif()
  50. else()
  51. set(eigen_path "${draco_root}/third_party/eigen")
  52. if(NOT IS_DIRECTORY "${eigen_path}")
  53. draco_die_missing_submodule("${eigen_path}")
  54. endif()
  55. endif()
  56. set(eigen_include_path "${eigen_path}/Eigen")
  57. if(NOT EXISTS "${eigen_path}/Eigen")
  58. message(FATAL_ERROR "The eigen path does not contain an Eigen directory.")
  59. endif()
  60. list(APPEND draco_include_paths "${eigen_path}")
  61. endmacro()
  62. # Determines the gulrak/filesystem location and updates the build configuration
  63. # accordingly.
  64. macro(draco_setup_filesystem)
  65. if(DRACO_FILESYSTEM_PATH)
  66. set(fs_path "${DRACO_FILESYSTEM_PATH}")
  67. if(NOT IS_DIRECTORY "${fs_path}")
  68. message(FATAL_ERROR "DRACO_FILESYSTEM_PATH does not exist.")
  69. endif()
  70. else()
  71. set(fs_path "${draco_root}/third_party/filesystem/include")
  72. if(NOT IS_DIRECTORY "${fs_path}")
  73. draco_die_missing_submodule("${fs_path}")
  74. endif()
  75. endif()
  76. list(APPEND draco_include_paths "${fs_path}")
  77. endmacro()
  78. # Determines the Googletest location and sets up include and source list vars
  79. # for the draco_tests build.
  80. macro(draco_setup_googletest)
  81. if(DRACO_GOOGLETEST_PATH)
  82. set(gtest_path "${DRACO_GOOGLETEST_PATH}")
  83. if(NOT IS_DIRECTORY "${gtest_path}")
  84. message(FATAL_ERROR "DRACO_GOOGLETEST_PATH does not exist.")
  85. endif()
  86. else()
  87. set(gtest_path "${draco_root}/third_party/googletest")
  88. endif()
  89. list(APPEND draco_test_include_paths ${draco_include_paths}
  90. "${gtest_path}/include" "${gtest_path}/googlemock"
  91. "${gtest_path}/googletest/include" "${gtest_path}/googletest")
  92. list(APPEND draco_gtest_all "${gtest_path}/googletest/src/gtest-all.cc")
  93. list(APPEND draco_gtest_main "${gtest_path}/googletest/src/gtest_main.cc")
  94. endmacro()
  95. # Determines the location of TinyGLTF and updates the build configuration
  96. # accordingly.
  97. macro(draco_setup_tinygltf)
  98. if(DRACO_TINYGLTF_PATH)
  99. set(tinygltf_path "${DRACO_TINYGLTF_PATH}")
  100. if(NOT IS_DIRECTORY "${tinygltf_path}")
  101. message(FATAL_ERROR "DRACO_TINYGLTF_PATH does not exist.")
  102. endif()
  103. else()
  104. set(tinygltf_path "${draco_root}/third_party/tinygltf")
  105. if(NOT IS_DIRECTORY "${tinygltf_path}")
  106. draco_die_missing_submodule("${tinygltf_path}")
  107. endif()
  108. endif()
  109. list(APPEND draco_include_paths "${tinygltf_path}")
  110. endmacro()