]> granicus.if.org Git - esp-idf/commitdiff
cmake: Only rewrite componend_depends.cmake if it changes
authorAngus Gratton <angus@espressif.com>
Fri, 10 Aug 2018 02:30:32 +0000 (12:30 +1000)
committerAngus Gratton <gus@projectgus.com>
Mon, 13 Aug 2018 05:37:03 +0000 (15:37 +1000)
tools/cmake/scripts/expand_requirements.cmake

index d602801bbab1b87d4ba47acb293aa8eef48ae4ac..a825a76473c15ac364a2c53851b148099955d2e3 100644 (file)
@@ -184,10 +184,10 @@ debug("components in build: ${build_component_paths}")
 debug("components not found: ${not_found}")
 
 function(line contents)
-    file(APPEND "${DEPENDENCIES_FILE}" "${contents}\n")
+    file(APPEND "${DEPENDENCIES_FILE}.tmp" "${contents}\n")
 endfunction()
 
-file(WRITE "${DEPENDENCIES_FILE}" "# Component requirements generated by expand_requirements.cmake\n\n")
+file(WRITE "${DEPENDENCIES_FILE}.tmp" "# Component requirements generated by expand_requirements.cmake\n\n")
 line("set(BUILD_COMPONENTS ${build_components})")
 line("set(BUILD_COMPONENT_PATHS ${build_component_paths})")
 line("")
@@ -216,3 +216,7 @@ endforeach()
 
 line("  message(FATAL_ERROR \"Component not found: \${component}\")")
 line("endfunction()")
+
+# only replace DEPENDENCIES_FILE if it has changed (prevents ninja/make build loops.)
+execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${DEPENDENCIES_FILE}.tmp" "${DEPENDENCIES_FILE}")
+execute_process(COMMAND ${CMAKE_COMMAND} -E remove "${DEPENDENCIES_FILE}.tmp")