[CMake] ADD_CUSTOM_COMMAND VERBATIM

Nicolas Tisserand nicolas.tisserand at gmail.com
Fri Apr 11 04:56:29 EDT 2008


Hi Cmakers,

I am trying to understand the VERBATIM option of the
ADD_CUSTOM_COMMAND CMake command.

Given the following macro:

macro   (bogus_post_build target)
  get_target_property(target_path ${target} LOCATION)
  file(TO_NATIVE_PATH ${target_path} native_target_path)
  add_custom_command(
    TARGET ${target}
    POST_BUILD
    COMMAND dir ${native_target_path}
    VERBATIM
  )
endmacro(bogus_post_build)

I am using CMake 2.4.8 with the Visual Studio 8.0 generator.

* When invoked on some target WITH the VERBATIM option, the generated
post-build command is:
dir SOMEPATH\"$"(OutDir)\target.exe
The command will fail and the target won't be found, because the
dollar sign is incorrectly quoted.

* And when invoked WITHOUT the VERBATIM option:
 dir SOMEPATH\$(OutDir)\target.exe
This is the correct command.

However, the documentation states:
Use of VERBATIM is recommended as it enables correct behavior.
In the future VERBATIM may be enabled by default.

Is there a bug in the code, in the documentation or in my head?
-- 
Nicolas


More information about the CMake mailing list