未验证 提交 066426d4 编写于 作者: D daquexian 提交者: GitHub

fix write_file_if_different cmake error when file doesn't exist (#4252)

Signed-off-by: Ndaquexian <daquexian566@gmail.com>
上级 7e0f915c
......@@ -6,10 +6,14 @@ function(SHOW_VARIABLES)
endfunction()
macro(write_file_if_different file_path content)
file(READ ${file_path} current_content)
# NOTE: it seems a cmake bug that "content" in this macro is not
# treated as a variable
if (NOT (current_content STREQUAL ${content}))
if (EXISTS ${file_path})
file(READ ${file_path} current_content)
# NOTE: it seems a cmake bug that "content" in this macro is not
# treated as a variable
if (NOT (current_content STREQUAL ${content}))
file(WRITE ${file_path} ${content})
endif()
else()
file(WRITE ${file_path} ${content})
endif()
endmacro()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册