Last active
May 4, 2018 11:46
-
-
Save kbinani/d042b6d630d175cc4941eaf6fd2c3a3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro(setup_source_groups SourceFileList ProjectRootDir) | |
get_filename_component(ProjectRootDir "${ProjectRootDir}" ABSOLUTE) | |
string(REPLACE "\\" "/" ProjectRootDir "${ProjectRootDir}") | |
string(FIND "${ProjectRootDir}" ".." contains_dotdot) | |
if ("${contains_dotdot}" GREATER -1) | |
message(FATAL_ERROR " ProjectRootDir must not contains '..'. Use 'get_filename_component(<VAR> <FileName> DIRECTORY)' to get parent directory.") | |
endif() | |
foreach(source_file_path ${SourceFileList}) | |
get_filename_component(source_file_path "${source_file_path}" ABSOLUTE) | |
string(REPLACE "\\" "/" source_file_path "${source_file_path}") | |
string(REGEX REPLACE "^${ProjectRootDir}/" "" relative_path "${source_file_path}") | |
get_filename_component(dirname "${relative_path}" DIRECTORY) | |
string(REPLACE "/" "\\" group_name "${dirname}") | |
source_group("${group_name}" FILES "${source_file_path}") | |
endforeach() | |
endmacro() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment