我这样称呼我的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被设置了!
发布于 2019-09-02 07:49:16
TARGET是用于if命令的一个特殊的关键字。它用于检查给定的目标(在CMake意义上)是否存在。正确使用此关键字包括、两个参数( of 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 ("JETSON_NANO" STREQUAL TARGET) # Compares string "JETSON_NANO" with variable TARGET在if命令的文档中可以看到更多关于它的信息。
https://stackoverflow.com/questions/57752427
复制相似问题