]> git.proxmox.com Git - libgit2.git/blob - cmake/IdeSplitSources.cmake
e2e09b4ce15443f3a335fb5d92b58bfa09c38ee1
[libgit2.git] / cmake / IdeSplitSources.cmake
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_clar 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 ${libgit2_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()