Fix recursive try_compile calls

When building an entire source tree with try_compile instead of just a
single source file, it is possible that the CMakeLists.txt file in the
try-compiled project invokes try_compile.  This commit fixes propagation
of language-initialization results from the outer-most project into any
number of try-compile levels.
This commit is contained in:
Brad King 2009-08-03 13:37:36 -04:00
parent 1a159bbf33
commit 73de2362dd
3 changed files with 25 additions and 4 deletions

View File

@ -1343,9 +1343,7 @@ cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator()
void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen ) void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen )
{ {
std::string cfp = gen->GetCMakeInstance()->GetHomeOutputDirectory(); this->SetConfiguredFilesPath(gen);
cfp += cmake::GetCMakeFilesDirectory();
this->SetConfiguredFilesPath(cfp.c_str());
const char* make = const char* make =
gen->GetCMakeInstance()->GetCacheDefinition("CMAKE_MAKE_PROGRAM"); gen->GetCMakeInstance()->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", make, this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", make,
@ -1360,6 +1358,20 @@ void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen )
this->OutputExtensions = gen->OutputExtensions; this->OutputExtensions = gen->OutputExtensions;
} }
//----------------------------------------------------------------------------
void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen)
{
if(!gen->ConfiguredFilesPath.empty())
{
this->ConfiguredFilesPath = gen->ConfiguredFilesPath;
}
else
{
this->ConfiguredFilesPath = gen->CMakeInstance->GetHomeOutputDirectory();
this->ConfiguredFilesPath += cmake::GetCMakeFilesDirectory();
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalGenerator::GetDocumentation(cmDocumentationEntry& entry) const void cmGlobalGenerator::GetDocumentation(cmDocumentationEntry& entry) const
{ {

View File

@ -123,7 +123,7 @@ public:
///! Get the CMake instance ///! Get the CMake instance
cmake *GetCMakeInstance() { return this->CMakeInstance; }; cmake *GetCMakeInstance() { return this->CMakeInstance; };
void SetConfiguredFilesPath(const char* s){this->ConfiguredFilesPath = s;} void SetConfiguredFilesPath(cmGlobalGenerator* gen);
const std::vector<cmLocalGenerator *>& GetLocalGenerators() const { const std::vector<cmLocalGenerator *>& GetLocalGenerators() const {
return this->LocalGenerators;} return this->LocalGenerators;}

View File

@ -1,4 +1,13 @@
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
project(TryCompileInner C) project(TryCompileInner C)
try_compile(SHOULD_PASS
${TryCompileInner_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
${TryCompileInner_SOURCE_DIR}/../pass.c
OUTPUT_VARIABLE TRY_OUT
)
if(NOT SHOULD_PASS)
message(FATAL_ERROR "Inner try-compile SHOULD_PASS failed!")
endif()
add_executable(inner ../pass.c) add_executable(inner ../pass.c)