Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CMake
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
André Pedro
CMake
Commits
8424d569
Commit
8424d569
authored
11 years ago
by
Brad King
Committed by
Kitware Robot
11 years ago
Browse files
Options
Downloads
Plain Diff
Merge topic 'unset-PARENT_SCOPE'
261c2482
unset: Add PARENT_SCOPE option
parents
12a7e2b1
261c2482
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Source/cmUnsetCommand.cxx
+7
-1
7 additions, 1 deletion
Source/cmUnsetCommand.cxx
Source/cmUnsetCommand.h
+4
-1
4 additions, 1 deletion
Source/cmUnsetCommand.h
Tests/Unset/CMakeLists.txt
+27
-0
27 additions, 0 deletions
Tests/Unset/CMakeLists.txt
with
38 additions
and
2 deletions
Source/cmUnsetCommand.cxx
+
7
−
1
View file @
8424d569
...
...
@@ -49,7 +49,13 @@ bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args,
this
->
Makefile
->
RemoveCacheDefinition
(
variable
);
return
true
;
}
// ERROR: second argument isn't CACHE
// unset(VAR PARENT_SCOPE)
else
if
((
args
.
size
()
==
2
)
&&
(
args
[
1
]
==
"PARENT_SCOPE"
))
{
this
->
Makefile
->
RaiseScope
(
variable
,
0
);
return
true
;
}
// ERROR: second argument isn't CACHE or PARENT_SCOPE
else
{
this
->
SetError
(
"called with an invalid second argument"
);
...
...
This diff is collapsed.
Click to expand it.
Source/cmUnsetCommand.h
+
4
−
1
View file @
8424d569
...
...
@@ -61,10 +61,13 @@ public:
virtual
const
char
*
GetFullDocumentation
()
const
{
return
" unset(<variable> [CACHE])
\n
"
" unset(<variable> [CACHE
| PARENT_SCOPE
])
\n
"
"Removes the specified variable causing it to become undefined. "
"If CACHE is present then the variable is removed from the cache "
"instead of the current scope.
\n
"
"If PARENT_SCOPE is present then the variable is removed from the "
"scope above the current scope. See the same option in the set() "
"command for further details.
\n
"
"<variable> can be an environment variable such as:
\n
"
" unset(ENV{LD_LIBRARY_PATH})
\n
"
"in which case the variable will be removed from the current "
...
...
This diff is collapsed.
Click to expand it.
Tests/Unset/CMakeLists.txt
+
27
−
0
View file @
8424d569
...
...
@@ -51,5 +51,32 @@ if(DEFINED BAR)
message
(
FATAL_ERROR
"BAR still defined"
)
endif
()
# Test unset(... PARENT_SCOPE)
function
(
unset_zots
)
if
(
NOT DEFINED ZOT1
)
message
(
FATAL_ERROR
"ZOT1 is not defined inside function"
)
endif
()
if
(
NOT DEFINED ZOT2
)
message
(
FATAL_ERROR
"ZOT2 is not defined inside function"
)
endif
()
unset
(
ZOT1
)
unset
(
ZOT2 PARENT_SCOPE
)
if
(
DEFINED ZOT1
)
message
(
FATAL_ERROR
"ZOT1 is defined inside function after unset"
)
endif
()
if
(
NOT DEFINED ZOT2
)
message
(
FATAL_ERROR
"ZOT2 is not defined inside function after unset(... PARENT_SCOPE)"
)
endif
()
endfunction
()
set
(
ZOT1 1
)
set
(
ZOT2 2
)
unset_zots
()
if
(
NOT DEFINED ZOT1
)
message
(
FATAL_ERROR
"ZOT1 is not still defined after function"
)
endif
()
if
(
DEFINED ZOT2
)
message
(
FATAL_ERROR
"ZOT2 is still defined after function unset PARENT_SCOPE"
)
endif
()
add_executable
(
Unset unset.c
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment