8000 cmake: break out the ugly split sources fn · libgit2/libgit2@e78aafe · GitHub
[go: up one dir, main page]

Skip to content

Commit e78aafe

Browse files
author
Edward Thomson
committed
cmake: break out the ugly split sources fn
1 parent 76be185 commit e78aafe

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ INCLUDE(CheckStructHasMember)
3232
INCLUDE(AddCFlagIfSupported)
3333
INCLUDE(FindPkgConfig)
3434
INCLUDE(FindStatNsec)
35+
INCLUDE(IdeSplitSources)
3536

3637
# Build options
3738
#

cmake/Modules/IdeSplitSources.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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 git2_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 ${CMAKE_CURRENT_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()

0 commit comments

Comments
 (0)
0