[CMake] Setting CMake Flags

Chris Wood c.c.wood at gmail.com
Wed Aug 7 14:13:11 EDT 2013


It appears that setting CMAKE_Fortran_FLAGS doesn't work unless you
give it a different cache string name.  For example, if I have a
CMakeLists.txt just containing the following:

project(Fortran)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-libgfortran")

and run cmake, the resulting line in CMakeCache.txt reads:

//Flags for Fortran compiler
CMAKE_Fortran_FLAGS:STRING=

However, changing the flag setting command to:

set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-libgfortran"
CACHE STRING "fortran flags" FORCE)

results in

//fortran flags
CMAKE_Fortran_FLAGS:STRING= -static-libgfortran

I get the same results whether I include ${CMAKE_Fortran_FLAGS} or
not.  Is the CACHE STRING property really necessary, or am I missing
something else?

Cheers,
Chris


More information about the CMake mailing list