Search code examples
cmakeunsetfile-not-found

How to manually set a CMake path variable to NOTFOUND?


I'm hardcoding a library path before hand and want to set the path to NOTFOUND manually if the file doesn't exist.

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()

Solution

  • How to manually set a CMake path variable to NOTFOUND?

    Just set it to the string:

    set(MY_LIB "NOTFOUND")