ENH: add new cmakedefine01 feature from bug report 2603

This commit is contained in:
Bill Hoffman 2006-01-03 16:40:51 -05:00
parent b08a151722
commit 2c73d2e0f3
11 changed files with 77 additions and 4 deletions

View File

@ -74,7 +74,8 @@ cmMakefile::cmMakefile()
this->AddSourceGroup("Header Files", "\\.(h|h\\+\\+|hm|hpp|hxx|in|txx|inl)$");
this->AddSourceGroup("CMake Rules", "\\.rule$");
this->AddDefaultDefinitions();
m_cmDefineRegex.compile("#cmakedefine[ \t]*([A-Za-z_0-9]*)");
m_cmDefineRegex.compile("#cmakedefine[ \t]+([A-Za-z_0-9]*)");
m_cmDefine01Regex.compile("#cmakedefine01[ \t]+([A-Za-z_0-9]*)");
this->PreOrder = false;
}
@ -2399,6 +2400,20 @@ void cmMakefile::ConfigureString(const std::string& input,
output += " */";
}
}
else if(m_cmDefine01Regex.find(line))
{
const char* def = this->GetDefinition(m_cmDefine01Regex.match(1).c_str());
cmSystemTools::ReplaceString(line, "#cmakedefine01", "#define");
output += line;
if(!cmSystemTools::IsOff(def))
{
output += " 1";
}
else
{
output += " 0";
}
}
else
{
output += line;

View File

@ -726,6 +726,7 @@ private:
DefinitionMap::key_type m_TemporaryDefinitionKey;
cmsys::RegularExpression m_cmDefineRegex;
cmsys::RegularExpression m_cmDefine01Regex;
std::map<cmStdString,cmStdString> m_Properties;

View File

@ -243,6 +243,8 @@ WHILE (while_var LESS 1000)
SET(while_var ${while_var}0)
ENDWHILE(while_var LESS 1000)
SET(SHOULD_BE_ZERO )
SET(SHOULD_BE_ONE 1)
#
# Configure file
# (plug vars to #define so that they can be tested)

View File

@ -1114,7 +1114,22 @@ int main()
#else
cmFailed("Generated header included by non-generated source failed.");
#endif
if(SHOULD_BE_ZERO == 0)
{
cmPassed("cmakedefine01 is working for 0");
}
else
{
cmFailed("cmakedefine01 is not working for 0");
}
if(SHOULD_BE_ONE == 1)
{
cmPassed("cmakedefine01 is working for 1");
}
else
{
cmFailed("cmakedefine01 is not working for 1");
}
#ifdef FORCE_TEST
cmFailed("CMake SET CACHE FORCE");
#else

View File

@ -39,6 +39,8 @@
#cmakedefine CMAKE_NO_ANSI_STRING_STREAM
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
#cmakedefine01 SHOULD_BE_ZERO
#cmakedefine01 SHOULD_BE_ONE
// Needed to check for files
#define BINARY_DIR "${Complex_BINARY_DIR}"

View File

@ -243,6 +243,8 @@ WHILE (while_var LESS 1000)
SET(while_var ${while_var}0)
ENDWHILE(while_var LESS 1000)
SET(SHOULD_BE_ZERO )
SET(SHOULD_BE_ONE 1)
#
# Configure file
# (plug vars to #define so that they can be tested)

View File

@ -1114,7 +1114,22 @@ int main()
#else
cmFailed("Generated header included by non-generated source failed.");
#endif
if(SHOULD_BE_ZERO == 0)
{
cmPassed("cmakedefine01 is working for 0");
}
else
{
cmFailed("cmakedefine01 is not working for 0");
}
if(SHOULD_BE_ONE == 1)
{
cmPassed("cmakedefine01 is working for 1");
}
else
{
cmFailed("cmakedefine01 is not working for 1");
}
#ifdef FORCE_TEST
cmFailed("CMake SET CACHE FORCE");
#else

View File

@ -39,6 +39,8 @@
#cmakedefine CMAKE_NO_ANSI_STRING_STREAM
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
#cmakedefine01 SHOULD_BE_ZERO
#cmakedefine01 SHOULD_BE_ONE
// Needed to check for files
#define BINARY_DIR "${Complex_BINARY_DIR}"

View File

@ -243,6 +243,8 @@ WHILE (while_var LESS 1000)
SET(while_var ${while_var}0)
ENDWHILE(while_var LESS 1000)
SET(SHOULD_BE_ZERO )
SET(SHOULD_BE_ONE 1)
#
# Configure file
# (plug vars to #define so that they can be tested)

View File

@ -1114,7 +1114,22 @@ int main()
#else
cmFailed("Generated header included by non-generated source failed.");
#endif
if(SHOULD_BE_ZERO == 0)
{
cmPassed("cmakedefine01 is working for 0");
}
else
{
cmFailed("cmakedefine01 is not working for 0");
}
if(SHOULD_BE_ONE == 1)
{
cmPassed("cmakedefine01 is working for 1");
}
else
{
cmFailed("cmakedefine01 is not working for 1");
}
#ifdef FORCE_TEST
cmFailed("CMake SET CACHE FORCE");
#else

View File

@ -39,6 +39,8 @@
#cmakedefine CMAKE_NO_ANSI_STRING_STREAM
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
#cmakedefine01 SHOULD_BE_ZERO
#cmakedefine01 SHOULD_BE_ONE
// Needed to check for files
#define BINARY_DIR "${Complex_BINARY_DIR}"