[CMake] Overriding intel default compiler flags

pellegrini pellegrini at ill.fr
Wed Sep 29 12:16:55 EDT 2010


Hello everybody,

I come back with a question I asked yesterday but that I surely 
misformulated. In the meantime I turned around
the problem all the day but still without any results ...

I would like to build my project using ifort fortran compiler with a set 
of compiler flags different from the
ones set by default by cmake in the "Windows-ifort.cmake" file of the 
distribution.

I was advised on the list to not introduce any specific compiler flags 
declaration in my CMakeLists.txt and to
introduce in my Src directory a Compiler/Intel-Fortran.cmake file 
storing the following compiler flags I would like to be
the default ones:

    SET(CMAKE_BUILD_TYPE_INIT Release)
    SET(CMAKE_Fortran_FLAGS_INIT "")
    SET(CMAKE_Fortran_FLAGS_DEBUG_INIT "/debug:full /check /traceback 
/nologo")
    SET(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "/O2 /nologo /Qvec-report0")
    SET(CMAKE_Fortran_FLAGS_RELEASE_INIT "/O2 /nologo /Qvec-report0")
    SET(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "/O2 /nologo /traceback 
/debug:full")

 Now my CMakeLists.txt file starts with:

cmake_minimum_required(VERSION 2.6.2)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
project(my_library Fortran)

Problem:
in doing so, cmake actually parses my Intel-Fortran.cmake file but all 
the variables stored in there are subsequently replaced by the
values stored in "Windows-ifort.cmake" during the "project" call. This 
does not happen when using the G95 to build my project because none
of these variables are set in the Windows-G95-Fortran.cmake file (and 
its dependancies).

Is that a known bug for intel fortran compiler ? Would you see any 
work-around or should I introduce in the CMakeLists a conditional for intel
compiler breaking in that special case one of the cmake programming 
rules ? !

thanks for your help

Eric



-- 
Eric Pellegrini
Calcul Scientifique
Insitut Laue-Langevin
Grenoble, France



More information about the CMake mailing list