Merge branch 'master' into v157_snapshot

This commit is contained in:
Ondrej Stava 2024-01-12 15:11:14 -08:00 committed by GitHub
commit dcce9d0b3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 88 additions and 85 deletions

View File

@ -23,99 +23,101 @@ include(GNUInstallDirs)
# Sets up the draco install targets. Must be called after the static library # Sets up the draco install targets. Must be called after the static library
# target is created. # target is created.
macro(draco_setup_install_target) macro(draco_setup_install_target)
set(bin_path "${CMAKE_INSTALL_BINDIR}") if(DRACO_INSTALL)
set(data_path "${CMAKE_INSTALL_DATAROOTDIR}") set(bin_path "${CMAKE_INSTALL_BINDIR}")
set(includes_path "${CMAKE_INSTALL_INCLUDEDIR}") set(data_path "${CMAKE_INSTALL_DATAROOTDIR}")
set(libs_path "${CMAKE_INSTALL_LIBDIR}") set(includes_path "${CMAKE_INSTALL_INCLUDEDIR}")
set(libs_path "${CMAKE_INSTALL_LIBDIR}")
foreach(file ${draco_sources}) foreach(file ${draco_sources})
if(file MATCHES "h$") if(file MATCHES "h$")
list(APPEND draco_api_includes ${file}) list(APPEND draco_api_includes ${file})
endif()
endforeach()
list(REMOVE_DUPLICATES draco_api_includes)
# Strip $draco_src_root from the file paths: we need to install relative to
# $include_directory.
list(TRANSFORM draco_api_includes REPLACE "${draco_src_root}/" "")
foreach(draco_api_include ${draco_api_includes})
get_filename_component(file_directory ${draco_api_include} DIRECTORY)
set(target_directory "${includes_path}/draco/${file_directory}")
install(FILES ${draco_src_root}/${draco_api_include}
DESTINATION "${target_directory}")
endforeach()
install(FILES "${draco_build}/draco/draco_features.h"
DESTINATION "${includes_path}/draco/")
install(TARGETS draco_decoder DESTINATION "${bin_path}")
install(TARGETS draco_encoder DESTINATION "${bin_path}")
if(DRACO_TRANSCODER_SUPPORTED)
install(TARGETS draco_transcoder DESTINATION "${bin_path}")
endif() endif()
endforeach()
list(REMOVE_DUPLICATES draco_api_includes) if(MSVC)
# Strip $draco_src_root from the file paths: we need to install relative to
# $include_directory.
list(TRANSFORM draco_api_includes REPLACE "${draco_src_root}/" "")
foreach(draco_api_include ${draco_api_includes})
get_filename_component(file_directory ${draco_api_include} DIRECTORY)
set(target_directory "${includes_path}/draco/${file_directory}")
install(FILES ${draco_src_root}/${draco_api_include}
DESTINATION "${target_directory}")
endforeach()
install(FILES "${draco_build}/draco/draco_features.h"
DESTINATION "${includes_path}/draco/")
install(TARGETS draco_decoder DESTINATION "${bin_path}")
install(TARGETS draco_encoder DESTINATION "${bin_path}")
if(DRACO_TRANSCODER_SUPPORTED)
install(TARGETS draco_transcoder DESTINATION "${bin_path}")
endif()
if(MSVC)
install(
TARGETS draco
EXPORT dracoExport
RUNTIME DESTINATION "${bin_path}"
ARCHIVE DESTINATION "${libs_path}"
LIBRARY DESTINATION "${libs_path}")
else()
install(
TARGETS draco_static
EXPORT dracoExport
DESTINATION "${libs_path}")
if(BUILD_SHARED_LIBS)
install( install(
TARGETS draco_shared TARGETS draco
EXPORT dracoExport EXPORT dracoExport
RUNTIME DESTINATION "${bin_path}" RUNTIME DESTINATION "${bin_path}"
ARCHIVE DESTINATION "${libs_path}" ARCHIVE DESTINATION "${libs_path}"
LIBRARY DESTINATION "${libs_path}") LIBRARY DESTINATION "${libs_path}")
else()
install(
TARGETS draco_static
EXPORT dracoExport
DESTINATION "${libs_path}")
if(BUILD_SHARED_LIBS)
install(
TARGETS draco_shared
EXPORT dracoExport
RUNTIME DESTINATION "${bin_path}"
ARCHIVE DESTINATION "${libs_path}"
LIBRARY DESTINATION "${libs_path}")
endif()
endif() endif()
endif()
if(DRACO_UNITY_PLUGIN) if(DRACO_UNITY_PLUGIN)
install(TARGETS dracodec_unity DESTINATION "${libs_path}") install(TARGETS dracodec_unity DESTINATION "${libs_path}")
endif() endif()
if(DRACO_MAYA_PLUGIN) if(DRACO_MAYA_PLUGIN)
install(TARGETS draco_maya_wrapper DESTINATION "${libs_path}") install(TARGETS draco_maya_wrapper DESTINATION "${libs_path}")
endif() endif()
# pkg-config: draco.pc # pkg-config: draco.pc
configure_file("${draco_root}/cmake/draco.pc.template" configure_file("${draco_root}/cmake/draco.pc.template"
"${draco_build}/draco.pc" @ONLY NEWLINE_STYLE UNIX) "${draco_build}/draco.pc" @ONLY NEWLINE_STYLE UNIX)
install(FILES "${draco_build}/draco.pc" DESTINATION "${libs_path}/pkgconfig") install(FILES "${draco_build}/draco.pc" DESTINATION "${libs_path}/pkgconfig")
# CMake config: draco-config.cmake # CMake config: draco-config.cmake
configure_package_config_file( configure_package_config_file(
"${draco_root}/cmake/draco-config.cmake.template" "${draco_root}/cmake/draco-config.cmake.template"
"${draco_build}/draco-config.cmake" "${draco_build}/draco-config.cmake"
INSTALL_DESTINATION "${data_path}/cmake/draco") INSTALL_DESTINATION "${data_path}/cmake/draco")
write_basic_package_version_file( write_basic_package_version_file(
"${draco_build}/draco-config-version.cmake" "${draco_build}/draco-config-version.cmake"
VERSION ${DRACO_VERSION} VERSION ${DRACO_VERSION}
COMPATIBILITY AnyNewerVersion) COMPATIBILITY AnyNewerVersion)
export( export(
EXPORT dracoExport EXPORT dracoExport
NAMESPACE draco:: NAMESPACE draco::
FILE "${draco_build}/draco-targets.cmake") FILE "${draco_build}/draco-targets.cmake")
install( install(
EXPORT dracoExport EXPORT dracoExport
NAMESPACE draco:: NAMESPACE draco::
FILE draco-targets.cmake FILE draco-targets.cmake
DESTINATION "${data_path}/cmake/draco") DESTINATION "${data_path}/cmake/draco")
install(FILES "${draco_build}/draco-config.cmake" install(FILES "${draco_build}/draco-config.cmake"
"${draco_build}/draco-config-version.cmake" "${draco_build}/draco-config-version.cmake"
DESTINATION "${data_path}/cmake/draco") DESTINATION "${data_path}/cmake/draco")
endif(DRACO_INSTALL)
endmacro() endmacro()

