diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..05f9ae1 --- /dev/null +++ b/.clang-format @@ -0,0 +1,9 @@ +--- +Language: Cpp +BasedOnStyle: Google +DerivePointerAlignment: false +PointerAlignment: Right +AllowShortIfStatementsOnASingleLine: false +AllowShortFunctionsOnASingleLine: true +AllowShortLoopsOnASingleLine: false +... diff --git a/.cmake-format.py b/.cmake-format.py new file mode 100644 index 0000000..64f2495 --- /dev/null +++ b/.cmake-format.py @@ -0,0 +1,102 @@ +# Generated with cmake-format 0.5.1 +# How wide to allow formatted cmake files +line_width = 80 + +# How many spaces to tab for indent +tab_size = 2 + +# If arglists are longer than this, break them always +max_subargs_per_line = 10 + +# If true, separate flow control names from their parentheses with a space +separate_ctrl_name_with_space = False + +# If true, separate function names from parentheses with a space +separate_fn_name_with_space = False + +# If a statement is wrapped to more than one line, than dangle the closing +# parenthesis on its own line +dangle_parens = False + +# What character to use for bulleted lists +bullet_char = '*' + +# What character to use as punctuation after numerals in an enumerated list +enum_char = '.' + +# What style line endings to use in the output. +line_ending = u'unix' + +# Format command names consistently as 'lower' or 'upper' case +command_case = u'lower' + +# Format keywords consistently as 'lower' or 'upper' case +keyword_case = u'unchanged' + +# Specify structure for custom cmake functions +additional_commands = { + "foo": { + "flags": [ + "BAR", + "BAZ" + ], + "kwargs": { + "HEADERS": "*", + "DEPENDS": "*", + "SOURCES": "*" + } + } +} + +# A list of command names which should always be wrapped +always_wrap = [] + +# Specify the order of wrapping algorithms during successive reflow attempts +algorithm_order = [0, 1, 2, 3, 4] + +# If true, the argument lists which are known to be sortable will be sorted +# lexicographicall +autosort = False + +# enable comment markup parsing and reflow +enable_markup = True + +# If comment markup is enabled, don't reflow the first comment block in +# eachlistfile. Use this to preserve formatting of your +# copyright/licensestatements. +first_comment_is_literal = False + +# If comment markup is enabled, don't reflow any comment block which matchesthis +# (regex) pattern. Default is `None` (disabled). +literal_comment_pattern = None + +# Regular expression to match preformat fences in comments +# default=r'^\s*([`~]{3}[`~]*)(.*)$' +fence_pattern = u'^\\s*([`~]{3}[`~]*)(.*)$' + +# Regular expression to match rulers in comments +# default=r'^\s*[^\w\s]{3}.*[^\w\s]{3}$' +ruler_pattern = u'^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$' + +# If true, emit the unicode byte-order mark (BOM) at the start of the file +emit_byteorder_mark = False + +# If a comment line starts with at least this many consecutive hash characters, +# then don't lstrip() them off. This allows for lazy hash rulers where the first +# hash char is not separated by space +hashruler_min_length = 10 + +# If true, then insert a space between the first hash char and remaining hash +# chars in a hash ruler, and normalize its length to fill the column +canonicalize_hashrulers = True + +# Specify the encoding of the input file. Defaults to utf-8. +input_encoding = u'utf-8' + +# Specify the encoding of the output file. Defaults to utf-8. Note that cmake +# only claims to support utf-8 so be careful when using anything else +output_encoding = u'utf-8' + +# A dictionary containing any per-command configuration overrides. Currently +# only `command_case` is supported. +per_command = {} diff --git a/CMakeLists.txt b/CMakeLists.txt index 62fe812..7e70d01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,13 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR) -if (NOT CMAKE_BUILD_TYPE AND NOT IGNORE_EMPTY_BUILD_TYPE) - if (CMAKE_CURRENT_LIST_FILE STREQUAL CMAKE_PARENT_LIST_FILE) +if(NOT CMAKE_BUILD_TYPE AND NOT IGNORE_EMPTY_BUILD_TYPE) + if(CMAKE_CURRENT_LIST_FILE STREQUAL CMAKE_PARENT_LIST_FILE) message(INFO "|Draco: ignoring empty build type, forcing release mode.") - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Draco overridden build type" - FORCE) - endif () -endif () + set(CMAKE_BUILD_TYPE + "Release" + CACHE STRING "Draco overridden build type" FORCE) + endif() +endif() project(draco C CXX) @@ -14,15 +15,14 @@ set(draco_root "${CMAKE_CURRENT_SOURCE_DIR}") set(draco_src_root "${draco_root}/src/draco") set(draco_build_dir "${CMAKE_BINARY_DIR}") -if ("${draco_root}" STREQUAL "${draco_build_dir}") - message(FATAL_ERROR - "Building from within the Draco source tree is not supported.\n" - "Hint: Run these commands\n" - "$ rm -rf CMakeCache.txt CMakeFiles\n" - "$ mkdir -p ../draco_build\n" - "$ cd ../draco_build\n" - "And re-run CMake from the draco_build directory.") -endif () +if("${draco_root}" STREQUAL "${draco_build_dir}") + message( + FATAL_ERROR "Building from within the Draco source tree is not supported.\n" + "Hint: Run these commands\n" + "$ rm -rf CMakeCache.txt CMakeFiles\n" + "$ mkdir -p ../draco_build\n" "$ cd ../draco_build\n" + "And re-run CMake from the draco_build directory.") +endif() include(CMakePackageConfigHelpers) include("${draco_root}/cmake/compiler_flags.cmake") @@ -56,47 +56,47 @@ option(BUILD_FOR_GLTF "" OFF) option(BUILD_MAYA_PLUGIN "Build plugin library for Maya." OFF) option(BUILD_USD_PLUGIN "Build plugin library for USD." OFF) -if (WIN32 AND BUILD_SHARED_LIBS) +if(WIN32 AND BUILD_SHARED_LIBS) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) include(GenerateExportHeader) -endif () +endif() -if (BUILD_FOR_GLTF) +if(BUILD_FOR_GLTF) # Override settings when building for GLTF. draco_enable_feature(FEATURE "DRACO_MESH_COMPRESSION_SUPPORTED") draco_enable_feature(FEATURE "DRACO_NORMAL_ENCODING_SUPPORTED") draco_enable_feature(FEATURE "DRACO_STANDARD_EDGEBREAKER_SUPPORTED") -else () - if (ENABLE_POINT_CLOUD_COMPRESSION) +else() + if(ENABLE_POINT_CLOUD_COMPRESSION) draco_enable_feature(FEATURE "DRACO_POINT_CLOUD_COMPRESSION_SUPPORTED") - endif () - if (ENABLE_MESH_COMPRESSION) + endif() + if(ENABLE_MESH_COMPRESSION) draco_enable_feature(FEATURE "DRACO_MESH_COMPRESSION_SUPPORTED") draco_enable_feature(FEATURE "DRACO_NORMAL_ENCODING_SUPPORTED") - if (ENABLE_STANDARD_EDGEBREAKER) + if(ENABLE_STANDARD_EDGEBREAKER) draco_enable_feature(FEATURE "DRACO_STANDARD_EDGEBREAKER_SUPPORTED") - endif () - if (ENABLE_PREDICTIVE_EDGEBREAKER) + endif() + if(ENABLE_PREDICTIVE_EDGEBREAKER) draco_enable_feature(FEATURE "DRACO_PREDICTIVE_EDGEBREAKER_SUPPORTED") - endif () - endif () + endif() + endif() - if (ENABLE_BACKWARDS_COMPATIBILITY) + if(ENABLE_BACKWARDS_COMPATIBILITY) draco_enable_feature(FEATURE "DRACO_BACKWARDS_COMPATIBILITY_SUPPORTED") - endif () -endif () + endif() +endif() # Turn on more compiler warnings. -if (ENABLE_EXTRA_WARNINGS) - if (MSVC) +if(ENABLE_EXTRA_WARNINGS) + if(MSVC) add_compiler_flag_if_supported("/W3") # Disable MSVC warnings that suggest making code non-portable. add_compiler_flag_if_supported("/wd4996") - if (ENABLE_WERROR) + if(ENABLE_WERROR) add_compiler_flag_if_supported("/WX") - endif () - else () + endif() + else() add_compiler_flag_if_supported("-Wall") add_compiler_flag_if_supported("-Wfloat-conversion") add_compiler_flag_if_supported("-Wimplicit-function-declaration") @@ -106,45 +106,45 @@ if (ENABLE_EXTRA_WARNINGS) add_compiler_flag_if_supported("-Wtype-limits") add_compiler_flag_if_supported("-Wuninitialized") add_compiler_flag_if_supported("-Wunused") - endif () -endif () + endif() +endif() -if (ENABLE_WERROR) +if(ENABLE_WERROR) add_compiler_flag_if_supported("-Werror") -endif () -if (ENABLE_WEXTRA) +endif() +if(ENABLE_WEXTRA) add_compiler_flag_if_supported("-Wextra") -endif () -if (ENABLE_CCACHE) +endif() +if(ENABLE_CCACHE) set_compiler_launcher(ENABLE_CCACHE ccache) -endif () -if (ENABLE_DISTCC) +endif() +if(ENABLE_DISTCC) set_compiler_launcher(ENABLE_DISTCC distcc) -endif () -if (ENABLE_GOMA) +endif() +if(ENABLE_GOMA) set_compiler_launcher(ENABLE_GOMA gomacc) -endif () -if (BUILD_UNITY_PLUGIN) +endif() +if(BUILD_UNITY_PLUGIN) set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared library for unity plugin.") draco_enable_feature(FEATURE "BUILD_UNITY_PLUGIN") -endif () -if (BUILD_MAYA_PLUGIN) +endif() +if(BUILD_MAYA_PLUGIN) set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared library for maya plugin.") draco_enable_feature(FEATURE "BUILD_MAYA_PLUGIN") -endif () -if (BUILD_USD_PLUGIN) +endif() +if(BUILD_USD_PLUGIN) set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared library for USD plugin.") draco_enable_feature(FEATURE "BUILD_USD_PLUGIN") -endif () +endif() -if (ENABLE_EXTRA_SPEED) - if (MSVC) +if(ENABLE_EXTRA_SPEED) + if(MSVC) # Maximum optimization in Release mode. add_compile_options("$<$:/Ox>") - else () + else() add_compiler_flag_if_supported("-O3") - endif () -endif () + endif() +endif() # Generate a version file containing repository info. include(FindGit) @@ -152,76 +152,80 @@ find_package(Git) # Default the hash and description to empty strings in case git is unavailable. set(draco_git_hash "") set(draco_git_desc "") -if (GIT_FOUND) +if(GIT_FOUND) set(draco_git_dir "${draco_root}/.git") - if (NOT EXISTS "${draco_git_dir}") + if(NOT EXISTS "${draco_git_dir}") set(draco_git_dir "${draco_root}/../../../.git") - endif () - if (EXISTS "${draco_git_dir}") + endif() + if(EXISTS "${draco_git_dir}") execute_process(COMMAND ${GIT_EXECUTABLE} - --git-dir=${draco_git_dir} rev-parse HEAD + --git-dir=${draco_git_dir} rev-parse HEAD OUTPUT_VARIABLE draco_git_hash) - execute_process( - COMMAND ${GIT_EXECUTABLE} --git-dir=${draco_git_dir}/.git describe - OUTPUT_VARIABLE draco_git_desc ERROR_QUIET) + execute_process(COMMAND ${GIT_EXECUTABLE} + --git-dir=${draco_git_dir}/.git describe + OUTPUT_VARIABLE draco_git_desc + ERROR_QUIET) # Consume newlines from Git output. string(STRIP "${draco_git_hash}" draco_git_hash) string(STRIP "${draco_git_desc}" draco_git_desc) - endif () -endif () -if (draco_git_hash STREQUAL "") + endif() +endif() +if(draco_git_hash STREQUAL "") set(draco_git_desc "unknown") -endif () -if (draco_git_desc STREQUAL "") +endif() +if(draco_git_desc STREQUAL "") set(draco_git_desc "unreleased") -endif () +endif() configure_file("${draco_root}/cmake/draco_version.cc.cmake" "${draco_build_dir}/draco_version.cc") configure_file("${draco_root}/cmake/draco_version.h.cmake" "${draco_build_dir}/draco_version.h" COPYONLY) -if (EMSCRIPTEN) +if(EMSCRIPTEN) include(FindPythonInterp) - if (NOT PYTHONINTERP_FOUND) - message(FATAL_ERROR - "Python required for Emscripten builds, but cmake cannot find it.") - endif () -else () - if (ENABLE_TESTS) - if (MSVC) + if(NOT PYTHONINTERP_FOUND) + message( + FATAL_ERROR + "Python required for Emscripten builds, but cmake cannot find it.") + endif() +else() + if(ENABLE_TESTS) + if(MSVC) # Default runtime selected by cmake collides with Googletest settings, # just force all Draco builds to be static (instead of dll/msvcrt). include("${draco_root}/cmake/msvc_runtime.cmake") - endif () + endif() # Googletest defaults. set(GTEST_SOURCE_DIR - "${draco_root}/../googletest" CACHE STRING - "Path to googletest source directory") - set(GTEST_BUILD_DIR - "${draco_build_dir}/googletest" CACHE STRING - "Path to directory where googletest will be configured and built.") + "${draco_root}/../googletest" + CACHE STRING "Path to googletest source directory") + set( + GTEST_BUILD_DIR + "${draco_build_dir}/googletest" + CACHE STRING + "Path to directory where googletest will be configured and built.") # Confirm Googletest is where expected. - if (NOT EXISTS "${GTEST_SOURCE_DIR}/CMakeLists.txt") + if(NOT EXISTS "${GTEST_SOURCE_DIR}/CMakeLists.txt") set(ENABLE_TESTS OFF) message("Tests disabled: Google test CMakeLists.txt does not exist.") - else () - if (APPLE AND BUILD_SHARED_LIBS) - # Silence an RPATH warning emitted during processing of Googletest - # cmake files. + else() + if(APPLE AND BUILD_SHARED_LIBS) + # Silence an RPATH warning emitted during processing of Googletest cmake + # files. set(CMAKE_MACOSX_RPATH 1) - endif () + endif() set(DRACO_TEST_DATA_DIR "${draco_root}/testdata") configure_file("${draco_root}/cmake/draco_test_config.h.cmake" "${draco_build_dir}/testing/draco_test_config.h") add_subdirectory("${GTEST_SOURCE_DIR}" "${GTEST_BUILD_DIR}" EXCLUDE_FROM_ALL) - endif () + endif() include_directories("${GTEST_SOURCE_DIR}") - endif () -endif () + endif() +endif() # Draco source file listing variables. set(draco_attributes_sources @@ -239,100 +243,108 @@ set(draco_attributes_sources "${draco_src_root}/attributes/point_attribute.cc" "${draco_src_root}/attributes/point_attribute.h") -set(draco_compression_attributes_dec_sources - "${draco_src_root}/compression/attributes/attributes_decoder.cc" - "${draco_src_root}/compression/attributes/attributes_decoder.h" - "${draco_src_root}/compression/attributes/kd_tree_attributes_decoder.cc" - "${draco_src_root}/compression/attributes/kd_tree_attributes_decoder.h" - "${draco_src_root}/compression/attributes/kd_tree_attributes_shared.h" - "${draco_src_root}/compression/attributes/mesh_attribute_indices_encoding_data.h" - "${draco_src_root}/compression/attributes/normal_compression_utils.h" - "${draco_src_root}/compression/attributes/point_d_vector.h" - "${draco_src_root}/compression/attributes/sequential_attribute_decoder.cc" - "${draco_src_root}/compression/attributes/sequential_attribute_decoder.h" - "${draco_src_root}/compression/attributes/sequential_attribute_decoders_controller.cc" - "${draco_src_root}/compression/attributes/sequential_attribute_decoders_controller.h" - "${draco_src_root}/compression/attributes/sequential_integer_attribute_decoder.cc" - "${draco_src_root}/compression/attributes/sequential_integer_attribute_decoder.h" - "${draco_src_root}/compression/attributes/sequential_normal_attribute_decoder.cc" - "${draco_src_root}/compression/attributes/sequential_normal_attribute_decoder.h" - "${draco_src_root}/compression/attributes/sequential_quantization_attribute_decoder.cc" - "${draco_src_root}/compression/attributes/sequential_quantization_attribute_decoder.h") +set( + draco_compression_attributes_dec_sources + "${draco_src_root}/compression/attributes/attributes_decoder.cc" + "${draco_src_root}/compression/attributes/attributes_decoder.h" + "${draco_src_root}/compression/attributes/kd_tree_attributes_decoder.cc" + "${draco_src_root}/compression/attributes/kd_tree_attributes_decoder.h" + "${draco_src_root}/compression/attributes/kd_tree_attributes_shared.h" + "${draco_src_root}/compression/attributes/mesh_attribute_indices_encoding_data.h" + "${draco_src_root}/compression/attributes/normal_compression_utils.h" + "${draco_src_root}/compression/attributes/point_d_vector.h" + "${draco_src_root}/compression/attributes/sequential_attribute_decoder.cc" + "${draco_src_root}/compression/attributes/sequential_attribute_decoder.h" + "${draco_src_root}/compression/attributes/sequential_attribute_decoders_controller.cc" + "${draco_src_root}/compression/attributes/sequential_attribute_decoders_controller.h" + "${draco_src_root}/compression/attributes/sequential_integer_attribute_decoder.cc" + "${draco_src_root}/compression/attributes/sequential_integer_attribute_decoder.h" + "${draco_src_root}/compression/attributes/sequential_normal_attribute_decoder.cc" + "${draco_src_root}/compression/attributes/sequential_normal_attribute_decoder.h" + "${draco_src_root}/compression/attributes/sequential_quantization_attribute_decoder.cc" + "${draco_src_root}/compression/attributes/sequential_quantization_attribute_decoder.h" + ) -set(draco_compression_attributes_enc_sources - "${draco_src_root}/compression/attributes/attributes_encoder.cc" - "${draco_src_root}/compression/attributes/attributes_encoder.h" - "${draco_src_root}/compression/attributes/kd_tree_attributes_encoder.cc" - "${draco_src_root}/compression/attributes/kd_tree_attributes_encoder.h" - "${draco_src_root}/compression/attributes/linear_sequencer.h" - "${draco_src_root}/compression/attributes/points_sequencer.h" - "${draco_src_root}/compression/attributes/sequential_attribute_encoder.cc" - "${draco_src_root}/compression/attributes/sequential_attribute_encoder.h" - "${draco_src_root}/compression/attributes/sequential_attribute_encoders_controller.cc" - "${draco_src_root}/compression/attributes/sequential_attribute_encoders_controller.h" - "${draco_src_root}/compression/attributes/sequential_integer_attribute_encoder.cc" - "${draco_src_root}/compression/attributes/sequential_integer_attribute_encoder.h" - "${draco_src_root}/compression/attributes/sequential_normal_attribute_encoder.cc" - "${draco_src_root}/compression/attributes/sequential_normal_attribute_encoder.h" - "${draco_src_root}/compression/attributes/sequential_quantization_attribute_encoder.cc" - "${draco_src_root}/compression/attributes/sequential_quantization_attribute_encoder.h") +set( + draco_compression_attributes_enc_sources + "${draco_src_root}/compression/attributes/attributes_encoder.cc" + "${draco_src_root}/compression/attributes/attributes_encoder.h" + "${draco_src_root}/compression/attributes/kd_tree_attributes_encoder.cc" + "${draco_src_root}/compression/attributes/kd_tree_attributes_encoder.h" + "${draco_src_root}/compression/attributes/linear_sequencer.h" + "${draco_src_root}/compression/attributes/points_sequencer.h" + "${draco_src_root}/compression/attributes/sequential_attribute_encoder.cc" + "${draco_src_root}/compression/attributes/sequential_attribute_encoder.h" + "${draco_src_root}/compression/attributes/sequential_attribute_encoders_controller.cc" + "${draco_src_root}/compression/attributes/sequential_attribute_encoders_controller.h" + "${draco_src_root}/compression/attributes/sequential_integer_attribute_encoder.cc" + "${draco_src_root}/compression/attributes/sequential_integer_attribute_encoder.h" + "${draco_src_root}/compression/attributes/sequential_normal_attribute_encoder.cc" + "${draco_src_root}/compression/attributes/sequential_normal_attribute_encoder.h" + "${draco_src_root}/compression/attributes/sequential_quantization_attribute_encoder.cc" + "${draco_src_root}/compression/attributes/sequential_quantization_attribute_encoder.h" + ) -set(draco_compression_attributes_pred_schemes_dec_sources - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_decoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_decoder_factory.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_decoder_interface.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_decoding_transform.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_delta_decoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_factory.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_interface.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_decoding_transform.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_wrap_decoding_transform.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h") +set( + draco_compression_attributes_pred_schemes_dec_sources + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_decoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_decoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_decoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_decoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_decoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_decoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_decoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_decoder_factory.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_decoder_interface.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_decoding_transform.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_delta_decoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_factory.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_interface.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_decoding_transform.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_decoding_transform.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_wrap_decoding_transform.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h" + ) -set(draco_compression_attributes_pred_schemes_enc_sources - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_encoder.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.cc" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_factory.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_interface.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_encoding_transform.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_wrap_encoding_transform.h" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h") +set( + draco_compression_attributes_pred_schemes_enc_sources + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_encoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_constrained_multi_parallelogram_shared.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_data.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_encoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_encoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_area.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_geometric_normal_predictor_base.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_multi_parallelogram_encoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_encoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_parallelogram_shared.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_encoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_encoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/mesh_prediction_scheme_tex_coords_portable_predictor.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_delta_encoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_encoder.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.cc" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_encoder_factory.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_encoder_interface.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_encoding_transform.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_factory.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_interface.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_encoding_transform.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_base.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_encoding_transform.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_base.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_wrap_encoding_transform.h" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_wrap_transform_base.h" + ) set(draco_compression_bit_coders_sources "${draco_src_root}/compression/bit_coders/adaptive_rans_bit_coding_shared.h" @@ -366,9 +378,8 @@ set(draco_dec_config_sources "${draco_src_root}/compression/config/decoder_options.h" "${draco_src_root}/compression/config/draco_options.h") -set(draco_compression_decode_sources - "${draco_src_root}/compression/decode.cc" - "${draco_src_root}/compression/decode.h") +set(draco_compression_decode_sources "${draco_src_root}/compression/decode.cc" + "${draco_src_root}/compression/decode.h") set(draco_compression_encode_sources "${draco_src_root}/compression/encode.cc" @@ -377,61 +388,65 @@ set(draco_compression_encode_sources "${draco_src_root}/compression/expert_encode.cc" "${draco_src_root}/compression/expert_encode.h") +set( + draco_compression_mesh_traverser_sources + "${draco_src_root}/compression/mesh/traverser/depth_first_traverser.h" + "${draco_src_root}/compression/mesh/traverser/max_prediction_degree_traverser.h" + "${draco_src_root}/compression/mesh/traverser/mesh_attribute_indices_encoding_observer.h" + "${draco_src_root}/compression/mesh/traverser/mesh_traversal_sequencer.h" + "${draco_src_root}/compression/mesh/traverser/traverser_base.h") -set(draco_compression_mesh_traverser_sources - "${draco_src_root}/compression/mesh/traverser/depth_first_traverser.h" - "${draco_src_root}/compression/mesh/traverser/max_prediction_degree_traverser.h" - "${draco_src_root}/compression/mesh/traverser/mesh_attribute_indices_encoding_observer.h" - "${draco_src_root}/compression/mesh/traverser/mesh_traversal_sequencer.h" - "${draco_src_root}/compression/mesh/traverser/traverser_base.h") +set( + draco_compression_mesh_dec_sources + "${draco_src_root}/compression/mesh/mesh_decoder.cc" + "${draco_src_root}/compression/mesh/mesh_decoder.h" + "${draco_src_root}/compression/mesh/mesh_decoder_helpers.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_decoder.cc" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_decoder.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_decoder_impl.cc" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_decoder_impl.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_shared.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_traversal_decoder.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_traversal_predictive_decoder.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h" + "${draco_src_root}/compression/mesh/mesh_sequential_decoder.cc" + "${draco_src_root}/compression/mesh/mesh_sequential_decoder.h") -set(draco_compression_mesh_dec_sources - "${draco_src_root}/compression/mesh/mesh_decoder.cc" - "${draco_src_root}/compression/mesh/mesh_decoder.h" - "${draco_src_root}/compression/mesh/mesh_decoder_helpers.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_decoder.cc" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_decoder.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_decoder_impl.cc" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_decoder_impl.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_decoder_impl_interface.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_shared.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_traversal_decoder.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_traversal_predictive_decoder.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_traversal_valence_decoder.h" - "${draco_src_root}/compression/mesh/mesh_sequential_decoder.cc" - "${draco_src_root}/compression/mesh/mesh_sequential_decoder.h") +set( + draco_compression_mesh_enc_sources + "${draco_src_root}/compression/mesh/mesh_edgebreaker_encoder.cc" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_encoder.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_encoder_impl.cc" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_encoder_impl.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_shared.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_traversal_encoder.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h" + "${draco_src_root}/compression/mesh/mesh_encoder.cc" + "${draco_src_root}/compression/mesh/mesh_encoder.h" + "${draco_src_root}/compression/mesh/mesh_encoder_helpers.h" + "${draco_src_root}/compression/mesh/mesh_sequential_encoder.cc" + "${draco_src_root}/compression/mesh/mesh_sequential_encoder.h") -set(draco_compression_mesh_enc_sources - "${draco_src_root}/compression/mesh/mesh_edgebreaker_encoder.cc" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_encoder.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_encoder_impl.cc" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_encoder_impl.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_encoder_impl_interface.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_shared.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_traversal_encoder.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_traversal_predictive_encoder.h" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_traversal_valence_encoder.h" - "${draco_src_root}/compression/mesh/mesh_encoder.cc" - "${draco_src_root}/compression/mesh/mesh_encoder.h" - "${draco_src_root}/compression/mesh/mesh_encoder_helpers.h" - "${draco_src_root}/compression/mesh/mesh_sequential_encoder.cc" - "${draco_src_root}/compression/mesh/mesh_sequential_encoder.h") +set( + draco_compression_point_cloud_dec_sources + "${draco_src_root}/compression/point_cloud/point_cloud_decoder.cc" + "${draco_src_root}/compression/point_cloud/point_cloud_decoder.h" + "${draco_src_root}/compression/point_cloud/point_cloud_kd_tree_decoder.cc" + "${draco_src_root}/compression/point_cloud/point_cloud_kd_tree_decoder.h" + "${draco_src_root}/compression/point_cloud/point_cloud_sequential_decoder.cc" + "${draco_src_root}/compression/point_cloud/point_cloud_sequential_decoder.h") -set(draco_compression_point_cloud_dec_sources - "${draco_src_root}/compression/point_cloud/point_cloud_decoder.cc" - "${draco_src_root}/compression/point_cloud/point_cloud_decoder.h" - "${draco_src_root}/compression/point_cloud/point_cloud_kd_tree_decoder.cc" - "${draco_src_root}/compression/point_cloud/point_cloud_kd_tree_decoder.h" - "${draco_src_root}/compression/point_cloud/point_cloud_sequential_decoder.cc" - "${draco_src_root}/compression/point_cloud/point_cloud_sequential_decoder.h") - -set(draco_compression_point_cloud_enc_sources - "${draco_src_root}/compression/point_cloud/point_cloud_encoder.cc" - "${draco_src_root}/compression/point_cloud/point_cloud_encoder.h" - "${draco_src_root}/compression/point_cloud/point_cloud_kd_tree_encoder.cc" - "${draco_src_root}/compression/point_cloud/point_cloud_kd_tree_encoder.h" - "${draco_src_root}/compression/point_cloud/point_cloud_sequential_encoder.cc" - "${draco_src_root}/compression/point_cloud/point_cloud_sequential_encoder.h") +set( + draco_compression_point_cloud_enc_sources + "${draco_src_root}/compression/point_cloud/point_cloud_encoder.cc" + "${draco_src_root}/compression/point_cloud/point_cloud_encoder.h" + "${draco_src_root}/compression/point_cloud/point_cloud_kd_tree_encoder.cc" + "${draco_src_root}/compression/point_cloud/point_cloud_kd_tree_encoder.h" + "${draco_src_root}/compression/point_cloud/point_cloud_sequential_encoder.cc" + "${draco_src_root}/compression/point_cloud/point_cloud_sequential_encoder.h") set(draco_compression_entropy_sources "${draco_src_root}/compression/entropy/ans.h" @@ -526,41 +541,42 @@ set(draco_point_cloud_sources "${draco_src_root}/point_cloud/point_cloud_builder.cc" "${draco_src_root}/point_cloud/point_cloud_builder.h") -set(draco_points_common_sources - "${draco_src_root}/compression/point_cloud/algorithms/point_cloud_compression_method.h" - "${draco_src_root}/compression/point_cloud/algorithms/point_cloud_types.h" - "${draco_src_root}/compression/point_cloud/algorithms/quantize_points_3.h" - "${draco_src_root}/compression/point_cloud/algorithms/queuing_policy.h") +set( + draco_points_common_sources + "${draco_src_root}/compression/point_cloud/algorithms/point_cloud_compression_method.h" + "${draco_src_root}/compression/point_cloud/algorithms/point_cloud_types.h" + "${draco_src_root}/compression/point_cloud/algorithms/quantize_points_3.h" + "${draco_src_root}/compression/point_cloud/algorithms/queuing_policy.h") -set(draco_points_dec_sources - "${draco_src_root}/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.cc" - "${draco_src_root}/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h" - "${draco_src_root}/compression/point_cloud/algorithms/float_points_tree_decoder.cc" - "${draco_src_root}/compression/point_cloud/algorithms/float_points_tree_decoder.h") +set( + draco_points_dec_sources + "${draco_src_root}/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.cc" + "${draco_src_root}/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_decoder.h" + "${draco_src_root}/compression/point_cloud/algorithms/float_points_tree_decoder.cc" + "${draco_src_root}/compression/point_cloud/algorithms/float_points_tree_decoder.h" + ) -set(draco_points_enc_sources - "${draco_src_root}/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.cc" - "${draco_src_root}/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h" - "${draco_src_root}/compression/point_cloud/algorithms/float_points_tree_encoder.cc" - "${draco_src_root}/compression/point_cloud/algorithms/float_points_tree_encoder.h") +set( + draco_points_enc_sources + "${draco_src_root}/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.cc" + "${draco_src_root}/compression/point_cloud/algorithms/dynamic_integer_points_kd_tree_encoder.h" + "${draco_src_root}/compression/point_cloud/algorithms/float_points_tree_encoder.cc" + "${draco_src_root}/compression/point_cloud/algorithms/float_points_tree_encoder.h" + ) -set(draco_metadata_sources - "${draco_src_root}/metadata/geometry_metadata.cc" - "${draco_src_root}/metadata/geometry_metadata.h" - "${draco_src_root}/metadata/metadata.cc" - "${draco_src_root}/metadata/metadata.h") +set(draco_metadata_sources "${draco_src_root}/metadata/geometry_metadata.cc" + "${draco_src_root}/metadata/geometry_metadata.h" + "${draco_src_root}/metadata/metadata.cc" + "${draco_src_root}/metadata/metadata.h") -set(draco_metadata_enc_sources - "${draco_src_root}/metadata/metadata_encoder.cc" - "${draco_src_root}/metadata/metadata_encoder.h") +set(draco_metadata_enc_sources "${draco_src_root}/metadata/metadata_encoder.cc" + "${draco_src_root}/metadata/metadata_encoder.h") -set(draco_metadata_dec_sources - "${draco_src_root}/metadata/metadata_decoder.cc" - "${draco_src_root}/metadata/metadata_decoder.h") +set(draco_metadata_dec_sources "${draco_src_root}/metadata/metadata_decoder.cc" + "${draco_src_root}/metadata/metadata_decoder.h") -set(draco_animation_sources - "${draco_src_root}/animation/keyframe_animation.cc" - "${draco_src_root}/animation/keyframe_animation.h") +set(draco_animation_sources "${draco_src_root}/animation/keyframe_animation.cc" + "${draco_src_root}/animation/keyframe_animation.h") set(draco_animation_enc_sources "${draco_src_root}/animation/keyframe_animation_encoder.cc" @@ -578,96 +594,98 @@ set(draco_js_enc_sources "${draco_src_root}/javascript/emscripten/draco_encoder_glue_wrapper.cc" "${draco_src_root}/javascript/emscripten/encoder_webidl_wrapper.cc") -set(draco_animation_js_dec_sources - "${draco_src_root}/javascript/emscripten/animation_decoder_webidl_wrapper.cc" - "${draco_src_root}/javascript/emscripten/draco_animation_decoder_glue_wrapper.cc") +set( + draco_animation_js_dec_sources + "${draco_src_root}/javascript/emscripten/animation_decoder_webidl_wrapper.cc" + "${draco_src_root}/javascript/emscripten/draco_animation_decoder_glue_wrapper.cc" + ) -set(draco_animation_js_enc_sources - "${draco_src_root}/javascript/emscripten/animation_encoder_webidl_wrapper.cc" - "${draco_src_root}/javascript/emscripten/draco_animation_encoder_glue_wrapper.cc") +set( + draco_animation_js_enc_sources + "${draco_src_root}/javascript/emscripten/animation_encoder_webidl_wrapper.cc" + "${draco_src_root}/javascript/emscripten/draco_animation_encoder_glue_wrapper.cc" + ) -set(draco_test_sources - "${draco_src_root}/animation/keyframe_animation_encoding_test.cc" - "${draco_src_root}/animation/keyframe_animation_test.cc" - "${draco_src_root}/attributes/point_attribute_test.cc" - "${draco_src_root}/compression/attributes/point_d_vector_test.cc" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_test.cc" - "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_test.cc" - "${draco_src_root}/compression/attributes/sequential_integer_attribute_encoding_test.cc" - "${draco_src_root}/compression/bit_coders/rans_coding_test.cc" - "${draco_src_root}/compression/decode_test.cc" - "${draco_src_root}/compression/encode_test.cc" - "${draco_src_root}/compression/entropy/shannon_entropy_test.cc" - "${draco_src_root}/compression/entropy/symbol_coding_test.cc" - "${draco_src_root}/compression/mesh/mesh_edgebreaker_encoding_test.cc" - "${draco_src_root}/compression/mesh/mesh_encoder_test.cc" - "${draco_src_root}/compression/point_cloud/point_cloud_kd_tree_encoding_test.cc" - "${draco_src_root}/compression/point_cloud/point_cloud_sequential_encoding_test.cc" - "${draco_src_root}/core/buffer_bit_coding_test.cc" - "${draco_src_root}/core/draco_test_base.h" - "${draco_src_root}/core/draco_test_utils.cc" - "${draco_src_root}/core/draco_test_utils.h" - "${draco_src_root}/core/draco_tests.cc" - "${draco_src_root}/core/math_utils_test.cc" - "${draco_src_root}/core/quantization_utils_test.cc" - "${draco_src_root}/core/status_test.cc" - "${draco_src_root}/core/vector_d_test.cc" - "${draco_src_root}/io/obj_decoder_test.cc" - "${draco_src_root}/io/obj_encoder_test.cc" - "${draco_src_root}/io/ply_decoder_test.cc" - "${draco_src_root}/io/ply_reader_test.cc" - "${draco_src_root}/io/point_cloud_io_test.cc" - "${draco_src_root}/mesh/mesh_are_equivalent_test.cc" - "${draco_src_root}/mesh/mesh_cleanup_test.cc" - "${draco_src_root}/mesh/triangle_soup_mesh_builder_test.cc" - "${draco_src_root}/metadata/metadata_encoder_test.cc" - "${draco_src_root}/metadata/metadata_test.cc" - "${draco_src_root}/point_cloud/point_cloud_builder_test.cc" - "${draco_src_root}/point_cloud/point_cloud_test.cc") +set( + draco_test_sources + "${draco_src_root}/animation/keyframe_animation_encoding_test.cc" + "${draco_src_root}/animation/keyframe_animation_test.cc" + "${draco_src_root}/attributes/point_attribute_test.cc" + "${draco_src_root}/compression/attributes/point_d_vector_test.cc" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_canonicalized_transform_test.cc" + "${draco_src_root}/compression/attributes/prediction_schemes/prediction_scheme_normal_octahedron_transform_test.cc" + "${draco_src_root}/compression/attributes/sequential_integer_attribute_encoding_test.cc" + "${draco_src_root}/compression/bit_coders/rans_coding_test.cc" + "${draco_src_root}/compression/decode_test.cc" + "${draco_src_root}/compression/encode_test.cc" + "${draco_src_root}/compression/entropy/shannon_entropy_test.cc" + "${draco_src_root}/compression/entropy/symbol_coding_test.cc" + "${draco_src_root}/compression/mesh/mesh_edgebreaker_encoding_test.cc" + "${draco_src_root}/compression/mesh/mesh_encoder_test.cc" + "${draco_src_root}/compression/point_cloud/point_cloud_kd_tree_encoding_test.cc" + "${draco_src_root}/compression/point_cloud/point_cloud_sequential_encoding_test.cc" + "${draco_src_root}/core/buffer_bit_coding_test.cc" + "${draco_src_root}/core/draco_test_base.h" + "${draco_src_root}/core/draco_test_utils.cc" + "${draco_src_root}/core/draco_test_utils.h" + "${draco_src_root}/core/draco_tests.cc" + "${draco_src_root}/core/math_utils_test.cc" + "${draco_src_root}/core/quantization_utils_test.cc" + "${draco_src_root}/core/status_test.cc" + "${draco_src_root}/core/vector_d_test.cc" + "${draco_src_root}/io/obj_decoder_test.cc" + "${draco_src_root}/io/obj_encoder_test.cc" + "${draco_src_root}/io/ply_decoder_test.cc" + "${draco_src_root}/io/ply_reader_test.cc" + "${draco_src_root}/io/point_cloud_io_test.cc" + "${draco_src_root}/mesh/mesh_are_equivalent_test.cc" + "${draco_src_root}/mesh/mesh_cleanup_test.cc" + "${draco_src_root}/mesh/triangle_soup_mesh_builder_test.cc" + "${draco_src_root}/metadata/metadata_encoder_test.cc" + "${draco_src_root}/metadata/metadata_test.cc" + "${draco_src_root}/point_cloud/point_cloud_builder_test.cc" + "${draco_src_root}/point_cloud/point_cloud_test.cc") -set(draco_version_sources - "${draco_build_dir}/draco_version.cc" - "${draco_build_dir}/draco_version.h") +set(draco_version_sources "${draco_build_dir}/draco_version.cc" + "${draco_build_dir}/draco_version.h") -set(draco_unity_plug_sources - "${draco_src_root}/unity/draco_unity_plugin.cc" - "${draco_src_root}/unity/draco_unity_plugin.h") +set(draco_unity_plug_sources "${draco_src_root}/unity/draco_unity_plugin.cc" + "${draco_src_root}/unity/draco_unity_plugin.h") -set(draco_maya_plug_sources - "${draco_src_root}/maya/draco_maya_plugin.cc" - "${draco_src_root}/maya/draco_maya_plugin.h") +set(draco_maya_plug_sources "${draco_src_root}/maya/draco_maya_plugin.cc" + "${draco_src_root}/maya/draco_maya_plugin.h") include_directories("${draco_root}/src" "${draco_build_dir}") # # Draco targets. # -if (EMSCRIPTEN AND ENABLE_JS_GLUE) +if(EMSCRIPTEN AND ENABLE_JS_GLUE) # Draco js decoder. require_compiler_flag("-s ALLOW_MEMORY_GROWTH=1" YES) require_compiler_flag("-Wno-almost-asm" YES) require_compiler_flag("--memory-init-file 0" YES) require_compiler_flag("-fno-omit-frame-pointer" YES) require_compiler_flag("-s MODULARIZE=1" YES) - if (ENABLE_EXTRA_SPEED) + if(ENABLE_EXTRA_SPEED) require_compiler_flag("--llvm-lto 1" YES) - endif () + endif() require_compiler_flag("-s NO_FILESYSTEM=1" YES) require_compiler_flag("-s EXPORTED_RUNTIME_METHODS=[]" YES) require_compiler_flag("-s PRECISE_F32=1" YES) - if (ENABLE_WASM) + if(ENABLE_WASM) require_compiler_flag("-s WASM=1" YES) - else () + else() require_compiler_flag("-s ELIMINATE_DUPLICATE_FUNCTIONS=1" YES) - endif () - if (IE_COMPATIBLE) + endif() + if(IE_COMPATIBLE) require_compiler_flag("-s LEGACY_VM_SUPPORT=1" YES) - endif () + endif() - if (CMAKE_BUILD_TYPE STREQUAL "") + if(CMAKE_BUILD_TYPE STREQUAL "") # Force -O3 when no build type is specified. add_compiler_flag_if_supported("-O3") - endif () + endif() set(draco_js_dec_idl "${draco_src_root}/javascript/emscripten/draco_web_decoder.idl") @@ -681,31 +699,29 @@ if (EMSCRIPTEN AND ENABLE_JS_GLUE) # Generate ${draco_build_dir}/glue_decoder.cpp at cmake generation time so it # can be added to targets without cmake reporting errors. execute_process(COMMAND ${PYTHON_EXECUTABLE} - $ENV{EMSCRIPTEN}/tools/webidl_binder.py - ${draco_js_dec_idl} - ${draco_build_dir}/glue_decoder) + $ENV{EMSCRIPTEN}/tools/webidl_binder.py + ${draco_js_dec_idl} ${draco_build_dir}/glue_decoder) execute_process(COMMAND ${PYTHON_EXECUTABLE} - $ENV{EMSCRIPTEN}/tools/webidl_binder.py - ${draco_js_enc_idl} - ${draco_build_dir}/glue_encoder) + $ENV{EMSCRIPTEN}/tools/webidl_binder.py + ${draco_js_enc_idl} ${draco_build_dir}/glue_encoder) - if (NOT EXISTS "${draco_build_dir}/glue_decoder.cpp" OR - NOT EXISTS "${draco_build_dir}/glue_encoder.cpp") + if(NOT EXISTS "${draco_build_dir}/glue_decoder.cpp" + OR NOT EXISTS "${draco_build_dir}/glue_encoder.cpp") message(FATAL_ERROR "Glue generation failed.") - endif () + endif() - if (BUILD_ANIMATION_ENCODING) + if(BUILD_ANIMATION_ENCODING) execute_process(COMMAND ${PYTHON_EXECUTABLE} - $ENV{EMSCRIPTEN}/tools/webidl_binder.py - ${draco_animation_js_dec_idl} - ${draco_build_dir}/glue_animation_decoder) + $ENV{EMSCRIPTEN}/tools/webidl_binder.py + ${draco_animation_js_dec_idl} + ${draco_build_dir}/glue_animation_decoder) execute_process(COMMAND ${PYTHON_EXECUTABLE} - $ENV{EMSCRIPTEN}/tools/webidl_binder.py - ${draco_animation_js_enc_idl} - ${draco_build_dir}/glue_animation_encoder) - if (NOT EXISTS "${draco_build_dir}/glue_animation_decoder.cpp" OR - NOT EXISTS "${draco_build_dir}/glue_animation_encoder.cpp") + $ENV{EMSCRIPTEN}/tools/webidl_binder.py + ${draco_animation_js_enc_idl} + ${draco_build_dir}/glue_animation_encoder) + if(NOT EXISTS "${draco_build_dir}/glue_animation_decoder.cpp" + OR NOT EXISTS "${draco_build_dir}/glue_animation_encoder.cpp") message(FATAL_ERROR "Animation glue generation failed.") endif() endif() @@ -714,9 +730,8 @@ if (EMSCRIPTEN AND ENABLE_JS_GLUE) # ${draco_build_dir}/glue_decoder.cpp as needed. add_custom_command(OUTPUT ${draco_build_dir}/glue_decoder.cpp COMMAND ${PYTHON_EXECUTABLE} - $ENV{EMSCRIPTEN}/tools/webidl_binder.py - ${draco_js_dec_idl} - ${draco_build_dir}/glue_decoder + $ENV{EMSCRIPTEN}/tools/webidl_binder.py + ${draco_js_dec_idl} ${draco_build_dir}/glue_decoder DEPENDS ${draco_js_dec_idl} COMMENT "Generating ${draco_build_dir}/glue_decoder.cpp." WORKING_DIRECTORY ${draco_build_dir} @@ -724,33 +739,32 @@ if (EMSCRIPTEN AND ENABLE_JS_GLUE) add_custom_command(OUTPUT ${draco_build_dir}/glue_encoder.cpp COMMAND ${PYTHON_EXECUTABLE} - $ENV{EMSCRIPTEN}/tools/webidl_binder.py - ${draco_js_enc_idl} - ${draco_build_dir}/glue_encoder + $ENV{EMSCRIPTEN}/tools/webidl_binder.py + ${draco_js_enc_idl} ${draco_build_dir}/glue_encoder DEPENDS ${draco_js_enc_idl} COMMENT "Generating ${draco_build_dir}/glue_encoder.cpp." WORKING_DIRECTORY ${draco_build_dir} VERBATIM) - if (BUILD_ANIMATION_ENCODING) - add_custom_command(OUTPUT ${draco_build_dir}/glue_animation_decoder.cpp - COMMAND ${PYTHON_EXECUTABLE} - $ENV{EMSCRIPTEN}/tools/webidl_binder.py - ${draco_animation_js_dec_idl} - ${draco_build_dir}/glue_animation_decoder - DEPENDS ${draco_animation_js_dec_idl} - COMMENT "Generating ${draco_build_dir}/glue_animation_decoder.cpp." - WORKING_DIRECTORY ${draco_build_dir} - VERBATIM) - add_custom_command(OUTPUT ${draco_build_dir}/glue_animation_encoder.cpp - COMMAND ${PYTHON_EXECUTABLE} - $ENV{EMSCRIPTEN}/tools/webidl_binder.py - ${draco_animation_js_enc_idl} - ${draco_build_dir}/glue_animation_encoder - DEPENDS ${draco_animation_js_enc_idl} - COMMENT "Generating ${draco_build_dir}/glue_animation_encoder.cpp." - WORKING_DIRECTORY ${draco_build_dir} - VERBATIM) + if(BUILD_ANIMATION_ENCODING) + add_custom_command( + OUTPUT ${draco_build_dir}/glue_animation_decoder.cpp + COMMAND ${PYTHON_EXECUTABLE} $ENV{EMSCRIPTEN}/tools/webidl_binder.py + ${draco_animation_js_dec_idl} + ${draco_build_dir}/glue_animation_decoder + DEPENDS ${draco_animation_js_dec_idl} + COMMENT "Generating ${draco_build_dir}/glue_animation_decoder.cpp." + WORKING_DIRECTORY ${draco_build_dir} + VERBATIM) + add_custom_command( + OUTPUT ${draco_build_dir}/glue_animation_encoder.cpp + COMMAND ${PYTHON_EXECUTABLE} $ENV{EMSCRIPTEN}/tools/webidl_binder.py + ${draco_animation_js_enc_idl} + ${draco_build_dir}/glue_animation_encoder + DEPENDS ${draco_animation_js_enc_idl} + COMMENT "Generating ${draco_build_dir}/glue_animation_encoder.cpp." + WORKING_DIRECTORY ${draco_build_dir} + VERBATIM) endif() set(draco_decoder_src @@ -793,15 +807,11 @@ if (EMSCRIPTEN AND ENABLE_JS_GLUE) ${draco_points_enc_sources} ${draco_version_sources}) - add_executable(draco_decoder - ${draco_js_dec_sources} - ${draco_decoder_src}) + add_executable(draco_decoder ${draco_js_dec_sources} ${draco_decoder_src}) append_link_flag_to_target(draco_decoder "-s EXPORT_NAME=\"'DracoDecoderModule'\"") - add_executable(draco_encoder - ${draco_js_enc_sources} - ${draco_encoder_src}) + add_executable(draco_encoder ${draco_js_enc_sources} ${draco_encoder_src}) append_link_flag_to_target(draco_encoder "-s EXPORT_NAME=\"'DracoEncoderModule'\"") @@ -809,50 +819,52 @@ if (EMSCRIPTEN AND ENABLE_JS_GLUE) TARGETS draco_encoder) draco_enable_feature(FEATURE DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED TARGETS draco_encoder) - if (ENABLE_DECODER_ATTRIBUTE_DEDUPLICATION) + if(ENABLE_DECODER_ATTRIBUTE_DEDUPLICATION) draco_enable_feature(FEATURE DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED TARGETS draco_decoder) draco_enable_feature(FEATURE DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED TARGETS draco_decoder) - endif () + endif() # Make $draco_js_sources source files depend on glue_decoder.cpp. - set_property(SOURCE ${draco_js_sources} APPEND PROPERTY OBJECT_DEPENDS - ${draco_build_dir}/glue_decoder.cpp) + set_property(SOURCE ${draco_js_sources} + APPEND + PROPERTY OBJECT_DEPENDS ${draco_build_dir}/glue_decoder.cpp) em_link_pre_js(draco_decoder "${draco_src_root}/javascript/emscripten/prepareCallbacks.js" "${draco_src_root}/javascript/emscripten/version.js") - em_link_post_js(draco_decoder - "${draco_build_dir}/glue_decoder.js" + em_link_post_js(draco_decoder "${draco_build_dir}/glue_decoder.js" "${draco_src_root}/javascript/emscripten/finalize.js") - set_property(SOURCE ${draco_js_enc_sources} APPEND PROPERTY OBJECT_DEPENDS - ${draco_build_dir}/glue_encoder.cpp) + set_property(SOURCE ${draco_js_enc_sources} + APPEND + PROPERTY OBJECT_DEPENDS ${draco_build_dir}/glue_encoder.cpp) em_link_pre_js(draco_encoder "${draco_src_root}/javascript/emscripten/prepareCallbacks.js" "${draco_src_root}/javascript/emscripten/version.js") - em_link_post_js(draco_encoder - "${draco_build_dir}/glue_encoder.js" + em_link_post_js(draco_encoder "${draco_build_dir}/glue_encoder.js" "${draco_src_root}/javascript/emscripten/finalize.js") - if (BUILD_ANIMATION_ENCODING) - add_executable(draco_animation_decoder - ${draco_animation_dec_sources} - ${draco_animation_js_dec_sources} - ${draco_animation_sources} - ${draco_decoder_src}) - add_executable(draco_animation_encoder - ${draco_animation_enc_sources} - ${draco_animation_js_enc_sources} - ${draco_animation_sources} - ${draco_encoder_src}) - append_link_flag_to_target(draco_animation_decoder - "-s EXPORT_NAME=\"'DracoAnimationDecoderModule'\"") - append_link_flag_to_target(draco_animation_encoder - "-s EXPORT_NAME=\"'DracoAnimationEncoderModule'\"") + if(BUILD_ANIMATION_ENCODING) + add_executable(draco_animation_decoder ${draco_animation_dec_sources} + ${draco_animation_js_dec_sources} + ${draco_animation_sources} + ${draco_decoder_src}) + add_executable(draco_animation_encoder ${draco_animation_enc_sources} + ${draco_animation_js_enc_sources} + ${draco_animation_sources} + ${draco_encoder_src}) + append_link_flag_to_target( + draco_animation_decoder + "-s EXPORT_NAME=\"'DracoAnimationDecoderModule'\"") + append_link_flag_to_target( + draco_animation_encoder + "-s EXPORT_NAME=\"'DracoAnimationEncoderModule'\"") - set_property(SOURCE ${draco_js_sources} APPEND PROPERTY OBJECT_DEPENDS - ${draco_build_dir}/glue_animation_decoder.cpp) + set_property(SOURCE ${draco_js_sources} + APPEND + PROPERTY OBJECT_DEPENDS + ${draco_build_dir}/glue_animation_decoder.cpp) em_link_pre_js(draco_animation_decoder "${draco_src_root}/javascript/emscripten/prepareCallbacks.js" "${draco_src_root}/javascript/emscripten/version.js") @@ -860,8 +872,10 @@ if (EMSCRIPTEN AND ENABLE_JS_GLUE) "${draco_build_dir}/glue_animation_decoder.js" "${draco_src_root}/javascript/emscripten/finalize.js") - set_property(SOURCE ${draco_js_enc_sources} APPEND PROPERTY OBJECT_DEPENDS - ${draco_build_dir}/glue_animation_encoder.cpp) + set_property(SOURCE ${draco_js_enc_sources} + APPEND + PROPERTY OBJECT_DEPENDS + ${draco_build_dir}/glue_animation_encoder.cpp) em_link_pre_js(draco_animation_encoder "${draco_src_root}/javascript/emscripten/prepareCallbacks.js" "${draco_src_root}/javascript/emscripten/version.js") @@ -869,43 +883,41 @@ if (EMSCRIPTEN AND ENABLE_JS_GLUE) "${draco_build_dir}/glue_animation_encoder.js" "${draco_src_root}/javascript/emscripten/finalize.js") endif() -else () - # Standard Draco libs, encoder and decoder. - # Object collections that mirror the Draco directory structure. - if (BUILD_SHARED_LIBS) +else() + # Standard Draco libs, encoder and decoder. Object collections that mirror the + # Draco directory structure. + if(BUILD_SHARED_LIBS) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() add_library(draco_attributes OBJECT ${draco_attributes_sources}) - add_library(draco_compression_attributes_dec OBJECT - ${draco_compression_attributes_dec_sources}) - add_library(draco_compression_attributes_enc OBJECT - ${draco_compression_attributes_enc_sources}) - add_library(draco_compression_attributes_pred_schemes_dec OBJECT - ${draco_compression_attributes_pred_schemes_dec_sources}) - add_library(draco_compression_attributes_pred_schemes_enc OBJECT - ${draco_compression_attributes_pred_schemes_enc_sources}) - add_library(draco_compression_bit_coders OBJECT - ${draco_compression_bit_coders_sources}) - add_library(draco_enc_config OBJECT - ${draco_enc_config_sources}) - add_library(draco_dec_config OBJECT - ${draco_dec_config_sources}) + add_library(draco_compression_attributes_dec + OBJECT ${draco_compression_attributes_dec_sources}) + add_library(draco_compression_attributes_enc + OBJECT ${draco_compression_attributes_enc_sources}) + add_library(draco_compression_attributes_pred_schemes_dec + OBJECT ${draco_compression_attributes_pred_schemes_dec_sources}) + add_library(draco_compression_attributes_pred_schemes_enc + OBJECT ${draco_compression_attributes_pred_schemes_enc_sources}) + add_library(draco_compression_bit_coders + OBJECT ${draco_compression_bit_coders_sources}) + add_library(draco_enc_config OBJECT ${draco_enc_config_sources}) + add_library(draco_dec_config OBJECT ${draco_dec_config_sources}) add_library(draco_compression_decode OBJECT - ${draco_compression_decode_sources}) + ${draco_compression_decode_sources}) add_library(draco_compression_encode OBJECT - ${draco_compression_encode_sources}) + ${draco_compression_encode_sources}) add_library(draco_compression_entropy OBJECT - ${draco_compression_entropy_sources}) - add_library(draco_compression_mesh_traverser OBJECT - ${draco_compression_mesh_traverser_sources}) + ${draco_compression_entropy_sources}) + add_library(draco_compression_mesh_traverser + OBJECT ${draco_compression_mesh_traverser_sources}) add_library(draco_compression_mesh_dec OBJECT - ${draco_compression_mesh_dec_sources}) + ${draco_compression_mesh_dec_sources}) add_library(draco_compression_mesh_enc OBJECT - ${draco_compression_mesh_enc_sources}) - add_library(draco_compression_point_cloud_dec OBJECT - ${draco_compression_point_cloud_dec_sources}) - add_library(draco_compression_point_cloud_enc OBJECT - ${draco_compression_point_cloud_enc_sources}) + ${draco_compression_mesh_enc_sources}) + add_library(draco_compression_point_cloud_dec + OBJECT ${draco_compression_point_cloud_dec_sources}) + add_library(draco_compression_point_cloud_enc + OBJECT ${draco_compression_point_cloud_enc_sources}) add_library(draco_core OBJECT ${draco_core_sources}) add_library(draco_io OBJECT ${draco_io_sources}) add_library(draco_mesh OBJECT ${draco_mesh_sources}) @@ -916,22 +928,18 @@ else () add_library(draco_animation_enc OBJECT ${draco_animation_enc_sources}) add_library(draco_animation OBJECT ${draco_animation_sources}) add_library(draco_point_cloud OBJECT ${draco_point_cloud_sources}) - add_library(draco_points_dec OBJECT - ${draco_points_common_sources} - ${draco_points_dec_sources}) - add_library(draco_points_enc OBJECT - ${draco_points_common_sources} - ${draco_points_enc_sources}) + add_library(draco_points_dec OBJECT ${draco_points_common_sources} + ${draco_points_dec_sources}) + add_library(draco_points_enc OBJECT ${draco_points_common_sources} + ${draco_points_enc_sources}) - if (BUILD_UNITY_PLUGIN) - add_library(draco_unity_plugin OBJECT - ${draco_unity_plug_sources}) - endif () + if(BUILD_UNITY_PLUGIN) + add_library(draco_unity_plugin OBJECT ${draco_unity_plug_sources}) + endif() - if (BUILD_MAYA_PLUGIN) - add_library(draco_maya_plugin OBJECT - ${draco_maya_plug_sources}) - endif () + if(BUILD_MAYA_PLUGIN) + add_library(draco_maya_plugin OBJECT ${draco_maya_plug_sources}) + endif() # Library targets that consume the object collections. add_library(dracodec @@ -1001,9 +1009,8 @@ else () $ $ $) - if (BUILD_UNITY_PLUGIN) - add_library(dracodec_unity - MODULE + if(BUILD_UNITY_PLUGIN) + add_library(dracodec_unity MODULE ${draco_version_sources} $ $ @@ -1022,14 +1029,13 @@ else () $ $) # For Mac, we need to build a .bundle for plugin. - if (APPLE) + if(APPLE) set_target_properties(dracodec_unity PROPERTIES BUNDLE true) - endif () - endif () + endif() + endif() - if (BUILD_MAYA_PLUGIN) - add_library(draco_maya_wrapper - MODULE + if(BUILD_MAYA_PLUGIN) + add_library(draco_maya_wrapper MODULE ${draco_version_sources} $ $ @@ -1056,16 +1062,14 @@ else () $) # For Mac, we need to build a .bundle for plugin. - if (APPLE) + if(APPLE) set_target_properties(draco_maya_wrapper PROPERTIES BUNDLE true) - endif () - endif () + endif() + endif() - set(draco_header_only_targets - draco_compression_attributes_pred_schemes_dec - draco_compression_mesh_traverser - draco_dec_config - draco_enc_config) + set(draco_header_only_targets draco_compression_attributes_pred_schemes_dec + draco_compression_mesh_traverser + draco_dec_config draco_enc_config) # For now, enable deduplication for both encoder and decoder. # TODO(ostava): Support for disabling attribute deduplication for the C++ @@ -1073,21 +1077,21 @@ else () draco_enable_feature(FEATURE DRACO_ATTRIBUTE_INDICES_DEDUPLICATION_SUPPORTED) draco_enable_feature(FEATURE DRACO_ATTRIBUTE_VALUES_DEDUPLICATION_SUPPORTED) - if (BUILD_SHARED_LIBS) + if(BUILD_SHARED_LIBS) set_target_properties(dracodec PROPERTIES SOVERSION 1) set_target_properties(dracoenc PROPERTIES SOVERSION 1) set_target_properties(draco PROPERTIES SOVERSION 1) - if (BUILD_UNITY_PLUGIN AND (NOT APPLE)) + if(BUILD_UNITY_PLUGIN AND (NOT APPLE)) set_target_properties(dracodec_unity PROPERTIES SOVERSION 1) - endif () - if (BUILD_MAYA_PLUGIN AND (NOT APPLE)) + endif() + if(BUILD_MAYA_PLUGIN AND (NOT APPLE)) set_target_properties(draco_maya_wrapper PROPERTIES SOVERSION 1) - endif () - endif () + endif() + endif() extract_version_string("${draco_src_root}/core/draco_version.h" draco_version) - if (NOT MSVC) + if(NOT MSVC) # Generate draco.pc. set(prefix "${CMAKE_INSTALL_PREFIX}") set(pkgconfig_file "${draco_build_dir}/draco.pc") @@ -1103,54 +1107,53 @@ else () file(APPEND "${pkgconfig_file}" "Conflicts:\n") file(APPEND "${pkgconfig_file}" "Libs: -L${prefix}/lib -ldraco\n") file(APPEND "${pkgconfig_file}" "Cflags: -I${prefix}/include -std=c++11\n") - endif () + endif() # Draco app targets. add_executable(draco_decoder "${draco_src_root}/tools/draco_decoder.cc") target_link_libraries(draco_decoder PRIVATE dracodec) - add_executable(draco_encoder - "${draco_src_root}/tools/draco_encoder.cc") + add_executable(draco_encoder "${draco_src_root}/tools/draco_encoder.cc") target_link_libraries(draco_encoder PRIVATE draco) - if (ENABLE_TESTS) + if(ENABLE_TESTS) add_executable(draco_tests ${draco_test_sources}) include_directories("${draco_build_dir}" "${GTEST_SOURCE_DIR}/googletest/include") target_link_libraries(draco_tests draco gtest) - endif () + endif() # Collect all of the header files in the tree, and add an install rule for # each. file(GLOB_RECURSE draco_headers RELATIVE ${draco_root}/src/draco "*.h") - foreach (filename ${draco_headers}) + foreach(filename ${draco_headers}) get_filename_component(file_directory ${filename} DIRECTORY) - install(FILES src/draco/${filename} DESTINATION - "${CMAKE_INSTALL_PREFIX}/include/draco/${file_directory}") + install( + FILES src/draco/${filename} + DESTINATION "${CMAKE_INSTALL_PREFIX}/include/draco/${file_directory}") endforeach() install(FILES "${draco_build_dir}/draco/draco_features.h" DESTINATION "${CMAKE_INSTALL_PREFIX}/include/draco/") - if (NOT MSVC) + if(NOT MSVC) # Install our pkg-config file. install(FILES "${draco_build_dir}/draco.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") - endif () + endif() # Add install rules for lib and executable targets. - install(TARGETS dracodec dracoenc draco - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") - if (BUILD_UNITY_PLUGIN) - install(TARGETS dracodec_unity - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") - endif () - if (BUILD_MAYA_PLUGIN) - install(TARGETS draco_maya_wrapper - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") - endif () + install(TARGETS dracodec dracoenc draco DESTINATION + "${CMAKE_INSTALL_PREFIX}/lib") + if(BUILD_UNITY_PLUGIN) + install(TARGETS dracodec_unity DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") + endif() + if(BUILD_MAYA_PLUGIN) + install( + TARGETS draco_maya_wrapper DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") + endif() install(TARGETS draco_decoder draco_encoder DESTINATION - "${CMAKE_INSTALL_PREFIX}/bin") + "${CMAKE_INSTALL_PREFIX}/bin") # Generate a CMake config file. set(draco_include_install_dir "include/draco") @@ -1160,39 +1163,37 @@ else () set(draco_config_in_file "${draco_root}/cmake/DracoConfig.cmake") set(draco_config_out_file "${draco_build_dir}/DracoConfig.cmake") - configure_package_config_file( - "${draco_config_in_file}" - "${draco_config_out_file}" - NO_CHECK_REQUIRED_COMPONENTS_MACRO - INSTALL_DESTINATION "${draco_lib_install_dir}/draco/cmake" - PATH_VARS draco_include_install_dir draco_lib_install_dir) - write_basic_package_version_file( - "${draco_build_dir}/DracoConfigVersion.cmake" - VERSION ${draco_version} - COMPATIBILITY SameMajorVersion) + configure_package_config_file("${draco_config_in_file}" + "${draco_config_out_file}" + NO_CHECK_REQUIRED_COMPONENTS_MACRO + INSTALL_DESTINATION + "${draco_lib_install_dir}/draco/cmake" PATH_VARS + draco_include_install_dir draco_lib_install_dir) + write_basic_package_version_file("${draco_build_dir}/DracoConfigVersion.cmake" + VERSION ${draco_version} + COMPATIBILITY SameMajorVersion) # Read in the config file and rewrite it with a version string included. file(STRINGS "${draco_config_out_file}" draco_config_strings) file(WRITE "${draco_config_out_file}" "set(draco_VERSION \"${draco_version}\")\n") - foreach (config_string ${draco_config_strings}) + foreach(config_string ${draco_config_strings}) file(APPEND "${draco_config_out_file}" "${config_string}\n") - endforeach () + endforeach() # Add install rules for CMake helper scripts. - set(draco_cmake_helper_scripts - "${draco_root}/cmake/FindDraco.cmake" - "${draco_build_dir}/DracoConfig.cmake" - "${draco_build_dir}/DracoConfigVersion.cmake") + set(draco_cmake_helper_scripts "${draco_root}/cmake/FindDraco.cmake" + "${draco_build_dir}/DracoConfig.cmake" + "${draco_build_dir}/DracoConfigVersion.cmake") install(FILES ${draco_cmake_helper_scripts} DESTINATION "${draco_script_install_dir}") # Some generators complain about unknown link language for header only # targets. Silence the harmless warnings/errors with some dummy source files. - foreach (target ${draco_header_only_targets}) + foreach(target ${draco_header_only_targets}) add_dummy_source_file_to_target("${target}" "cc") - endforeach () -endif () + endforeach() +endif() # Generate $draco_build_dir/draco/draco_features.h. draco_generate_features_h() diff --git a/cmake/FindDraco.cmake b/cmake/FindDraco.cmake index 5f27bf2..0a91930 100644 --- a/cmake/FindDraco.cmake +++ b/cmake/FindDraco.cmake @@ -2,10 +2,7 @@ # # Locates draco and sets the following variables: # -# draco_FOUND -# draco_INCLUDE_DIRS -# draco_LIBARY_DIRS -# draco_LIBRARIES +# draco_FOUND draco_INCLUDE_DIRS draco_LIBARY_DIRS draco_LIBRARIES # draco_VERSION_STRING # # draco_FOUND is set to YES only when all other variables are successfully @@ -28,31 +25,32 @@ set(draco_version_file_no_prefix "draco/src/draco/core/draco_version.h") # Set draco_INCLUDE_DIRS find_path(draco_INCLUDE_DIRS NAMES "${draco_version_file_no_prefix}") -# Extract the version string from draco_version.h. -if (draco_INCLUDE_DIRS) +# Extract the version string from draco_version.h. +if(draco_INCLUDE_DIRS) set(draco_version_file "${draco_INCLUDE_DIRS}/draco/src/draco/core/draco_version.h") - file(STRINGS "${draco_version_file}" draco_version - REGEX "kdracoVersion") + file(STRINGS "${draco_version_file}" draco_version REGEX "kdracoVersion") list(GET draco_version 0 draco_version) string(REPLACE "static const char kdracoVersion[] = " "" draco_version - "${draco_version}") + "${draco_version}") string(REPLACE ";" "" draco_version "${draco_version}") string(REPLACE "\"" "" draco_version "${draco_version}") set(draco_VERSION_STRING ${draco_version}) -endif () +endif() # Find the library. -if (BUILD_SHARED_LIBS) +if(BUILD_SHARED_LIBS) find_library(draco_LIBRARIES NAMES draco.dll libdraco.dylib libdraco.so) -else () +else() find_library(draco_LIBRARIES NAMES draco.lib libdraco.a) -endif () +endif() # Store path to library. get_filename_component(draco_LIBRARY_DIRS ${draco_LIBRARIES} DIRECTORY) -if (draco_INCLUDE_DIRS AND draco_LIBRARY_DIRS AND draco_LIBRARIES AND - draco_VERSION_STRING) +if(draco_INCLUDE_DIRS + AND draco_LIBRARY_DIRS + AND draco_LIBRARIES + AND draco_VERSION_STRING) set(draco_FOUND YES) -endif () +endif() diff --git a/cmake/compiler_flags.cmake b/cmake/compiler_flags.cmake index d842a8a..8750e6f 100644 --- a/cmake/compiler_flags.cmake +++ b/cmake/compiler_flags.cmake @@ -1,4 +1,6 @@ -if (NOT DRACO_CMAKE_COMPILER_FLAGS_CMAKE_) +if(DRACO_CMAKE_COMPILER_FLAGS_CMAKE_) + return() +endif() set(DRACO_CMAKE_COMPILER_FLAGS_CMAKE_ 1) include(CheckCCompilerFlag) @@ -12,195 +14,199 @@ set(DRACO_FAILED_CXX_FLAGS) # Checks C compiler for support of $c_flag. Adds $c_flag to $CMAKE_C_FLAGS when # the compile test passes. Caches $c_flag in $DRACO_FAILED_C_FLAGS when the test # fails. -macro (add_c_flag_if_supported c_flag) +macro(add_c_flag_if_supported c_flag) unset(C_FLAG_FOUND CACHE) string(FIND "${CMAKE_C_FLAGS}" "${c_flag}" C_FLAG_FOUND) unset(C_FLAG_FAILED CACHE) string(FIND "${DRACO_FAILED_C_FLAGS}" "${c_flag}" C_FLAG_FAILED) - if (${C_FLAG_FOUND} EQUAL -1 AND ${C_FLAG_FAILED} EQUAL -1) + if(${C_FLAG_FOUND} EQUAL -1 AND ${C_FLAG_FAILED} EQUAL -1) unset(C_FLAG_SUPPORTED CACHE) message("Checking C compiler flag support for: " ${c_flag}) check_c_compiler_flag("${c_flag}" C_FLAG_SUPPORTED) - if (${C_FLAG_SUPPORTED}) + if(${C_FLAG_SUPPORTED}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${c_flag}" CACHE STRING "") - else () - set(DRACO_FAILED_C_FLAGS "${DRACO_FAILED_C_FLAGS} ${c_flag}" CACHE STRING - "" FORCE) - endif () - endif () -endmacro () + else() + set(DRACO_FAILED_C_FLAGS + "${DRACO_FAILED_C_FLAGS} ${c_flag}" + CACHE STRING "" FORCE) + endif() + endif() +endmacro() # Checks C++ compiler for support of $cxx_flag. Adds $cxx_flag to # $CMAKE_CXX_FLAGS when the compile test passes. Caches $c_flag in # $DRACO_FAILED_CXX_FLAGS when the test fails. -macro (add_cxx_flag_if_supported cxx_flag) +macro(add_cxx_flag_if_supported cxx_flag) unset(CXX_FLAG_FOUND CACHE) string(FIND "${CMAKE_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FOUND) unset(CXX_FLAG_FAILED CACHE) string(FIND "${DRACO_FAILED_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FAILED) - if (${CXX_FLAG_FOUND} EQUAL -1 AND ${CXX_FLAG_FAILED} EQUAL -1) + if(${CXX_FLAG_FOUND} EQUAL -1 AND ${CXX_FLAG_FAILED} EQUAL -1) unset(CXX_FLAG_SUPPORTED CACHE) message("Checking CXX compiler flag support for: " ${cxx_flag}) check_cxx_compiler_flag("${cxx_flag}" CXX_FLAG_SUPPORTED) - if (${CXX_FLAG_SUPPORTED}) + if(${CXX_FLAG_SUPPORTED}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_flag}" CACHE STRING "") else() - set(DRACO_FAILED_CXX_FLAGS "${DRACO_FAILED_CXX_FLAGS} ${cxx_flag}" CACHE - STRING "" FORCE) - endif () - endif () -endmacro () + set(DRACO_FAILED_CXX_FLAGS + "${DRACO_FAILED_CXX_FLAGS} ${cxx_flag}" + CACHE STRING "" FORCE) + endif() + endif() +endmacro() # Convenience method for adding a flag to both the C and C++ compiler command # lines. -macro (add_compiler_flag_if_supported flag) +macro(add_compiler_flag_if_supported flag) add_c_flag_if_supported(${flag}) add_cxx_flag_if_supported(${flag}) -endmacro () +endmacro() # Checks C compiler for support of $c_flag and terminates generation when # support is not present. -macro (require_c_flag c_flag update_c_flags) +macro(require_c_flag c_flag update_c_flags) unset(C_FLAG_FOUND CACHE) string(FIND "${CMAKE_C_FLAGS}" "${c_flag}" C_FLAG_FOUND) - if (${C_FLAG_FOUND} EQUAL -1) + if(${C_FLAG_FOUND} EQUAL -1) unset(HAVE_C_FLAG CACHE) message("Checking C compiler flag support for: " ${c_flag}) check_c_compiler_flag("${c_flag}" HAVE_C_FLAG) - if (NOT ${HAVE_C_FLAG}) - message(FATAL_ERROR - "${PROJECT_NAME} requires support for C flag: ${c_flag}.") - endif () - if (${update_c_flags}) + if(NOT ${HAVE_C_FLAG}) + message( + FATAL_ERROR "${PROJECT_NAME} requires support for C flag: ${c_flag}.") + endif() + if(${update_c_flags}) set(CMAKE_C_FLAGS "${c_flag} ${CMAKE_C_FLAGS}" CACHE STRING "" FORCE) - endif () - endif () -endmacro () + endif() + endif() +endmacro() # Checks CXX compiler for support of $cxx_flag and terminates generation when # support is not present. -macro (require_cxx_flag cxx_flag update_cxx_flags) +macro(require_cxx_flag cxx_flag update_cxx_flags) unset(CXX_FLAG_FOUND CACHE) string(FIND "${CMAKE_CXX_FLAGS}" "${cxx_flag}" CXX_FLAG_FOUND) - if (${CXX_FLAG_FOUND} EQUAL -1) + if(${CXX_FLAG_FOUND} EQUAL -1) unset(HAVE_CXX_FLAG CACHE) message("Checking CXX compiler flag support for: " ${cxx_flag}) check_cxx_compiler_flag("${cxx_flag}" HAVE_CXX_FLAG) - if (NOT ${HAVE_CXX_FLAG}) - message(FATAL_ERROR - "${PROJECT_NAME} requires support for CXX flag: ${cxx_flag}.") - endif () - if (${update_cxx_flags}) - set(CMAKE_CXX_FLAGS "${cxx_flag} ${CMAKE_CXX_FLAGS}" CACHE STRING "" - FORCE) - endif () - endif () -endmacro () + if(NOT ${HAVE_CXX_FLAG}) + message( + FATAL_ERROR + "${PROJECT_NAME} requires support for CXX flag: ${cxx_flag}.") + endif() + if(${update_cxx_flags}) + set(CMAKE_CXX_FLAGS + "${cxx_flag} ${CMAKE_CXX_FLAGS}" + CACHE STRING "" FORCE) + endif() + endif() +endmacro() # Checks for support of $flag by both the C and CXX compilers. Terminates # generation when support is not present in both compilers. -macro (require_compiler_flag flag update_cmake_flags) +macro(require_compiler_flag flag update_cmake_flags) require_c_flag(${flag} ${update_cmake_flags}) require_cxx_flag(${flag} ${update_cmake_flags}) -endmacro () +endmacro() # Checks only non-MSVC targets for support of $c_flag and terminates generation # when support is not present. -macro (require_c_flag_nomsvc c_flag update_c_flags) - if (NOT MSVC) +macro(require_c_flag_nomsvc c_flag update_c_flags) + if(NOT MSVC) require_c_flag(${c_flag} ${update_c_flags}) - endif () -endmacro () + endif() +endmacro() # Checks only non-MSVC targets for support of $cxx_flag and terminates # generation when support is not present. -macro (require_cxx_flag_nomsvc cxx_flag update_cxx_flags) - if (NOT MSVC) +macro(require_cxx_flag_nomsvc cxx_flag update_cxx_flags) + if(NOT MSVC) require_cxx_flag(${cxx_flag} ${update_cxx_flags}) - endif () -endmacro () + endif() +endmacro() # Checks only non-MSVC targets for support of $flag by both the C and CXX # compilers. Terminates generation when support is not present in both # compilers. -macro (require_compiler_flag_nomsvc flag update_cmake_flags) +macro(require_compiler_flag_nomsvc flag update_cmake_flags) require_c_flag_nomsvc(${flag} ${update_cmake_flags}) require_cxx_flag_nomsvc(${flag} ${update_cmake_flags}) -endmacro () +endmacro() # Adds $flag to assembler command line. -macro (append_as_flag flag) +macro(append_as_flag flag) unset(AS_FLAG_FOUND CACHE) string(FIND "${DRACO_AS_FLAGS}" "${flag}" AS_FLAG_FOUND) - if (${AS_FLAG_FOUND} EQUAL -1) + if(${AS_FLAG_FOUND} EQUAL -1) set(DRACO_AS_FLAGS "${DRACO_AS_FLAGS} ${flag}") - endif () -endmacro () + endif() +endmacro() # Adds $flag to the C compiler command line. -macro (append_c_flag flag) +macro(append_c_flag flag) unset(C_FLAG_FOUND CACHE) string(FIND "${CMAKE_C_FLAGS}" "${flag}" C_FLAG_FOUND) - if (${C_FLAG_FOUND} EQUAL -1) + if(${C_FLAG_FOUND} EQUAL -1) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") - endif () -endmacro () + endif() +endmacro() # Adds $flag to the CXX compiler command line. -macro (append_cxx_flag flag) +macro(append_cxx_flag flag) unset(CXX_FLAG_FOUND CACHE) string(FIND "${CMAKE_CXX_FLAGS}" "${flag}" CXX_FLAG_FOUND) - if (${CXX_FLAG_FOUND} EQUAL -1) + if(${CXX_FLAG_FOUND} EQUAL -1) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") - endif () -endmacro () + endif() +endmacro() # Adds $flag to the C and CXX compiler command lines. -macro (append_compiler_flag flag) +macro(append_compiler_flag flag) append_c_flag(${flag}) append_cxx_flag(${flag}) -endmacro () +endmacro() # Adds $flag to the executable linker command line. -macro (append_exe_linker_flag flag) +macro(append_exe_linker_flag flag) unset(LINKER_FLAG_FOUND CACHE) string(FIND "${CMAKE_EXE_LINKER_FLAGS}" "${flag}" LINKER_FLAG_FOUND) - if (${LINKER_FLAG_FOUND} EQUAL -1) + if(${LINKER_FLAG_FOUND} EQUAL -1) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}") - endif () -endmacro () + endif() +endmacro() # Adds $flag to the link flags for $target. -function (append_link_flag_to_target target flags) +function(append_link_flag_to_target target flags) unset(target_link_flags) get_target_property(target_link_flags ${target} LINK_FLAGS) - if (target_link_flags) + if(target_link_flags) unset(link_flag_found) string(FIND "${target_link_flags}" "${flags}" link_flag_found) - if (NOT ${link_flag_found} EQUAL -1) + if(NOT ${link_flag_found} EQUAL -1) return() - endif () + endif() set(target_link_flags "${target_link_flags} ${flags}") - else () + else() set(target_link_flags "${flags}") - endif () + endif() set_target_properties(${target} PROPERTIES LINK_FLAGS ${target_link_flags}) -endfunction () +endfunction() # Adds $flag to executable linker flags, and makes sure C/CXX builds still work. -macro (require_linker_flag flag) +macro(require_linker_flag flag) append_exe_linker_flag(${flag}) unset(c_passed) @@ -208,9 +214,7 @@ macro (require_linker_flag flag) unset(cxx_passed) draco_check_cxx_compiles("LINKER_FLAG_CXX_TEST(${flag})" "" cxx_passed) - if (NOT c_passed OR NOT cxx_passed) + if(NOT c_passed OR NOT cxx_passed) message(FATAL_ERROR "Linker flag test for ${flag} failed.") - endif () -endmacro () - -endif () # DRACO_CMAKE_COMPILER_FLAGS_CMAKE_ + endif() +endmacro() diff --git a/cmake/compiler_tests.cmake b/cmake/compiler_tests.cmake index bbc770c..e781a65 100644 --- a/cmake/compiler_tests.cmake +++ b/cmake/compiler_tests.cmake @@ -1,4 +1,6 @@ -if (NOT DRACO_CMAKE_COMPILER_TESTS_CMAKE_) +if(DRACO_CMAKE_COMPILER_TESTS_CMAKE_) + return() +endif() set(DRACO_CMAKE_COMPILER_TESTS_CMAKE_ 1) include(CheckCSourceCompiles) @@ -17,41 +19,41 @@ set(DRACO_CXX_FAILED_TESTS) macro(draco_push_var var new_value) set(SAVED_${var} ${var}) set(${var} ${new_value}) -endmacro () +endmacro() macro(draco_pop_var var) set(var ${SAVED_${var}}) unset(SAVED_${var}) -endmacro () +endmacro() # Confirms $test_source compiles and stores $test_name in one of # $DRACO_C_PASSED_TESTS or $DRACO_C_FAILED_TESTS depending on out come. When the -# test passes $result_var is set to 1. When it fails $result_var is unset. -# The test is not run if the test name is found in either of the passed or -# failed test variables. +# test passes $result_var is set to 1. When it fails $result_var is unset. The +# test is not run if the test name is found in either of the passed or failed +# test variables. macro(draco_check_c_compiles test_name test_source result_var) unset(C_TEST_PASSED CACHE) unset(C_TEST_FAILED CACHE) string(FIND "${DRACO_C_PASSED_TESTS}" "${test_name}" C_TEST_PASSED) string(FIND "${DRACO_C_FAILED_TESTS}" "${test_name}" C_TEST_FAILED) - if (${C_TEST_PASSED} EQUAL -1 AND ${C_TEST_FAILED} EQUAL -1) + if(${C_TEST_PASSED} EQUAL -1 AND ${C_TEST_FAILED} EQUAL -1) unset(C_TEST_COMPILED CACHE) message("Running C compiler test: ${test_name}") check_c_source_compiles("${test_source} ${DRACO_C_MAIN}" C_TEST_COMPILED) set(${result_var} ${C_TEST_COMPILED}) - if (${C_TEST_COMPILED}) + if(${C_TEST_COMPILED}) set(DRACO_C_PASSED_TESTS "${DRACO_C_PASSED_TESTS} ${test_name}") - else () + else() set(DRACO_C_FAILED_TESTS "${DRACO_C_FAILED_TESTS} ${test_name}") message("C Compiler test ${test_name} failed.") - endif () - elseif (NOT ${C_TEST_PASSED} EQUAL -1) + endif() + elseif(NOT ${C_TEST_PASSED} EQUAL -1) set(${result_var} 1) - else () # ${C_TEST_FAILED} NOT EQUAL -1 + else() # ${C_TEST_FAILED} NOT EQUAL -1 unset(${result_var}) - endif () -endmacro () + endif() +endmacro() # Confirms $test_source compiles and stores $test_name in one of # $DRACO_CXX_PASSED_TESTS or $DRACO_CXX_FAILED_TESTS depending on out come. When @@ -63,42 +65,39 @@ macro(draco_check_cxx_compiles test_name test_source result_var) unset(CXX_TEST_FAILED CACHE) string(FIND "${DRACO_CXX_PASSED_TESTS}" "${test_name}" CXX_TEST_PASSED) string(FIND "${DRACO_CXX_FAILED_TESTS}" "${test_name}" CXX_TEST_FAILED) - if (${CXX_TEST_PASSED} EQUAL -1 AND ${CXX_TEST_FAILED} EQUAL -1) + if(${CXX_TEST_PASSED} EQUAL -1 AND ${CXX_TEST_FAILED} EQUAL -1) unset(CXX_TEST_COMPILED CACHE) message("Running CXX compiler test: ${test_name}") check_cxx_source_compiles("${test_source} ${DRACO_CXX_MAIN}" CXX_TEST_COMPILED) set(${result_var} ${CXX_TEST_COMPILED}) - if (${CXX_TEST_COMPILED}) + if(${CXX_TEST_COMPILED}) set(DRACO_CXX_PASSED_TESTS "${DRACO_CXX_PASSED_TESTS} ${test_name}") - else () + else() set(DRACO_CXX_FAILED_TESTS "${DRACO_CXX_FAILED_TESTS} ${test_name}") message("CXX Compiler test ${test_name} failed.") - endif () - elseif (NOT ${CXX_TEST_PASSED} EQUAL -1) + endif() + elseif(NOT ${CXX_TEST_PASSED} EQUAL -1) set(${result_var} 1) - else () # ${CXX_TEST_FAILED} NOT EQUAL -1 + else() # ${CXX_TEST_FAILED} NOT EQUAL -1 unset(${result_var}) - endif () -endmacro () + endif() +endmacro() # Convenience macro that confirms $test_source compiles as C and C++. # $result_var is set to 1 when both tests are successful, and 0 when one or both -# tests fail. -# Note: This macro is intended to be used to write to result variables that -# are expanded via configure_file(). $result_var is set to 1 or 0 to allow -# direct usage of the value in generated source files. +# tests fail. Note: This macro is intended to be used to write to result +# variables that are expanded via configure_file(). $result_var is set to 1 or 0 +# to allow direct usage of the value in generated source files. macro(draco_check_source_compiles test_name test_source result_var) unset(C_PASSED) unset(CXX_PASSED) draco_check_c_compiles(${test_name} ${test_source} C_PASSED) draco_check_cxx_compiles(${test_name} ${test_source} CXX_PASSED) - if (${C_PASSED} AND ${CXX_PASSED}) + if(${C_PASSED} AND ${CXX_PASSED}) set(${result_var} 1) - else () + else() set(${result_var} 0) - endif () -endmacro () - -endif () # DRACO_CMAKE_COMPILER_TESTS_CMAKE_ + endif() +endmacro() diff --git a/cmake/draco_features.cmake b/cmake/draco_features.cmake index 057b0b0..a10dbb0 100644 --- a/cmake/draco_features.cmake +++ b/cmake/draco_features.cmake @@ -1,4 +1,6 @@ -if (NOT DRACO_CMAKE_DRACO_FEATURES_CMAKE_) +if(DRACO_CMAKE_DRACO_FEATURES_CMAKE_) + return() +endif() set(DRACO_CMAKE_DRACO_FEATURES_CMAKE_ 1) set(draco_features_file_name "${draco_build_dir}/draco/draco_features.h") @@ -7,51 +9,48 @@ set(draco_features_list) # Macro that handles tracking of Draco preprocessor symbols for the purpose of # producing draco_features.h. # -# draco_enable_feature(FEATURE [TARGETS ]) -# FEATURE is required. It should be a Draco preprocessor symbol. -# TARGETS is optional. It can be one or more draco targets. +# draco_enable_feature(FEATURE [TARGETS ]) FEATURE +# is required. It should be a Draco preprocessor symbol. TARGETS is optional. It +# can be one or more draco targets. # # When the TARGETS argument is not present the preproc symbol is added to # draco_features.h. When it is draco_features.h is unchanged, and # target_compile_options() is called for each target specified. -macro (draco_enable_feature) +macro(draco_enable_feature) set(def_flags) set(def_single_arg_opts FEATURE) set(def_multi_arg_opts TARGETS) cmake_parse_arguments(DEF "${def_flags}" "${def_single_arg_opts}" "${def_multi_arg_opts}" ${ARGN}) - if ("${DEF_FEATURE}" STREQUAL "") + if("${DEF_FEATURE}" STREQUAL "") message(FATAL_ERROR "Empty FEATURE passed to draco_enable_feature().") - endif () + endif() # Do nothing/return early if $DEF_FEATURE is already in the list. list(FIND draco_features_list ${DEF_FEATURE} df_index) - if (NOT df_index EQUAL -1) - return () - endif () + if(NOT df_index EQUAL -1) + return() + endif() list(LENGTH DEF_TARGETS df_targets_list_length) - if (${df_targets_list_length} EQUAL 0) + if(${df_targets_list_length} EQUAL 0) list(APPEND draco_features_list ${DEF_FEATURE}) - else () - foreach (target ${DEF_TARGETS}) + else() + foreach(target ${DEF_TARGETS}) target_compile_definitions(${target} PRIVATE ${DEF_FEATURE}) - endforeach () - endif () -endmacro () + endforeach() + endif() +endmacro() # Function for generating draco_features.h. -function (draco_generate_features_h) +function(draco_generate_features_h) file(WRITE "${draco_features_file_name}" - "// GENERATED FILE -- DO NOT EDIT\n\n" - "#ifndef DRACO_FEATURES_H_\n" + "// GENERATED FILE -- DO NOT EDIT\n\n" "#ifndef DRACO_FEATURES_H_\n" "#define DRACO_FEATURES_H_\n\n") - foreach (feature ${draco_features_list}) + foreach(feature ${draco_features_list}) file(APPEND "${draco_features_file_name}" "#define ${feature}\n") - endforeach () + endforeach() file(APPEND "${draco_features_file_name}" "\n#endif // DRACO_FEATURES_H_") -endfunction () - -endif () # DRACO_CMAKE_DRACO_FEATURES_CMAKE_ +endfunction() diff --git a/cmake/msvc_runtime.cmake b/cmake/msvc_runtime.cmake index ca8de08..5bc455b 100644 --- a/cmake/msvc_runtime.cmake +++ b/cmake/msvc_runtime.cmake @@ -1,14 +1,14 @@ cmake_minimum_required(VERSION 3.2) -if (MSVC) +if(MSVC) # Use statically linked versions of the MS standard libraries. - if (NOT "${MSVC_RUNTIME}" STREQUAL "dll") - foreach (flag_var - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if (${flag_var} MATCHES "/MD") + if(NOT "${MSVC_RUNTIME}" STREQUAL "dll") + foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG + CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL + CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - endif () - endforeach () - endif () -endif () + endif() + endforeach() + endif() +endif() diff --git a/cmake/sanitizers.cmake b/cmake/sanitizers.cmake index e966cd8..e720bc0 100644 --- a/cmake/sanitizers.cmake +++ b/cmake/sanitizers.cmake @@ -1,9 +1,11 @@ -if (NOT DRACO_CMAKE_SANITIZERS_CMAKE_) +if(DRACO_CMAKE_SANITIZERS_CMAKE_) + return() +endif() set(DRACO_CMAKE_SANITIZERS_CMAKE_ 1) -if (MSVC OR NOT SANITIZE) - return () -endif () +if(MSVC OR NOT SANITIZE) + return() +endif() include("${draco_root}/cmake/compiler_flags.cmake") @@ -15,5 +17,3 @@ require_compiler_flag("-fsanitize=${SANITIZE}" YES) # Make callstacks accurate. require_compiler_flag("-fno-omit-frame-pointer -fno-optimize-sibling-calls" YES) - -endif() # DRACO_CMAKE_SANITIZERS_CMAKE_ diff --git a/cmake/toolchains/android-ndk-common.cmake b/cmake/toolchains/android-ndk-common.cmake new file mode 100644 index 0000000..58b27a6 --- /dev/null +++ b/cmake/toolchains/android-ndk-common.cmake @@ -0,0 +1,11 @@ +if(DRACO_CMAKE_TOOLCHAINS_ANDROID_NDK_COMMON_CMAKE_) + return() +endif() +set(DRACO_CMAKE_TOOLCHAINS_ANDROID_NDK_COMMON_CMAKE_ 1) + +include("${CMAKE_CURRENT_LIST_DIR}/../util.cmake") + +require_variable(CMAKE_ANDROID_NDK) +set(CMAKE_SYSTEM_NAME Android) +set_variable_if_unset(CMAKE_ANDROID_STL_TYPE c++_static) +set_variable_if_unset(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang) diff --git a/cmake/toolchains/arm-ios-common.cmake b/cmake/toolchains/arm-ios-common.cmake index 48f5ce5..b43f04b 100644 --- a/cmake/toolchains/arm-ios-common.cmake +++ b/cmake/toolchains/arm-ios-common.cmake @@ -1,4 +1,6 @@ -if (NOT DRACO_CMAKE_TOOLCHAINS_ARM_IOS_COMMON_CMAKE_) +if(DRACO_CMAKE_TOOLCHAINS_ARM_IOS_COMMON_CMAKE_) + return() +endif() set(DRACO_CMAKE_ARM_IOS_COMMON_CMAKE_ 1) set(CMAKE_SYSTEM_NAME "Darwin") @@ -9,5 +11,3 @@ set(CMAKE_CXX_COMPILER clang++) set(CMAKE_CXX_COMPILER_ARG1 "-arch ${CMAKE_SYSTEM_PROCESSOR}") # TODO(tomfinegan): Handle bit code embedding. - -endif () # DRACO_CMAKE_TOOLCHAINS_ARM_IOS_COMMON_CMAKE_ diff --git a/cmake/toolchains/arm64-android-ndk-libcpp.cmake b/cmake/toolchains/arm64-android-ndk-libcpp.cmake index bd04419..efc9cd1 100644 --- a/cmake/toolchains/arm64-android-ndk-libcpp.cmake +++ b/cmake/toolchains/arm64-android-ndk-libcpp.cmake @@ -1,12 +1,10 @@ -if (NOT DRACO_CMAKE_TOOLCHAINS_ARM64_ANDROID_NDK_LIBCPP_CMAKE_) +if(DRACO_CMAKE_TOOLCHAINS_ARM64_ANDROID_NDK_LIBCPP_CMAKE_) + return() +endif() set(DRACO_CMAKE_TOOLCHAINS_ARM64_ANDROID_NDK_LIBCPP_CMAKE_ 1) include("${CMAKE_CURRENT_LIST_DIR}/../util.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/android-ndk-common.cmake") -set(CMAKE_SYSTEM_NAME Android) set(CMAKE_ANDROID_ARCH_ABI arm64-v8a) -require_variable(CMAKE_ANDROID_NDK) set_variable_if_unset(CMAKE_SYSTEM_VERSION 21) -set_variable_if_unset(CMAKE_ANDROID_STL_TYPE c++_static) - -endif () # DRACO_CMAKE_TOOLCHAINS_ARM64_ANDROID_NDK_LIBCPP_CMAKE_ diff --git a/cmake/toolchains/arm64-ios.cmake b/cmake/toolchains/arm64-ios.cmake index 0d4909e..c4ec7e3 100644 --- a/cmake/toolchains/arm64-ios.cmake +++ b/cmake/toolchains/arm64-ios.cmake @@ -1,14 +1,14 @@ -if (NOT DRACO_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_) +if(DRACO_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_) + return() +endif() set(DRACO_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_ 1) -if (XCODE) +if(XCODE) # TODO(tomfinegan): Handle arm builds in Xcode. message(FATAL_ERROR "This toolchain does not support Xcode.") -endif () +endif() set(CMAKE_SYSTEM_PROCESSOR "arm64") set(CMAKE_OSX_ARCHITECTURES "arm64") include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake") - -endif () # DRACO_CMAKE_TOOLCHAINS_ARM64_IOS_CMAKE_ diff --git a/cmake/toolchains/arm64-linux-gcc.cmake b/cmake/toolchains/arm64-linux-gcc.cmake index 3bab482..046ff01 100644 --- a/cmake/toolchains/arm64-linux-gcc.cmake +++ b/cmake/toolchains/arm64-linux-gcc.cmake @@ -1,12 +1,14 @@ -if (NOT DRACO_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_) +if(DRACO_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_) + return() +endif() set(DRACO_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_ 1) set(CMAKE_SYSTEM_NAME "Linux") -if ("${CROSS}" STREQUAL "") +if("${CROSS}" STREQUAL "") # Default the cross compiler prefix to something known to work. set(CROSS aarch64-linux-gnu-) -endif () +endif() set(CMAKE_C_COMPILER ${CROSS}gcc) set(CMAKE_CXX_COMPILER ${CROSS}g++) @@ -14,5 +16,3 @@ set(AS_EXECUTABLE ${CROSS}as) set(CMAKE_C_COMPILER_ARG1 "-march=armv8-a") set(CMAKE_CXX_COMPILER_ARG1 "-march=armv8-a") set(CMAKE_SYSTEM_PROCESSOR "arm64") - -endif () # DRACO_CMAKE_TOOLCHAINS_ARM64_LINUX_GCC_CMAKE_ diff --git a/cmake/toolchains/armv7-android-ndk-libcpp.cmake b/cmake/toolchains/armv7-android-ndk-libcpp.cmake index fd50def..a1b0a6b 100644 --- a/cmake/toolchains/armv7-android-ndk-libcpp.cmake +++ b/cmake/toolchains/armv7-android-ndk-libcpp.cmake @@ -1,12 +1,10 @@ -if (NOT DRACO_CMAKE_TOOLCHAINS_ARMV7_ANDROID_NDK_LIBCPP_CMAKE_) +if(DRACO_CMAKE_TOOLCHAINS_ARMV7_ANDROID_NDK_LIBCPP_CMAKE_) + return() +endif() set(DRACO_CMAKE_TOOLCHAINS_ARMV7_ANDROID_NDK_LIBCPP_CMAKE_ 1) include("${CMAKE_CURRENT_LIST_DIR}/../util.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/android-ndk-common.cmake") -set(CMAKE_SYSTEM_NAME Android) set(CMAKE_ANDROID_ARCH_ABI armeabi-v7a) -require_variable(CMAKE_ANDROID_NDK) set_variable_if_unset(CMAKE_SYSTEM_VERSION 18) -set_variable_if_unset(CMAKE_ANDROID_STL_TYPE c++_static) - -endif () # DRACO_CMAKE_TOOLCHAINS_ARMV7_ANDROID_NDK_LIBCPP_CMAKE_ diff --git a/cmake/toolchains/armv7-ios.cmake b/cmake/toolchains/armv7-ios.cmake index 61d6787..8ddd699 100644 --- a/cmake/toolchains/armv7-ios.cmake +++ b/cmake/toolchains/armv7-ios.cmake @@ -1,14 +1,14 @@ -if (NOT DRACO_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_) +if(DRACO_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_) + return() +endif() set(DRACO_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_ 1) -if (XCODE) +if(XCODE) # TODO(tomfinegan): Handle arm builds in Xcode. message(FATAL_ERROR "This toolchain does not support Xcode.") -endif () +endif() set(CMAKE_SYSTEM_PROCESSOR "armv7") set(CMAKE_OSX_ARCHITECTURES "armv7") include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake") - -endif () # DRACO_CMAKE_TOOLCHAINS_ARMV7_IOS_CMAKE_ diff --git a/cmake/toolchains/armv7-linux-gcc.cmake b/cmake/toolchains/armv7-linux-gcc.cmake index e0f850f..9c94723 100644 --- a/cmake/toolchains/armv7-linux-gcc.cmake +++ b/cmake/toolchains/armv7-linux-gcc.cmake @@ -1,16 +1,18 @@ -if (NOT DRACO_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_) +if(DRACO_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_) + return() +endif() set(DRACO_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_ 1) set(CMAKE_SYSTEM_NAME "Linux") -if ("${CROSS}" STREQUAL "") +if("${CROSS}" STREQUAL "") # Default the cross compiler prefix to something known to work. set(CROSS arm-linux-gnueabihf-) -endif () +endif() -if (NOT ${CROSS} MATCHES hf-$) +if(NOT ${CROSS} MATCHES hf-$) set(DRACO_EXTRA_TOOLCHAIN_FLAGS "-mfloat-abi=softfp") -endif () +endif() set(CMAKE_C_COMPILER ${CROSS}gcc) set(CMAKE_CXX_COMPILER ${CROSS}g++) @@ -20,5 +22,3 @@ set(CMAKE_C_COMPILER_ARG1 set(CMAKE_CXX_COMPILER_ARG1 "-march=armv7-a -mfpu=neon ${DRACO_EXTRA_TOOLCHAIN_FLAGS}") set(CMAKE_SYSTEM_PROCESSOR "armv7") - -endif () # DRACO_CMAKE_TOOLCHAINS_ARMV7_LINUX_GCC_CMAKE_ diff --git a/cmake/toolchains/armv7s-ios.cmake b/cmake/toolchains/armv7s-ios.cmake index 4509793..b433025 100644 --- a/cmake/toolchains/armv7s-ios.cmake +++ b/cmake/toolchains/armv7s-ios.cmake @@ -1,14 +1,14 @@ -if (NOT DRACO_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_) +if(DRACO_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_) + return() +endif() set(DRACO_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_ 1) -if (XCODE) +if(XCODE) # TODO(tomfinegan): Handle arm builds in Xcode. message(FATAL_ERROR "This toolchain does not support Xcode.") -endif () +endif() set(CMAKE_SYSTEM_PROCESSOR "armv7s") set(CMAKE_OSX_ARCHITECTURES "armv7s") include("${CMAKE_CURRENT_LIST_DIR}/arm-ios-common.cmake") - -endif () # DRACO_CMAKE_TOOLCHAINS_ARMV7S_IOS_CMAKE_ diff --git a/cmake/toolchains/default-android-ndk-libcpp.cmake b/cmake/toolchains/default-android-ndk-libcpp.cmake new file mode 100644 index 0000000..cd1d7ca --- /dev/null +++ b/cmake/toolchains/default-android-ndk-libcpp.cmake @@ -0,0 +1,7 @@ +if(DRACO_CMAKE_TOOLCHAINS_DEFAULT_ANDROID_NDK_LIBCPP_CMAKE_) + return() +endif() +set(DRACO_CMAKE_TOOLCHAINS_DEFAULT_ANDROID_NDK_LIBCPP_CMAKE_ 1) + +include("${CMAKE_CURRENT_LIST_DIR}/../util.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/android-ndk-common.cmake") diff --git a/cmake/toolchains/x86-android-ndk-libcpp.cmake b/cmake/toolchains/x86-android-ndk-libcpp.cmake index 7bb3717..38e7d31 100644 --- a/cmake/toolchains/x86-android-ndk-libcpp.cmake +++ b/cmake/toolchains/x86-android-ndk-libcpp.cmake @@ -1,12 +1,10 @@ -if (NOT DRACO_CMAKE_TOOLCHAINS_X86_ANDROID_NDK_LIBCPP_CMAKE_) +if(DRACO_CMAKE_TOOLCHAINS_X86_ANDROID_NDK_LIBCPP_CMAKE_) + return() +endif() set(DRACO_CMAKE_TOOLCHAINS_X86_ANDROID_NDK_LIBCPP_CMAKE_ 1) include("${CMAKE_CURRENT_LIST_DIR}/../util.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/android-ndk-common.cmake") -set(CMAKE_SYSTEM_NAME Android) set(CMAKE_ANDROID_ARCH_ABI x86) -require_variable(CMAKE_ANDROID_NDK) set_variable_if_unset(CMAKE_SYSTEM_VERSION 18) -set_variable_if_unset(CMAKE_ANDROID_STL_TYPE c++_static) - -endif () # DRACO_CMAKE_TOOLCHAINS_X86_ANDROID_NDK_LIBCPP_CMAKE_ diff --git a/cmake/toolchains/x86_64-android-ndk-libcpp.cmake b/cmake/toolchains/x86_64-android-ndk-libcpp.cmake index 3b86b9d..2230e50 100644 --- a/cmake/toolchains/x86_64-android-ndk-libcpp.cmake +++ b/cmake/toolchains/x86_64-android-ndk-libcpp.cmake @@ -1,12 +1,10 @@ -if (NOT DRACO_CMAKE_TOOLCHAINS_X86_64_ANDROID_NDK_LIBCPP_CMAKE_) +if(DRACO_CMAKE_TOOLCHAINS_X86_64_ANDROID_NDK_LIBCPP_CMAKE_) + return() +endif() set(DRACO_CMAKE_TOOLCHAINS_X86_64_ANDROID_NDK_LIBCPP_CMAKE_ 1) include("${CMAKE_CURRENT_LIST_DIR}/../util.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/android-ndk-common.cmake") -set(CMAKE_SYSTEM_NAME Android) set(CMAKE_ANDROID_ARCH_ABI x86_64) -require_variable(CMAKE_ANDROID_NDK) set_variable_if_unset(CMAKE_SYSTEM_VERSION 21) -set_variable_if_unset(CMAKE_ANDROID_STL_TYPE c++_static) - -endif () # DRACO_CMAKE_TOOLCHAINS_X86_64_ANDROID_NDK_LIBCPP_CMAKE_ diff --git a/cmake/util.cmake b/cmake/util.cmake index 252761f..8c82f46 100644 --- a/cmake/util.cmake +++ b/cmake/util.cmake @@ -1,10 +1,12 @@ -if (NOT DRACO_CMAKE_UTIL_CMAKE_) +if(DRACO_CMAKE_UTIL_CMAKE_) + return() +endif() set(DRACO_CMAKE_UTIL_CMAKE_ 1) # Creates dummy source file in $draco_build_dir named $basename.$extension and # returns the full path to the dummy source file via the $out_file_path # parameter. -function (create_dummy_source_file basename extension out_file_path) +function(create_dummy_source_file basename extension out_file_path) set(dummy_source_file "${draco_build_dir}/${basename}.${extension}") file(WRITE "${dummy_source_file}" "// Generated file. DO NOT EDIT!\n" @@ -12,63 +14,60 @@ function (create_dummy_source_file basename extension out_file_path) "// or to silence a harmless CMake warning: Ignore me.\n" "void ${target_name}_dummy_function(void) {}\n") set(${out_file_path} ${dummy_source_file} PARENT_SCOPE) -endfunction () +endfunction() # Convenience function for adding a dummy source file to $target_name using # $extension as the file extension. Wraps create_dummy_source_file(). -function (add_dummy_source_file_to_target target_name extension) +function(add_dummy_source_file_to_target target_name extension) create_dummy_source_file("${target_name}" "${extension}" "dummy_source_file") target_sources(${target_name} PRIVATE ${dummy_source_file}) -endfunction () +endfunction() # Extracts the version number from $version_file and returns it to the user via -# $version_string_out_var. This is achieved by finding the first instance of -# the kDracoVersion variable and then removing everything but the string literal +# $version_string_out_var. This is achieved by finding the first instance of the +# kDracoVersion variable and then removing everything but the string literal # assigned to the variable. Quotes and semicolon are stripped from the returned # string. -function (extract_version_string version_file version_string_out_var) +function(extract_version_string version_file version_string_out_var) file(STRINGS "${version_file}" draco_version REGEX "kDracoVersion") list(GET draco_version 0 draco_version) string(REPLACE "static const char kDracoVersion[] = " "" draco_version - "${draco_version}") + "${draco_version}") string(REPLACE ";" "" draco_version "${draco_version}") string(REPLACE "\"" "" draco_version "${draco_version}") set("${version_string_out_var}" "${draco_version}" PARENT_SCOPE) -endfunction () +endfunction() # Sets CMake compiler launcher to $launcher_name when $launcher_name is found in # $PATH. Warns user about ignoring build flag $launcher_flag when $launcher_name # is not found in $PATH. -function (set_compiler_launcher launcher_flag launcher_name) +function(set_compiler_launcher launcher_flag launcher_name) find_program(launcher_path "${launcher_name}") - if (launcher_path) + if(launcher_path) set(CMAKE_C_COMPILER_LAUNCHER "${launcher_path}" PARENT_SCOPE) set(CMAKE_CXX_COMPILER_LAUNCHER "${launcher_path}" PARENT_SCOPE) message("--- Using ${launcher_name} as compiler launcher.") - else () - message(WARNING - "--- Cannot find ${launcher_name}, ${launcher_flag} ignored.") - endif () -endfunction () + else() + message( + WARNING "--- Cannot find ${launcher_name}, ${launcher_flag} ignored.") + endif() +endfunction() # Terminates CMake execution when $var_name is unset in the environment. Sets # CMake variable to the value of the environment variable when the variable is # present in the environment. macro(require_variable var_name) - if ("$ENV{${var_name}}" STREQUAL "") + if("$ENV{${var_name}}" STREQUAL "") message(FATAL_ERROR "${var_name} must be set in environment.") - endif () + endif() set_variable_if_unset(${var_name} "") -endmacro () +endmacro() -# Sets $var_name to $default_value if not already set in the environment. -macro (set_variable_if_unset var_name default_value) - if (NOT "$ENV{${var_name}}" STREQUAL "") +# Sets $var_name to $default_value if not already set. +macro(set_variable_if_unset var_name default_value) + if(NOT "$ENV{${var_name}}" STREQUAL "") set(${var_name} $ENV{${var_name}}) - else () + elseif(NOT ${var_name}) set(${var_name} ${default_value}) - endif () -endmacro () - -endif() # DRACO_CMAKE_UTIL_CMAKE_ - + endif() +endmacro()