summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorDarragh Coy <darragh.coy@ea.com>2024-10-01 16:23:23 (GMT)
committerBrad King <brad.king@kitware.com>2024-10-01 18:00:00 (GMT)
commit55831faf5ba43650dcab14fbb08b51890cbe954c (patch)
treeddfd6c4265004dd620a74ce1577ff0719741ce4c /Source
parentd0ad8fd49c2d211081d32cdc2a7f96990947c340 (diff)
downloadCMake-55831faf5ba43650dcab14fbb08b51890cbe954c.zip
CMake-55831faf5ba43650dcab14fbb08b51890cbe954c.tar.gz
CMake-55831faf5ba43650dcab14fbb08b51890cbe954c.tar.bz2
VS: Honor VS_TOOL_OVERRIDE for known source file types too
Visual Studio Generator: The `VS_TOOL_OVERRIDE` source file property would previously only be respected for file types that CMake didn't know how to build out of the box. This change allows the user to override how any source file is built with a custom build tool, even ones with standard/recognized extensions such as `.cxx`, `.idl`, etc. Fixes: #26336
Diffstat (limited to 'Source')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx125
1 files changed, 66 insertions, 59 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 1e338b2..694976e 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2544,66 +2544,73 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
}
const char* tool = nullptr;
- switch (si.Kind) {
- case cmGeneratorTarget::SourceKindAppManifest:
- tool = "AppxManifest";
- break;
- case cmGeneratorTarget::SourceKindCertificate:
- tool = "None";
- break;
- case cmGeneratorTarget::SourceKindCustomCommand:
- // Handled elsewhere.
- break;
- case cmGeneratorTarget::SourceKindExternalObject:
- tool = "Object";
- break;
- case cmGeneratorTarget::SourceKindExtra:
- this->WriteExtraSource(e1, si.Source, toolSettings);
- break;
- case cmGeneratorTarget::SourceKindHeader:
- this->WriteHeaderSource(e1, si.Source, toolSettings);
- break;
- case cmGeneratorTarget::SourceKindIDL:
- tool = "Midl";
- break;
- case cmGeneratorTarget::SourceKindManifest:
- // Handled elsewhere.
- break;
- case cmGeneratorTarget::SourceKindModuleDefinition:
- tool = "None";
- break;
- case cmGeneratorTarget::SourceKindCxxModuleSource:
- case cmGeneratorTarget::SourceKindUnityBatched:
- case cmGeneratorTarget::SourceKindObjectSource: {
- const std::string& lang = si.Source->GetLanguage();
- if (lang == "C"_s || lang == "CXX"_s) {
- tool = "ClCompile";
- } else if (lang == "ASM_MARMASM"_s &&
- this->GlobalGenerator->IsMarmasmEnabled()) {
- tool = "MARMASM";
- } else if (lang == "ASM_MASM"_s &&
- this->GlobalGenerator->IsMasmEnabled()) {
- tool = "MASM";
- } else if (lang == "ASM_NASM"_s &&
- this->GlobalGenerator->IsNasmEnabled()) {
- tool = "NASM";
- } else if (lang == "RC"_s) {
- tool = "ResourceCompile";
- } else if (lang == "CSharp"_s) {
- tool = "Compile";
- } else if (lang == "CUDA"_s &&
- this->GlobalGenerator->IsCudaEnabled()) {
- tool = "CudaCompile";
- } else {
+ const cmValue toolOverride = si.Source->GetProperty("VS_TOOL_OVERRIDE");
+
+ if (cmNonempty(toolOverride)) {
+ // Custom tool specified: the file will be built in a user-defined way
+ this->WriteExtraSource(e1, si.Source, toolSettings);
+ } else {
+ switch (si.Kind) {
+ case cmGeneratorTarget::SourceKindAppManifest:
+ tool = "AppxManifest";
+ break;
+ case cmGeneratorTarget::SourceKindCertificate:
tool = "None";
- }
- } break;
- case cmGeneratorTarget::SourceKindResx:
- this->ResxObjs.push_back(si.Source);
- break;
- case cmGeneratorTarget::SourceKindXaml:
- this->XamlObjs.push_back(si.Source);
- break;
+ break;
+ case cmGeneratorTarget::SourceKindCustomCommand:
+ // Handled elsewhere.
+ break;
+ case cmGeneratorTarget::SourceKindExternalObject:
+ tool = "Object";
+ break;
+ case cmGeneratorTarget::SourceKindExtra:
+ this->WriteExtraSource(e1, si.Source, toolSettings);
+ break;
+ case cmGeneratorTarget::SourceKindHeader:
+ this->WriteHeaderSource(e1, si.Source, toolSettings);
+ break;
+ case cmGeneratorTarget::SourceKindIDL:
+ tool = "Midl";
+ break;
+ case cmGeneratorTarget::SourceKindManifest:
+ // Handled elsewhere.
+ break;
+ case cmGeneratorTarget::SourceKindModuleDefinition:
+ tool = "None";
+ break;
+ case cmGeneratorTarget::SourceKindCxxModuleSource:
+ case cmGeneratorTarget::SourceKindUnityBatched:
+ case cmGeneratorTarget::SourceKindObjectSource: {
+ const std::string& lang = si.Source->GetLanguage();
+ if (lang == "C"_s || lang == "CXX"_s) {
+ tool = "ClCompile";
+ } else if (lang == "ASM_MARMASM"_s &&
+ this->GlobalGenerator->IsMarmasmEnabled()) {
+ tool = "MARMASM";
+ } else if (lang == "ASM_MASM"_s &&
+ this->GlobalGenerator->IsMasmEnabled()) {
+ tool = "MASM";
+ } else if (lang == "ASM_NASM"_s &&
+ this->GlobalGenerator->IsNasmEnabled()) {
+ tool = "NASM";
+ } else if (lang == "RC"_s) {
+ tool = "ResourceCompile";
+ } else if (lang == "CSharp"_s) {
+ tool = "Compile";
+ } else if (lang == "CUDA"_s &&
+ this->GlobalGenerator->IsCudaEnabled()) {
+ tool = "CudaCompile";
+ } else {
+ tool = "None";
+ }
+ } break;
+ case cmGeneratorTarget::SourceKindResx:
+ this->ResxObjs.push_back(si.Source);
+ break;
+ case cmGeneratorTarget::SourceKindXaml:
+ this->XamlObjs.push_back(si.Source);
+ break;
+ }
}
std::string config;