The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=13008 
====================================================================== 
Reported By:                David Coles
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13008
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2012-03-01 21:27 EST
Last Modified:              2012-03-01 21:27 EST
====================================================================== 
Summary:                    CFLAGs set in toolchain file are overwritten
Description: 
It's possible to set common CMAKE variables in a toolchain file with the
assumption that they'll be used in external builds. This would be the ideal
location for toolchain specific compiler flags, but unfortunately these are
overwritten after the toolchain testing is complete.

A workaround[1] is to set the CFLAGS to the CMAKE Cache using something like
`SET(CMAKE_C_FLAGS "-Wall" CACHE STRING "Toolchain")` but this breaks the use of
CFLAGS environment variable.

[1] http://www.mail-archive.com/cmake@cmake.org/msg40214.html

Steps to Reproduce: 
# Toolchain.cmake
# ===============
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)

set( CLANG True )

# Set the cross compiler
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)

set(CMAKE_C_FLAGS "-Wextra")
#set(CMAKE_C_FLAGS "-Wextra" CACHE STRING "Toolchain")
set(MY_C_FLAGS "-Wextra")
MESSAGE(STATUS "Toolchain CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
MESSAGE(STATUS "Toolchain MY_C_FLAGS: ${MY_C_FLAGS}")



# CMakeLists.txt
# ==============
PROJECT (Test)
CMAKE_MINIMUM_REQUIRED (VERSION 2.8)

# Expect that toolchain variables are still set
MESSAGE (STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
MESSAGE (STATUS "MY_C_FLAGS: ${MY_C_FLAGS}")


# Command Line
# ============
$ rm CMakeCache.txt; cmake -DCMAKE_TOOLCHAIN_FILE=Toolchain.cmake .
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-03-01 21:27 David Coles    New Issue                                    
======================================================================

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to