我像这样调用我的 CMakeLists.txt:
cmake ../.. -DTARGET=JETSON_NANO
然后,这一行:
message(STATUS "------------ TARGET: ${TARGET}")
印刷 ------------ TARGET: JETSON_NANO
但这一行:
if (TARGET STREQUAL JETSON_NANO)
给出错误:
if given arguments:
"TARGET" "STREQUAL" "JETSON_NANO"
为什么?TARGET
已设置!
TARGET
是一个特殊的关键字的if
命令。它用于检查给定的目标(在 CMake 意义上)是否存在。此关键字的正确使用包括两个参数的if
:
if(TARGET JETSON_NANO) # Checks whether CMake target JETSON_NANO exists
这就是当您使用带有三个参数的此关键字时 CMake 发出错误的原因:
if (TARGET STREQUAL "JETSON_NANO") # Error: 'TARGET' keyword requires two `if` arguments
但是,您可以在命令中交换比较字符串if
:
if ("JETSON_NANO" STREQUAL TARGET) # Compares string "JETSON_NANO" with variable TARGET
if
在其文档中查看有关命令的更多信息。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句