Commit df1ddeec authored by Jean-Christophe Fillion-Robin's avatar Jean-Christophe Fillion-Robin Committed by Craig Scott
Browse files

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: default avatarPablo Hernandez <pablo.hernandez@kitware.com>
Co-authored-by: Craig Scott's avatarCraig Scott <craig.scott@crascit.com>
parent eba2b13a
......@@ -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)
......
^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\)$
function(IncludeScope_IncludeOnly)
include(ExternalProject)
endfunction()
IncludeScope_IncludeOnly()
ExternalProject_Add(MyProj
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
^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\)$
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")
include(RunCMake)
run_cmake(IncludeScope-Add)
run_cmake(IncludeScope-Add_Step)
run_cmake(NoOptions)
run_cmake(SourceEmpty)
run_cmake(SourceMissing)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment