Changing Intel Fortran compiler option /fpconstant


I am new to CMake although I have been aware of its existence for several years.

I am trying to use CMake to build a static library project in Visual Studio Community 2015. I have to pass compiler flag /fpconstant. Here is how I have prepared my CMakeLists.txt:

cmake_minimum_required(VERSION 3.19.4 FATAL_ERROR)
set(ENV{FC} "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2016.2.180/windows/bin/ia32/ifort.exe")

project(plybck LANGUAGES Fortran)


add_library("${PROJECT_NAME}" STATIC plybckutils.f90)

However, after the project is built by CMake and I open the sln solution in Visual Studio, the flag has not changed (Fortran>Floating Point > Extend Precision of Single-Precision Constants).

I opened .vfproj in a text editor and verified that /fpconstant is in the string AdditionalOptions, so it seems like the add_compile_options is doing its job.

Then, I manually changed the flag in Visual Studio GUI to /fpconstant, and saved the project. I can see that ExtendSinglePrecisionConstants=“true” has been subsequently added to .vfproj which was not there before.

How can I change get CMake to do this change for me?

CMake uses some flag tables to map flags to .vcproj file properties. Not all flags are mapped though. Does it work with the way CMake generates the project as-is at least?

Cc: @brad.king

For reference, the Fortran flag table for VS is in the code here.

Thanks for the info @ben.boeckel and @brad.king
So yes CMake generates the Visual Studio project. Then I have to change a few flags (/fpconstant is one of them) as the main application for which I am building the static library uses certain compiler flags that affect code generation.
I went over the Fortran flag table. Maybe I can add a few flags to it and compile from source? I have never done this before and have no idea how challenging it can be!

Yes, try adding some flags and building from source. If you get it working, please see CONTRIBUTING.rst and open a merge request to add the entries.