8000 cmake: Move IDE source munging to a module · libgit2/libgit2@fc6e38c · GitHub
[go: up one dir, main page]

Skip to content

Commit fc6e38c

Browse files
committed
cmake: Move IDE source munging to a module
Move the odd code that provides a hierarchical display for projects within the IDEs to its own module.
1 parent ed298c8 commit fc6e38c

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

CMakeLists.txt

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

3738
# Build options
@@ -95,29 +96,6 @@ IF(MSVC)
9596
OPTION(MSVC_CRTDBG "Enable CRTDBG memory leak reporting" OFF)
9697
ENDIF()
9798

98-
# This function splits the sources files up into their appropriate
99-
# subdirectories. This is especially useful for IDEs like Xcode and
100-
# Visual Studio, so that you can navigate into the libgit2_clar project,
101-
# and see the folders within the tests folder (instead of just seeing all
102-
# source and tests in a single folder.)
103-
FUNCTION(IDE_SPLIT_SOURCES target)
104-
IF(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode)
105-
GET_TARGET_PROPERTY(sources ${target} SOURCES)
106-
FOREACH(source ${sources})
107-
IF(source MATCHES ".*/")
108-
STRING(REPLACE ${libgit2_SOURCE_DIR}/ "" rel ${source})
109-
IF(rel)
110-
STRING(REGEX REPLACE "/([^/]*)$" "" rel ${rel})
111-
IF(rel)
112-
STRING(REPLACE "/" "\\\\" rel ${rel})
113-
SOURCE_GROUP(${rel} FILES ${source})
114-
ENDIF()
115-
ENDIF()
116-
ENDIF()
117-
ENDFOREACH()
118-
ENDIF()
119-
ENDFUNCTION()
120-
12199
FILE(STRINGS "${libgit2_SOURCE_DIR}/include/git2/version.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$")
122100

123101
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${GIT2_HEADER}")

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 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()

0 commit comments

Comments
 (0)
0