CMake und TFS

Für die Bindings einer Visual Studio Solution mit dem TFS-Server werden folgende Einträge angelegt (Beispiele aus ImageTo3D).

Unter dem Abschnitt Global im Solution-File:

GlobalSection(TeamFoundationVersionControl) = preSolution
	SccNumberOfProjects = 3
	SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
	SccTeamFoundationServer = http://tfs-server.ntb.ch:8080/tfs/classcad
	SccProjectUniqueName0 = 3DReconstruction\\3DReconstruction.vcxproj
	SccProjectName0 = 3DReconstruction
	SccAuxPath0 = http://tfs-server.ntb.ch:8080/tfs/classcad
	SccLocalPath0 = 3DReconstruction
	SccProvider0 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
	SccProjectUniqueName1 = 3DRecConsole\\3DRecConsole.vcxproj
	SccProjectName1 = 3DRecConsole
	SccAuxPath1 = http://tfs-server.ntb.ch:8080/tfs/classcad
	SccLocalPath1 = 3DRecConsole
	SccProvider1 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
	SccProjectUniqueName2 = VanishingPointDetection\\VanishingPointDetection.vcxproj
	SccProjectName2 = VanishingPointDetection
	SccAuxPath2 = http://tfs-server.ntb.ch:8080/tfs/classcad
	SccLocalPath2 = VanishingPointDetection
	SccProvider2 = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
EndGlobalSection

Sowie im Projektfile unter der Propertygroup Globals:

<PropertyGroup Label="Globals">
	<ProjectGUID>{180ABFA3-1346-484E-8843-4E777FC7BFE9}</ProjectGUID>
	<Keyword>Win32Proj</Keyword>
	<Platform>Win32</Platform>
	<ProjectName>ImageTo3D</ProjectName>
	<SccProjectName>SAK</SccProjectName>
	<SccAuxPath>SAK</SccAuxPath>
	<SccLocalPath>SAK</SccLocalPath>
	<SccProvider>SAK</SccProvider>
</PropertyGroup>

Für jedes verbundene Projekt besteht ein Eintrag in der Solution mit den Angaben zur TFS-URL sowie dem Pfad innerhalb des Workspaces. Sobald das Projekt gebunden ist, stehen in den Scc* Einträgen des Projektes der Wert SAK für Should already know - soll heissen, dass die Einstellungen aus der Solution kommen.

CMake-Code in Unterprojekten:

# Define TFS Source Control project bindings
# SAK stands for should already know, as already done in the solution file
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
	VS_SCC_PROJECTNAME SAK
	VS_SCC_LOCALPATH SAK
	VS_SCC_PROVIDER SAK
	VS_SCC_AUXPATH SAK)

CMake-Code in Hauptprojekt (Variable PROJECTS muss vorher definiert werden):

SET(TFS_URL <tfs-url> CACHE STRING "Path to Team Foundation Server Team Project")
# Link to Team Foundation Servers
LIST(LENGTH PROJECTS NOF_PROJECTS)
LIST(APPEND TFS_GLOBAL_SECTION SccNumberOfProjects=${NOF_PROJECTS})
LIST(APPEND TFS_GLOBAL_SECTION SccEnterpriseProvider={4CA58AB2-18FA-4F8D-95D4-32DDF27D184C})
LIST(APPEND TFS_GLOBAL_SECTION SccTeamFoundationServer=${CLASSCAD_TFS_URL})
LIST(APPEND TFS_GLOBAL_SECTION SccEnterpriseProvider={4CA58AB2-18FA-4F8D-95D4-32DDF27D184C})
SET(project_index 0)
FOREACH(project ${PROJECTS})
	LIST(APPEND TFS_GLOBAL_SECTION SccProjectUniqueName${project_index}=${project}\\${project}.vcxproj)
	LIST(APPEND TFS_GLOBAL_SECTION SccProjectName${project_index}=${project})
	LIST(APPEND TFS_GLOBAL_SECTION SccAuxPath${project_index}=${CLASSCAD_TFS_URL})
	LIST(APPEND TFS_GLOBAL_SECTION SccLocalPath${project_index}=${project})
	LIST(APPEND TFS_GLOBAL_SECTION SccProvider${project_index}={4CA58AB2-18FA-4F8D-95D4-32DDF27D184C})
	MATH(EXPR project_index "${project_index} + 1")
ENDFOREACH(project)
set_property(DIRECTORY . PROPERTY VS_GLOBAL_SECTION_PRE_TeamFoundationVersionControl ${TFS_GLOBAL_SECTION})