Cha*_*ang 5 linux bash makefile cmake cmake-custom-command
我想通过 add_custom_command(...) 在 CMakeLists.txt 中使用 Linux if 条件,因为我需要运行这些 if 条件并在 makefile 中做一些判断。像这样:
cmake_minimum_required(VERSION 2.8)
add_custom_target(temp_target ALL)
add_custom_command(TARGET temp_target
PRE_BUILD
COMMAND if ["a" != "b"]; then echo 1; fi;
VERBATIM )
Run Code Online (Sandbox Code Playgroud)
如果我想使用我该怎么办
if ["a" != "b"]; then echo 1; fi;
Run Code Online (Sandbox Code Playgroud)
什么时候制作makefile?非常感谢您的帮助!
您可以使用 using 作为 COMMAND 参数来指定一行 shell 代码/bin/sh -c:
COMMAND /bin/sh -c "if [ 'a' != 'b' ]; then echo 1; fi;"
Run Code Online (Sandbox Code Playgroud)
请注意,这[是 bash 的扩展,对于像“dash”这样的简单 shell 来说可能是未知的。