Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7208ff4

Browse files
committed
cmake: split sources into original paths for Xcode and MSVC
The MSVC_SPLIT_SOURCES function is helpful for other IDEs, like Xcode, and will split the source files up into their target directories, instead of merely placing them all in a "Sources" directory. Rename MSVC_SPLIT_SOURCES to IDE_SPLIT_SOURCES and enable it for Xcode.
1 parent dc2cf3e commit 7208ff4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

CMakeLists.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ FUNCTION(TARGET_OS_LIBRARIES target)
137137
ENDIF()
138138
ENDFUNCTION()
139139

140-
# For the MSVC IDE, this function splits up the source files like windows
141-
# explorer does. This is esp. useful with the libgit2_clar project, were
142-
# usually 2 or more files share the same name. Sadly, this file grouping
143-
# is a per-directory option in cmake and not per-target, resulting in
144-
# empty virtual folders "tests" for the git2.dll
145-
FUNCTION(MSVC_SPLIT_SOURCES target)
146-
IF(MSVC_IDE)
140+
# This function splits the sources files up into their appropriate
141+
# subdirectories. This is especially useful for IDEs like Xcode and
142+
# Visual Studio, so that you can navigate into the libgit2_clar project,
143+
# and see the folders within the tests folder (instead of just seeing all
144+
# source and tests in a single folder.)
145+
FUNCTION(IDE_SPLIT_SOURCES target)
146+
IF(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode)
147147
GET_TARGET_PROPERTY(sources ${target} SOURCES)
148148
FOREACH(source ${sources})
149149
IF(source MATCHES ".*/")
@@ -560,7 +560,7 @@ IF(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS)
560560
SET_TARGET_PROPERTIES(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64")
561561
ENDIF()
562562

563-
MSVC_SPLIT_SOURCES(git2)
563+
IDE_SPLIT_SOURCES(git2)
564564

565565
IF (SONAME)
566566
SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION ${LIBGIT2_VERSION_STRING})
@@ -629,7 +629,7 @@ IF (BUILD_CLAR)
629629
TARGET_LINK_LIBRARIES(libgit2_clar ${GSSAPI_LIBRARIES})
630630
TARGET_LINK_LIBRARIES(libgit2_clar ${ICONV_LIBRARIES})
631631
TARGET_OS_LIBRARIES(libgit2_clar)
632-
MSVC_SPLIT_SOURCES(libgit2_clar)
632+
IDE_SPLIT_SOURCES(libgit2_clar)
633633

634634
IF (MSVC_IDE)
635635
# Precompiled headers

0 commit comments

Comments
 (0)