问题标签 [add-custom-target]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
string - CMake 将反斜杠附加到 add_custom_target 添加的命令
我有一个公司内部工具,它使用以下模式在每个命令行中获取多个文件
要将此工具添加到我的 CMake 构建中,我一直在使用 add_custom_target 命令,如下所示
只要 FILES 仅扩展为单个文件,此方法就可以正常工作,但是当我传入多个文件时,该命令开始仅产生垃圾输出。在检查 CMake 生成的 build.ninja 文件后,我发现 custom_target 命令被转换为一个调用,其中参数后跟这样的反斜杠
我怀疑这就是这不起作用的原因。
现在为什么 F. CMake 会这样做,我该如何摆脱这种行为?
/edit
在将 FILES 字符串传递给 add_custom_target 之前打印它我看不到那些反斜杠...
好的,我知道了。构建一个新列表并在 foreach 循环中附加 -i 和文件是有效的。
cmake - add_custom_target 中的生成器表达式
我正在尝试创建一个 cmake (3.22) 函数,该函数创建一个cppclean
为我在参数中提供的目标调用的目标
但是我不处理错误:
没有这样的文件或目录:'--include-path ... --include-path ... --include-path ...'
当我查看创建的 make 文件时,我确实看到了扩展生成器表达式周围的引号,这可能是错误的。
如果我删除生成器表达式周围的引号,它会给出不同的错误:
无法创建/home/foo/src:是目录
并且make文件显示JOIN表达式没有展开。
如何解决这个问题?
cmake - Do I always need a target in CMake?
I have a python script, which generates some files for me, and in my script, I have an argument --outputdir
to specify the location of output files. I want to run this script to generate these files and install them later. I used
So output files are generated under ${CMAKE_CURRENT_BINARY_DIR}
, and I can install them later.
but above code did not work, because I have to use a TARGET
or OUTPUT
from the error message. So if I use a dummy one:
This just worked and I can see files are generated under ${CMAKE_CURRENT_BINARY_DIR}
. I believe if I use something like:
this should also work. My question is why do I need a dummy
target anyway? Actually just with COMMAND
I can run my script and with args I can specify where the output files are generated, then with some install command I can install files around. So Am I correct to use a dummy
target in this case and do I have to use a it? Note generateFiles.py
are not changed during the build process and will generate the same files every time. Thanks, i am new to CMake.