[Cmake-commits] [cmake-commits] king committed CMakeLists.txt 1.420 1.421 cmIDEOptions.cxx NONE 1.1 cmIDEOptions.h NONE 1.1 cmVisualStudioGeneratorOptions.cxx 1.2 1.3 cmVisualStudioGeneratorOptions.h 1.2 1.3
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Jul 29 11:29:12 EDT 2009
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv4653/Source
Modified Files:
CMakeLists.txt cmVisualStudioGeneratorOptions.cxx
cmVisualStudioGeneratorOptions.h
Added Files:
cmIDEOptions.cxx cmIDEOptions.h
Log Message:
ENH: Separate option mapping from VS generators
Split cmVisualStudioGeneratorOptions core functionality out into a
base class cmIDEOptions. It will be useful for other generators.
Index: cmVisualStudioGeneratorOptions.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmVisualStudioGeneratorOptions.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -C 2 -d -r1.2 -r1.3
*** cmVisualStudioGeneratorOptions.cxx 13 Jul 2009 20:58:24 -0000 1.2
--- cmVisualStudioGeneratorOptions.cxx 29 Jul 2009 15:29:07 -0000 1.3
***************
*** 32,39 ****
cmVS7FlagTable const* extraTable,
cmVisualStudio10TargetGenerator* g):
LocalGenerator(lg), Version(version), CurrentTool(tool),
- DoingDefine(false), FlagTable(table), ExtraFlagTable(extraTable),
TargetGenerator(g)
{
}
--- 32,49 ----
cmVS7FlagTable const* extraTable,
cmVisualStudio10TargetGenerator* g):
+ cmIDEOptions(),
LocalGenerator(lg), Version(version), CurrentTool(tool),
TargetGenerator(g)
{
+ // Store the given flag tables.
+ cmIDEFlagTable const** ft = this->FlagTable;
+ if(table) { *ft++ = table; }
+ if(extraTable) { *ft++ = extraTable; }
+
+ // Preprocessor definitions are not allowed for linker tools.
+ this->AllowDefine = (tool != Linker);
+
+ // Slash options are allowed for VS.
+ this->AllowSlash = true;
}
***************
*** 86,113 ****
}
- //----------------------------------------------------------------------------
- void cmVisualStudioGeneratorOptions::AddDefine(const std::string& def)
- {
- this->Defines.push_back(def);
- }
-
- //----------------------------------------------------------------------------
- void cmVisualStudioGeneratorOptions::AddDefines(const char* defines)
- {
- if(defines)
- {
- // Expand the list of definitions.
- cmSystemTools::ExpandListArgument(defines, this->Defines);
- }
- }
-
- //----------------------------------------------------------------------------
- void cmVisualStudioGeneratorOptions::AddFlag(const char* flag,
- const char* value)
- {
- this->FlagMap[flag] = value;
- }
-
-
bool cmVisualStudioGeneratorOptions::IsDebug()
{
--- 96,99 ----
***************
*** 148,199 ****
//----------------------------------------------------------------------------
! void cmVisualStudioGeneratorOptions::HandleFlag(const char* flag)
{
- // If the last option was -D then this option is the definition.
- if(this->DoingDefine)
- {
- this->DoingDefine = false;
- this->Defines.push_back(flag);
- return;
- }
-
- // Look for known arguments.
- if(flag[0] == '-' || flag[0] == '/')
- {
- // Look for preprocessor definitions.
- if(this->CurrentTool == Compiler && flag[1] == 'D')
- {
- if(flag[2] == '\0')
- {
- // The next argument will have the definition.
- this->DoingDefine = true;
- }
- else
- {
- // Store this definition.
- this->Defines.push_back(flag+2);
- }
- return;
- }
-
- // Look through the available flag tables.
- bool flag_handled = false;
- if(this->FlagTable &&
- this->CheckFlagTable(this->FlagTable, flag, flag_handled))
- {
- return;
- }
- if(this->ExtraFlagTable &&
- this->CheckFlagTable(this->ExtraFlagTable, flag, flag_handled))
- {
- return;
- }
-
- // If any map entry handled the flag we are done.
- if(flag_handled)
- {
- return;
- }
- }
// This option is not known. Store it in the output flags.
this->FlagString += " ";
--- 134,139 ----
//----------------------------------------------------------------------------
! void cmVisualStudioGeneratorOptions::StoreUnknownFlag(const char* flag)
{
// This option is not known. Store it in the output flags.
this->FlagString += " ";
***************
*** 206,280 ****
//----------------------------------------------------------------------------
- bool
- cmVisualStudioGeneratorOptions
- ::CheckFlagTable(cmVS7FlagTable const* table, const char* flag,
- bool& flag_handled)
- {
- // Look for an entry in the flag table matching this flag.
- for(cmVS7FlagTable const* entry = table; entry->IDEName; ++entry)
- {
- bool entry_found = false;
- if(entry->special & cmVS7FlagTable::UserValue)
- {
- // This flag table entry accepts a user-specified value. If
- // the entry specifies UserRequired we must match only if a
- // non-empty value is given.
- int n = static_cast<int>(strlen(entry->commandFlag));
- if(strncmp(flag+1, entry->commandFlag, n) == 0 &&
- (!(entry->special & cmVS7FlagTable::UserRequired) ||
- static_cast<int>(strlen(flag+1)) > n))
- {
- if(entry->special & cmVS7FlagTable::UserIgnored)
- {
- // Ignore the user-specified value.
- this->FlagMap[entry->IDEName] = entry->value;
- }
- else if(entry->special & cmVS7FlagTable::SemicolonAppendable)
- {
- const char *new_value = flag+1+n;
-
- std::map<cmStdString,cmStdString>::iterator itr;
- itr = this->FlagMap.find(entry->IDEName);
- if(itr != this->FlagMap.end())
- {
- // Append to old value (if present) with semicolons;
- itr->second += ";";
- itr->second += new_value;
- }
- else
- {
- this->FlagMap[entry->IDEName] = new_value;
- }
- }
- else
- {
- // Use the user-specified value.
- this->FlagMap[entry->IDEName] = flag+1+n;
- }
- entry_found = true;
- }
- }
- else if(strcmp(flag+1, entry->commandFlag) == 0)
- {
- // This flag table entry provides a fixed value.
- this->FlagMap[entry->IDEName] = entry->value;
- entry_found = true;
- }
-
- // If the flag has been handled by an entry not requesting a
- // search continuation we are done.
- if(entry_found && !(entry->special & cmVS7FlagTable::Continue))
- {
- return true;
- }
-
- // If the entry was found the flag has been handled.
- flag_handled = flag_handled || entry_found;
- }
-
- return false;
- }
-
-
void cmVisualStudioGeneratorOptions::SetConfiguration(const char* config)
{
--- 146,149 ----
Index: cmVisualStudioGeneratorOptions.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmVisualStudioGeneratorOptions.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C 2 -d -r1.2 -r1.3
*** cmVisualStudioGeneratorOptions.h 29 Jul 2009 15:28:55 -0000 1.2
--- cmVisualStudioGeneratorOptions.h 29 Jul 2009 15:29:08 -0000 1.3
***************
*** 20,24 ****
#include "cmLocalGenerator.h"
! #include "cmIDEFlagTable.h"
typedef cmIDEFlagTable cmVS7FlagTable;
--- 20,24 ----
#include "cmLocalGenerator.h"
! #include "cmIDEOptions.h"
typedef cmIDEFlagTable cmVS7FlagTable;
***************
*** 26,30 ****
//----------------------------------------------------------------------------
! class cmVisualStudioGeneratorOptions
{
public:
--- 26,30 ----
//----------------------------------------------------------------------------
! class cmVisualStudioGeneratorOptions: public cmIDEOptions
{
public:
***************
*** 52,60 ****
void SetVerboseMakefile(bool verbose);
- // Store definitions and flags.
- void AddDefine(const std::string& define);
- void AddDefines(const char* defines);
- void AddFlag(const char* flag, const char* value);
-
// Check for specific options.
bool UsingUnicode();
--- 52,55 ----
***************
*** 74,100 ****
int Version;
- // create a map of xml tags to the values they should have in the output
- // for example, "BufferSecurityCheck" = "TRUE"
- // first fill this table with the values for the configuration
- // Debug, Release, etc,
- // Then parse the command line flags specified in CMAKE_CXX_FLAGS
- // and CMAKE_C_FLAGS
- // and overwrite or add new values to this map
- std::map<cmStdString, cmStdString> FlagMap;
-
- // Preprocessor definitions.
- std::vector<std::string> Defines;
-
- // Unrecognized flags that get no special handling.
- cmStdString FlagString;
std::string Configuration;
- cmVisualStudio10TargetGenerator* TargetGenerator;
Tool CurrentTool;
! bool DoingDefine;
! cmVS7FlagTable const* FlagTable;
! cmVS7FlagTable const* ExtraFlagTable;
! void HandleFlag(const char* flag);
! bool CheckFlagTable(cmVS7FlagTable const* table, const char* flag,
! bool& flag_handled);
};
--- 69,77 ----
int Version;
std::string Configuration;
Tool CurrentTool;
! cmVisualStudio10TargetGenerator* TargetGenerator;
!
! virtual void StoreUnknownFlag(const char* flag);
};
Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CMakeLists.txt,v
retrieving revision 1.420
retrieving revision 1.421
diff -C 2 -d -r1.420 -r1.421
*** CMakeLists.txt 29 Jul 2009 15:28:52 -0000 1.420
--- CMakeLists.txt 29 Jul 2009 15:29:02 -0000 1.421
***************
*** 297,300 ****
--- 297,302 ----
cmGlobalWatcomWMakeGenerator.cxx
cmIDEFlagTable.h
+ cmIDEOptions.cxx
+ cmIDEOptions.h
cmLocalVisualStudio6Generator.cxx
cmLocalVisualStudio6Generator.h
--- NEW FILE: cmIDEOptions.h ---
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile: cmIDEOptions.h,v $
Language: C++
Date: $Date: 2009-07-29 15:29:06 $
Version: $Revision: 1.1 $
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmIDEOptions_h
#define cmIDEOptions_h
#include "cmStandardIncludes.h"
#include "cmIDEFlagTable.h"
/** \class cmIDEOptions
* \brief Superclass for IDE option processing
*/
class cmIDEOptions
{
public:
cmIDEOptions();
virtual ~cmIDEOptions();
// Store definitions and flags.
void AddDefine(const std::string& define);
void AddDefines(const char* defines);
void AddFlag(const char* flag, const char* value);
protected:
// create a map of xml tags to the values they should have in the output
// for example, "BufferSecurityCheck" = "TRUE"
// first fill this table with the values for the configuration
// Debug, Release, etc,
// Then parse the command line flags specified in CMAKE_CXX_FLAGS
// and CMAKE_C_FLAGS
// and overwrite or add new values to this map
std::map<cmStdString, cmStdString> FlagMap;
// Preprocessor definitions.
std::vector<std::string> Defines;
// Unrecognized flags that get no special handling.
cmStdString FlagString;
bool DoingDefine;
bool AllowDefine;
bool AllowSlash;
enum { FlagTableCount = 16 };
cmIDEFlagTable const* FlagTable[FlagTableCount];
void HandleFlag(const char* flag);
bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag,
bool& flag_handled);
virtual void StoreUnknownFlag(const char* flag) = 0;
};
#endif
--- NEW FILE: cmIDEOptions.cxx ---
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile: cmIDEOptions.cxx,v $
Language: C++
Date: $Date: 2009-07-29 15:29:03 $
Version: $Revision: 1.1 $
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmIDEOptions.h"
#include "cmSystemTools.h"
//----------------------------------------------------------------------------
cmIDEOptions::cmIDEOptions()
{
this->DoingDefine = false;
this->AllowDefine = true;
this->AllowSlash = false;
for(int i=0; i < FlagTableCount; ++i)
{
this->FlagTable[i] = 0;
}
}
//----------------------------------------------------------------------------
cmIDEOptions::~cmIDEOptions()
{
}
//----------------------------------------------------------------------------
void cmIDEOptions::HandleFlag(const char* flag)
{
// If the last option was -D then this option is the definition.
if(this->DoingDefine)
{
this->DoingDefine = false;
this->Defines.push_back(flag);
return;
}
// Look for known arguments.
if(flag[0] == '-' || (this->AllowSlash && flag[0] == '/'))
{
// Look for preprocessor definitions.
if(this->AllowDefine && flag[1] == 'D')
{
if(flag[2] == '\0')
{
// The next argument will have the definition.
this->DoingDefine = true;
}
else
{
// Store this definition.
this->Defines.push_back(flag+2);
}
return;
}
// Look through the available flag tables.
bool flag_handled = false;
for(int i=0; i < FlagTableCount && this->FlagTable[i]; ++i)
{
if(this->CheckFlagTable(this->FlagTable[i], flag, flag_handled))
{
return;
}
}
// If any map entry handled the flag we are done.
if(flag_handled)
{
return;
}
}
// This option is not known. Store it in the output flags.
this->StoreUnknownFlag(flag);
}
//----------------------------------------------------------------------------
bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table,
const char* flag, bool& flag_handled)
{
// Look for an entry in the flag table matching this flag.
for(cmIDEFlagTable const* entry = table; entry->IDEName; ++entry)
{
bool entry_found = false;
if(entry->special & cmIDEFlagTable::UserValue)
{
// This flag table entry accepts a user-specified value. If
// the entry specifies UserRequired we must match only if a
// non-empty value is given.
int n = static_cast<int>(strlen(entry->commandFlag));
if(strncmp(flag+1, entry->commandFlag, n) == 0 &&
(!(entry->special & cmIDEFlagTable::UserRequired) ||
static_cast<int>(strlen(flag+1)) > n))
{
if(entry->special & cmIDEFlagTable::UserIgnored)
{
// Ignore the user-specified value.
this->FlagMap[entry->IDEName] = entry->value;
}
else if(entry->special & cmIDEFlagTable::SemicolonAppendable)
{
const char *new_value = flag+1+n;
std::map<cmStdString,cmStdString>::iterator itr;
itr = this->FlagMap.find(entry->IDEName);
if(itr != this->FlagMap.end())
{
// Append to old value (if present) with semicolons;
itr->second += ";";
itr->second += new_value;
}
else
{
this->FlagMap[entry->IDEName] = new_value;
}
}
else
{
// Use the user-specified value.
this->FlagMap[entry->IDEName] = flag+1+n;
}
entry_found = true;
}
}
else if(strcmp(flag+1, entry->commandFlag) == 0)
{
// This flag table entry provides a fixed value.
this->FlagMap[entry->IDEName] = entry->value;
entry_found = true;
}
// If the flag has been handled by an entry not requesting a
// search continuation we are done.
if(entry_found && !(entry->special & cmIDEFlagTable::Continue))
{
return true;
}
// If the entry was found the flag has been handled.
flag_handled = flag_handled || entry_found;
}
return false;
}
//----------------------------------------------------------------------------
void cmIDEOptions::AddDefine(const std::string& def)
{
this->Defines.push_back(def);
}
//----------------------------------------------------------------------------
void cmIDEOptions::AddDefines(const char* defines)
{
if(defines)
{
// Expand the list of definitions.
cmSystemTools::ExpandListArgument(defines, this->Defines);
}
}
//----------------------------------------------------------------------------
void cmIDEOptions::AddFlag(const char* flag, const char* value)
{
this->FlagMap[flag] = value;
}
More information about the Cmake-commits
mailing list