[CMake] Three problems with cmake under windows

Bill Hoffman bill.hoffman at kitware.com
Tue May 29 09:47:50 EDT 2007


lucatrv wrote:
> Hi, I use cmake under windows, with both gfortran (gnu fortran) and 
> ifort (intel fortran) compilers.
>
> I have found some problems that I would like to put at your attention.
>
> 1) the default intel fortran installation set two environment 
> variables FFLAGS and F90FLAGS, with the following value:
> /w /I:"C:\Programmi\VNI\CTT6.0\include\IA32" /fpe:3 /nologo.
> I found that cmake have problems when it tests if the ifort compiler 
> works. It seems to be a problem in the path format. In fact, a 
> possible solution is to remove the 
> /I:"C:\Programmi\VNI\CTT6.0\include\IA32" part from the variable. 
> Otherwise it is possible to use se folowing cmake command:
> FILE(TO_CMAKE_PATH $ENV{F90FLAGS} CMAKE_Fortran_FLAGS)
> However, in this case, the first time §I call cmake it still fails, 
> while the following times it works.
CMake does look at FFLAGS like it looks at CFLAGS.   What is the error 
that you get with the values set?
>
> 2) Since I have two fortran compilers installed, sometimes I chose to 
> use gfortran and sometimes ifort.
> However, If I use the following commands in this order:
> PROJECT (hello Fortran)
> SET (CMAKE_Fortran_COMPILER gfortran)
> cmake still tests ifort working when creating the makefile.
> The only whay to have cmake make use only of gfortran is to use the 
> commands in the following order:
> SET (CMAKE_Fortran_COMPILER gfortran)
> PROJECT (hello Fortran)
> I think it would be better that cmake set the right compiler also in 
> the first case, also because the required order is not specified in 
> the cmake documentation.
>
You can not set the compiler like that.   You have to set the 
environment variable FC before you run cmake.  There has been a request 
to add a way to do this from CMakeSetup, but it has not yet been 
implemented. 
> 3) When I build my project with ifort (which makes use of the 
> microsoft linker) at the EXECUTABLE_OUTPUT_PATH, i get a hello.ilk 
> file together with the hello.exe file (the ilk file is a Microsoft 
> Linker Database).
That is the default behavior of CMake with c/C++.   We do not separate 
the linker database from the executable.   You may want to look at the 
install commands and cpack if you want to create executables that are 
moved to a different machine, and only contain the stuff you need to run 
them.

-Bill



More information about the CMake mailing list