summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2022-12-08 13:52:56 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2022-12-13 15:54:56 (GMT)
commit7480fa0a5fd0ebc3fe06c702f3368e06a50c10ab (patch)
tree1b2e7a5a5a2a6297a763385535c233817f53d5e8 /Source/cmGlobalXCodeGenerator.cxx
parentff875ed8591afdb87055b8e43b1fcd04438a4d1e (diff)
downloadCMake-7480fa0a5fd0ebc3fe06c702f3368e06a50c10ab.zip
CMake-7480fa0a5fd0ebc3fe06c702f3368e06a50c10ab.tar.gz
CMake-7480fa0a5fd0ebc3fe06c702f3368e06a50c10ab.tar.bz2
COMPILE_DEFINITIONS property: ensure leading -D is removed in all cases
Fixes: #24186
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx8
1 files changed, 7 insertions, 1 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 6751efd..e5c50cd 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -4995,7 +4995,13 @@ void cmGlobalXCodeGenerator::AppendDefines(
std::string def;
for (auto const& define : defines) {
// Start with -D if requested.
- def = cmStrCat(dflag ? "-D" : "", define);
+ if (dflag && !cmHasLiteralPrefix(define, "-D")) {
+ def = cmStrCat("-D", define);
+ } else if (!dflag && cmHasLiteralPrefix(define, "-D")) {
+ def = define.substr(2);
+ } else {
+ def = define;
+ }
// Append the flag with needed escapes.
std::string tmp;