-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoadSources.cmake
28 lines (27 loc) · 1.06 KB
/
LoadSources.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Get list of all directories within 'dir', including 'dir'
MACRO(DIRLIST_RECURSE result dir)
FILE(GLOB_RECURSE file_list RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${dir}/*)
SET(dir_list "")
FOREACH(file_path ${file_list})
GET_FILENAME_COMPONENT(file_dir ${file_path} DIRECTORY)
LIST(APPEND dir_list ${file_dir})
ENDFOREACH()
LIST(APPEND dir_list ${dir})
LIST(REMOVE_DUPLICATES dir_list)
SET(${result} ${dir_list})
ENDMACRO()
# Find all CPP source files recursively in a certain directory
# and store it in result while also generating source_groups to
# maintain the original directory structure in Visual Studio.
MACRO(LOAD_SOURCES result dir)
IF(NOT DEFINED ${result})
set(${result} "")
ENDIF()
DIRLIST_RECURSE(dir_list ${dir})
FOREACH(subdir ${dir_list})
file(GLOB file_list RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${subdir}/*.h ${subdir}/*.cc ${subdir}/*.cpp)
list(APPEND ${result} ${file_list})
string(REGEX REPLACE "/" "\\\\\\\\" _sourcegroup "${subdir}")
source_group("${_sourcegroup}" FILES ${file_list})
ENDFOREACH()
ENDMACRO()