[Cmake] CMAKE_C/CXX_FLAGS and CMakeCache

Nils H. Busch nilsb at cns.mpg.de
Mon Mar 31 12:32:09 EST 2003


Hi,

I am trying to set CMAKE_C/CXX_FLAGS with some compiler specific flags.
I have written a cmake module for this much like the
Modules/Platform/IRIX.cmake and the CMakeBackwardCompatibilityCXX.cmake
module.
However, my settings are not transported into the CMakeCache file for my
project and thus the compilation does not work as expected.
Looking at the above modules, I see that this is not the case for the
settings computed there either. They get, however, written to the actual
Makefile.
I can only customize my build for a specific platform/compiler by
setting them manually during the cmake configure step.
Now, I am a bit confused, as to why
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}") works
for the Makefile, but does not appear in CMakeCache,  and
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_FLAGS}")  does not work in
either case.

How/when are those variables written to the cache and/or how do they get
used in Makefile, even when those variables seem to be empty in the
CMakeCache file ?

What is the correct approach for providing those default values to the
configure step ?

I am working on Irix with CC compiler and CMake 1.6.5.

I have attached the cmake module in question, but tend to believe I
haven't understood a more basic mechanism of how cmake works .

Any explanations greatly appreciated.

# Select ABI style and object model for IRIX
#
IF (CMAKE_SYSTEM_NAME MATCHES "IRIX.*")

  IF (CMAKE_SYSTEM_NAME MATCHES ".*64.*")
    SET(64_ABI_STYLE_CONF ON)
  ELSE (CMAKE_SYSTEM_NAME MATCHES ".*64.*")
    SET(64_ABI_STYLE_CONF OFF)
  ENDIF (CMAKE_SYSTEM_NAME MATCHES ".*64.*")

  SET(64_ABI_STYLE ${64_ABI_STYLE_CONF} CACHE BOOL "ABI and Object model
is 64 bit (IRIX only)")
  MARK_AS_ADVANCED(64_ABI_STYLE)

  IF(NOT CMAKE_COMPILER_IS_GNUCXX)
    IF (64_ABI_STYLE)
      SET (CMAKE_C_ABI_FLAGS "-mips4 -64")
      SET (CMAKE_CXX_ABI_FLAGS "-mips4 -64")
      SET (CMAKE_LINKER_ABI_FLAGS "-mips4 -64")
      SET (LIB_LOCATION "lib64" CACHE INTERNAL "Location of ABI specific
libraries")
    ELSE (64_ABI_STYLE)
      SET (CMAKE_C_ABI_FLAGS "-mips4 -n32")
      SET (CMAKE_CXX_ABI_FLAGS "-mips4 -n32")
      SET (CMAKE_LINKER_ABI_FLAGS "-mips4 -n32")
      SET (LIB_LOCATION "lib32" CACHE INTERNAL "Location of ABI specific
libraries")
    ENDIF (64_ABI_STYLE)
    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_ABI_FLAGS}")
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_ABI_FLAGS}")
    SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}
${CMAKE_LINKER_ABI_FLAGS}")

  ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)

  SET (CMAKE_SHLIB_BUILD_FLAGS "-set_version sgi1.0")
  SET (CMAKE_MODULE_BUILD_FLAGS "-set_version sgi1.0")

ELSE (CMAKE_SYSTEM_NAME MATCHES "IRIX.*")
  SET (LIB_LOCATION "lib" CACHE INTERNAL "Location of ABI specific
libraries")
ENDIF (CMAKE_SYSTEM_NAME MATCHES "IRIX.*")

--
    Nils H. Busch
    Max-Planck-Institute of Cognitive Neuroscience
    phone:  ++49 (341) 9940-035 fax:  ++49 (341) 9940-204
    e-mail: nilsb at cns.mpg.de






More information about the CMake mailing list