View File

@ -131,6 +131,10 @@ macro(draco_set_default_options)
NAME DRACO_DEBUG_COMPILER_WARNINGS NAME DRACO_DEBUG_COMPILER_WARNINGS
HELPSTRING "Turn on more warnings." HELPSTRING "Turn on more warnings."
VALUE OFF) VALUE OFF)
draco_option(
NAME DRACO_INSTALL
HELPSTRING "Enable installation."
VALUE ON)
draco_check_deprecated_options() draco_check_deprecated_options()
endmacro() endmacro()

View File

@ -38,11 +38,10 @@ bool DirectoryExists(const std::string &path_arg) {
struct stat path_stat; struct stat path_stat;
std::string path = path_arg; std::string path = path_arg;
#if defined(_WIN32) && not defined(__MINGW32__) #if defined(_WIN32) && !defined(__MINGW32__)
// Avoid a silly windows issue: stat() will fail on a drive letter missing the // Avoid a silly windows issue: stat() will fail on a drive letter missing the
// trailing slash. // trailing slash. To keep it simple, append a path separator to all paths.
if (path.size() > 0 && path[path.size()] != '\\' && if (!path.empty() && path.back() != '\\' && path.back() != '/') {
path[path.size()] != '/') {
path.append("\\"); path.append("\\");
} }
#endif #endif
@ -68,9 +67,7 @@ bool CheckAndCreatePathForFile(const std::string &filename) {
const ghc::filesystem::path ghc_path(path); const ghc::filesystem::path ghc_path(path);
ghc::filesystem::create_directories(ghc_path); ghc::filesystem::create_directories(ghc_path);
#endif // DRACO_TRANSCODER_SUPPORTED #endif // DRACO_TRANSCODER_SUPPORTED
const bool directory_exists = DirectoryExists(path); return DirectoryExists(path);
return directory_exists;
} }
} // namespace draco } // namespace draco