Last active
June 3, 2021 12:00
-
-
Save Zeex/5291602 to your computer and use it in GitHub Desktop.
group_target_sources(target) - group target's source files on based on their directory.
This file contains 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
# group_target_sources(target) - group target's source files on based on | |
# their directory. | |
function(group_target_sources target) | |
get_target_property(sources ${target} SOURCES) | |
foreach(file ${sources}) | |
get_filename_component(path "${file}" ABSOLUTE) | |
get_filename_component(path "${path}" PATH) | |
if(file MATCHES "${PROJECT_BINARY_DIR}") | |
file(RELATIVE_PATH path ${PROJECT_BINARY_DIR} "${path}") | |
else() | |
file(RELATIVE_PATH path ${PROJECT_SOURCE_DIR} "${path}") | |
endif() | |
string(REGEX REPLACE "/" "\\\\" win_path "${path}") | |
source_group("${win_path}" REGULAR_EXPRESSION "${path}/[^/\\]+\\..*") | |
endforeach() | |
endfunction() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment