Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

MSBUILD: setting property for separate files

$
0
0

Hi,

Our extension provides our own platform toolset for our C++ compiler which is based upon VC++ toolsets (v100). Target file from this toolset sets preprocessor define (__MYCOMPILER) via property PreprocessorDefinitions:

<ItemDefinitionGroup>
    <ClCompile>
        <PreprocessorDefinitions Condition="'%(ClCompile.UseMSVC)'!='true'">__MYCOMPILER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
  </ItemDefinitionGroup>

Here is the example of the source code (in c++ file added to the project):

#ifdef __MYCOMPILER
#include "my/mycompiler.h"
#endif

int main() {

}


UseMSVC is a C++ compiler property accessible in project properties dialog. It's available for both project and source file levels. So, when UseMSVC is set to false (that means use our own compiler for compiling sources) on the project level, everything works fine:

Intellicense recognizes preprocessor definitions of __MYCOMPILER and marks preprocessor blocks active and code (specific for our compiler) inside the blocks is compiled successfully.

When UseMSVC is set to true (VC++ is used), everything works fine again - preprocessor block are inactive.

The problem occurs when I set UseMSVC to true for file configuration rather than project configuration. In this case, preprocessor is still active because preprocessor definition is set on project level and inherited for file configurations.

How to provide preprocessor definitions for separate files that follow the condition - UseMSVC == false?

Thanks, Vadim.


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>