Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CMake
CMake
Commits
f4b1c388
Commit
f4b1c388
authored
Dec 03, 2007
by
Ken Martin
Browse files
ENH: add functions and raise scope
parent
257b775f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Source/cmBootstrapCommands.cxx
View file @
f4b1c388
...
...
@@ -36,7 +36,9 @@
#include
"cmElseCommand.cxx"
#include
"cmEnableTestingCommand.cxx"
#include
"cmEndForEachCommand.cxx"
#include
"cmEndFunctionCommand.cxx"
#include
"cmEndIfCommand.cxx"
#include
"cmEndMacroCommand.cxx"
#include
"cmExecProgramCommand.cxx"
#include
"cmExternalMakefileProjectGenerator.cxx"
#include
"cmFindBase.cxx"
...
...
@@ -47,6 +49,7 @@
#include
"cmFindPathCommand.cxx"
#include
"cmFindProgramCommand.cxx"
#include
"cmForEachCommand.cxx"
#include
"cmFunctionCommand.cxx"
#include
"cmGetCMakePropertyCommand.cxx"
#include
"cmGetFilenameComponentCommand.cxx"
#include
"cmGetSourceFilePropertyCommand.cxx"
...
...
@@ -66,6 +69,7 @@
#include
"cmMessageCommand.cxx"
#include
"cmOptionCommand.cxx"
#include
"cmProjectCommand.cxx"
#include
"cmRaiseScopeCommand.cxx"
#include
"cmSetCommand.cxx"
#include
"cmSetPropertiesCommand.cxx"
#include
"cmSetSourceFilesPropertiesCommand.cxx"
...
...
@@ -95,7 +99,9 @@ void GetBootstrapCommands(std::list<cmCommand*>& commands)
commands
.
push_back
(
new
cmElseCommand
);
commands
.
push_back
(
new
cmEnableTestingCommand
);
commands
.
push_back
(
new
cmEndForEachCommand
);
commands
.
push_back
(
new
cmEndFunctionCommand
);
commands
.
push_back
(
new
cmEndIfCommand
);
commands
.
push_back
(
new
cmEndMacroCommand
);
commands
.
push_back
(
new
cmExecProgramCommand
);
commands
.
push_back
(
new
cmFileCommand
);
commands
.
push_back
(
new
cmFindFileCommand
);
...
...
@@ -104,6 +110,7 @@ void GetBootstrapCommands(std::list<cmCommand*>& commands)
commands
.
push_back
(
new
cmFindPathCommand
);
commands
.
push_back
(
new
cmFindProgramCommand
);
commands
.
push_back
(
new
cmForEachCommand
);
commands
.
push_back
(
new
cmFunctionCommand
);
commands
.
push_back
(
new
cmGetCMakePropertyCommand
);
commands
.
push_back
(
new
cmGetFilenameComponentCommand
);
commands
.
push_back
(
new
cmGetSourceFilePropertyCommand
);
...
...
@@ -122,6 +129,7 @@ void GetBootstrapCommands(std::list<cmCommand*>& commands)
commands
.
push_back
(
new
cmMessageCommand
);
commands
.
push_back
(
new
cmOptionCommand
);
commands
.
push_back
(
new
cmProjectCommand
);
commands
.
push_back
(
new
cmRaiseScopeCommand
);
commands
.
push_back
(
new
cmSetCommand
);
commands
.
push_back
(
new
cmSetPropertiesCommand
);
commands
.
push_back
(
new
cmSetSourceFilesPropertiesCommand
);
...
...
Source/cmCommands.cxx
View file @
f4b1c388
...
...
@@ -21,7 +21,6 @@
#include
"cmDefinePropertyCommand.cxx"
#include
"cmElseIfCommand.cxx"
#include
"cmEnableLanguageCommand.cxx"
#include
"cmEndMacroCommand.cxx"
#include
"cmEndWhileCommand.cxx"
#include
"cmExecuteProcessCommand.cxx"
#include
"cmExportCommand.cxx"
...
...
@@ -72,7 +71,6 @@ void GetPredefinedCommands(std::list<cmCommand*>&
commands
.
push_back
(
new
cmDefinePropertyCommand
);
commands
.
push_back
(
new
cmElseIfCommand
);
commands
.
push_back
(
new
cmEnableLanguageCommand
);
commands
.
push_back
(
new
cmEndMacroCommand
);
commands
.
push_back
(
new
cmEndWhileCommand
);
commands
.
push_back
(
new
cmExecuteProcessCommand
);
commands
.
push_back
(
new
cmExportCommand
);
...
...
Source/cmMakefile.cxx
View file @
f4b1c388
...
...
@@ -42,6 +42,8 @@
// default is not to be building executables
cmMakefile
::
cmMakefile
()
{
this
->
DefinitionStack
.
push_back
(
DefinitionMap
());
// Setup the default include file regular expression (match everything).
this
->
IncludeFileRegularExpression
=
"^.*$"
;
// Setup the default include complaint regular expression (match nothing).
...
...
@@ -120,7 +122,7 @@ cmMakefile::cmMakefile(const cmMakefile& mf)
this
->
SourceGroups
=
mf
.
SourceGroups
;
#endif
this
->
Definition
s
=
mf
.
Definitions
;
this
->
Definition
Stack
.
push_back
(
mf
.
DefinitionStack
.
back
())
;
this
->
LocalGenerator
=
mf
.
LocalGenerator
;
this
->
FunctionBlockers
=
mf
.
FunctionBlockers
;
this
->
DataMap
=
mf
.
DataMap
;
...
...
@@ -1046,7 +1048,7 @@ void cmMakefile::InitializeFromParent()
cmMakefile
*
parent
=
this
->
LocalGenerator
->
GetParent
()
->
GetMakefile
();
// copy the definitions
this
->
Definition
s
=
parent
->
Definition
s
;
this
->
Definition
Stack
.
front
()
=
parent
->
Definition
Stack
.
back
()
;
// copy include paths
this
->
IncludeDirectories
=
parent
->
IncludeDirectories
;
...
...
@@ -1225,7 +1227,7 @@ void cmMakefile::AddDefinition(const char* name, const char* value)
#endif
this
->
TemporaryDefinitionKey
=
name
;
this
->
Definition
s
[
this
->
TemporaryDefinitionKey
]
=
value
;
this
->
Definition
Stack
.
back
()
[
this
->
TemporaryDefinitionKey
]
=
value
;
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch
*
vv
=
this
->
GetVariableWatch
();
...
...
@@ -1274,7 +1276,7 @@ void cmMakefile::AddCacheDefinition(const char* name, const char* value,
}
this
->
GetCacheManager
()
->
AddCacheEntry
(
name
,
val
,
doc
,
type
);
// if there was a definition then remove it
this
->
Definition
s
.
erase
(
DefinitionMap
::
key_type
(
name
));
this
->
Definition
Stack
.
back
()
.
erase
(
DefinitionMap
::
key_type
(
name
));
}
...
...
@@ -1282,13 +1284,17 @@ void cmMakefile::AddDefinition(const char* name, bool value)
{
if
(
value
)
{
this
->
Definitions
.
erase
(
DefinitionMap
::
key_type
(
name
));
this
->
Definitions
.
insert
(
DefinitionMap
::
value_type
(
name
,
"ON"
));
this
->
DefinitionStack
.
back
()
.
erase
(
DefinitionMap
::
key_type
(
name
));
this
->
DefinitionStack
.
back
()
.
insert
(
DefinitionMap
::
value_type
(
name
,
"ON"
));
}
else
{
this
->
Definitions
.
erase
(
DefinitionMap
::
key_type
(
name
));
this
->
Definitions
.
insert
(
DefinitionMap
::
value_type
(
name
,
"OFF"
));
this
->
DefinitionStack
.
back
()
.
erase
(
DefinitionMap
::
key_type
(
name
));
this
->
DefinitionStack
.
back
()
.
insert
(
DefinitionMap
::
value_type
(
name
,
"OFF"
));
}
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch
*
vv
=
this
->
GetVariableWatch
();
...
...
@@ -1319,7 +1325,7 @@ void cmMakefile::AddCacheDefinition(const char* name,
void
cmMakefile
::
RemoveDefinition
(
const
char
*
name
)
{
this
->
Definition
s
.
erase
(
DefinitionMap
::
key_type
(
name
));
this
->
Definition
Stack
.
back
()
.
erase
(
DefinitionMap
::
key_type
(
name
));
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch
*
vv
=
this
->
GetVariableWatch
();
if
(
vv
)
...
...
@@ -1653,8 +1659,9 @@ const char* cmMakefile::GetRequiredDefinition(const char* name) const
bool
cmMakefile
::
IsDefinitionSet
(
const
char
*
name
)
const
{
const
char
*
def
=
0
;
DefinitionMap
::
const_iterator
pos
=
this
->
Definitions
.
find
(
name
);
if
(
pos
!=
this
->
Definitions
.
end
())
DefinitionMap
::
const_iterator
pos
=
this
->
DefinitionStack
.
back
().
find
(
name
);
if
(
pos
!=
this
->
DefinitionStack
.
back
().
end
())
{
def
=
(
*
pos
).
second
.
c_str
();
}
...
...
@@ -1686,8 +1693,9 @@ const char* cmMakefile::GetDefinition(const char* name) const
}
#endif
const
char
*
def
=
0
;
DefinitionMap
::
const_iterator
pos
=
this
->
Definitions
.
find
(
name
);
if
(
pos
!=
this
->
Definitions
.
end
())
DefinitionMap
::
const_iterator
pos
=
this
->
DefinitionStack
.
back
().
find
(
name
);
if
(
pos
!=
this
->
DefinitionStack
.
back
().
end
())
{
def
=
(
*
pos
).
second
.
c_str
();
}
...
...
@@ -1708,8 +1716,9 @@ const char* cmMakefile::GetDefinition(const char* name) const
{
// are unknown access allowed
DefinitionMap
::
const_iterator
pos2
=
this
->
Definitions
.
find
(
"CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS"
);
if
(
pos2
!=
this
->
Definitions
.
end
()
&&
this
->
DefinitionStack
.
back
()
.
find
(
"CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS"
);
if
(
pos2
!=
this
->
DefinitionStack
.
back
().
end
()
&&
cmSystemTools
::
IsOn
((
*
pos2
).
second
.
c_str
()))
{
vv
->
VariableAccessed
(
name
,
...
...
@@ -1743,8 +1752,8 @@ std::vector<std::string> cmMakefile
if
(
!
cacheonly
)
{
DefinitionMap
::
const_iterator
it
;
for
(
it
=
this
->
Definition
s
.
begin
();
it
!=
this
->
Definition
s
.
end
();
it
++
)
for
(
it
=
this
->
Definition
Stack
.
back
()
.
begin
();
it
!=
this
->
Definition
Stack
.
back
()
.
end
();
it
++
)
{
definitions
[
it
->
first
]
=
1
;
}
...
...
@@ -2822,6 +2831,38 @@ std::string cmMakefile::GetListFileStack()
return
tmp
.
str
();
}
void
cmMakefile
::
PushScope
()
{
this
->
DefinitionStack
.
push_back
(
this
->
DefinitionStack
.
back
());
}
void
cmMakefile
::
PopScope
()
{
this
->
DefinitionStack
.
pop_back
();
}
void
cmMakefile
::
RaiseScope
(
const
char
*
var
)
{
const
char
*
varDef
=
this
->
GetDefinition
(
var
);
// multiple scopes in this directory?
if
(
this
->
DefinitionStack
.
size
()
>
1
)
{
this
->
DefinitionStack
[
this
->
DefinitionStack
.
size
()
-
2
][
var
]
=
varDef
;
}
// otherwise do the parent
else
{
cmMakefile
*
parent
=
this
->
LocalGenerator
->
GetParent
()
->
GetMakefile
();
if
(
parent
)
{
parent
->
AddDefinition
(
var
,
varDef
);
}
}
}
// define properties
void
cmMakefile
::
DefineProperties
(
cmake
*
cm
)
{
...
...
Source/cmMakefile.h
View file @
f4b1c388
...
...
@@ -737,6 +737,11 @@ public:
// Define the properties
static
void
DefineProperties
(
cmake
*
cm
);
// push and pop variable scopes
void
PushScope
();
void
PopScope
();
void
RaiseScope
(
const
char
*
var
);
protected:
// add link libraries and directories to the target
void
AddGlobalLinkInformation
(
const
char
*
name
,
cmTarget
&
target
);
...
...
@@ -787,7 +792,7 @@ protected:
std
::
vector
<
cmSourceGroup
>
SourceGroups
;
#endif
DefinitionMap
Definition
s
;
std
::
vector
<
DefinitionMap
>
Definition
Stack
;
std
::
vector
<
cmCommand
*>
UsedCommands
;
cmLocalGenerator
*
LocalGenerator
;
bool
IsFunctionBlocked
(
const
cmListFileFunction
&
lff
);
...
...
Source/cmake.cxx
View file @
f4b1c388
...
...
@@ -224,7 +224,8 @@ void cmake::CleanupCommandsAndMacros()
for
(
RegisteredCommandsMap
::
iterator
j
=
this
->
Commands
.
begin
();
j
!=
this
->
Commands
.
end
();
++
j
)
{
if
(
!
j
->
second
->
IsA
(
"cmMacroHelperCommand"
)
)
if
(
!
j
->
second
->
IsA
(
"cmMacroHelperCommand"
)
&&
!
j
->
second
->
IsA
(
"cmFunctionHelperCommand"
))
{
commands
.
push_back
(
j
->
second
);
}
...
...
Tests/CMakeLists.txt
View file @
f4b1c388
...
...
@@ -45,6 +45,7 @@ IF(BUILD_TESTING)
ADD_TEST_MACRO
(
LoadCommand LoadedCommand
)
ADD_TEST_MACRO
(
LinkLine LinkLine
)
ADD_TEST_MACRO
(
MacroTest miniMacroTest
)
ADD_TEST_MACRO
(
FunctionTest miniFunctionTest
)
ADD_TEST_MACRO
(
Properties Properties
)
ADD_TEST_MACRO
(
Assembler HelloAsm
)
ADD_TEST_MACRO
(
SourceGroups SourceGroups
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment