如何手动将 CMake 路径变量设置为 NOTFOUND?

How to manually set a CMake path variable to NOTFOUND?

我事先对库路径进行了硬编码,如果文件不存在,我想手动将路径设置为 NOTFOUND。

set(MY_LIB "path that doesn't exist")
if(NOT EXISTS "${MY_LIB}")
 message("not found")
 // set it back to NOTFOUND ??
endif()
if (MY_LIB)
 // set flags
endif()

How to manually set a CMake path variable to NOTFOUND?

只需将其设置为字符串:

set(MY_LIB "NOTFOUND")