Hi Chao,
> I was using 'for cyclic sentence' in command add_custom_command(...), the > content of the CMakeLists.txt as below: > add_custom_command(TARGET temp_target > POST_BUILD > COMMAND for x in a b c\; > do echo $x \; > done\;) > The $x is getting parsed by the makefile so you need to escape it with the $ makefile escape sequence. Try: add_custom_command(TARGET temp_target POST_BUILD COMMAND for x in a b c\; do echo $$x \; done\;) You can see the difference in a make VERBOSE=1 : [100%] Linking C static library libtemp_target.a /home/khq.kitware.com/chuck.atkins/Code/CMake/build/master-release/bin/cmake -P CMakeFiles/temp_target.dir/cmake_clean_target.cmake /home/khq.kitware.com/chuck.atkins/Code/CMake/build/master-release/bin/cmake -E cmake_link_script CMakeFiles/temp_target.dir/link.txt --verbose=1 /usr/bin/ar qc libtemp_target.a CMakeFiles/temp_target.dir/foo.c.o /usr/bin/ranlib libtemp_target.a *for x in a b c; do echo ; done;* make[2]: Leaving directory '/home/khq.kitware.com/chuck.atkins/tmp/bld' Now becomes: [100%] Linking C static library libtemp_target.a /home/khq.kitware.com/chuck.atkins/Code/CMake/build/master-release/bin/cmake -P CMakeFiles/temp_target.dir/cmake_clean_target.cmake /home/khq.kitware.com/chuck.atkins/Code/CMake/build/master-release/bin/cmake -E cmake_link_script CMakeFiles/temp_target.dir/link.txt --verbose=1 /usr/bin/ar qc libtemp_target.a CMakeFiles/temp_target.dir/foo.c.o /usr/bin/ranlib libtemp_target.a *for x in a b c; do echo $x ; done;abc* make[2]: Leaving directory '/home/khq.kitware.com/chuck.atkins/tmp/bld' - Chuck
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake