]> git.proxmox.com Git - libgit2.git/blame - cmake/IdeSplitSources.cmake
New upstream version 1.4.3+dfsg.1
[libgit2.git] / cmake / IdeSplitSources.cmake
CommitLineData
eae0bfdc
PP
1# This function splits the sources files up into their appropriate
2# subdirectories. This is especially useful for IDEs like Xcode and
e579e0f7 3# Visual Studio, so that you can navigate into the libgit2_tests project,
eae0bfdc
PP
4# and see the folders within the tests folder (instead of just seeing all
5# source and tests in a single folder.)
e579e0f7
MB
6function(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()
22endfunction()