diff options
author | mano-wii <germano.costa@ig.com.br> | 2019-06-15 21:44:47 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2019-06-15 21:44:47 +0300 |
commit | 22b705d2cbe7fd12a181c6db096fb8d84b5c2240 (patch) | |
tree | 9f7fb766d05f70e5827788cd2c780464db20450b /build_files/cmake | |
parent | bfd18c471d29b811bc2a16854ab1a389179b8368 (diff) |
Cmake: Add `WINDOWS_USE_VISUAL_STUDIO_SOURCE_FOLDERS` option
This allows grouping files in a filter corresponding to the source files name.
Differential Revision: https://developer.blender.org/D5077
Diffstat (limited to 'build_files/cmake')
-rw-r--r-- | build_files/cmake/macros.cmake | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 71bf7811135..4a03243af4e 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -173,23 +173,36 @@ function(blender_source_group sources ) - # Group by location on disk - source_group("Source Files" FILES CMakeLists.txt) - - foreach(_SRC ${sources}) - get_filename_component(_SRC_EXT ${_SRC} LAST_EXT) - if((${_SRC_EXT} MATCHES ".h") OR - (${_SRC_EXT} MATCHES ".hpp") OR - (${_SRC_EXT} MATCHES ".hh")) - - set(GROUP_ID "Header Files") - elseif(${_SRC_EXT} MATCHES ".glsl") - set(GROUP_ID "Shaders") - else() - set(GROUP_ID "Source Files") - endif() - source_group("${GROUP_ID}" FILES ${_SRC}) - endforeach() + #if enabled, use the sources directories as filters. + if(WINDOWS_USE_VISUAL_STUDIO_SOURCE_FOLDERS) + foreach(_SRC ${sources}) + # remove ../'s + get_filename_component(_SRC_DIR ${_SRC} REALPATH) + get_filename_component(_SRC_DIR ${_SRC_DIR} DIRECTORY) + if(${_SRC_DIR} MATCHES "${CMAKE_CURRENT_SOURCE_DIR}/") + string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" GROUP_ID ${_SRC_DIR}) + string(REPLACE "/" "\\" GROUP_ID ${GROUP_ID}) + source_group("${GROUP_ID}" FILES ${_SRC}) + endif() + endforeach() + else() + # Group by location on disk + source_group("Source Files" FILES CMakeLists.txt) + foreach(_SRC ${sources}) + get_filename_component(_SRC_EXT ${_SRC} LAST_EXT) + if((${_SRC_EXT} MATCHES ".h") OR + (${_SRC_EXT} MATCHES ".hpp") OR + (${_SRC_EXT} MATCHES ".hh")) + + set(GROUP_ID "Header Files") + elseif(${_SRC_EXT} MATCHES ".glsl") + set(GROUP_ID "Shaders") + else() + set(GROUP_ID "Source Files") + endif() + source_group("${GROUP_ID}" FILES ${_SRC}) + endforeach() + endif() endfunction() |