This ```if(NOT READLINE_FOUND)``` is not needed, and also causes the ```set(READLINE_INCLUDE_DIRS ${READLINE_INCLUDE_DIR})``` to be skipped on the second run of cmake, and therefore the ```READLINE_INCLUDE_DIRS``` variable (not cached) will be empty.