MantisBT - CMake
View Issue Details
0013008CMakeCMakepublic2012-03-01 21:272016-06-10 14:31
David Coles 
Kitware Robot 
normalminoralways
closedmoved 
LinuxUbuntu12.04 (dev)
CMake 2.8.7 
 
0013008: CFLAGs set in toolchain file are overwritten
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 [^]
# 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 .
No tags attached.
Issue History
2012-03-01 21:27David ColesNew Issue
2012-08-11 21:09David ColeStatusnew => backlog
2012-08-11 21:09David ColeNote Added: 0030371
2016-06-10 14:28Kitware RobotNote Added: 0041995
2016-06-10 14:28Kitware RobotStatusbacklog => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0030371)
David Cole   
2012-08-11 21:09   
Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0041995)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.