diff options
22 files changed, 140 insertions, 80 deletions
diff --git a/Modules/Compiler/NAG-Fortran.cmake b/Modules/Compiler/NAG-Fortran.cmake index 9a89746..18f141e 100644 --- a/Modules/Compiler/NAG-Fortran.cmake +++ b/Modules/Compiler/NAG-Fortran.cmake @@ -32,3 +32,4 @@ set(CMAKE_Fortran_MODDIR_FLAG "-mdir ") set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-PIC") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") +set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-PIC") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 384c26b..fdf42bb 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130219) +set(CMake_VERSION_TWEAK 20130225) #set(CMake_VERSION_RC 1) diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 4231243..3d5b24b 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -584,23 +584,15 @@ bool cmCacheManager::DeleteCache(const char* path) cmSystemTools::ConvertToUnixSlashes(cacheFile); std::string cmakeFiles = cacheFile; cacheFile += "/CMakeCache.txt"; - cmSystemTools::RemoveFile(cacheFile.c_str()); - // now remove the files in the CMakeFiles directory - // this cleans up language cache files - cmsys::Directory dir; - cmakeFiles += cmake::GetCMakeFilesDirectory(); - dir.Load(cmakeFiles.c_str()); - for (unsigned long fileNum = 0; - fileNum < dir.GetNumberOfFiles(); - ++fileNum) - { - if(!cmSystemTools:: - FileIsDirectory(dir.GetFile(fileNum))) + if(cmSystemTools::FileExists(cacheFile.c_str())) + { + cmSystemTools::RemoveFile(cacheFile.c_str()); + // now remove the files in the CMakeFiles directory + // this cleans up language cache files + cmakeFiles += cmake::GetCMakeFilesDirectory(); + if(cmSystemTools::FileIsDirectory(cmakeFiles.c_str())) { - std::string fullPath = cmakeFiles; - fullPath += "/"; - fullPath += dir.GetFile(fileNum); - cmSystemTools::RemoveFile(fullPath.c_str()); + cmSystemTools::RemoveADirectory(cmakeFiles.c_str()); } } return true; diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index cb15c30..9f3af71 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -41,11 +41,8 @@ void cmGlobalVisualStudio6Generator bool optional) { cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf); - mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); - mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); - mf->AddDefinition("CMAKE_GENERATOR_Fortran", "ifort"); this->GenerateConfigurations(mf); this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 71d79a1..154aa32 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -27,11 +27,8 @@ void cmGlobalVisualStudio7Generator ::EnableLanguage(std::vector<std::string>const & lang, cmMakefile *mf, bool optional) { - mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); - mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); - mf->AddDefinition("CMAKE_GENERATOR_FC", "ifort"); this->AddPlatformDefinitions(mf); // Create list of configurations requested by user's cache, if any. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 9600771..fbddc53 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -237,8 +237,6 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const& cmCacheManager::STRING); } } - mf->AddDefinition("CMAKE_GENERATOR_CC", "gcc"); - mf->AddDefinition("CMAKE_GENERATOR_CXX", "g++"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); if(!this->PlatformToolset.empty()) { @@ -956,6 +954,15 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen) } //---------------------------------------------------------------------------- +struct cmSourceFilePathCompare +{ + bool operator()(cmSourceFile* l, cmSourceFile* r) + { + return l->GetFullPath() < r->GetFullPath(); + } +}; + +//---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, std::vector<cmXCodeObject*>& @@ -981,7 +988,9 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, } // organize the sources - std::vector<cmSourceFile*> const &classes = cmtarget.GetSourceFiles(); + std::vector<cmSourceFile*> classes = cmtarget.GetSourceFiles(); + std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare()); + std::vector<cmXCodeObject*> externalObjFiles; std::vector<cmXCodeObject*> headerFiles; std::vector<cmXCodeObject*> resourceFiles; @@ -2517,47 +2526,25 @@ std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name, void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target, cmXCodeObject* dependTarget) { - // make sure a target does not depend on itself - if(target == dependTarget) - { - return; - } - // now avoid circular references if dependTarget already - // depends on target then skip it. Circular references crashes - // xcode - cmXCodeObject* dependTargetDepends = - dependTarget->GetObject("dependencies"); - if(dependTargetDepends) - { - if(dependTargetDepends->HasObject(target->GetPBXTargetDependency())) - { - return; - } - } - - cmXCodeObject* targetdep = dependTarget->GetPBXTargetDependency(); - if(!targetdep) - { - cmXCodeObject* container = - this->CreateObject(cmXCodeObject::PBXContainerItemProxy); - container->SetComment("PBXContainerItemProxy"); - container->AddAttribute("containerPortal", - this->CreateObjectReference(this->RootObject)); - container->AddAttribute("proxyType", this->CreateString("1")); - container->AddAttribute("remoteGlobalIDString", - this->CreateObjectReference(dependTarget)); - container->AddAttribute("remoteInfo", - this->CreateString( - dependTarget->GetTarget()->GetName())); - targetdep = - this->CreateObject(cmXCodeObject::PBXTargetDependency); - targetdep->SetComment("PBXTargetDependency"); - targetdep->AddAttribute("target", - this->CreateObjectReference(dependTarget)); - targetdep->AddAttribute("targetProxy", - this->CreateObjectReference(container)); - dependTarget->SetPBXTargetDependency(targetdep); - } + // This is called once for every edge in the target dependency graph. + cmXCodeObject* container = + this->CreateObject(cmXCodeObject::PBXContainerItemProxy); + container->SetComment("PBXContainerItemProxy"); + container->AddAttribute("containerPortal", + this->CreateObjectReference(this->RootObject)); + container->AddAttribute("proxyType", this->CreateString("1")); + container->AddAttribute("remoteGlobalIDString", + this->CreateObjectReference(dependTarget)); + container->AddAttribute("remoteInfo", + this->CreateString( + dependTarget->GetTarget()->GetName())); + cmXCodeObject* targetdep = + this->CreateObject(cmXCodeObject::PBXTargetDependency); + targetdep->SetComment("PBXTargetDependency"); + targetdep->AddAttribute("target", + this->CreateObjectReference(dependTarget)); + targetdep->AddAttribute("targetProxy", + this->CreateObjectReference(container)); cmXCodeObject* depends = target->GetObject("dependencies"); if(!depends) @@ -2914,7 +2901,7 @@ cmXCodeObject* cmGlobalXCodeGenerator { std::vector<std::string> folders = cmSystemTools::tokenize(sg->GetFullName(), "\\"); - cmStdString curr_folder = cmtarget.GetName(); + cmStdString curr_folder = target; curr_folder += "/"; for(std::vector<std::string>::size_type i = 0; i < folders.size();i++) { diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index de150ee..6abf6bf 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -38,7 +38,6 @@ cmXCodeObject::~cmXCodeObject() cmXCodeObject::cmXCodeObject(PBXType ptype, Type type) { this->Version = 15; - this->PBXTargetDependencyValue = 0; this->Target = 0; this->Object =0; diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index bb2d5b2..b89f78c 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -120,14 +120,6 @@ public: return 0; } - cmXCodeObject* GetPBXTargetDependency() - { - return this->PBXTargetDependencyValue; - } - void SetPBXTargetDependency(cmXCodeObject* d) - { - this->PBXTargetDependencyValue = d; - } void CopyAttributes(cmXCodeObject* ); void AddDependLibrary(const char* configName, @@ -170,7 +162,6 @@ protected: cmStdString Comment; cmStdString String; cmXCodeObject* Object; - cmXCodeObject* PBXTargetDependencyValue; std::vector<cmXCodeObject*> List; std::map<cmStdString, StringVec> DependLibraries; std::map<cmStdString, StringVec> DependTargets; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 320ebcc..c55bb3a 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -52,6 +52,9 @@ if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 3) endif() add_RunCMake_test(CMP0019) +if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") + add_RunCMake_test(CompilerChange) +endif() add_RunCMake_test(ExternalData) add_RunCMake_test(GeneratorExpression) add_RunCMake_test(GeneratorToolset) diff --git a/Tests/RunCMake/CompilerChange/CMakeLists.txt b/Tests/RunCMake/CompilerChange/CMakeLists.txt new file mode 100644 index 0000000..3b92518 --- /dev/null +++ b/Tests/RunCMake/CompilerChange/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 2.8) +if(NOT RunCMake_TEST) + set(RunCMake_TEST "$ENV{RunCMake_TEST}") # needed when cache is deleted +endif() +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CompilerChange/EmptyCompiler-result.txt b/Tests/RunCMake/CompilerChange/EmptyCompiler-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompilerChange/EmptyCompiler-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompilerChange/EmptyCompiler-stderr.txt b/Tests/RunCMake/CompilerChange/EmptyCompiler-stderr.txt new file mode 100644 index 0000000..4745b25 --- /dev/null +++ b/Tests/RunCMake/CompilerChange/EmptyCompiler-stderr.txt @@ -0,0 +1,5 @@ +You have changed variables that require your cache to be deleted. +Configure will be re-run and you may have to reset some variables. +The following variables have changed: +CMAKE_C_COMPILER= *( +|$) diff --git a/Tests/RunCMake/CompilerChange/EmptyCompiler.cmake b/Tests/RunCMake/CompilerChange/EmptyCompiler.cmake new file mode 100644 index 0000000..c87ec49 --- /dev/null +++ b/Tests/RunCMake/CompilerChange/EmptyCompiler.cmake @@ -0,0 +1,3 @@ +enable_language(C) +message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n") diff --git a/Tests/RunCMake/CompilerChange/FindCompiler.cmake b/Tests/RunCMake/CompilerChange/FindCompiler.cmake new file mode 100644 index 0000000..297ab2f --- /dev/null +++ b/Tests/RunCMake/CompilerChange/FindCompiler.cmake @@ -0,0 +1,2 @@ +enable_language(C) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n") diff --git a/Tests/RunCMake/CompilerChange/FirstCompiler-stdout.txt b/Tests/RunCMake/CompilerChange/FirstCompiler-stdout.txt new file mode 100644 index 0000000..17621b7 --- /dev/null +++ b/Tests/RunCMake/CompilerChange/FirstCompiler-stdout.txt @@ -0,0 +1 @@ +-- CMAKE_C_COMPILER is ".*/Tests/RunCMake/CompilerChange/cc1.sh" diff --git a/Tests/RunCMake/CompilerChange/FirstCompiler.cmake b/Tests/RunCMake/CompilerChange/FirstCompiler.cmake new file mode 100644 index 0000000..c87ec49 --- /dev/null +++ b/Tests/RunCMake/CompilerChange/FirstCompiler.cmake @@ -0,0 +1,3 @@ +enable_language(C) +message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n") diff --git a/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake b/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake new file mode 100644 index 0000000..d383716 --- /dev/null +++ b/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake @@ -0,0 +1,58 @@ +include(RunCMake) + +# Detect the compiler in use in the current environment. +run_cmake(FindCompiler) +include(${RunCMake_BINARY_DIR}/FindCompiler-build/cc.cmake) +if(NOT CMAKE_C_COMPILER) + message(FATAL_ERROR "FindCompiler provided no compiler!") +endif() +if(NOT IS_ABSOLUTE "${CMAKE_C_COMPILER}") + message(FATAL_ERROR "FindCompiler provided non-absolute path \"${CMAKE_C_COMPILER}\"!") +endif() +if(NOT EXISTS "${CMAKE_C_COMPILER}") + message(FATAL_ERROR "FindCompiler provided non-existing path \"${CMAKE_C_COMPILER}\"!") +endif() + +# Now that we have the full compiler path, hide CC. +unset(ENV{CC}) + +# Wrap around the real compiler so we can change the compiler +# path without changing the underlying compiler. +set(ccIn ${RunCMake_SOURCE_DIR}/cc.sh.in) +set(cc1 ${RunCMake_BINARY_DIR}/cc1.sh) +set(cc2 ${RunCMake_BINARY_DIR}/cc2.sh) +set(cc3 CMAKE_C_COMPILER-NOTFOUND) +configure_file(${ccIn} ${cc1} @ONLY IMMEDIATE) +configure_file(${ccIn} ${cc2} @ONLY IMMEDIATE) + +# Use a single build tree for remaining tests without cleaning. +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ChangeCompiler-build) +set(RunCMake_TEST_NO_CLEAN 1) +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + +# Check build with compiler wrapper 1. +set(RunCMake_TEST_OPTIONS -DCMAKE_C_COMPILER=${cc1}) +set(ENV{RunCMake_TEST} "FirstCompiler") +run_cmake(FirstCompiler) +include(${RunCMake_TEST_BINARY_DIR}/cc.cmake) +if(NOT "${CMAKE_C_COMPILER}" STREQUAL "${cc1}") + message(FATAL_ERROR "FirstCompiler built with compiler:\n ${CMAKE_C_COMPILER}\nand not with:\n ${cc1}") +endif() + +# Check rebuild with compiler wrapper 2. +set(RunCMake_TEST_OPTIONS -DCMAKE_C_COMPILER=${cc2}) +set(ENV{RunCMake_TEST} "SecondCompiler") +run_cmake(SecondCompiler) +include(${RunCMake_TEST_BINARY_DIR}/cc.cmake) +if(NOT "${CMAKE_C_COMPILER}" STREQUAL "${cc2}") + message(FATAL_ERROR "SecondCompiler built with compiler:\n ${CMAKE_C_COMPILER}\nand not with:\n ${cc2}") +endif() + +# Check failure with an empty compiler string. +set(RunCMake_TEST_OPTIONS -DCMAKE_C_COMPILER=) +set(ENV{RunCMake_TEST} "EmptyCompiler") +run_cmake(EmptyCompiler) +include(${RunCMake_TEST_BINARY_DIR}/cc.cmake) +if(NOT "${CMAKE_C_COMPILER}" STREQUAL "${cc3}") + message(FATAL_ERROR "Empty built with compiler:\n ${CMAKE_C_COMPILER}\nand not with:\n ${cc3}") +endif() diff --git a/Tests/RunCMake/CompilerChange/SecondCompiler-stderr.txt b/Tests/RunCMake/CompilerChange/SecondCompiler-stderr.txt new file mode 100644 index 0000000..3a01c53 --- /dev/null +++ b/Tests/RunCMake/CompilerChange/SecondCompiler-stderr.txt @@ -0,0 +1,4 @@ +You have changed variables that require your cache to be deleted. +Configure will be re-run and you may have to reset some variables. +The following variables have changed: +CMAKE_C_COMPILER=.*/Tests/RunCMake/CompilerChange/cc2.sh diff --git a/Tests/RunCMake/CompilerChange/SecondCompiler-stdout.txt b/Tests/RunCMake/CompilerChange/SecondCompiler-stdout.txt new file mode 100644 index 0000000..26ca964 --- /dev/null +++ b/Tests/RunCMake/CompilerChange/SecondCompiler-stdout.txt @@ -0,0 +1 @@ +-- CMAKE_C_COMPILER is ".*/Tests/RunCMake/CompilerChange/cc2.sh" diff --git a/Tests/RunCMake/CompilerChange/SecondCompiler.cmake b/Tests/RunCMake/CompilerChange/SecondCompiler.cmake new file mode 100644 index 0000000..c87ec49 --- /dev/null +++ b/Tests/RunCMake/CompilerChange/SecondCompiler.cmake @@ -0,0 +1,3 @@ +enable_language(C) +message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n") diff --git a/Tests/RunCMake/CompilerChange/cc.sh.in b/Tests/RunCMake/CompilerChange/cc.sh.in new file mode 100755 index 0000000..1d400e6 --- /dev/null +++ b/Tests/RunCMake/CompilerChange/cc.sh.in @@ -0,0 +1,2 @@ +#!/bin/sh +exec "@CMAKE_C_COMPILER@" "$@" diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 40b98d4..00faa4c 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -26,8 +26,12 @@ function(run_cmake test) endif() endforeach() set(RunCMake_TEST_SOURCE_DIR "${top_src}") - set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build") - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + if(NOT RunCMake_TEST_BINARY_DIR) + set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build") + endif() + if(NOT RunCMake_TEST_NO_CLEAN) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + endif() file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") if(NOT DEFINED RunCMake_TEST_OPTIONS) set(RunCMake_TEST_OPTIONS "") |