diff options
author | Brad King <brad.king@kitware.com> | 2018-01-11 16:23:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-01-12 19:27:37 (GMT) |
commit | c2f79c98677d43fb8686f9e4309acddfae8f3dfd (patch) | |
tree | 9c4cd2e7ece8bfd90aa13a23c4caa154ce95a1e4 /Source/cmLocalVisualStudio7Generator.cxx | |
parent | 0795d25b78d5b7682aea091d260eaf1bca7afd0a (diff) | |
download | CMake-c2f79c98677d43fb8686f9e4309acddfae8f3dfd.zip CMake-c2f79c98677d43fb8686f9e4309acddfae8f3dfd.tar.gz CMake-c2f79c98677d43fb8686f9e4309acddfae8f3dfd.tar.bz2 |
Genex: Enable COMPILE_LANGUAGE for COMPILE_DEFINITIONS with VS and Xcode
The set of compile flags used for a target's C and C++ sources is based
on the linker language. By default this is always the C++ flags if any
C++ sources appear in the target, and otherwise the C flags. Therefore
we can define the `COMPILE_LANGUAGE` generator expression in
`COMPILE_DEFINITIONS` to match the selected language.
This is not exactly the same as for other generators, but is the best VS
and Xcode can do. It is also sufficient for many use cases since the
set of definitions for C and C++ is frequently similar but may be
distinct from those for other languages like CUDA.
Issue: #17435
Diffstat (limited to 'Source/cmLocalVisualStudio7Generator.cxx')
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 4cc6e3c..003163e 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -705,7 +705,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); std::vector<std::string> targetDefines; - target->GetCompileDefinitions(targetDefines, configName, "CXX"); + if (!langForClCompile.empty()) { + target->GetCompileDefinitions(targetDefines, configName, langForClCompile); + } targetOptions.AddDefines(targetDefines); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); @@ -812,7 +814,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( } fout << "\"\n"; targetOptions.OutputFlagMap(fout, "\t\t\t\t"); - targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX"); + targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", + langForClCompile); fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"; if (target->GetType() <= cmStateEnums::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. |