Accept any filepath in llvm_check_source_file_list

Cmake function llvm_check_source_file_list currently only accepts paths
relative to current CMAKE_SOURCE_DIR or relative to argument SOURCE_DIR.

Extend it to accept any path, including absolute ones.

Differential revision: https://reviews.llvm.org/D44625

llvm-svn: 327912
This commit is contained in:
Serge Guelton 2018-03-19 21:35:30 +00:00
parent 2ecc0d3954
commit 1447c97909
1 changed files with 14 additions and 4 deletions

View File

@ -69,14 +69,18 @@ endfunction(llvm_process_sources)
function(llvm_check_source_file_list) function(llvm_check_source_file_list)
cmake_parse_arguments(ARG "" "SOURCE_DIR" "" ${ARGN}) cmake_parse_arguments(ARG "" "SOURCE_DIR" "" ${ARGN})
set(listed ${ARG_UNPARSED_ARGUMENTS}) foreach(l ${ARG_UNPARSED_ARGUMENTS})
get_filename_component(fp ${l} REALPATH)
list(APPEND listed ${fp})
endforeach()
if(ARG_SOURCE_DIR) if(ARG_SOURCE_DIR)
file(GLOB globbed file(GLOB globbed
RELATIVE "${CMAKE_CURRENT_LIST_DIR}"
"${ARG_SOURCE_DIR}/*.c" "${ARG_SOURCE_DIR}/*.cpp") "${ARG_SOURCE_DIR}/*.c" "${ARG_SOURCE_DIR}/*.cpp")
else() else()
file(GLOB globbed *.c *.cpp) file(GLOB globbed *.c *.cpp)
endif() endif()
foreach(g ${globbed}) foreach(g ${globbed})
get_filename_component(fn ${g} NAME) get_filename_component(fn ${g} NAME)
if(ARG_SOURCE_DIR) if(ARG_SOURCE_DIR)
@ -84,15 +88,21 @@ function(llvm_check_source_file_list)
else() else()
set(entry "${fn}") set(entry "${fn}")
endif() endif()
get_filename_component(gp ${g} REALPATH)
# Don't reject hidden files. Some editors create backups in the # Don't reject hidden files. Some editors create backups in the
# same directory as the file. # same directory as the file.
if (NOT "${fn}" MATCHES "^\\.") if (NOT "${fn}" MATCHES "^\\.")
list(FIND LLVM_OPTIONAL_SOURCES ${entry} idx) list(FIND LLVM_OPTIONAL_SOURCES ${entry} idx)
if( idx LESS 0 ) if( idx LESS 0 )
list(FIND listed ${entry} idx) list(FIND listed ${gp} idx)
if( idx LESS 0 ) if( idx LESS 0 )
message(SEND_ERROR "Found unknown source file ${g} if(ARG_SOURCE_DIR)
set(fn_relative "${ARG_SOURCE_DIR}/${fn}")
else()
set(fn_relative "${fn}")
endif()
message(SEND_ERROR "Found unknown source file ${fn_relative}
Please update ${CMAKE_CURRENT_LIST_FILE}\n") Please update ${CMAKE_CURRENT_LIST_FILE}\n")
endif() endif()
endif() endif()