问题
Is there a way to compare files using cmake? I've checked all parameters from https://cmake.org/cmake/help/latest/command/file.html
回答1:
cmake executable has a tool mode, when it performs some useful actions instead of project's configuration. And compare_files is one of the commands for that mode.
For get features of the CMake command line tool mode in the CMakeLists.txt, use execute_process command:
execute_process( COMMAND ${CMAKE_COMMAND} -E compare_files <file1> <file2>
RESULT_VARIABLE compare_result
)
if( compare_result EQUAL 0)
message("The files are identical.")
elseif( compare_result EQUAL 1)
message("The files are different.")
else()
message("Error while comparing the files.")
endif()
来源:https://stackoverflow.com/questions/54353120/how-to-compare-files-in-cmake