1.下载Draco源码
地址:https://github.com/google/draco/tree/main
下载 Draco 1.5.7 release 或直接克隆 master
2.依赖环境
克隆源码后,打开third_party文件夹可看到其依赖的第三方库,下载源码:
- eigen(3.4.1) :https://gitlab.com/libeigen/eigen/-/releases
- filesystem (1.5.14) :https://github.com/gulrak/filesystem
- googletest (1.17.0) :https://github.com/google/googletest
- tinygltf (2.7.0) :https://github.com/syoyo/tinygltf
注意tinygltf的版本,2.7之后有Api修改,影响后续Draco的编译。
依赖均使用CMake编译安装,CMAKE_INSTALL_PREFIX后路径可修改,若为C盘,则生成的解决方案用VS启动需要管理员模式。
生成解决方案后,打开编译INSTALL项目,编译成功后将CMAKE_INSTALL_PREFIX路径下的内容拷贝到third_party对应目录中。

3.生成Draco
使用CMake生成Draco, 项目编译若报错 无法打开源文件tiny_gltf.h,检查此文件在third_party中的路径,打开draco/cmake目录下的draco_dependencies.cmake文件,添加include子目录到包含路径.
# Determines the location of TinyGLTF and updates the build configuration
# accordingly.
macro(draco_setup_tinygltf)if(DRACO_TINYGLTF_PATH)set(tinygltf_path "${DRACO_TINYGLTF_PATH}")if(NOT IS_DIRECTORY "${tinygltf_path}")message(FATAL_ERROR "DRACO_TINYGLTF_PATH does not exist.")endif()else()set(tinygltf_path "${draco_root}/third_party/tinygltf")if(NOT IS_DIRECTORY "${tinygltf_path}")draco_die_missing_submodule("${tinygltf_path}")endif()endif()# 添加include子目录到包含路径if(EXISTS "${tinygltf_path}/include")list(APPEND draco_include_paths "${tinygltf_path}/include")else()list(APPEND draco_include_paths "${tinygltf_path}")endif()
endmacro()
删除draco的build路径重新cmake,再次编译即可。