Installed files are never up to date with CMAKE_CROSSCOMPILING enabled
Hi,
I am experiencing unexpected behavior when installing a file with CMAKE_CROSSCOMPILING
enabled.
Consider the following script (test.txt
):
if(NOT EXISTS "file.txt")
file(WRITE "file.txt" "Some text")
endif()
file(MAKE_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/install")
file(INSTALL DESTINATION "${CMAKE_CURRENT_LIST_DIR}/install" TYPE FILE MESSAGE_LAZY FILES "${CMAKE_CURRENT_LIST_DIR}/file.txt")
When running this script, I expect that the first time file.txt
will be installed. The second time, CMake will detect that the file is up-to-date and do (or at least report) nothing. The actual behavior seems to depend on the value of CMAKE_CROSSCOMPILING
though.
$ cmake -DCMAKE_CROSSCOMPILING=OFF -P test.txt
-- Installing: C:/.../install/file.txt
$ cmake -DCMAKE_CROSSCOMPILING=OFF -P test.txt
$
This is as expected. Setting CMAKE_CROSSCOMPILING
to ON
, things change:
$ rm -rf install/
$ cmake -DCMAKE_CROSSCOMPILING=ON -P test.txt
-- Installing: C:/.../install/file.txt
$ cmake -DCMAKE_CROSSCOMPILING=ON -P test.txt
-- Installing: C:/.../install/file.txt
This seems surprising. Is there something that I am unaware of in the context of cross-compiling so that this behavior is indeed correct? Thanks.