[Cmake-commits] CMake branch, master, updated. v3.12.2-557-g49cb2a5
Kitware Robot
kwrobot at kitware.com
Fri Sep 7 19:45:04 EDT 2018
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, master has been updated
via 49cb2a504d1e00e51774a23bf1b91c982fa69e5d (commit)
via df1ddeec128d68cc636f2dde6c2acd87af5658b6 (commit)
from 917d98699e8dd13de89e2993b0b630cf64f17706 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49cb2a504d1e00e51774a23bf1b91c982fa69e5d
commit 49cb2a504d1e00e51774a23bf1b91c982fa69e5d
Merge: 917d986 df1ddee
Author: Craig Scott <craig.scott at crascit.com>
AuthorDate: Fri Sep 7 23:40:15 2018 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Sep 7 19:40:24 2018 -0400
Merge topic 'ExternalProject-check-explicit-include'
df1ddeec12 ExternalProject: Report error if local variables are not defined
Acked-by: Kitware Robot <kwrobot at kitware.com>
Acked-by: Brad King <brad.king at kitware.com>
Merge-request: !2281
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=df1ddeec128d68cc636f2dde6c2acd87af5658b6
commit df1ddeec128d68cc636f2dde6c2acd87af5658b6
Author: Jean-Christophe Fillion-Robin <jchris.fillionr at kitware.com>
AuthorDate: Fri Aug 10 12:30:48 2018 -0400
Commit: Craig Scott <craig.scott at crascit.com>
CommitDate: Thu Sep 6 23:02:24 2018 +1000
ExternalProject: Report error if local variables are not defined
Since in some situations, ExternalProject module may be included in
a sub-directory, functions will be available in the global scope but
local variables like "_ep_keywords_<keyword>" will not be defined, this
commit checks and reports an error indicating that the ExternalProject
module must be explicitly included before using any of the ExternalProject_*
functions that require the module's inclusion within the current scope
or above.
Co-authored-by: Pablo Hernandez <pablo.hernandez at kitware.com>
Co-authored-by: Craig Scott <craig.scott at crascit.com>
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 0c5b33f..f987d2d 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -934,6 +934,11 @@ function(_ep_parse_arguments f name ns args)
# We loop through ARGN and consider the namespace starting with an
# upper-case letter followed by at least two more upper-case letters,
# numbers or underscores to be keywords.
+
+ if(NOT DEFINED _ExternalProject_SELF)
+ message(FATAL_ERROR "error: ExternalProject module must be explicitly included before using ${f} function")
+ endif()
+
set(key)
foreach(arg IN LISTS args)
diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add-result.txt b/Tests/RunCMake/ExternalProject/IncludeScope-Add-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt b/Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt
new file mode 100644
index 0000000..ff3e5c1
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\):
+ error: ExternalProject module must be explicitly included before using
+ ExternalProject_Add function
+Call Stack \(most recent call first\):
+ .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_parse_arguments\)
+ IncludeScope-Add.cmake:[0-9]+ \(ExternalProject_Add\)
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake b/Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake
new file mode 100644
index 0000000..1061ffd
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake
@@ -0,0 +1,12 @@
+function(IncludeScope_IncludeOnly)
+ include(ExternalProject)
+endfunction()
+
+IncludeScope_IncludeOnly()
+
+ExternalProject_Add(MyProj
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ""
+)
diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-result.txt b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-stderr.txt b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-stderr.txt
new file mode 100644
index 0000000..cbad4be
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\):
+ error: ExternalProject module must be explicitly included before using
+ ExternalProject_Add_Step function
+Call Stack \(most recent call first\):
+ .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_parse_arguments\)
+ IncludeScope-Add_Step.cmake:[0-9]+ \(ExternalProject_Add_Step\)
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake
new file mode 100644
index 0000000..2a820f8
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake
@@ -0,0 +1,13 @@
+function(IncludeScope_DefineProj)
+ include(ExternalProject)
+ ExternalProject_Add(MyProj
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ""
+ )
+endfunction()
+
+IncludeScope_DefineProj()
+
+ExternalProject_Add_Step(MyProj extraStep COMMENT "Foo")
diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
index 09607f6..bf11381 100644
--- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
@@ -1,5 +1,7 @@
include(RunCMake)
+run_cmake(IncludeScope-Add)
+run_cmake(IncludeScope-Add_Step)
run_cmake(NoOptions)
run_cmake(SourceEmpty)
run_cmake(SourceMissing)
-----------------------------------------------------------------------
Summary of changes:
Modules/ExternalProject.cmake | 5 +++++
.../IncludeScope-Add-result.txt} | 0
Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt | 7 +++++++
Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake | 12 ++++++++++++
.../IncludeScope-Add_Step-result.txt} | 0
.../ExternalProject/IncludeScope-Add_Step-stderr.txt | 7 +++++++
Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake | 13 +++++++++++++
Tests/RunCMake/ExternalProject/RunCMakeTest.cmake | 2 ++
8 files changed, 46 insertions(+)
copy Tests/RunCMake/{while/MissingArgument-result.txt => ExternalProject/IncludeScope-Add-result.txt} (100%)
create mode 100644 Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt
create mode 100644 Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake
copy Tests/RunCMake/{while/MissingArgument-result.txt => ExternalProject/IncludeScope-Add_Step-result.txt} (100%)
create mode 100644 Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-stderr.txt
create mode 100644 Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list