mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-24 16:49:18 -06:00
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
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user