Skip to content

Commit

Permalink
Merge pull request google#556 from rbuch703/master
Browse files Browse the repository at this point in the history
Update CMake-generated headers only when their content changes
  • Loading branch information
tomfinegan committed Sep 25, 2019
2 parents 9976532 + d7f6ff3 commit e8daed7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmake/draco_features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit e8daed7

Please sign in to comment.