Property Sheets

반응형
http://msdn.microsoft.com/en-us/library/a4xbdz1e(VS.80).aspx
Visual C++ Concepts: Creating and Managing Projects 
Property Sheets (C++) 

A project property sheet is an .xml file with the extension .vsprops. It enables you to specify switches for build tools such as the compiler or linker and create user-defined macros.

You can use property sheets to create project configurations that can be applied to multiple projects since project settings that are defined in .vsprops files are inheritable, unlike project settings defined in Project Files (.vcproj files). Therefore, a project configuration defined in a .vcproj file can inherit project settings from one or more property sheets (.vsprops files). For more information, see Property Inheritance.

For information on tasks that demonstrate this concept, see:

Example

The following .vsprops file contains both build tool properties and user-defined macros.

<?xml version="1.0" ?>
<VisualStudioPropertySheet ProjectType="Visual C++" Version="8.00"
   Name="Visual C++ Project Properties" OutputDirectory="$(VCPACKAGES)"
   UseMFC="FALSE" UseATL="FALSE">

      <Tool Name="VCCLCompilerTool" UsePrecompiledHeader="3"
         ForcedIncludeFiles="warning.h" /> 
      <Tool Name="VCMIDLTool" />
      <Tool Name="VCResourceCompilerTool" /> 
      <Tool Name="VCLinkerTool" OptimizeForWindows98="1" />

      <UserMacro Name="VCROOT" Value="$(DDROOT)\vc" /> 
      <UserMacro Name="VCPROJDEFAULTS"
         Value="$(BINDIR)\VC8\VCProjectDefaults" /> 
      <UserMacro Name="VCPACKAGES" Value="$(BINDIR)\VC8\VCPackages" />
      <UserMacro Name="INCLUDEPATH" Value="$(VCROOT)\Inc"
         InheritsFromParent="TRUE" Delimiter=";" />

</VisualStudioPropertySheet>

Use the XSD Schema for Property Sheets to validate your own .vsprops files.


http://naiades.tistory.com/79

Visual C++을 사용하다 보면 환경 변수에 대한 설정을 하고싶을 때가 있습니다. 그럴때 편하게 사용할 수 있는 방법이 macro를 이용하는거죠.

Name에 보이는 항목들을 $(Name) 형태로 사용하게 되면 Value의 값으로 치환되어 실행이 되게 됩니다. 가장 많이 쓰이는 부분이 Linker -> Output File의 경로설정과 헤더 파일과 라이브러리 파일의 경로 설정입니다.

프로젝트를 진행하다 보면 이런 macro를 추가해서 환경 구성을 파고 싶은 경우가 있습니다. 제가 알고 있기로는 macro를 추가하는 방법이 2가지가 있습니다.

첫번째 방법은 환경 변수를 이용하는 방법입니다. 내 컴퓨터 -> 고급 탭 -> 환경 변수에 가면 변수와 값으로 표기되어 있는 부분이 macro에서 Name과 Value에 해당되게 됩니다.
Visual C++에서 $(OS)라고 사용하면 Windows_NT로 치환되어 동작되게 됩니다. 문제는 하나의 프로젝를 위해 이런 OS 환경 변수에 등록하는건 상황이 부적절 하다는 거죠. 프로젝트가 늘어 날수록 환경 변수도 늘어난다는건 말이 안되잖아요.

두번째 방법은 Visual Studio Property Sheet를 이용하는겁니다. 추가 방법은 다음과 같습니다.
메인 메뉴 View -> Property Manager 를 클릭하면 IDE의 왼쪽 메뉴에 창이 추가 됩니다.

이 창에서 Add New Project Property Sheet를 지정하고 이름을 지정해주면 완료 됩니다. 프로젝트 이름에서 추가를 하면 Debug, Release에 모두다 적용이 되지만 Debug나 Release에서 Property Sheet를 생성하면 해당하는 Configuration에서만 macro가 동작을 하니까 주의하시기 바랍니다.
추가된 Property Sheet를 더블클릭 하시고 메뉴를 User Macros에 가시면 새로운 macro를 추가 할 수 있는 UI가 나타납니다. 이렇게 구성을 하면 프로젝트의 설정 환경을 깔끔하게 정리 할 수 있습니다.

개발 환경을 구성 할 때마다 빌드 환경같은 귀찮은 설정 작업을 해줘야 되는 불편함을 많이 줄일수 있습니다. 작은 프로젝트에서는 그다지 쓸모가 없지만 큰 프로젝트에서는 유용하게 사용될때가 있으니 알아 두시면 좋을것 같습니다. (참고로 추가된 Property Sheet는 확장자가 .props로 추가 되며 XML로 되어 있기 때문에 메모장을 열어서 직접 편집도 가능합니다.)

주의 : 이 기능은 Visual Studio 2005 이상 부터 사용 가능합니다. Visual Studio 2003은 Property Sheet를 지원하지 않습니다.
TAGS.

Comments