[CMake] Bug or misusage ???
Brad King
brad.king at kitware.com
Mon Mar 6 14:50:07 EST 2006
Philippe Poilbarbe wrote:
> I build some files extracted from a compressed one and I have the
> following declaration:
>
> #############
> ADD_CUSTOM_TARGET(gshhs_f.b ALL
> ${CMAKE_CURRENT_SOURCE_DIR}/UnzipFile.pl
> ${CMAKE_CURRENT_SOURCE_DIR}/gshhs_data_files.zip gshhs_f.b
> DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gshhs_data_files.zip)
> #############
[snip]
> And as it is declared, the file is always extracted (the UnzipFile.pl
> script changes the date of extracted file in order to be greater than
> the one of the zip file avoiding a further extraction).
> It is due to the dependency made on data/CMakeFiles/gshhs_f.b.dir/build
> in build.make which does not exists and is never created (so building of
> gshhs_f.b is always done).
>
> Do I misuse CMake in this case or do you think it is a bug?
ADD_CUSTOM_TARGET is meant to add a new top-level target (like
ADD_LIBRARY or ADD_EXECUTABLE) in which build commands with dependencies
are evaluated. Note this sentence in the command's documentation: "Adds
a target with the given name that executes the given commands every time
the target is built."
You should use ADD_CUSTOM_COMMAND within the target:
ADD_CUSTOM_COMMAND(
OUTPUT gshhs_f.b
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/UnzipFile.pl
${CMAKE_CURRENT_SOURCE_DIR}/gshhs_data_files.zip gshhs_f.b
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gshhs_data_files.zip
)
ADD_CUSTOM_TARGET(extract_gshhs ALL DEPENDS gshhs_f.b)
-Brad
More information about the CMake
mailing list