On Wed, Aug 18, 2010 at 1:07 PM, Kei Okada wrote: > How to add compile definition with string variable, for example > -DFOO="bar" in rosbuild_add_compile_flags? > > I tried > >  set(COMPILE_FLAGS "-O2 -DFOO=\"bar\") >  rosbuild_add_compile_flags(hoge ${COMPILE_FLAGS}) > > but, this did not works well, it seems compile with >  gcc -O2 -DFOO=bar. Here's how rosbuild does something similar, where PROJECT_NAME is an unquoted string: add_definitions(-DROS_PACKAGE_NAME='\"${PROJECT_NAME}\"') Note the outer single quotes, and escaped double quotes. I suspect that there are alternatives that would also work. Btw, CMake usually takes -D definitions via add_definitions(), as in this example. But adding them via rosbuild_add_compile_flags() will also work. brian.