find_file: different results for same predefined cache variable
I just discovered a strange behavior, and I am not sure if it is on purpose or not.
The following CMake
snippet is used:
cmake_minimum_required(VERSION 3.1...3.21)
project(Test LANGUAGES NONE)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/my_file.txt" "")
find_file(MY_FILE NAMES my_file.txt PATHS "${CMAKE_CURRENT_BINARY_DIR}")
message("RESULT: ${MY_FILE}")
-
Evaluating this
CMakeLists.txt
display, as expected,RESULT: .../my_file.txt
. -
Now with command line
cmake -DMY_FILE=NOTFOUND
, we getRESULT: NOTFOUND
rather than the expected.../my_file.txt
. -
And if we add type to the variable on the command line, i.e.
cmake -DMY_FILE:FILEPATH=NOTFOUND
, we get the expected result:RESULT: .../my_file.txt
.
Is the behavior of item 2
a bug or not?