'get_source_file_property' doesn't work correctly when path ends with '/'
The bellow snippet shows the issue:
cmake_minimum_required(VERSION 3.16)
project(test_global_flags)
set(dir_path1 "sub_dir1/")
set(dir_path2 "sub_dir2/")
unset(prop)
get_source_file_property(prop "${dir_path1}" MY_PROPERTY)
message("dir_path1 ${dir_path1} prop '${prop}'")
if(prop STREQUAL "NOTFOUND")
set_property(SOURCE "${dir_path1}" PROPERTY MY_PROPERTY "dir_path1 property value")
endif()
unset(prop)
get_source_file_property(prop "${dir_path2}" MY_PROPERTY)
message("dir_path2 ${dir_path2} prop '${prop}'")
set(dir_path1 "sub_dir1")
set(dir_path2 "sub_dir2")
unset(prop)
get_source_file_property(prop "${dir_path1}" MY_PROPERTY)
message("dir_path1 ${dir_path1} prop '${prop}'")
if(prop STREQUAL "NOTFOUND")
set_property(SOURCE "${dir_path1}" PROPERTY MY_PROPERTY "dir_path1 property value")
endif()
unset(prop)
get_source_file_property(prop "${dir_path2}" MY_PROPERTY)
message("dir_path2 ${dir_path2} prop '${prop}'")
The output is following:
...
dir_path1 sub_dir1/ prop 'NOTFOUND'
dir_path2 sub_dir2/ prop 'dir_path1 property value'
dir_path1 sub_dir1 prop 'NOTFOUND'
dir_path2 sub_dir2 prop 'NOTFOUND'
...
Note: if I use the ending '\' instead of '/' setter/getter works as expected.
Edited by Alexey Edelev