Subdirs: Initialize from parent before configuring.
Add new API for the subdirs command to cmState.
This fixes a regression introduced in commit f716460e
(cmMakefile: Move
invokation to initialize snapshot., 2015-10-06).
This commit is contained in:
parent
0aa34de549
commit
2bf7de167f
|
@ -1647,6 +1647,7 @@ void cmMakefile::Configure()
|
||||||
std::vector<cmMakefile*>::iterator sdi = subdirs.begin();
|
std::vector<cmMakefile*>::iterator sdi = subdirs.begin();
|
||||||
for (; sdi != subdirs.end(); ++sdi)
|
for (; sdi != subdirs.end(); ++sdi)
|
||||||
{
|
{
|
||||||
|
(*sdi)->StateSnapshot.InitializeFromParent_ForSubdirsCommand();
|
||||||
this->ConfigureSubDirectory(*sdi);
|
this->ConfigureSubDirectory(*sdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1447,6 +1447,20 @@ std::string cmState::Snapshot::GetProjectName() const
|
||||||
return this->Position->BuildSystemDirectory->ProjectName;
|
return this->Position->BuildSystemDirectory->ProjectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmState::Snapshot::InitializeFromParent_ForSubdirsCommand()
|
||||||
|
{
|
||||||
|
std::string currentSrcDir = this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR");
|
||||||
|
std::string currentBinDir = this->GetDefinition("CMAKE_CURRENT_BINARY_DIR");
|
||||||
|
this->InitializeFromParent();
|
||||||
|
this->SetDefinition("CMAKE_SOURCE_DIR",
|
||||||
|
this->State->GetSourceDirectory());
|
||||||
|
this->SetDefinition("CMAKE_BINARY_DIR",
|
||||||
|
this->State->GetBinaryDirectory());
|
||||||
|
|
||||||
|
this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", currentSrcDir.c_str());
|
||||||
|
this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", currentBinDir.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
cmState::Directory::Directory(
|
cmState::Directory::Directory(
|
||||||
cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter,
|
cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter,
|
||||||
const cmState::Snapshot& snapshot)
|
const cmState::Snapshot& snapshot)
|
||||||
|
|
|
@ -90,6 +90,8 @@ public:
|
||||||
void SetProjectName(std::string const& name);
|
void SetProjectName(std::string const& name);
|
||||||
std::string GetProjectName() const;
|
std::string GetProjectName() const;
|
||||||
|
|
||||||
|
void InitializeFromParent_ForSubdirsCommand();
|
||||||
|
|
||||||
struct StrictWeakOrder
|
struct StrictWeakOrder
|
||||||
{
|
{
|
||||||
bool operator()(const cmState::Snapshot& lhs,
|
bool operator()(const cmState::Snapshot& lhs,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
cmake_minimum_required (VERSION 2.6)
|
cmake_minimum_required (VERSION 2.6)
|
||||||
project(SUBDIR)
|
project(SUBDIR)
|
||||||
|
|
||||||
subdirs(Executable EXCLUDE_FROM_ALL Examples)
|
subdirs(Executable EXCLUDE_FROM_ALL Examples)
|
||||||
|
|
||||||
|
set(DEFINED_AFTER_SUBDIRS_COMMAND 42)
|
||||||
|
|
||||||
write_file(${SUBDIR_BINARY_DIR}/ShouldBeHere "This file should exist.")
|
write_file(${SUBDIR_BINARY_DIR}/ShouldBeHere "This file should exist.")
|
||||||
#WATCOM WMAKE does not support + in the name of a file!
|
#WATCOM WMAKE does not support + in the name of a file!
|
||||||
if(WATCOM)
|
if(WATCOM)
|
||||||
|
|
|
@ -1 +1,13 @@
|
||||||
add_executable(test test.cxx)
|
add_executable(test test.cxx)
|
||||||
|
|
||||||
|
if (NOT DEFINED_AFTER_SUBDIRS_COMMAND)
|
||||||
|
message(FATAL_ERROR "DEFINED_AFTER_SUBDIRS_COMMAND should be defined.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(FIND "${CMAKE_CURRENT_BINARY_DIR}" "SubDir/Executable" location)
|
||||||
|
string(LENGTH "${CMAKE_CURRENT_BINARY_DIR}" dirLength)
|
||||||
|
math(EXPR suffixLength "${dirLength} - ${location}")
|
||||||
|
|
||||||
|
if (NOT suffixLength EQUAL 17)
|
||||||
|
message(FATAL_ERROR "CMAKE_CURRENT_BINARY_DIR does not end with \"SubDir/Executable\"")
|
||||||
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue