c++ - Conditionals in Visual Studio 2010 Project files -


In a Visual Studio 2010 C ++ project file, it is possible conditionally, to determine the presence of a library And to change the preprocessor, the flags, etc. are appropriately

, say that we have a directory C: \ libraries \ MKL , I want Add another mkl_dll.lib to the #define MKL and an additional dependency if that directory exists.

Many solutions have been used to achieve this goal first, but it is difficult to maintain. The following, when an F # paste in the bottom of the project, has the recommended effect (if

> C: \ temporary \ foo.txt is present, then #define is added to THE_FILE_EXISTS ). I hope that only a slight modification will be required for the C ++ project, because they both use MSBuild. It's a little hacky probably the first thing I've been doing,

  . & Lt; UsingTask TaskName = "SeeIfFileExists" TaskFactory = "CodeTaskFactory" AssemblyFile = "$ (MSBuildToolsPath) \ Microsoft.Build .Tasks.v4.0.dll" & gt; & Lt; ParameterGroup & gt; & Lt; Path parameter type = "System.String" required = "true" /> & Lt; ItExists parameter type = "System.Boolean" output = "true" /> & Lt; / ParameterGroup & gt; & Lt; Tasks & gt; & Lt; Code type = "piece" language = "cs" & gt; & Lt ;! [Cdata [itxists = system.io.file. Axis (path); ]] & Gt; & Lt; / Code & gt; & Lt; / Tasks & gt; & Lt; / UsingTask & gt; & Lt; Goal name = "SeeIfFileExistsTarget" before Targets = "PrepareFilbuild" & gt; & Lt; SeeIfFileExists path = "c: \ temp \ foo.txt" & gt; & Lt; Output Task parameter = "This axis" item name = "The file axis" /> & Lt; / SeeIfFileExists & gt; & Lt; PropertyGroup & gt; & Lt; DefineConstants status = "'@ (TheFileExists)' == 'This is true'"> $ (DefineConstants); THE_FILE_EXISTS  << PropertyGroup & gt; & lt; / target & gt; ;  

It has happened to me that

  property group & gt; defineConstants bet = "exists ('c: Temp \ foo.txt ') "& gt; $ (defined resource); THE_FILE_EXISTS & lt; / define resource & gt; & lt; / PropertyGroup & gt;  

Maybe enough, but close Not Sexy


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -