From: Modestas Vainius Subject: Support CPPFLAGS environment variable Bug: http://www.cmake.org/Bug/view.php?id=12928 Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=653916 Forwarded: no Last-Update: 2012-02-18 For now, append CPPFLAGS to CFLAGS and CXXFLAGS. In the perfect world, whenever C/C++ preprocessor is invoked, CPPFLAGS should be passed to it. --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -102,7 +102,7 @@ IF(NOT CMAKE_MODULE_EXISTS) SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}) ENDIF(NOT CMAKE_MODULE_EXISTS) -SET(CMAKE_C_FLAGS_INIT "$ENV{CFLAGS} ${CMAKE_C_FLAGS_INIT}") +SET(CMAKE_C_FLAGS_INIT "$ENV{CFLAGS} $ENV{CPPFLAGS} ${CMAKE_C_FLAGS_INIT}") # avoid just having a space as the initial value for the cache IF(CMAKE_C_FLAGS_INIT STREQUAL " ") SET(CMAKE_C_FLAGS_INIT) --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -183,7 +183,7 @@ ENDFOREACH(type) # on the initial values computed in the platform/*.cmake files # use _INIT variables so that this only happens the first time # and you can set these flags in the cmake cache -SET(CMAKE_CXX_FLAGS_INIT "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_INIT}") +SET(CMAKE_CXX_FLAGS_INIT "$ENV{CXXFLAGS} $ENV{CPPFLAGS} ${CMAKE_CXX_FLAGS_INIT}") # avoid just having a space as the initial value for the cache IF(CMAKE_CXX_FLAGS_INIT STREQUAL " ") SET(CMAKE_CXX_FLAGS_INIT)