summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/LexerParser/cmGccDepfileLexer.cxx115
-rw-r--r--Source/LexerParser/cmGccDepfileLexer.h7
-rw-r--r--Source/LexerParser/cmGccDepfileLexer.in.l11
-rw-r--r--Source/cmDefinePropertyCommand.cxx63
-rw-r--r--Source/cmDependsCompiler.cxx9
-rw-r--r--Source/cmGccDepfileLexerHelper.cxx40
-rw-r--r--Source/cmGetPropertyCommand.cxx6
-rw-r--r--Source/cmTransformDepfile.cxx17
-rw-r--r--Source/cmake.cxx54
10 files changed, 167 insertions, 157 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 5edd5c0..1e65a88 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 22)
-set(CMake_VERSION_PATCH 20220118)
+set(CMake_VERSION_PATCH 20220119)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/LexerParser/cmGccDepfileLexer.cxx b/Source/LexerParser/cmGccDepfileLexer.cxx
index 194ae0c..e588853 100644
--- a/Source/LexerParser/cmGccDepfileLexer.cxx
+++ b/Source/LexerParser/cmGccDepfileLexer.cxx
@@ -256,6 +256,7 @@ typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
+typedef uint64_t flex_uint64_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
@@ -420,7 +421,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
- int yy_n_chars;
+ yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@@ -497,7 +498,7 @@ static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner
YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
-YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner );
void *yyalloc ( yy_size_t , yyscan_t yyscanner );
void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
@@ -544,12 +545,12 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
*/
#define YY_DO_BEFORE_ACTION \
yyg->yytext_ptr = yy_bp; \
- yyleng = (int) (yy_cp - yy_bp); \
+ yyleng = (yy_size_t) (yy_cp - yy_bp); \
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
-#define YY_NUM_RULES 11
-#define YY_END_OF_BUFFER 12
+#define YY_NUM_RULES 12
+#define YY_END_OF_BUFFER 13
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -557,11 +558,11 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static const flex_int16_t yy_accept[26] =
+static const flex_int16_t yy_accept[31] =
{ 0,
- 0, 0, 12, 10, 8, 6, 10, 9, 10, 10,
- 10, 8, 0, 6, 9, 1, 7, 5, 0, 3,
- 2, 0, 4, 0, 0
+ 0, 0, 13, 11, 9, 6, 11, 10, 11, 11,
+ 11, 9, 0, 6, 10, 1, 8, 7, 0, 0,
+ 5, 0, 3, 2, 0, 8, 0, 4, 0, 0
} ;
static const YY_CHAR yy_ec[256] =
@@ -601,36 +602,40 @@ static const YY_CHAR yy_meta[11] =
1, 2, 1, 1, 2, 1, 1, 1, 1, 3
} ;
-static const flex_int16_t yy_base[28] =
+static const flex_int16_t yy_base[33] =
{ 0,
- 0, 0, 29, 35, 18, 35, 22, 18, 15, 0,
- 8, 12, 16, 35, 11, 35, 0, 35, 13, 35,
- 35, 16, 35, 22, 35, 31, 12
+ 0, 0, 36, 46, 25, 46, 31, 27, 18, 9,
+ 17, 15, 25, 46, 17, 46, 0, 46, 15, 27,
+ 46, 14, 46, 46, 27, 46, 13, 46, 33, 46,
+ 42, 13
} ;
-static const flex_int16_t yy_def[28] =
+static const flex_int16_t yy_def[33] =
{ 0,
- 25, 1, 25, 25, 26, 25, 25, 25, 25, 27,
- 25, 26, 25, 25, 25, 25, 27, 25, 25, 25,
- 25, 25, 25, 25, 0, 25, 25
+ 30, 1, 30, 30, 31, 30, 30, 30, 30, 30,
+ 30, 31, 30, 30, 30, 30, 32, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 0,
+ 30, 30
} ;
-static const flex_int16_t yy_nxt[46] =
+static const flex_int16_t yy_nxt[57] =
{ 0,
4, 5, 6, 7, 5, 8, 4, 9, 10, 11,
- 18, 19, 20, 17, 21, 18, 15, 22, 18, 19,
- 23, 13, 16, 15, 14, 24, 20, 13, 25, 25,
- 25, 22, 12, 12, 3, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25
+ 17, 18, 19, 17, 17, 26, 21, 18, 20, 21,
+ 22, 23, 15, 24, 13, 16, 25, 21, 22, 26,
+ 27, 28, 15, 14, 13, 30, 29, 23, 30, 30,
+ 30, 30, 25, 12, 12, 3, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30
} ;
-static const flex_int16_t yy_chk[46] =
+static const flex_int16_t yy_chk[57] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 11, 11, 11, 27, 11, 19, 15, 11, 13, 13,
- 22, 12, 9, 8, 7, 22, 24, 5, 3, 0,
- 0, 24, 26, 26, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25
+ 10, 10, 10, 10, 32, 27, 22, 19, 10, 11,
+ 11, 11, 15, 11, 12, 9, 11, 13, 13, 20,
+ 20, 25, 8, 7, 5, 3, 25, 29, 0, 0,
+ 0, 0, 29, 31, 31, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30
} ;
/* The intent behind this definition is that it'll catch
@@ -669,8 +674,8 @@ struct yyguts_t
size_t yy_buffer_stack_max; /**< capacity of stack. */
YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
char yy_hold_char;
- int yy_n_chars;
- int yyleng_r;
+ yy_size_t yy_n_chars;
+ yy_size_t yyleng_r;
char *yy_c_buf_p;
int yy_init;
int yy_start;
@@ -717,7 +722,7 @@ FILE *yyget_out ( yyscan_t yyscanner );
void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
- int yyget_leng ( yyscan_t yyscanner );
+ yy_size_t yyget_leng ( yyscan_t yyscanner );
char *yyget_text ( yyscan_t yyscanner );
@@ -790,7 +795,7 @@ static int input ( yyscan_t yyscanner );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
- int n; \
+ yy_size_t n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@@ -926,13 +931,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 26 )
+ if ( yy_current_state >= 31 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
- while ( yy_base[yy_current_state] != 35 );
+ while ( yy_base[yy_current_state] != 46 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -1006,34 +1011,46 @@ YY_RULE_SETUP
}
YY_BREAK
case 7:
+/* rule 7 can match eol */
YY_RULE_SETUP
{
- // A colon followed by space ends the rules and starts a new dependency.
+ // A colon ends the rules
yyextra->newDependency();
+ // A newline after colon terminates current rule.
+ yyextra->newEntry();
}
YY_BREAK
case 8:
+/* rule 8 can match eol */
+YY_RULE_SETUP
+{
+ // A colon followed by space or line continuation ends the rules
+ // and starts a new dependency.
+ yyextra->newDependency();
+ }
+ YY_BREAK
+case 9:
YY_RULE_SETUP
{
// Rules and dependencies are separated by blocks of whitespace.
yyextra->newRuleOrDependency();
}
YY_BREAK
-case 9:
+case 10:
YY_RULE_SETUP
{
// Got a span of plain text.
yyextra->addToCurrentPath(yytext);
}
YY_BREAK
-case 10:
+case 11:
YY_RULE_SETUP
{
// Got an otherwise unmatched character.
yyextra->addToCurrentPath(yytext);
}
YY_BREAK
-case 11:
+case 12:
YY_RULE_SETUP
ECHO;
YY_BREAK
@@ -1224,7 +1241,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
{
- int num_to_read =
+ yy_size_t num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
@@ -1238,7 +1255,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
if ( b->yy_is_our_buffer )
{
- int new_size = b->yy_buf_size * 2;
+ yy_size_t new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@@ -1296,7 +1313,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
- int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
+ yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
@@ -1335,7 +1352,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 26 )
+ if ( yy_current_state >= 31 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -1364,11 +1381,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 26 )
+ if ( yy_current_state >= 31 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
- yy_is_jam = (yy_current_state == 25);
+ yy_is_jam = (yy_current_state == 30);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state;
@@ -1389,7 +1406,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
- int number_to_move = yyg->yy_n_chars + 2;
+ yy_size_t number_to_move = yyg->yy_n_chars + 2;
char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
char *source =
@@ -1441,7 +1458,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
{ /* need more input */
- int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
+ yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
++yyg->yy_c_buf_p;
switch ( yy_get_next_buffer( yyscanner ) )
@@ -1819,12 +1836,12 @@ YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
- int i;
+ yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = (yy_size_t) (_yybytes_len + 2);
@@ -1868,7 +1885,7 @@ static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
do \
{ \
/* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
+ yy_size_t yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
yytext[yyleng] = yyg->yy_hold_char; \
yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
@@ -1936,7 +1953,7 @@ FILE *yyget_out (yyscan_t yyscanner)
/** Get the length of the current token.
* @param yyscanner The scanner object.
*/
-int yyget_leng (yyscan_t yyscanner)
+yy_size_t yyget_leng (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyleng;
diff --git a/Source/LexerParser/cmGccDepfileLexer.h b/Source/LexerParser/cmGccDepfileLexer.h
index 7d34060..ab73ebc 100644
--- a/Source/LexerParser/cmGccDepfileLexer.h
+++ b/Source/LexerParser/cmGccDepfileLexer.h
@@ -258,6 +258,7 @@ typedef int16_t flex_int16_t;
typedef uint16_t flex_uint16_t;
typedef int32_t flex_int32_t;
typedef uint32_t flex_uint32_t;
+typedef uint64_t flex_uint64_t;
#else
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
@@ -371,7 +372,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
- int yy_n_chars;
+ yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@@ -415,7 +416,7 @@ void yypop_buffer_state ( yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
-YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner );
void *yyalloc ( yy_size_t , yyscan_t yyscanner );
void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
@@ -462,7 +463,7 @@ FILE *yyget_out ( yyscan_t yyscanner );
void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
- int yyget_leng ( yyscan_t yyscanner );
+ yy_size_t yyget_leng ( yyscan_t yyscanner );
char *yyget_text ( yyscan_t yyscanner );
diff --git a/Source/LexerParser/cmGccDepfileLexer.in.l b/Source/LexerParser/cmGccDepfileLexer.in.l
index aa2351e..6336b5f 100644
--- a/Source/LexerParser/cmGccDepfileLexer.in.l
+++ b/Source/LexerParser/cmGccDepfileLexer.in.l
@@ -48,8 +48,15 @@ NEWLINE \r?\n
// A newline ends the current file name and the current rule.
yyextra->newEntry();
}
-:{WSPACE}+ {
- // A colon followed by space ends the rules and starts a new dependency.
+:{NEWLINE} {
+ // A colon ends the rules
+ yyextra->newDependency();
+ // A newline after colon terminates current rule.
+ yyextra->newEntry();
+ }
+:({WSPACE}+|\\{NEWLINE}) {
+ // A colon followed by space or line continuation ends the rules
+ // and starts a new dependency.
yyextra->newDependency();
}
{WSPACE}+ {
diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx
index 4e2d9b0..10c36cd 100644
--- a/Source/cmDefinePropertyCommand.cxx
+++ b/Source/cmDefinePropertyCommand.cxx
@@ -2,9 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDefinePropertyCommand.h"
+#include <cmext/string_view>
+
+#include "cmArgumentParser.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmProperty.h"
+#include "cmRange.h"
#include "cmState.h"
#include "cmStringAlgorithms.h"
@@ -44,37 +48,21 @@ bool cmDefinePropertyCommand(std::vector<std::string> const& args,
// Parse remaining arguments.
bool inherited = false;
std::string PropertyName;
- std::string BriefDocs;
- std::string FullDocs;
- enum Doing
- {
- DoingNone,
- DoingProperty,
- DoingBrief,
- DoingFull
- };
- Doing doing = DoingNone;
- for (unsigned int i = 1; i < args.size(); ++i) {
- if (args[i] == "PROPERTY") {
- doing = DoingProperty;
- } else if (args[i] == "BRIEF_DOCS") {
- doing = DoingBrief;
- } else if (args[i] == "FULL_DOCS") {
- doing = DoingFull;
- } else if (args[i] == "INHERITED") {
- doing = DoingNone;
- inherited = true;
- } else if (doing == DoingProperty) {
- doing = DoingNone;
- PropertyName = args[i];
- } else if (doing == DoingBrief) {
- BriefDocs += args[i];
- } else if (doing == DoingFull) {
- FullDocs += args[i];
- } else {
- status.SetError(cmStrCat("given invalid argument \"", args[i], "\"."));
- return false;
- }
+ std::vector<std::string> BriefDocs;
+ std::vector<std::string> FullDocs;
+
+ cmArgumentParser<void> parser;
+ parser.Bind("PROPERTY"_s, PropertyName);
+ parser.Bind("BRIEF_DOCS"_s, BriefDocs);
+ parser.Bind("FULL_DOCS"_s, FullDocs);
+ parser.Bind("INHERITED"_s, inherited);
+ std::vector<std::string> invalidArgs;
+
+ parser.Parse(cmMakeRange(args).advance(1), &invalidArgs);
+ if (!invalidArgs.empty()) {
+ status.SetError(
+ cmStrCat("given invalid argument \"", invalidArgs.front(), "\"."));
+ return false;
}
// Make sure a property name was found.
@@ -83,19 +71,10 @@ bool cmDefinePropertyCommand(std::vector<std::string> const& args,
return false;
}
- // Make sure documentation was given.
- if (BriefDocs.empty()) {
- status.SetError("not given a BRIEF_DOCS <brief-doc> argument.");
- return false;
- }
- if (FullDocs.empty()) {
- status.SetError("not given a FULL_DOCS <full-doc> argument.");
- return false;
- }
-
// Actually define the property.
status.GetMakefile().GetState()->DefineProperty(
- PropertyName, scope, BriefDocs, FullDocs, inherited);
+ PropertyName, scope, cmJoin(BriefDocs, ""), cmJoin(FullDocs, ""),
+ inherited);
return true;
}
diff --git a/Source/cmDependsCompiler.cxx b/Source/cmDependsCompiler.cxx
index bf599ff..0cc4946 100644
--- a/Source/cmDependsCompiler.cxx
+++ b/Source/cmDependsCompiler.cxx
@@ -4,6 +4,7 @@
#include "cmDependsCompiler.h"
#include <algorithm>
+#include <iterator>
#include <map>
#include <memory>
#include <string>
@@ -111,9 +112,13 @@ bool cmDependsCompiler::CheckDependencies(
// copy depends for each target, except first one, which can be
// moved
for (auto index = entry.rules.size() - 1; index > 0; --index) {
- dependencies[entry.rules[index]] = depends;
+ auto& rule_deps = dependencies[entry.rules[index]];
+ rule_deps.insert(rule_deps.end(), depends.cbegin(),
+ depends.cend());
}
- dependencies[entry.rules.front()] = std::move(depends);
+ auto& rule_deps = dependencies[entry.rules.front()];
+ std::move(depends.cbegin(), depends.cend(),
+ std::back_inserter(rule_deps));
}
} else {
if (format == "msvc"_s) {
diff --git a/Source/cmGccDepfileLexerHelper.cxx b/Source/cmGccDepfileLexerHelper.cxx
index afa8e9b..34c8824 100644
--- a/Source/cmGccDepfileLexerHelper.cxx
+++ b/Source/cmGccDepfileLexerHelper.cxx
@@ -113,6 +113,24 @@ void cmGccDepfileLexerHelper::addToCurrentPath(const char* s)
void cmGccDepfileLexerHelper::sanitizeContent()
{
for (auto it = this->Content.begin(); it != this->Content.end();) {
+ // Remove empty paths and normalize windows paths
+ for (auto pit = it->paths.begin(); pit != it->paths.end();) {
+ if (pit->empty()) {
+ pit = it->paths.erase(pit);
+ } else {
+#if defined(_WIN32)
+ // Unescape the colon following the drive letter.
+ // Some versions of GNU compilers can escape this character.
+ // c\:\path must be transformed to c:\path
+ if (pit->size() >= 3 && std::toupper((*pit)[0]) >= 'A' &&
+ std::toupper((*pit)[0]) <= 'Z' && (*pit)[1] == '\\' &&
+ (*pit)[2] == ':') {
+ pit->erase(1, 1);
+ }
+#endif
+ ++pit;
+ }
+ }
// Remove empty rules
for (auto rit = it->rules.begin(); rit != it->rules.end();) {
if (rit->empty()) {
@@ -121,28 +139,10 @@ void cmGccDepfileLexerHelper::sanitizeContent()
++rit;
}
}
- // Remove the entry if rules are empty
- if (it->rules.empty()) {
+ // Remove the entry if rules are empty or do not have any paths
+ if (it->rules.empty() || it->paths.empty()) {
it = this->Content.erase(it);
} else {
- // Remove empty paths and normalize windows paths
- for (auto pit = it->paths.begin(); pit != it->paths.end();) {
- if (pit->empty()) {
- pit = it->paths.erase(pit);
- } else {
-#if defined(_WIN32)
- // Unescape the colon following the drive letter.
- // Some versions of GNU compilers can escape this character.
- // c\:\path must be transformed to c:\path
- if (pit->size() >= 3 && std::toupper((*pit)[0]) >= 'A' &&
- std::toupper((*pit)[0]) <= 'Z' && (*pit)[1] == '\\' &&
- (*pit)[2] == ':') {
- pit->erase(1, 1);
- }
-#endif
- ++pit;
- }
- }
++it;
}
}
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index b74ed48..4a25311 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -184,7 +184,8 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args,
status.GetMakefile().GetState()->GetPropertyDefinition(propertyName,
scope)) {
output = def->GetShortDescription();
- } else {
+ }
+ if (output.empty()) {
output = "NOTFOUND";
}
status.GetMakefile().AddDefinition(variable, output);
@@ -195,7 +196,8 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args,
status.GetMakefile().GetState()->GetPropertyDefinition(propertyName,
scope)) {
output = def->GetFullDescription();
- } else {
+ }
+ if (output.empty()) {
output = "NOTFOUND";
}
status.GetMakefile().AddDefinition(variable, output);
diff --git a/Source/cmTransformDepfile.cxx b/Source/cmTransformDepfile.cxx
index 4032596..81a6507 100644
--- a/Source/cmTransformDepfile.cxx
+++ b/Source/cmTransformDepfile.cxx
@@ -4,7 +4,6 @@
#include <algorithm>
#include <functional>
-#include <memory>
#include <string>
#include <type_traits>
#include <utility>
@@ -95,14 +94,16 @@ void WriteMSBuildAdditionalInputs(cmsys::ofstream& fout,
// Write the format expected by MSBuild CustomBuild AdditionalInputs.
const char* sep = "";
- for (std::string path : content.front().paths) {
- if (!cmSystemTools::FileIsFullPath(path)) {
- path =
- cmSystemTools::CollapseFullPath(path, lg.GetCurrentBinaryDirectory());
+ for (const auto& c : content) {
+ for (std::string path : c.paths) {
+ if (!cmSystemTools::FileIsFullPath(path)) {
+ path = cmSystemTools::CollapseFullPath(path,
+ lg.GetCurrentBinaryDirectory());
+ }
+ std::replace(path.begin(), path.end(), '/', '\\');
+ fout << sep << path;
+ sep = ";";
}
- std::replace(path.begin(), path.end(), '/', '\\');
- fout << sep << path;
- sep = ";";
}
fout << "\n";
}
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index c708eb2..5632c38 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1456,7 +1456,6 @@ void cmake::SetDirectoriesFromFile(const std::string& arg)
// CMakeLists.txt file.
std::string listPath;
std::string cachePath;
- bool argIsFile = false;
if (cmSystemTools::FileIsDirectory(arg)) {
std::string path = cmSystemTools::CollapseFullPath(arg);
cmSystemTools::ConvertToUnixSlashes(path);
@@ -1469,7 +1468,6 @@ void cmake::SetDirectoriesFromFile(const std::string& arg)
listPath = path;
}
} else if (cmSystemTools::FileExists(arg)) {
- argIsFile = true;
std::string fullPath = cmSystemTools::CollapseFullPath(arg);
std::string name = cmSystemTools::GetFilenameName(fullPath);
name = cmSystemTools::LowerCase(name);
@@ -1485,7 +1483,6 @@ void cmake::SetDirectoriesFromFile(const std::string& arg)
std::string name = cmSystemTools::GetFilenameName(fullPath);
name = cmSystemTools::LowerCase(name);
if (name == "cmakecache.txt"_s || name == "cmakelists.txt"_s) {
- argIsFile = true;
listPath = cmSystemTools::GetFilenamePath(fullPath);
} else {
listPath = fullPath;
@@ -1505,36 +1502,37 @@ void cmake::SetDirectoriesFromFile(const std::string& arg)
}
}
+ bool no_source_tree = this->GetHomeDirectory().empty();
+ bool no_build_tree = this->GetHomeOutputDirectory().empty();
+
// If there is a CMakeLists.txt file, use it as the source tree.
if (!listPath.empty()) {
- this->SetHomeDirectory(listPath);
- if (argIsFile) {
- // Source CMakeLists.txt file given. It was probably dropped
- // onto the executable in a GUI. Default to an in-source build.
+ // When invoked with a path that points to an existing CMakeCache
+ // This function is called multiple times with the same path
+ if (no_source_tree && no_build_tree) {
+ this->SetHomeDirectory(listPath);
+
+ std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
+ this->SetHomeOutputDirectory(cwd);
+ } else if (no_source_tree) {
+ this->SetHomeDirectory(listPath);
+ } else if (no_build_tree) {
this->SetHomeOutputDirectory(listPath);
- } else {
- // Source directory given on command line. Use current working
- // directory as build tree if -B hasn't been given already
- if (this->GetHomeOutputDirectory().empty()) {
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- this->SetHomeOutputDirectory(cwd);
- }
}
- return;
- }
-
- if (this->GetHomeDirectory().empty()) {
- // We didn't find a CMakeLists.txt and it wasn't specified
- // with -S. Assume it is the path to the source tree
- std::string full = cmSystemTools::CollapseFullPath(arg);
- this->SetHomeDirectory(full);
- }
- if (this->GetHomeOutputDirectory().empty()) {
- // We didn't find a CMakeCache.txt and it wasn't specified
- // with -B. Assume the current working directory as the build tree.
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- this->SetHomeOutputDirectory(cwd);
+ } else {
+ if (no_source_tree) {
+ // We didn't find a CMakeLists.txt and it wasn't specified
+ // with -S. Assume it is the path to the source tree
+ std::string full = cmSystemTools::CollapseFullPath(arg);
+ this->SetHomeDirectory(full);
+ }
+ if (no_build_tree) {
+ // We didn't find a CMakeCache.txt and it wasn't specified
+ // with -B. Assume the current working directory as the build tree.
+ std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
+ this->SetHomeOutputDirectory(cwd);
+ }
}
}