diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:08 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:47:08 +0000 |
commit | 29b5ab554790bb57337a3b6ab9dcd963cf69d22e (patch) | |
tree | be1456d2bc6c1fb078695fad7bc8f6b212062d3c /cmake/IdeSplitSources.cmake | |
parent | Initial commit. (diff) | |
download | libgit2-29b5ab554790bb57337a3b6ab9dcd963cf69d22e.tar.xz libgit2-29b5ab554790bb57337a3b6ab9dcd963cf69d22e.zip |
Adding upstream version 1.7.2+ds.upstream/1.7.2+ds
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/IdeSplitSources.cmake')
-rw-r--r-- | cmake/IdeSplitSources.cmake | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/cmake/IdeSplitSources.cmake b/cmake/IdeSplitSources.cmake new file mode 100644 index 0000000..4f928ac --- /dev/null +++ b/cmake/IdeSplitSources.cmake @@ -0,0 +1,22 @@ +# This function splits the sources files up into their appropriate +# subdirectories. This is especially useful for IDEs like Xcode and +# Visual Studio, so that you can navigate into the libgit2_tests project, +# and see the folders within the tests folder (instead of just seeing all +# source and tests in a single folder.) +function(IDE_SPLIT_SOURCES target) + if(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode) + get_target_property(sources ${target} SOURCES) + foreach(source ${sources}) + if(source MATCHES ".*/") + string(REPLACE ${PROJECT_SOURCE_DIR}/ "" rel ${source}) + if(rel) + string(REGEX REPLACE "/([^/]*)$" "" rel ${rel}) + if(rel) + string(REPLACE "/" "\\\\" rel ${rel}) + source_group(${rel} FILES ${source}) + endif() + endif() + endif() + endforeach() + endif() +endfunction() |