[CMake] file COPY/INSTALL doesn't overwrite existing files?
Eric Noulard
eric.noulard at gmail.com
Thu Sep 30 17:20:27 EDT 2010
2010/9/30 Guillaume Duhamel <guillaume.duhamel at gmail.com>:
> Hi,
> I'm trying to use "file(COPY ..." during the build of one of my project.
"file(COPY ..." is a **CMake-time** command, i.e. it will be processed
when CMake runs
and not when building (unless make is triggering a cmake run)
If you want **Build-time** command you'll have to use
add_custom_command/add_custom_target
> The documentation says that files get overwritten according to their
> timestamps, but it seems they just never get overwritten.
> For instance, with this CMakeLists :
> ===================================
> project(test)
> cmake_minimum_required(VERSION 2.8)
> file(INSTALL dir DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
> file(INSTALL bar.txt DESTINATION ${test_BINARY_DIR}/dir)
> ===================================
> and those steps :
> $ mkdir build && cd build && cmake .. && make
> $ echo "something new" >> ../bar.txt
> $ make
> bar.txt doesn't get overwritten after the second make.
> Is there anything I'm doing wrong or do I have to detect existing files
> and remove them before the copy?
try
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dir ${CMAKE_CURRENT_BINARY_DIR}/dir/bar.txt
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/dir ${CMAKE_CURRENT_BINARY_DIR}/dir
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/bar.txt
${CMAKE_CURRENT_BINARY_DIR}/dir/bar.txt
)
or something similar.
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
More information about the CMake
mailing list