Merge pull request #556 from rbuch703/master

Update CMake-generated headers only when their content changes
This commit is contained in:
Tom Finegan 2019-09-25 14:15:32 -07:00 committed by GitHub
commit e8daed7f06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,13 +44,18 @@ endmacro()
# Function for generating draco_features.h.
function(draco_generate_features_h)
file(WRITE "${draco_features_file_name}"
file(WRITE "${draco_features_file_name}.new"
"// GENERATED FILE -- DO NOT EDIT\n\n" "#ifndef DRACO_FEATURES_H_\n"
"#define DRACO_FEATURES_H_\n\n")
foreach(feature ${draco_features_list})
file(APPEND "${draco_features_file_name}" "#define ${feature}\n")
file(APPEND "${draco_features_file_name}.new" "#define ${feature}\n")
endforeach()
file(APPEND "${draco_features_file_name}" "\n#endif // DRACO_FEATURES_H_")
file(APPEND "${draco_features_file_name}.new" "\n#endif // DRACO_FEATURES_H_")
# Will replace ${draco_features_file_name} only if the file content has changed.
# This prevents forced Draco rebuilds after CMake runs.
configure_file("${draco_features_file_name}.new" "${draco_features_file_name}")
file(REMOVE "${draco_features_file_name}.new")
endfunction()