View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0015365 | CMake | CMake | public | 2015-01-22 10:57 | 2015-07-08 08:57 | ||||
Reporter | Kevin Wojniak | ||||||||
Assigned To | |||||||||
Priority | normal | Severity | feature | Reproducibility | N/A | ||||
Status | closed | Resolution | duplicate | ||||||
Platform | OS | OS Version | |||||||
Product Version | CMake 3.1 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0015365: Allow per-language COMPILE_OPTIONS via generator expression | ||||||||
Description | CMake provides CMAKE_CXX_FLAGS, but this is global. It'd be good to have a per-target CXX flags ability. Possibly a macro such as target_compile_options_cxx() and target_compile_options_c(), or a way to do this with generator expressions (doesn't seem to have a LANG property for sources). | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | ||||||
|
Relationships |
Notes | |
(0037776) Paul Smith (reporter) 2015-01-22 11:16 |
I'm not sure exactly what you're looking for, but there are lots of properties that can be set via set_property() on a per-target, per-source file, etc. level including COMPILE_FLAGS and others: http://www.cmake.org/cmake/help/v3.0/manual/cmake-properties.7.html [^] Is there a specific thing you can't do? |
(0037777) Brad King (manager) 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 (manager) 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 (reporter) 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 (reporter) 2015-01-22 11:49 |
Brad, that would be perfect! |
(0037796) Brad King (manager) 2015-01-23 15:08 |
Resolving as duplicate of 0014857. |
(0039033) Robert Maynard (manager) 2015-07-08 08:57 |
Closing resolved issues that have not been updated in more than 4 months. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2015-01-22 10:57 | Kevin Wojniak | New Issue | |
2015-01-22 11:16 | Paul Smith | Note Added: 0037776 | |
2015-01-22 11:37 | Brad King | Note Added: 0037777 | |
2015-01-22 11:37 | Brad King | Status | new => acknowledged |
2015-01-22 11:37 | Brad King | Summary | Provide per-target CXX/C flags => Allow per-language COMPILE_OPTIONS via generator expression |
2015-01-22 11:39 | Brad King | Note Added: 0037778 | |
2015-01-22 11:39 | Kevin Wojniak | Note Added: 0037779 | |
2015-01-22 11:49 | Kevin Wojniak | Note Added: 0037780 | |
2015-01-22 17:04 | Stephen Kelly | Relationship added | duplicate of 0014857 |
2015-01-23 15:08 | Brad King | Note Added: 0037796 | |
2015-01-23 15:08 | Brad King | Status | acknowledged => resolved |
2015-01-23 15:08 | Brad King | Resolution | open => duplicate |
2015-07-08 08:57 | Robert Maynard | Note Added: 0039033 | |
2015-07-08 08:57 | Robert Maynard | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |