Retriggering a find_* search by setting the variable to NOTFOUND does not set that variable
After noticing that a wrong library was found via find_path
I invoked cmake again with -DFOO_INCLUDE_DIR=NOTFOUND
expecting it to search again.
However it does not reset that variable so it always stays at "NOTFOUND".
By debugging I found:
- the NOTFOUND is correctly detected retriggering a new search
-
https://gitlab.kitware.com/cmake/cmake/-/blob/5208b8c8532c770140c6e6eb902dc54751f55e87/Source/cmFindPathCommand.cxx#L46 then calls
AddCacheDefinition
with (defaulted)force=false
- This then reused the existing (old) value: https://gitlab.kitware.com/cmake/cmake/-/blob/5208b8c8532c770140c6e6eb902dc54751f55e87/Source/cmMakefile.cxx#L1893-1895
This affects the whole find_*
family of functions
I'm unsure what cmStateEnums::UNINITIALIZED
means but that makes the difference between the previous cache entry created by a failed find_*
call and the cache entry created by -D