Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28517 Discussions

Help with Visual Studio Post-Build conditional commands

Leigh_Wardle1
Beginner
602 Views

Hi all,

 

I have Intel Fortran code that uses the fpp pre-processor.

 

In my code, I am using conditional compilation with pre-processor constructs like:

#if conApplicationName==1

....

#endif

I want to use similar logic in the Visual Studio Post-Build commands.

 

I have had success with a VB.NET project, using a Preprocessor Definition:

conVB6ApplicationName="HIPAVE"

 

Then, the Post-Build command:

if "$(DefineConstants.Contains('HIPAVE'))" == "True" copy "$(TargetPath)" "$(TargetDir)HIPAVE Launcher\HIPAVE_Floating_Launcher.exe" /Y

worked.

 

But now my Project is Intel Fortran.

 

Again, my Preprocessor Definition:

conVB6ApplicationName="HIPAVE"

 

But now, I get this warning:

 

1>Project : warning PRJ0018 : The following environment variables were not found:

1>$(DefineConstants.Contains('HIPAVE')

 

Is there some other property in a VS project where I can define conVB6ApplicationName="HIPAVE"?

 

Regards,

Leigh

0 Kudos
1 Reply
Leigh_Wardle1
Beginner
538 Views

Just for the record, I found a solution with help from chatGPT.

The build commands do not see the Intel Fortran preprocessor variables.

You need to set your variables in the build command.

Something like this works:

 

SET YourCustomVariable=APSDS

IF "%YourCustomVariable%" == "APSDS" (

  copy "$(TargetPath)" "$(TargetDir)APSDS_Deleteme.exe" /Y

)

 

Performing Post-Build Event...
SET YourCustomVariable=APSDS
IF "%YourCustomVariable%" == "APSDS" (
copy "C:\Users\Administrator\source\repos\Conditional Post-Build Test\Debug\Conditional Post-Build Test.exe" "C:\Users\Administrator\source\repos\Conditional Post-Build Test\Debug\APSDS_Deleteme.exe" /Y
)
1 file(s) copied.

 

0 Kudos
Reply