Notes |
|
(0037776)
|
Paul Smith
|
2015-01-22 11:16
|
|
|
|
(0037777)
|
Brad King
|
2015-01-22 11:37
|
|
The COMPILE_OPTIONS property and target_compile_options command I think are the right place to add per-language support, but it is likely best done using generator expressions. I've updated the issue subject line accordingly
The cmLocalGenerator::AddCompileOptions method:
http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmLocalGenerator.cxx;hb=v3.1.0#l1439 [^]
which generators call to collect the per-target flags does have a "lang" parameter. However, it is not passed on to cmTarget::GetCompileOptions which would be needed to support a language-check generator expression.
|
|
|
(0037778)
|
Brad King
|
2015-01-22 11:39
|
|
Re 0015365:0037777: With updates starting there it should be possible to implement a language-check generator expression. Perhaps something like:
target_compile_options(MyTarget PRIVATE
$<$<LANG:C>:${MY_C_FLAGS}>
$<$<LANG:CXX>:${MY_CXX_FLAGS}>
) |
|
|
(0037779)
|
Kevin Wojniak
|
2015-01-22 11:39
|
|
GCC will generate errors and/or warnings for C++ flags on C files.
For example this file (test.cpp and test.c contents don't matter):
cmake_minimum_required(VERSION 3.1)
project(demo)
add_executable(demo test.cpp test.c)
target_compile_options(demo PRIVATE -Woverloaded-virtual -Werror -std=c++11)
on GCC 4.8.2 will generate:
cc1: warning: command line option ‘-Woverloaded-virtual’ is valid for C++/ObjC++ but not for C [enabled by default]
cc1: error: command line option ‘-std=c++11’ is valid for C++/ObjC++ but not for C [-Werror] |
|
|
(0037780)
|
Kevin Wojniak
|
2015-01-22 11:49
|
|
Brad, that would be perfect! |
|
|
(0037796)
|
Brad King
|
2015-01-23 15:08
|
|
|
|
(0039033)
|
Robert Maynard
|
2015-07-08 08:57
|
|
Closing resolved issues that have not been updated in more than 4 months. |
|