文件漏提交
This commit is contained in:
parent
6a3e65ca40
commit
5139d4985e
55
cmake/retrieve_files.cmake
Normal file
55
cmake/retrieve_files.cmake
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
function(retrieve_files path out_files)
|
||||
message(STATUS "Retrieving files in ${path}")
|
||||
|
||||
# 递归查找文件夹下的 .h .hpp. ini 文件保存到 HEAD_FILES
|
||||
file(GLOB_RECURSE HEAD_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS ${path}/*.h ${path}/*.hpp ${path}/*.ini)
|
||||
|
||||
# 递归查找文件夹下的 *.cpp *.c 文件保存到 SRC_FILES
|
||||
file(GLOB_RECURSE SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS ${path}/*.cpp ${path}*.c ${path}*.ixx)
|
||||
|
||||
# 将 HEDADER_FILES 和 SRC_FILES 保存到 ALL_FILES 变量
|
||||
set(ALL_FILES ${HEAD_FILES} ${SRC_FILES})
|
||||
|
||||
set(RESULT "")
|
||||
|
||||
# 对 ALL_FILES 变量里面的所有文件分类(保留资源管理器的目录结构)
|
||||
foreach(fileItem ${ALL_FILES})
|
||||
# Get the directory of the source file
|
||||
get_filename_component(PARENT_DIR "${fileItem}" DIRECTORY)
|
||||
|
||||
# 用于检查平台的条件
|
||||
if(PARENT_DIR STREQUAL "windows")
|
||||
if(WIN32)
|
||||
set(RESULT "${RESULT};${fileItem}")
|
||||
else()
|
||||
continue()
|
||||
endif()
|
||||
elseif(PARENT_DIR STREQUAL "linux")
|
||||
if(UNIX AND NOT APPLE)
|
||||
set(RESULT "${RESULT};${fileItem}")
|
||||
else()
|
||||
continue()
|
||||
endif()
|
||||
elseif(PARENT_DIR STREQUAL "mac")
|
||||
if(APPLE)
|
||||
set(RESULT "${RESULT};${fileItem}")
|
||||
else()
|
||||
continue()
|
||||
endif()
|
||||
else()
|
||||
# 如果文件夹名称不是平台,则始终包含
|
||||
set(RESULT "${RESULT};${fileItem}")
|
||||
endif()
|
||||
|
||||
# Remove common directory prefix to make the group
|
||||
string(REPLACE "${path}" "" GROUP "${PARENT_DIR}")
|
||||
# Make sure we are using windows slashes
|
||||
string(REPLACE "/" "\\" GROUP "${GROUP}")
|
||||
# Group into "Source Files" and "Header Files"
|
||||
set(GROUP "${GROUP}")
|
||||
source_group("${GROUP}" FILES "${fileItem}")
|
||||
endforeach()
|
||||
|
||||
set(${out_files} ${RESULT} PARENT_SCOPE)
|
||||
endfunction()
|
Loading…
x
Reference in New Issue
Block a user