View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014857CMakeCMakepublic2014-04-01 10:152015-11-02 09:13
ReporterStephen Kelly 
Assigned ToStephen Kelly 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in VersionCMake 3.3 
Summary0014857: Allow COMPILE_OPTIONS to vary by source file language
Description
Compile options like -fno-exceptions should be added for CXX files, but not for C files.

 http://thread.gmane.org/gmane.comp.kde.devel.frameworks/9222/focus=8215 [^]

 http://thread.gmane.org/gmane.comp.compilers.llvm.cvs/173869 [^]

Some methods like cmLocalGenerator::GetIncludeDirectories have a language in their API, but that is a linker language, not a source file language.

Making build properties vary by source file language is probably a large refactoring task of the existing generators.
TagsNo tags attached.
Attached Files

 Relationships
related to 0002086closedBill Hoffman Visual stuido sends c++ flags to c code 
has duplicate 0015365closed Allow per-language COMPILE_OPTIONS via generator expression 

  Notes
(0037107)
Edward Rudd (reporter)
2014-10-29 21:03

This can be made easier in modern cmake with generator expressions.. That is once a $<COMPILER_LANG:lang> type generator expression is added.. As it would be awesome to do something like this

$<$<AND:$<COMPILER_LANG:C++>,$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNUC>>>:-std=c++11>

OR better yet.. for the target_compile_options just use the fact that the language is known and fail any $<CXX_COMPILER_ID:comp> generator expressions for C or Obj-C code. (but not C++ and Obj-C++).
(0037797)
Brad King (manager)
2015-01-23 15:09

Some relevant comments appear in 0015365:0037777 and 0015365:0037778.
(0037798)
Brad King (manager)
2015-01-23 15:11

Re 0014857:0037107: Yes, but the description of the issue explains that adding $<COMPILER_LANG:...> (or whatever name is chosen) and allowing it to work in expected contexts will require some internal API refactoring to thread the "lang" parameter through necessary call stacks.
(0037912)
Sebastian Sauer (reporter)
2015-02-04 15:27
edited on: 2015-02-04 15:30

Related: http://public.kitware.com/pipermail/cmake-developers/2013-May/007210.html [^]

$<$<COMPILE_LANGUAGE:C>:C_ONLY>
$<$<COMPILE_LANGUAGE:CXX>:CXX_ONLY>
$<$<LINK_LANGUAGE:CXX>:LINK_AS_CXX>

A typical use-case, which I just run into and had/have a hard time to workaround, is Makefile code doing this on a library-target that has *.c and *.cpp files:
CFLAGS += -include c_config.h
CXXFLAGS += -include cpp_config.h

(0038035)
Stephen Kelly (developer)
2015-02-23 15:43

Discussion thread on the mailing list here:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/12488 [^]
(0038204)
Stephen Kelly (developer)
2015-03-11 15:52

Done:

 http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5c559f11 [^]
 Genex: Enable use of COMPILE_LANGUAGE for compile options.
(0039730)
Robert Maynard (manager)
2015-11-02 09:13

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2014-04-01 10:15 Stephen Kelly New Issue
2014-10-29 21:03 Edward Rudd Note Added: 0037107
2015-01-22 17:04 Stephen Kelly Relationship added has duplicate 0015365
2015-01-23 15:09 Brad King Note Added: 0037797
2015-01-23 15:11 Brad King Note Added: 0037798
2015-02-04 15:27 Sebastian Sauer Note Added: 0037912
2015-02-04 15:30 Sebastian Sauer Note Edited: 0037912
2015-02-23 15:43 Stephen Kelly Note Added: 0038035
2015-02-26 03:39 Stephen Kelly Relationship added related to 0002086
2015-03-11 15:52 Stephen Kelly Note Added: 0038204
2015-03-11 15:52 Stephen Kelly Status new => resolved
2015-03-11 15:52 Stephen Kelly Fixed in Version => CMake 3.3
2015-03-11 15:52 Stephen Kelly Resolution open => fixed
2015-03-11 15:52 Stephen Kelly Assigned To => Stephen Kelly
2015-11-02 09:13 Robert Maynard Note Added: 0039730
2015-11-02 09:13 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team