File: IdeSplitSources.cmake

package info (click to toggle)
libgit2 1.9.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 60,804 kB
  • sloc: ansic: 203,436; javascript: 2,458; sh: 1,763; python: 384; perl: 99; php: 65; makefile: 33
file content (22 lines) | stat: -rw-r--r-- 812 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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()