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

Setting the compiler version as a project setting

Andrew_Smith
Valued Contributor I
4,177 Views

Has anyone figured out how to control which version number of the IFX compiler is used when compiling in Visual studio. I know about the Tools/Options, but that is a global setting. I need to make sure that when maintaining old code, it does not switch to the latest compiler, but new code does use the latest compiler. The global setting affects compiling all projects which is not a useful feature.

I see there is a pre-build step, can we use this to set an appropriate environment variable?

0 Kudos
6 Replies
andrew_4619
Honored Contributor III
4,011 Views
That would be a useful feature, I did some investigation and this far have found nothing useful.
garraleta_fortran
3,718 Views

USE ISO_FORTRAN_ENV
CHARACTER(LEN=256) :: VERSION
VERSION=COMPILER_VERSION( )
WRITE(*,*)TRIM(VERSION)
END

0 Kudos
andrew_4619
Honored Contributor III
3,665 Views

That tells you what version you used the request is to SET the version to be used from those installed for specific projects in a solution.

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
2,978 Views

This is something you can try. I haven't experimented with this.

Separate the IFX version dependent code (libraries) into different Solutions (not Projects).

For each, add a pre-build event that performs the setvars.bat of the desired IFX version

 

Note, I have not tested this to see if the environment variables from the pre-build event are used by the solution build.

This is something you might be able to do.

 

Note, the pre-build event is for Solution build, not a per-project build.

 

Another hack that might work in a single solution (you will have to try this).

Have each project dependent on the output of something that performs the intended setvars for the project.

IIF the setvars are sticky (persists) this may work

This will require that the solution pre-build event deletes these dependencies.

Also, you may need to disable multi-process compilation.

EDIT:

You can also create two batch files:

: batch to build using old version
call setenvold.bat
devenv YourOldIFXSolution.sln

The other is similar using different file names.

Place shortcuts on your desktop to these batch files.

Modify the shortcuts to specify an appropriate start in location

Jim Dempsey

0 Kudos
Steve_Lionel
Honored Contributor III
2,650 Views

Unfortunately, compiler version selection is not a project or solution property.  Jim's suggestion of using a batch file to establish the desired version is good - you must then use "devenv /useenv" to start Visual Studio with the designated environment.

0 Kudos
jimdempseyatthecove
Honored Contributor III
2,512 Views

Thanks Steve for mentioning the /useenv, I missed that.

 

Jim

0 Kudos
Reply