CMake quote escape conumdrum

最后都变了- 提交于 2019-12-02 05:41:54
Florian

Actually you ran into two problems:

  1. Don't quote CMake variables in custom commands. CMake will do the necessary escape sequences for you.
  2. The first literal after COMMAND is assumed to be a command name or file. So CMake tries to handle it as a single "string".

So I changed the quoting and the env call and the following did work for me:

cmake_minimum_required(VERSION 2.8)

project(QuotedStrings)

set(X "A B C")
add_custom_target( works COMMAND env DUMMY=0 X=${X} | grep ^X= COMMENT "This works")
add_custom_target( fails_no_more COMMAND env X=${X} | grep ^X= COMMENT "This works too")

For more details and possibilities see:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!