Debian Codegraph @

cmake/IdeSplitSources.cmake

raw
1 # This function splits the sources files up into their appropriate
2 # subdirectories. This is especially useful for IDEs like Xcode and
3 # Visual Studio, so that you can navigate into the libgit2_tests project,
4 # and see the folders within the tests folder (instead of just seeing all
5 # source and tests in a single folder.)
6 function(IDE_SPLIT_SOURCES target)
7 if(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode)
8 get_target_property(sources ${target} SOURCES)
9 foreach(source ${sources})
10 if(source MATCHES ".*/")
11 string(REPLACE ${PROJECT_SOURCE_DIR}/ "" rel ${source})
12 if(rel)
13 string(REGEX REPLACE "/([^/]*)$" "" rel ${rel})
14 if(rel)
15 string(REPLACE "/" "\\\\" rel ${rel})
16 source_group(${rel} FILES ${source})
17 endif()
18 endif()
19 endif()
20 endforeach()
21 endif()
22 endfunction()