mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 23:28:32 -05:00
MSVC: Recognize -XYZ as well as /XYZ when parsing MS tool command lines
Fixes: #23772
This commit is contained in:
@@ -3148,12 +3148,14 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if ASan is enabled.
|
// Check if ASan is enabled.
|
||||||
if (flags.find("/fsanitize=address") != std::string::npos) {
|
if (flags.find("/fsanitize=address") != std::string::npos ||
|
||||||
|
flags.find("-fsanitize=address") != std::string::npos) {
|
||||||
this->ASanEnabledConfigurations.insert(configName);
|
this->ASanEnabledConfigurations.insert(configName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if (lib)Fuzzer is enabled.
|
// Check if (lib)Fuzzer is enabled.
|
||||||
if (flags.find("/fsanitize=fuzzer") != std::string::npos) {
|
if (flags.find("/fsanitize=fuzzer") != std::string::npos ||
|
||||||
|
flags.find("-fsanitize=fuzzer") != std::string::npos) {
|
||||||
this->FuzzerEnabledConfigurations.insert(configName);
|
this->FuzzerEnabledConfigurations.insert(configName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3198,7 +3200,9 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
|||||||
// anymore, because cmGeneratorTarget may not be aware that the
|
// anymore, because cmGeneratorTarget may not be aware that the
|
||||||
// target uses C++/CLI.
|
// target uses C++/CLI.
|
||||||
if (flags.find("/clr") != std::string::npos ||
|
if (flags.find("/clr") != std::string::npos ||
|
||||||
defineFlags.find("/clr") != std::string::npos) {
|
flags.find("-clr") != std::string::npos ||
|
||||||
|
defineFlags.find("/clr") != std::string::npos ||
|
||||||
|
defineFlags.find("-clr") != std::string::npos) {
|
||||||
if (configName == this->Configurations[0]) {
|
if (configName == this->Configurations[0]) {
|
||||||
std::string message = "For the target \"" +
|
std::string message = "For the target \"" +
|
||||||
this->GeneratorTarget->GetName() +
|
this->GeneratorTarget->GetName() +
|
||||||
|
|||||||
@@ -273,6 +273,7 @@ int main()
|
|||||||
std::string clrest = rest;
|
std::string clrest = rest;
|
||||||
// rc: /fo x.dir\x.rc.res -> cl: /out:x.dir\x.rc.res.dep.obj
|
// rc: /fo x.dir\x.rc.res -> cl: /out:x.dir\x.rc.res.dep.obj
|
||||||
clrest = replace(clrest, "/fo ", "/out:");
|
clrest = replace(clrest, "/fo ", "/out:");
|
||||||
|
clrest = replace(clrest, "-fo ", "-out:");
|
||||||
clrest = replace(clrest, objfile, objfile + ".dep.obj ");
|
clrest = replace(clrest, objfile, objfile + ".dep.obj ");
|
||||||
|
|
||||||
cl = "\"" + cl + "\" /P /DRC_INVOKED /TC ";
|
cl = "\"" + cl + "\" /P /DRC_INVOKED /TC ";
|
||||||
|
|||||||
+9
-4
@@ -2242,13 +2242,18 @@ bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg,
|
|||||||
// Parse the link command to extract information we need.
|
// Parse the link command to extract information we need.
|
||||||
for (; arg != argEnd; ++arg) {
|
for (; arg != argEnd; ++arg) {
|
||||||
if (cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL:YES") == 0 ||
|
if (cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL:YES") == 0 ||
|
||||||
cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL") == 0) {
|
cmSystemTools::Strucmp(arg->c_str(), "-INCREMENTAL:YES") == 0 ||
|
||||||
|
cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL") == 0 ||
|
||||||
|
cmSystemTools::Strucmp(arg->c_str(), "-INCREMENTAL") == 0) {
|
||||||
this->Incremental = true;
|
this->Incremental = true;
|
||||||
} else if (cmSystemTools::Strucmp(arg->c_str(), "/MANIFEST:NO") == 0) {
|
} else if (cmSystemTools::Strucmp(arg->c_str(), "/MANIFEST:NO") == 0 ||
|
||||||
|
cmSystemTools::Strucmp(arg->c_str(), "-MANIFEST:NO") == 0) {
|
||||||
this->LinkGeneratesManifest = false;
|
this->LinkGeneratesManifest = false;
|
||||||
} else if (cmHasLiteralPrefix(*arg, "/Fe")) {
|
} else if (cmHasLiteralPrefix(*arg, "/Fe") ||
|
||||||
|
cmHasLiteralPrefix(*arg, "-Fe")) {
|
||||||
this->TargetFile = arg->substr(3);
|
this->TargetFile = arg->substr(3);
|
||||||
} else if (cmHasLiteralPrefix(*arg, "/out:")) {
|
} else if (cmHasLiteralPrefix(*arg, "/out:") ||
|
||||||
|
cmHasLiteralPrefix(*arg, "-out:")) {
|
||||||
this->TargetFile = arg->substr(5);
|
this->TargetFile = arg->substr(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ if(MSVC)
|
|||||||
"CMAKE_CXX_FLAGS_${CONFIG}"
|
"CMAKE_CXX_FLAGS_${CONFIG}"
|
||||||
"${CMAKE_CXX_FLAGS_${CONFIG}}"
|
"${CMAKE_CXX_FLAGS_${CONFIG}}"
|
||||||
)
|
)
|
||||||
|
string(REPLACE "-MD" "-MT"
|
||||||
|
"CMAKE_CXX_FLAGS_${CONFIG}"
|
||||||
|
"${CMAKE_CXX_FLAGS_${CONFIG}}"
|
||||||
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1465,6 +1465,8 @@ if(MSVC)
|
|||||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
|
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
|
||||||
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
|
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
|
||||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||||
|
elseif(CMAKE_C_FLAGS MATCHES "-W[0-4]")
|
||||||
|
string(REGEX REPLACE "-W[0-4]" "-W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
Reference in New Issue
Block a user