[CMake] Help with ADD_CUSTOM_COMMAND
Michael Kaplan
kaplanmn at npt.nuwc.navy.mil
Wed Feb 13 17:04:35 EST 2008
I am currently using cmake 2.4 (patch 8) and i'm having a problem with
ADD_CUSTOM_COMMAND
I created a macro which defined an add_custom_command to which i'd like
to pass some extra arguments in variables. However, when I try to pass
in a string with spaces, the spaces get "escaped" which breaks the
command. Below is a simplified CMakeLists.txt that illustrates the
issue I am having.
SET(OPTIONS "-H -l")
MACRO(RUN_CMD FILENAME)
ADD_CUSTOM_COMMAND(
OUTPUT new.cpp
COMMAND cp ${OPTIONS} ${FILENAME} new.cpp
)
ENDMACRO(RUN_CMD)
RUN_CMD(old.cpp)
ADD_EXECUTABLE(new new.cpp)
I'd like the the custom command to run to be
cp -H -l old.cpp new.cpp
but instead, what is generated into the CMakeFiles/new.dir/build.make
file is
cp -H\ -l old.cpp new.cpp
Note the -H\ -l. This breaks the command I need to run. The above is a
contrived example. In actuality, I define the Macro in a "UseXXX.cmake"
type file and it is used elsewhere. The "OPTIONS" variable is used to
pass extra options as needed to the command. Is there anyway to do this
with getting the string escaped when run as part of the command?
Thanks,
Michael Kaplan
More information about the CMake
mailing list