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 It has happened to me that Maybe enough, but close Not Sexy
#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; ;
property group & gt; defineConstants bet = "exists ('c: Temp \ foo.txt ') "& gt; $ (defined resource); THE_FILE_EXISTS & lt; / define resource & gt; & lt; / PropertyGroup & gt;
Comments
Post a Comment