From b976e70063008c0633cb5dd4ecb1f40278c67935 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 2 Jul 2011 17:08:34 +0200 Subject: [PATCH 001/539] Make clLocalGenerator::GetTargetFlags() public This will later on be used for getting the link flags Alex --- Source/cmLocalGenerator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index aebf9f39a30..a204a73d5f3 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -307,7 +307,6 @@ class cmLocalGenerator std::string const& dir_max, bool* hasSourceExtension = 0); -protected: /** Fill out these strings for the given target. Libraries to link, * flags, and linkflags. */ void GetTargetFlags(std::string& linkLibs, @@ -315,6 +314,7 @@ class cmLocalGenerator std::string& linkFlags, cmTarget&target); +protected: ///! put all the libraries for a target on into the given stream virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink); From a91d662f46fd2781fc5a3b73c2d244ac6dc2a343 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 2 Jul 2011 17:50:05 +0200 Subject: [PATCH 002/539] Add find-package mode, which does nothing yet -add command line argument --find-package and handle it, i.e. call an empty function cmake::FindPackage() -add basic help Alex --- Source/cmMakefile.cxx | 4 +++- Source/cmake.cxx | 25 +++++++++++++++++++++++++ Source/cmake.h | 5 +++++ Source/cmakemain.cxx | 13 ++++++++++++- 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 63bf03bdda4..163145eb78a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -384,7 +384,9 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, // Decide whether to invoke the command. if(pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() && - (!this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable())) + (this->GetCMakeInstance()->GetFindPackageMode() + || !this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable())) + { // if trace is one, print out invoke information if(this->GetCMakeInstance()->GetTrace()) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 45927cb049c..3d42c7fa4ec 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -181,6 +181,7 @@ cmake::cmake() this->ProgressCallback = 0; this->ProgressCallbackClientData = 0; this->ScriptMode = false; + this->FindPackageMode = false; #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch = new cmVariableWatch; @@ -353,6 +354,7 @@ void cmake::RemoveUnscriptableCommands() // Parse the args bool cmake::SetCacheArgs(const std::vector& args) { + bool findPackageMode = false; for(unsigned int i=1; i < args.size(); ++i) { std::string arg = args[i]; @@ -480,7 +482,17 @@ bool cmake::SetCacheArgs(const std::vector& args) } this->ReadListFile(args, path.c_str()); } + else if (arg.find("--find-package",0) == 0) + { + findPackageMode = true; + } + } + + if (findPackageMode) + { + return this->FindPackage(args); } + return true; } @@ -532,6 +544,14 @@ void cmake::ReadListFile(const std::vector& args, } } + +bool cmake::FindPackage(const std::vector& args) +{ + // create empty function for now, will be filled later + return true; +} + + // Parse the args void cmake::SetArgs(const std::vector& args, bool directoriesSetBefore) @@ -604,6 +624,11 @@ void cmake::SetArgs(const std::vector& args, // skip for now i++; } + else if(arg.find("--find-package",0) == 0) + { + // skip for now + i++; + } else if(arg.find("-Wno-dev",0) == 0) { // skip for now diff --git a/Source/cmake.h b/Source/cmake.h index fac86c18e0d..7335813bc00 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -282,6 +282,9 @@ class cmake void SetScriptMode(bool mode) { this->ScriptMode = mode; } bool GetScriptMode() { return this->ScriptMode; } + void SetFindPackageMode(bool mode) {this->FindPackageMode = mode; } + bool GetFindPackageMode() {return this->FindPackageMode;} + ///! Debug the try compile stuff by not delelting the files bool GetDebugTryCompile(){return this->DebugTryCompile;} void DebugTryCompileOn(){this->DebugTryCompile = true;} @@ -407,6 +410,7 @@ class cmake ///! read in a cmake list file to initialize the cache void ReadListFile(const std::vector& args, const char *path); + bool FindPackage(const std::vector& args); ///! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file. /// If it is set, truncate it to 50kb @@ -461,6 +465,7 @@ class cmake bool Verbose; bool InTryCompile; bool ScriptMode; + bool FindPackageMode; bool DebugOutput; bool Trace; bool WarnUninitialized; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 663ce8f07fc..ae4529a4428 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -102,6 +102,9 @@ static const char * cmDocumentationOptions[][3] = "No configure or generate step is performed and the cache is not" " modified. If variables are defined using -D, this must be done " "before the -P argument."}, + {"--find-package", "Run in pkg-config like mode.", + "Search a package using find_package() and print the resulting flags " + "to stdout. "}, {"--graphviz=[file]", "Generate graphviz of dependencies.", "Generate a graphviz input file that will contain all the library and " "executable dependencies in the project."}, @@ -434,6 +437,7 @@ int do_cmake(int ac, char** av) bool list_help = false; bool view_only = false; bool script_mode = false; + bool find_package_mode = false; std::vector args; for(int i =0; i < ac; ++i) { @@ -487,6 +491,12 @@ int do_cmake(int ac, char** av) args.push_back(av[i]); } } + else if (!command && strncmp(av[i], "--find-package", + strlen("--find-package")) == 0) + { + find_package_mode = true; + args.push_back(av[i]); + } else { args.push_back(av[i]); @@ -511,7 +521,8 @@ int do_cmake(int ac, char** av) cmake cm; cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm); cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm); - cm.SetScriptMode(script_mode); + cm.SetScriptMode(script_mode || find_package_mode); + cm.SetFindPackageMode(find_package_mode); int res = cm.Run(args, view_only); if ( list_cached || list_all_cached ) From e4f603b698a13857e79a5f6df18a7461b20d4bd4 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 2 Jul 2011 23:14:28 +0200 Subject: [PATCH 003/539] Implement find-package mode of cmake In find-package mode, cmake executes Modules/CMakeFindPackage.cmake, which calls find_package(), and this is then evaluated in cmake.cxx, which prints an appropriate message to stdout, so it can be used e.g. in a normal Makefile: $ /opt/cmake-HEAD/bin/cmake --find-package -DNAME=JPEG -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=EXIST JPEG found. $ /opt/cmake-HEAD/bin/cmake --find-package -DNAME=JPEG -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=COMPILE $ /opt/cmake-HEAD/bin/cmake --find-package -DNAME=JPEG -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK -rdynamic -ljpeg Alex --- Modules/CMakeFindPackageMode.cmake | 125 +++++++++++++++++++++++++++++ Source/cmake.cxx | 100 ++++++++++++++++++++++- 2 files changed, 223 insertions(+), 2 deletions(-) create mode 100644 Modules/CMakeFindPackageMode.cmake diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake new file mode 100644 index 00000000000..5842c7aefae --- /dev/null +++ b/Modules/CMakeFindPackageMode.cmake @@ -0,0 +1,125 @@ +# COMPILER_ID = GNU/Intel/etc. +# LANGUAGE = C/CXX/Fortan/ASM +# MODE = EXIST/COMPILE/LINK +# NAME = name of the package +# QUIET = if TRUE, don't print anything + +if(NOT NAME) + message(FATAL_ERROR "NAME argument not specified.") +endif() + +if(NOT COMPILER_ID) + message(FATAL_ERROR "COMPILER_ID argument not specified. In doubt, use GNU.") +endif() + +if(NOT LANGUAGE) + message(FATAL_ERROR "LANGUAGE argument not specified. Use C, CXX or Fortran.") +endif() + +if(NOT MODE) + message(FATAL_ERROR "MODE argument not specified. Use either EXIST, COMPILE or LINK.") +endif() + + +include(CMakeDetermineSystem) + +# Also load the system specific file, which sets up e.g. the search paths. +# This makes the FIND_XXX() calls work much better +include(CMakeSystemSpecificInformation) + +# this is ugly, and not enough for the multilib-stuff I guess +if(UNIX AND EXISTS /usr/lib64) + set(CMAKE_SIZEOF_VOID_P 8) +endif() + +set(CMAKE_${LANGUAGE}_COMPILER "dummy") +set(CMAKE_${LANGUAGE}_COMPILER_ID "${COMPILER_ID}") +include(CMake${LANGUAGE}Information) + + +function(print_compile_flags _packageName) + string(TOUPPER "${_packageName}" PACKAGE_NAME) + # Check the following variables: + # FOO_INCLUDE_DIRS + # Foo_INCLUDE_DIRS + # FOO_INCLUDES + # Foo_INCLUDES + # FOO_INCLUDE_DIR + # Foo_INCLUDE_DIR + set(includes) + if(DEFINED ${_packageName}_INCLUDE_DIRS) + set(includes ${_packageName}_INCLUDE_DIRS) + elseif(DEFINED ${PACKAGE_NAME}_INCLUDE_DIRS) + set(includes ${PACKAGE_NAME}_INCLUDE_DIRS) + elseif(DEFINED ${_packageName}_INCLUDES) + set(includes ${_packageName}_INCLUDES) + elseif(DEFINED ${PACKAGE_NAME}_INCLUDES) + set(includes ${PACKAGE_NAME}_INCLUDES) + elseif(DEFINED ${_packageName}_INCLUDE_DIR) + set(includes ${_packageName}_INCLUDE_DIR) + elseif(DEFINED ${PACKAGE_NAME}_INCLUDE_DIR) + set(includes ${PACKAGE_NAME}_INCLUDE_DIR) + endif() + + set(PACKAGE_INCLUDE_DIRS "${${includes}}" PARENT_SCOPE) + + # Check the following variables: + # FOO_DEFINITIONS + # Foo_DEFINITIONS + set(definitions) + if(DEFINED ${_packageName}_DEFINITIONS) + set(definitions ${_packageName}_DEFINITIONS) + elseif(DEFINED ${PACKAGE_NAME}_DEFINITIONS) + set(definitions ${PACKAGE_NAME}_DEFINITIONS) + endif() + + set(PACKAGE_DEFINITIONS "${${definitions}}" ) + +endfunction() + + +function(print_link_flags _packageName) + string(TOUPPER "${_packageName}" PACKAGE_NAME) + # Check the following variables: + # FOO_LIBRARIES + # Foo_LIBRARIES + # FOO_LIBS + # Foo_LIBS + set(libs) + if(DEFINED ${_packageName}_LIBRARIES) + set(libs ${_packageName}_LIBRARIES) + elseif(DEFINED ${PACKAGE_NAME}_LIBRARIES) + set(libs ${PACKAGE_NAME}_LIBRARIES) + elseif(DEFINED ${_packageName}_LIBS) + set(libs ${_packageName}_LIBS) + elseif(DEFINED ${PACKAGE_NAME}_LIBS) + set(libs ${PACKAGE_NAME}_LIBS) + endif() + + set(PACKAGE_LIBRARIES "${${libs}}" PARENT_SCOPE ) + +endfunction() + + +find_package("${NAME}" QUIET) + +set(PACKAGE_FOUND FALSE) + +string(TOUPPER "${NAME}" UPPERCASE_NAME) + +if(${NAME}_FOUND OR ${UPPERCASE_NAME}_FOUND) + set(PACKAGE_FOUND TRUE) + + if("${MODE}" STREQUAL "EXIST") + # do nothing + elseif("${MODE}" STREQUAL "COMPILE") + print_compile_flags(${NAME}) + elseif("${MODE}" STREQUAL "LINK") + print_link_flags(${NAME}) + else("${MODE}" STREQUAL "LINK") + message(FATAL_ERROR "Invalid mode argument ${MODE} given.") + endif() + +endif() + +set(PACKAGE_QUIET ${SILENT} ) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 3d42c7fa4ec..5b6286eec9b 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -547,8 +547,104 @@ void cmake::ReadListFile(const std::vector& args, bool cmake::FindPackage(const std::vector& args) { - // create empty function for now, will be filled later - return true; + // if a generator was not yet created, temporarily create one + cmGlobalGenerator *gg = new cmGlobalGenerator; + gg->SetCMakeInstance(this); + this->SetGlobalGenerator(gg); + + // read in the list file to fill the cache + std::auto_ptr lg(gg->CreateLocalGenerator()); + cmMakefile* mf = lg->GetMakefile(); + mf->SetHomeOutputDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + mf->SetStartOutputDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + mf->SetHomeDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + mf->SetStartDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + + mf->SetArgcArgv(args); + + std::string systemFile = mf->GetModulesFile("CMakeFindPackageMode.cmake"); + mf->ReadListFile(0, systemFile.c_str()); + + std::string language = mf->GetSafeDefinition("LANGUAGE"); + std::string mode = mf->GetSafeDefinition("MODE"); + std::string packageName = mf->GetSafeDefinition("NAME"); + bool packageFound = mf->IsOn("PACKAGE_FOUND"); + bool quiet = mf->IsOn("PACKAGE_QUIET"); + + if (!packageFound) + { + if (!quiet) + { + printf("%s not found.\n", packageName.c_str()); + } + } + else if (mode == "EXIST") + { + if (!quiet) + { + printf("%s found.\n", packageName.c_str()); + } + } + else if (mode == "COMPILE") + { + std::string includes = mf->GetSafeDefinition("PACKAGE_INCLUDE_DIRS"); + std::vector includeDirs; + cmSystemTools::ExpandListArgument(includes, includeDirs); + for(std::vector::const_iterator dirIt=includeDirs.begin(); + dirIt != includeDirs.end(); + ++dirIt) + { + mf->AddIncludeDirectory(dirIt->c_str(), false); + } + + std::string includeFlags = lg->GetIncludeFlags(language.c_str(), false); + std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS"); + printf("%s %s\n", includeFlags.c_str(), definitions.c_str()); + } + else if (mode == "LINK") + { + const char* targetName = "dummy"; + std::vector srcs; + cmTarget* tgt = mf->AddExecutable(targetName, srcs, true); + tgt->SetProperty("LINKER_LANGUAGE", language.c_str()); + + std::string libs = mf->GetSafeDefinition("PACKAGE_LIBRARIES"); + std::vector libList; + cmSystemTools::ExpandListArgument(libs, libList); + for(std::vector::const_iterator libIt=libList.begin(); + libIt != libList.end(); + ++libIt) + { + mf->AddLinkLibraryForTarget(targetName, libIt->c_str(), cmTarget::GENERAL); + } + + + std::string linkLibs; + std::string flags; + std::string linkFlags; + lg->GetTargetFlags(linkLibs, flags, linkFlags, *tgt); + + printf("%s\n", linkLibs.c_str() ); + +/* if ( use_win32 ) + { + tgt->SetProperty("WIN32_EXECUTABLE", "ON"); + } + if ( use_macbundle) + { + tgt->SetProperty("MACOSX_BUNDLE", "ON"); + }*/ + } + + // free generic one if generated +// this->SetGlobalGenerator(0); // setting 0-pointer is not possible +// delete gg; // this crashes inside the cmake instance + + return packageFound; } From 6c72d25aee92c6cd412c79969b7b18a814ac99cb Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 8 Jul 2011 17:08:43 -0400 Subject: [PATCH 004/539] Initial support for Intel Fortran VS2010. --- Source/cmLocalVisualStudio10Generator.cxx | 16 ++++++++++++---- Source/cmLocalVisualStudio7Generator.h | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 1850c1688db..ef378f9fcf6 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -93,10 +93,18 @@ void cmLocalVisualStudio10Generator::Generate() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { - cmVisualStudio10TargetGenerator tg( - &l->second, static_cast( - this->GetGlobalGenerator())); - tg.Generate(); + if(static_cast(this->GlobalGenerator) + ->TargetIsFortranOnly(l->second)) + { + this->CreateSingleVCProj(l->first.c_str(),l->second); + } + else + { + cmVisualStudio10TargetGenerator tg( + &l->second, static_cast( + this->GetGlobalGenerator())); + tg.Generate(); + } } this->WriteStampFiles(); } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 160e2d49313..8f7c7eb052e 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -75,6 +75,8 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator virtual void ReadAndStoreExternalGUID(const char* name, const char* path); +protected: + void CreateSingleVCProj(const char *lname, cmTarget &tgt); private: typedef cmVisualStudioGeneratorOptions Options; typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo; @@ -85,7 +87,6 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator void WriteVCProjHeader(std::ostream& fout, const char *libName, cmTarget &tgt, std::vector &sgs); void WriteVCProjFooter(std::ostream& fout); - void CreateSingleVCProj(const char *lname, cmTarget &tgt); void WriteVCProjFile(std::ostream& fout, const char *libName, cmTarget &tgt); void WriteConfigurations(std::ostream& fout, From d216a67e4a41d443d97f9e3b0470b21d1c822b3d Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 1 Aug 2011 22:59:18 +0200 Subject: [PATCH 005/539] Provide macro write_basic_config_version_file() This macro can be used to generate basic version files which can be installed along a Config.cmake file to provide versioning support. This (3rd try) is implemented using a macro, which maps the COMPATIBILITY mode to a filename and configure_file()s the resulting file. Alex --- ...asicConfigVersion-AnyNewerVersion.cmake.in | 29 +++++++++++ ...sicConfigVersion-SameMajorVersion.cmake.in | 43 ++++++++++++++++ Modules/WriteBasicConfigVersionFile.cmake | 49 +++++++++++++++++++ Source/cmFindPackageCommand.cxx | 3 ++ 4 files changed, 124 insertions(+) create mode 100644 Modules/BasicConfigVersion-AnyNewerVersion.cmake.in create mode 100644 Modules/BasicConfigVersion-SameMajorVersion.cmake.in create mode 100644 Modules/WriteBasicConfigVersionFile.cmake diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in new file mode 100644 index 00000000000..600deb1a6d3 --- /dev/null +++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in @@ -0,0 +1,29 @@ +# This is a basic file for the new style find_package() search mode, +# i.e. Config-mode. +# It is used by WriteBasicConfigVersionFile.cmake as input file for configure_file() +# to create a version-file which can be installed along a config.cmake file. +# +# The created file sets PACKAGE_VERSION_EXACT if the current version string and +# the requested version string are exactly the same and it sets +# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version. +# The variable CVF_VERSION must be set before calling configure_file(). + +set(PACKAGE_VERSION "@CVF_VERSION@") + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@") + math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + + if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() + endif() + +endif() \ No newline at end of file diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in new file mode 100644 index 00000000000..b41ffba403b --- /dev/null +++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in @@ -0,0 +1,43 @@ +# This is a basic file for the new style find_package() search mode, +# i.e. Config-mode. +# It is used by WriteBasicConfigVersionFile.cmake as input file for configure_file() +# to create a version-file which can be installed along a config.cmake file. +# +# The created file sets PACKAGE_VERSION_EXACT if the current version string and +# the requested version string are exactly the same and it sets +# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version, +# but only if the requested major version is the same as the current one. +# The variable CVF_VERSION must be set before calling configure_file(). + + +set(PACKAGE_VERSION "@CVF_VERSION@") + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@") + math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + + if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + else() + + if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.") + set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") + else() + set(CVF_VERSION_MAJOR "@CVF_VERSION@") + endif() + + if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${CVF_VERSION_MAJOR}") + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() + endif() + +endif() diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake new file mode 100644 index 00000000000..a6175c701d3 --- /dev/null +++ b/Modules/WriteBasicConfigVersionFile.cmake @@ -0,0 +1,49 @@ +# WRITE_BASIC_CONFIG_VERSION_FILE( filename VERSION major.minor.patch COMPATIBILITY (AnyNewerVersion|SameMajorVersion) ) +# +# Writes a file for use as ConfigVersion.cmake file to . +# See the documentation of FIND_PACKAGE() for details on this. +# filename is the output filename, it should be in the build tree. +# major.minor.patch is the version number of the project to be installed +# The COMPATIBILITY mode AnyNewerVersion means that the installed package version +# will be considered suitable if it is newer or exactly the same as the requested version. +# If SameMajorVersion is used instead, then the behaviour differs from AnyNewerVersion +# in that the major version number must be the same as requested, e.g. version 2.0 will +# not be considered suitable to 1.0 is requested. +# If you project has more elaborated version matching rules, you will need to write your +# own custom ConfigVersion.cmake file, instead of using this macro. +# +# Internally, this macro executes configure_file() on the input file +# Modules/BasicConfigVersion-AnyNewerVersion/SameMajorVersion.cmake.in to +# create the resulting version file. + +# Copyright (c) 2008, Alexander Neundorf, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +include(CMakeParseArguments) + +function(WRITE_BASIC_CONFIG_VERSION_FILE _filename) + + set(options ) + set(oneValueArgs VERSION COMPATIBILITY ) + set(multiValueArgs ) + + cmake_parse_arguments(CVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(CVF_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_UNPARSED_ARGUMENTS}\"") + endif(CVF_UNPARSED_ARGUMENTS) + + set(versionTemplateFile "${CMAKE_ROOT}/Modules/BasicConfigVersion-${CVF_COMPATIBILITY}.cmake.in") + if(NOT EXISTS "${versionTemplateFile}") + message(FATAL_ERROR "Bad COMPATIBILITY value used for WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_COMPATIBILITY}\"") + endif() + + if("${CVF_VERSION}" STREQUAL "") + message(FATAL_ERROR "No VERSION specified for WRITE_BASIC_CONFIG_VERSION_FILE()") + endif() + + configure_file("${versionTemplateFile}" "${_filename}" @ONLY) + +endfunction(WRITE_BASIC_CONFIG_VERSION_FILE) diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 9d1c220257e..feb8aa6a861 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -191,6 +191,9 @@ void cmFindPackageCommand::GenerateDocumentation() "\"-version.cmake\" or \"Version.cmake\". " "If no such version file is available then the configuration file " "is assumed to not be compatible with any requested version. " + "A basic version file containing generic version matching code can be " + "created using the macro write_basic_config_version_file(), see its " + "documentation for more details. " "When a version file is found it is loaded to check the requested " "version number. " "The version file is loaded in a nested scope in which the following " From 02b1e4b96a10b77e40dbc7f5e5d23ccd61a2b08b Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 1 Aug 2011 23:03:47 +0200 Subject: [PATCH 006/539] Add example to documentation Alex --- Modules/WriteBasicConfigVersionFile.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake index a6175c701d3..361eb601758 100644 --- a/Modules/WriteBasicConfigVersionFile.cmake +++ b/Modules/WriteBasicConfigVersionFile.cmake @@ -12,6 +12,13 @@ # If you project has more elaborated version matching rules, you will need to write your # own custom ConfigVersion.cmake file, instead of using this macro. # +# Example: +# write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake +# VERSION 1.2.3 +# COMPATIBILITY SameMajorVersion ) +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake +# DESTINATION lib/cmake/Foo ) +# # Internally, this macro executes configure_file() on the input file # Modules/BasicConfigVersion-AnyNewerVersion/SameMajorVersion.cmake.in to # create the resulting version file. From 4ba09bc6a22ab9aa3f59b6804224e3f96159658d Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 1 Aug 2011 23:29:27 +0200 Subject: [PATCH 007/539] Add some tests for write_basic_config_version_file() Alex --- ...asicConfigVersion-AnyNewerVersion.cmake.in | 2 + ...sicConfigVersion-SameMajorVersion.cmake.in | 2 + Tests/FindPackageTest/CMakeLists.txt | 80 +++++++++++++++++++ 3 files changed, 84 insertions(+) diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in index 600deb1a6d3..30749c47528 100644 --- a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in +++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in @@ -10,6 +10,8 @@ set(PACKAGE_VERSION "@CVF_VERSION@") +set(PACKAGE_VERSION_EXACT FALSE) # initialize to FALSE + # check that the installed version has the same 32/64bit-ness as the one which is currently searching: if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@") math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in index b41ffba403b..f633ee8b9e5 100644 --- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in @@ -12,6 +12,8 @@ set(PACKAGE_VERSION "@CVF_VERSION@") +set(PACKAGE_VERSION_EXACT FALSE) # initialize to FALSE + # check that the installed version has the same 32/64bit-ness as the one which is currently searching: if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@") math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 0169ac96a54..ca644403b12 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -303,3 +303,83 @@ SET(CMakeTestExportPackage_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) STRING(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION}) FIND_PACKAGE(CMakeTestExportPackage 1.${version} EXACT REQUIRED) + +#----------------------------------------------------------------------------- +# Test write_basic_config_version_file(). + +include(WriteBasicConfigVersionFile) + +write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake + VERSION 1.2.3 + COMPATIBILITY AnyNewerVersion) + +set(PACKAGE_FIND_VERSION 2.3.4) +include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Foo123 with version 1.2.3, but 2.3.4 was requested !") +endif() + +set(PACKAGE_FIND_VERSION 0.0.1) +include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (0.0.1 was requested) !") +endif() + +set(PACKAGE_FIND_VERSION 1.0.0) +include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.0.0 was requested) !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 1.2.3) +include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.2.3 was requested) !") +endif() +if(NOT PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !") +endif() + + +####################### + +write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake + VERSION 1.2.3 + COMPATIBILITY SameMajorVersion) + +set(PACKAGE_FIND_VERSION 2.3.4) +set(PACKAGE_FIND_VERSION_MAJOR 2) +include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Boo123 with version 1.2.3, but 2.3.4 was requested !") +endif() + +set(PACKAGE_FIND_VERSION 0.0.1) +set(PACKAGE_FIND_VERSION_MAJOR 0) +include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Boo123 with version 1.2.3, but 0.0.1 was requested !") +endif() + +set(PACKAGE_FIND_VERSION 1.0.0) +set(PACKAGE_FIND_VERSION_MAJOR 1) +include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.0.0 was requested) !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 1.2.3) +set(PACKAGE_FIND_VERSION_MAJOR 1) +include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.2.3 was requested) !") +endif() +if(NOT PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !") +endif() From d50a61a1ae6a530e3ebc2672c2e5e38b700d61e8 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 1 Aug 2011 23:44:17 +0200 Subject: [PATCH 008/539] Fix copyright notice Alex --- Modules/WriteBasicConfigVersionFile.cmake | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake index 361eb601758..d7947ab18c7 100644 --- a/Modules/WriteBasicConfigVersionFile.cmake +++ b/Modules/WriteBasicConfigVersionFile.cmake @@ -23,10 +23,19 @@ # Modules/BasicConfigVersion-AnyNewerVersion/SameMajorVersion.cmake.in to # create the resulting version file. -# Copyright (c) 2008, Alexander Neundorf, +#============================================================================= +# Copyright (c) 2008-2011, Alexander Neundorf, +# Copyright 2004-2009 Kitware, Inc. # -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) include(CMakeParseArguments) From bb03c2dd3a9afafd6c24ea12e16edf4f9189813f Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 1 Aug 2011 23:57:32 +0200 Subject: [PATCH 009/539] Really fix copyright notice Alex --- Modules/WriteBasicConfigVersionFile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake index d7947ab18c7..f0ad6ea6f3b 100644 --- a/Modules/WriteBasicConfigVersionFile.cmake +++ b/Modules/WriteBasicConfigVersionFile.cmake @@ -24,7 +24,7 @@ # create the resulting version file. #============================================================================= -# Copyright (c) 2008-2011, Alexander Neundorf, +# Copyright 2008-2011 Alexander Neundorf, # Copyright 2004-2009 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); From ad218e435d0f25d2022dc2d7b569ad88d10dc6d1 Mon Sep 17 00:00:00 2001 From: Will Dicharry Date: Tue, 2 Aug 2011 10:39:04 -0600 Subject: [PATCH 010/539] Added HDF5 high level Fortran bindings to available components. --- Modules/FindHDF5.cmake | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 6f01ea0b211..bc606389bd3 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -10,8 +10,8 @@ # are specified, then the find module will default to finding only the HDF5 C # library. If one or more COMPONENTS are specified, the module will attempt to # find the language bindings for the specified components. The only valid -# components are C, CXX, Fortran, and HL. If the COMPONENTS argument is not -# given, the module will attempt to find only the C bindings. +# components are C, CXX, Fortran, HL, and Fortran_HL. If the COMPONENTS +# argument is not given, the module will attempt to find only the C bindings. # # On UNIX systems, this module will read the variable HDF5_USE_STATIC_LIBRARIES # to determine whether or not to prefer a static link to a dynamic link for HDF5 @@ -34,6 +34,8 @@ # HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings # HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings # HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API +# HDF5_Fortran_HL_LIBRARIES - Required libraries for the high level Fortran +# bindings. # HDF5_LIBRARIES - Required libraries for all requested bindings # HDF5_FOUND - true if HDF5 was found on the system # HDF5_LIBRARY_DIRS - the full set of library directories @@ -67,6 +69,7 @@ set( HDF5_VALID_COMPONENTS CXX Fortran HL + Fortran_HL ) # Validate the list of find components. @@ -189,6 +192,7 @@ if( NOT HDF5_FOUND ) set( HDF5_CXX_TARGET hdf5_cpp ) set( HDF5_HL_TARGET hdf5_hl ) set( HDF5_Fortran_TARGET hdf5_fortran ) + set( HDF5_Fortran_HL_TARGET hdf5_hl_fortran ) foreach( _component ${HDF5_LANGUAGE_BINDINGS} ) list( FIND HDF5_VALID_COMPONENTS ${_component} _component_location ) get_target_property( _comp_location ${HDF5_${_component}_TARGET} LOCATION ) @@ -211,7 +215,10 @@ if( NOT HDF5_FOUND ) set( HDF5_C_LIBRARY_NAMES_INIT hdf5 ) set( HDF5_HL_LIBRARY_NAMES_INIT hdf5_hl ${HDF5_C_LIBRARY_NAMES_INIT} ) set( HDF5_CXX_LIBRARY_NAMES_INIT hdf5_cpp ${HDF5_C_LIBRARY_NAMES_INIT} ) - set( HDF5_Fortran_LIBRARY_NAMES_INIT hdf5_fortran ${HDF5_C_LIBRARY_NAMES_INIT} ) + set( HDF5_Fortran_LIBRARY_NAMES_INIT hdf5_fortran + ${HDF5_C_LIBRARY_NAMES_INIT} ) + set( HDF5_Fortran_HL_LIBRARY_NAMES_INIT hdf5hl_fortran + ${HDF5_Fortran_LIBRARY_NAMES_INIT} ) foreach( LANGUAGE ${HDF5_LANGUAGE_BINDINGS} ) if( HDF5_${LANGUAGE}_COMPILE_LINE ) @@ -222,8 +229,8 @@ if( NOT HDF5_FOUND ) HDF5_${LANGUAGE}_LIBRARY_NAMES ) - # take a guess that the includes may be in the 'include' sibling directory - # of a library directory. + # take a guess that the includes may be in the 'include' sibling + # directory of a library directory. foreach( dir ${HDF5_${LANGUAGE}_LIBRARY_DIRS} ) list( APPEND HDF5_${LANGUAGE}_INCLUDE_FLAGS ${dir}/../include ) endforeach() @@ -233,7 +240,7 @@ if( NOT HDF5_FOUND ) list( APPEND HDF5_DEFINITIONS ${HDF5_${LANGUAGE}_DEFINITIONS} ) # find the HDF5 include directories - if(${LANGUAGE} STREQUAL "Fortran") + if(${LANGUAGE} MATCHES "Fortran.*") set(HDF5_INCLUDE_FILENAME hdf5.mod) else() set(HDF5_INCLUDE_FILENAME hdf5.h) From ad542d821db91c89129630ace9342776c098d2f3 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 2 Aug 2011 17:26:29 -0400 Subject: [PATCH 011/539] XL: Fix old VisualAge branding of Fortran compiler Commit 6d434ee6 (Split XL compiler information files, 2009-09-30) added Platform/AIX-(XL|VisualAge)-(C|CXX|Fortran).cmake modules to support the old and new compiler branding for all languages. Add the "AIX-VisualAge-Fortran" combination that was left out accidentally. --- Modules/Platform/AIX-VisualAge-Fortran.cmake | 1 + 1 file changed, 1 insertion(+) create mode 100644 Modules/Platform/AIX-VisualAge-Fortran.cmake diff --git a/Modules/Platform/AIX-VisualAge-Fortran.cmake b/Modules/Platform/AIX-VisualAge-Fortran.cmake new file mode 100644 index 00000000000..19e59d6663e --- /dev/null +++ b/Modules/Platform/AIX-VisualAge-Fortran.cmake @@ -0,0 +1 @@ +include(Platform/AIX-XL-Fortran) From f46236949e8c981703fd4b0f7b32d588c888d98d Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 8 Apr 2011 07:56:39 +0200 Subject: [PATCH 012/539] remove extra output message from FindJava.cmake FPHSA already prints out the version number. And this line was printed on every subsequent CMake run. --- Modules/FindJava.cmake | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 1b11a345c2e..34a7077e818 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -130,11 +130,6 @@ IF(Java_JAVA_EXECUTABLE) else( ) set(Java_VERSION ${Java_VERSION_MAJOR}.${Java_VERSION_MINOR}.${Java_VERSION_PATCH}.${Java_VERSION_TWEAK}) endif( ) - # display info - #MESSAGE( STATUS "Java version ${Java_VERSION_STRING} configured successfully!" ) # keep me, used for debug - IF(NOT Java_FIND_QUIETLY) - MESSAGE( STATUS "Java version ${Java_VERSION} configured successfully!" ) - ENDIF(NOT Java_FIND_QUIETLY) ENDIF() ENDIF(Java_JAVA_EXECUTABLE) From ba4886b717d4c72f4b7c8960862ff44af187d114 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 3 Aug 2011 10:24:59 -0400 Subject: [PATCH 013/539] CTest: print failed tests in index order (#11746) This deterministic ordering makes it easier for a developer comparing the ctest output of two test runs to see what changed from run to run. Thanks to Fraser Hutchison for the patch. --- Source/CTest/cmCTestTestHandler.cxx | 10 +++++++--- Source/CTest/cmCTestTestHandler.h | 13 +++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index b824e47084c..078e4309821 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -33,6 +33,7 @@ #include #include // auto_ptr +#include //---------------------------------------------------------------------- class cmCTestSubdirCommand : public cmCommand @@ -617,9 +618,12 @@ int cmCTestTestHandler::ProcessHandler() << "The following tests FAILED:" << std::endl); this->StartLogFile("TestsFailed", ofs); - std::vector::iterator ftit; - for(ftit = this->TestResults.begin(); - ftit != this->TestResults.end(); ++ftit) + typedef std::set SetOfTests; + SetOfTests resultsSet(this->TestResults.begin(), this->TestResults.end()); + + for(SetOfTests::iterator ftit = resultsSet.begin(); + ftit != resultsSet.end(); ++ftit) { if ( ftit->Status != cmCTestTestHandler::COMPLETED ) { diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 3089d35d406..8e59e5915af 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -125,7 +125,16 @@ class cmCTestTestHandler : public cmCTestGenericHandler cmCTestTestProperties* Properties; }; - // add configuraitons to a search path for an executable + struct cmCTestTestResultLess + { + bool operator() (const cmCTestTestResult &lhs, + const cmCTestTestResult &rhs) const + { + return lhs.TestCount < rhs.TestCount; + } + }; + + // add configurations to a search path for an executable static void AddConfigurations(cmCTest *ctest, std::vector &attempted, std::vector &attemptedConfigs, @@ -141,7 +150,7 @@ class cmCTestTestHandler : public cmCTestGenericHandler typedef std::vector ListOfTests; protected: - // comput a final test list + // compute a final test list virtual int PreProcessHandler(); virtual int PostProcessHandler(); virtual void GenerateTestCommand(std::vector& args); From 4575ed9e2ace903b29a8b10c7e7f78c4fe6b9d21 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 3 Aug 2011 11:37:59 -0400 Subject: [PATCH 014/539] Fix line too long style violation --- Source/CTest/cmCTestTestHandler.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 078e4309821..9b12393c5e1 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -620,7 +620,8 @@ int cmCTestTestHandler::ProcessHandler() typedef std::set SetOfTests; - SetOfTests resultsSet(this->TestResults.begin(), this->TestResults.end()); + SetOfTests resultsSet(this->TestResults.begin(), + this->TestResults.end()); for(SetOfTests::iterator ftit = resultsSet.begin(); ftit != resultsSet.end(); ++ftit) From fe6bb7af2aef536d29593f1da8ae4dd19b195e88 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 3 Aug 2011 22:32:28 +0200 Subject: [PATCH 015/539] Remove trailing whitespace Alex --- Modules/FindX11.cmake | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index df44979236e..29f2be5df4e 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -57,11 +57,11 @@ IF (UNIX) SET(CMAKE_FIND_FRAMEWORK NEVER) SET(X11_INC_SEARCH_PATH /usr/pkg/xorg/include - /usr/X11R6/include - /usr/X11R7/include + /usr/X11R6/include + /usr/X11R7/include /usr/include/X11 - /usr/openwin/include - /usr/openwin/share/include + /usr/openwin/include + /usr/openwin/share/include /opt/graphics/OpenGL/include ) @@ -69,7 +69,7 @@ IF (UNIX) /usr/pkg/xorg/lib /usr/X11R6/lib /usr/X11R7/lib - /usr/openwin/lib + /usr/openwin/lib ) FIND_PATH(X11_X11_INCLUDE_PATH X11/X.h ${X11_INC_SEARCH_PATH}) @@ -77,7 +77,7 @@ IF (UNIX) # Look for includes; keep the list sorted by name of the cmake *_INCLUDE_PATH # variable (which doesn't need to match the include file name). - + # Solaris lacks XKBrules.h, so we should skip kxkbd there. FIND_PATH(X11_ICE_INCLUDE_PATH X11/ICE/ICE.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xaccessrules_INCLUDE_PATH X11/extensions/XKBrules.h ${X11_INC_SEARCH_PATH}) @@ -306,11 +306,11 @@ IF (UNIX) CHECK_LIBRARY_EXISTS("${X11_LIBRARIES}" "XOpenDisplay" "${X11_LIBRARY_DIR}" X11_LIB_X11_SOLO) IF(NOT X11_LIB_X11_SOLO) # Find library needed for dnet_ntoa. - CHECK_LIBRARY_EXISTS("dnet" "dnet_ntoa" "" X11_LIB_DNET_HAS_DNET_NTOA) + CHECK_LIBRARY_EXISTS("dnet" "dnet_ntoa" "" X11_LIB_DNET_HAS_DNET_NTOA) IF (X11_LIB_DNET_HAS_DNET_NTOA) SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -ldnet) ELSE (X11_LIB_DNET_HAS_DNET_NTOA) - CHECK_LIBRARY_EXISTS("dnet_stub" "dnet_ntoa" "" X11_LIB_DNET_STUB_HAS_DNET_NTOA) + CHECK_LIBRARY_EXISTS("dnet_stub" "dnet_ntoa" "" X11_LIB_DNET_STUB_HAS_DNET_NTOA) IF (X11_LIB_DNET_STUB_HAS_DNET_NTOA) SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -ldnet_stub) ENDIF (X11_LIB_DNET_STUB_HAS_DNET_NTOA) @@ -320,11 +320,11 @@ IF (UNIX) # Find library needed for gethostbyname. CHECK_FUNCTION_EXISTS("gethostbyname" CMAKE_HAVE_GETHOSTBYNAME) IF(NOT CMAKE_HAVE_GETHOSTBYNAME) - CHECK_LIBRARY_EXISTS("nsl" "gethostbyname" "" CMAKE_LIB_NSL_HAS_GETHOSTBYNAME) + CHECK_LIBRARY_EXISTS("nsl" "gethostbyname" "" CMAKE_LIB_NSL_HAS_GETHOSTBYNAME) IF (CMAKE_LIB_NSL_HAS_GETHOSTBYNAME) SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lnsl) ELSE (CMAKE_LIB_NSL_HAS_GETHOSTBYNAME) - CHECK_LIBRARY_EXISTS("bsd" "gethostbyname" "" CMAKE_LIB_BSD_HAS_GETHOSTBYNAME) + CHECK_LIBRARY_EXISTS("bsd" "gethostbyname" "" CMAKE_LIB_BSD_HAS_GETHOSTBYNAME) IF (CMAKE_LIB_BSD_HAS_GETHOSTBYNAME) SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lbsd) ENDIF (CMAKE_LIB_BSD_HAS_GETHOSTBYNAME) @@ -334,7 +334,7 @@ IF (UNIX) # Find library needed for connect. CHECK_FUNCTION_EXISTS("connect" CMAKE_HAVE_CONNECT) IF(NOT CMAKE_HAVE_CONNECT) - CHECK_LIBRARY_EXISTS("socket" "connect" "" CMAKE_LIB_SOCKET_HAS_CONNECT) + CHECK_LIBRARY_EXISTS("socket" "connect" "" CMAKE_LIB_SOCKET_HAS_CONNECT) IF (CMAKE_LIB_SOCKET_HAS_CONNECT) SET (X11_X_EXTRA_LIBS -lsocket ${X11_X_EXTRA_LIBS}) ENDIF (CMAKE_LIB_SOCKET_HAS_CONNECT) @@ -343,7 +343,7 @@ IF (UNIX) # Find library needed for remove. CHECK_FUNCTION_EXISTS("remove" CMAKE_HAVE_REMOVE) IF(NOT CMAKE_HAVE_REMOVE) - CHECK_LIBRARY_EXISTS("posix" "remove" "" CMAKE_LIB_POSIX_HAS_REMOVE) + CHECK_LIBRARY_EXISTS("posix" "remove" "" CMAKE_LIB_POSIX_HAS_REMOVE) IF (CMAKE_LIB_POSIX_HAS_REMOVE) SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lposix) ENDIF (CMAKE_LIB_POSIX_HAS_REMOVE) @@ -352,7 +352,7 @@ IF (UNIX) # Find library needed for shmat. CHECK_FUNCTION_EXISTS("shmat" CMAKE_HAVE_SHMAT) IF(NOT CMAKE_HAVE_SHMAT) - CHECK_LIBRARY_EXISTS("ipc" "shmat" "" CMAKE_LIB_IPS_HAS_SHMAT) + CHECK_LIBRARY_EXISTS("ipc" "shmat" "" CMAKE_LIB_IPS_HAS_SHMAT) IF (CMAKE_LIB_IPS_HAS_SHMAT) SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lipc) ENDIF (CMAKE_LIB_IPS_HAS_SHMAT) From 6899e58fa0d819638aa5de1408721b718d3299b8 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 3 Aug 2011 22:33:18 +0200 Subject: [PATCH 016/539] Also search for libxkbfile, XSync and SM include dir Alex --- Modules/FindX11.cmake | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index 29f2be5df4e..9df3f014ce2 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -6,6 +6,7 @@ # # and also the following more fine grained variables: # Include paths: X11_ICE_INCLUDE_PATH, X11_ICE_LIB, X11_ICE_FOUND +# X11_SM_INCLUDE_PATH, X11_SM_LIB, X11_SM_FOUND # X11_X11_INCLUDE_PATH, X11_X11_LIB # X11_Xaccessrules_INCLUDE_PATH, X11_Xaccess_FOUND # X11_Xaccessstr_INCLUDE_PATH, X11_Xaccess_FOUND @@ -27,6 +28,7 @@ # X11_Xinput_INCLUDE_PATH, X11_Xinput_LIB, X11_Xinput_FOUND # X11_Xkb_INCLUDE_PATH, X11_Xkb_FOUND # X11_Xkblib_INCLUDE_PATH, X11_Xkb_FOUND +# X11_Xkbfile_INCLUDE_PATH, X11_Xkbfile_LIB, X11_Xkbfile_FOUND # X11_Xpm_INCLUDE_PATH, X11_Xpm_LIB, X11_Xpm_FOUND # X11_XTest_INCLUDE_PATH, X11_XTest_LIB, X11_XTest_FOUND # X11_Xrandr_INCLUDE_PATH, X11_Xrandr_LIB, X11_Xrandr_FOUND @@ -35,6 +37,8 @@ # X11_Xt_INCLUDE_PATH, X11_Xt_LIB, X11_Xt_FOUND # X11_Xutil_INCLUDE_PATH, X11_Xutil_FOUND # X11_Xv_INCLUDE_PATH, X11_Xv_LIB, X11_Xv_FOUND +# X11_XSync_INCLUDE_PATH, (in X11_Xext_LIB), X11_XSync_FOUND + #============================================================================= # Copyright 2001-2009 Kitware, Inc. @@ -80,6 +84,7 @@ IF (UNIX) # Solaris lacks XKBrules.h, so we should skip kxkbd there. FIND_PATH(X11_ICE_INCLUDE_PATH X11/ICE/ICE.h ${X11_INC_SEARCH_PATH}) + FIND_PATH(X11_SM_INCLUDE_PATH X11/SM/SM.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xaccessrules_INCLUDE_PATH X11/extensions/XKBrules.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xaccessstr_INCLUDE_PATH X11/extensions/XKBstr.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xau_INCLUDE_PATH X11/Xauth.h ${X11_INC_SEARCH_PATH}) @@ -97,6 +102,7 @@ IF (UNIX) FIND_PATH(X11_Xinput_INCLUDE_PATH X11/extensions/XInput.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xkb_INCLUDE_PATH X11/extensions/XKB.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xkblib_INCLUDE_PATH X11/XKBlib.h ${X11_INC_SEARCH_PATH}) + FIND_PATH(X11_Xkbfile_INCLUDE_PATH X11/extensions/XKBfile.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xpm_INCLUDE_PATH X11/xpm.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_XTest_INCLUDE_PATH X11/extensions/XTest.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_XShm_INCLUDE_PATH X11/extensions/XShm.h ${X11_INC_SEARCH_PATH}) @@ -107,6 +113,7 @@ IF (UNIX) FIND_PATH(X11_Xutil_INCLUDE_PATH X11/Xutil.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xt_INCLUDE_PATH X11/Intrinsic.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xv_INCLUDE_PATH X11/extensions/Xvlib.h ${X11_INC_SEARCH_PATH}) + FIND_PATH(X11_XSync_INCLUDE_PATH X11/extensions/sync.h ${X11_INC_SEARCH_PATH}) FIND_LIBRARY(X11_X11_LIB X11 ${X11_LIB_SEARCH_PATH}) @@ -125,6 +132,7 @@ IF (UNIX) FIND_LIBRARY(X11_Xi_LIB Xi ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xinerama_LIB Xinerama ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xinput_LIB Xi ${X11_LIB_SEARCH_PATH}) + FIND_LIBRARY(X11_Xkbfile_LIB xkbfile ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xpm_LIB Xpm ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xrandr_LIB Xrandr ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xrender_LIB Xrender ${X11_LIB_SEARCH_PATH}) @@ -277,15 +285,30 @@ IF (UNIX) SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xkb_INCLUDE_PATH} ) ENDIF (X11_Xkb_INCLUDE_PATH AND X11_Xkblib_INCLUDE_PATH AND X11_Xlib_INCLUDE_PATH) + IF (X11_Xkbfile_INCLUDE_PATH AND X11_Xkbfile_LIB AND X11_Xlib_INCLUDE_PATH) + SET(X11_Xkbfile_FOUND TRUE) + SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xkbfile_INCLUDE_PATH} ) + ENDIF (X11_Xkbfile_INCLUDE_PATH AND X11_Xkbfile_LIB AND X11_Xlib_INCLUDE_PATH) + IF (X11_Xinput_INCLUDE_PATH AND X11_Xinput_LIB) SET(X11_Xinput_FOUND TRUE) SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xinput_INCLUDE_PATH}) ENDIF (X11_Xinput_INCLUDE_PATH AND X11_Xinput_LIB) + IF (X11_XSync_INCLUDE_PATH) + SET(X11_XSync_FOUND TRUE) + SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_XSync_INCLUDE_PATH}) + ENDIF (X11_XSync_INCLUDE_PATH) + IF(X11_ICE_LIB AND X11_ICE_INCLUDE_PATH) SET(X11_ICE_FOUND TRUE) ENDIF(X11_ICE_LIB AND X11_ICE_INCLUDE_PATH) + IF(X11_SM_LIB AND X11_SM_INCLUDE_PATH) + SET(X11_SM_FOUND TRUE) + ENDIF(X11_SM_LIB AND X11_SM_INCLUDE_PATH) + + # Deprecated variable for backwards compatibility with CMake 1.4 IF (X11_X11_INCLUDE_PATH AND X11_LIBRARIES) SET(X11_FOUND 1) @@ -422,6 +445,8 @@ IF (UNIX) X11_Xdmcp_INCLUDE_PATH X11_Xkb_INCLUDE_PATH X11_Xkblib_INCLUDE_PATH + X11_Xkbfile_INCLUDE_PATH + X11_Xkbfile_LIB X11_Xscreensaver_INCLUDE_PATH X11_Xscreensaver_LIB X11_Xpm_INCLUDE_PATH @@ -437,6 +462,8 @@ IF (UNIX) X11_ICE_LIB X11_ICE_INCLUDE_PATH X11_SM_LIB + X11_SM_INCLUDE_PATH + X11_XSync_INCLUDE_PATH ) SET(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_SAVE}) ENDIF (UNIX) From 3c53fbb1f0d7276d0ef1f07facb2a1d937fc5153 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Wed, 3 Aug 2011 17:24:43 -0400 Subject: [PATCH 017/539] Fix custom commands in VS2010 Fortran projects using CFG_INTDIR and test. For custom commands in VS2010 Fortran projects the INTDIR variable is different than in the rest of the solution because Intel fortran still uses the old VS project files even in VS2010. So, we replace $(Configuration) directly in the project files. I have also added a FortranOnly test that tests this feature and is run on any generator that has Fortran abilities. --- Source/cmLocalVisualStudio7Generator.cxx | 4 +++ Source/cmVisualStudio10TargetGenerator.cxx | 7 ++++ Tests/CMakeLists.txt | 6 +++- Tests/FortranOnly/CMakeLists.txt | 42 ++++++++++++++++++++++ Tests/FortranOnly/checksayhello.cmake | 7 ++++ Tests/FortranOnly/checktestf2.cmake | 8 +++++ Tests/FortranOnly/hello.f | 5 +++ Tests/FortranOnly/testf.f | 6 ++++ Tests/FortranOnly/world.f | 5 +++ 9 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 Tests/FortranOnly/CMakeLists.txt create mode 100644 Tests/FortranOnly/checksayhello.cmake create mode 100644 Tests/FortranOnly/checktestf2.cmake create mode 100644 Tests/FortranOnly/hello.f create mode 100644 Tests/FortranOnly/testf.f create mode 100644 Tests/FortranOnly/world.f diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 7a62b9cb149..d254164eafb 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1622,6 +1622,10 @@ WriteCustomRule(std::ostream& fout, } std::string script = this->ConstructScript(command, i->c_str()); + if(this->FortranProject) + { + cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str()); + } fout << "\t\t\t\t\t(this->GlobalGenerator) + ->TargetIsFortranOnly(*dt)) + { + continue; + } this->WriteString("GetMakefile(); std::string name = dt->GetName(); diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2ad9a7759c8..da4eda0ea59 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -16,6 +16,8 @@ MACRO(ADD_TEST_MACRO NAME COMMAND) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}") ENDMACRO(ADD_TEST_MACRO) +INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) + # Fake a user home directory to avoid polluting the real one. IF(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) SET(TEST_HOME "${CMake_BINARY_DIR}/Tests/CMakeFiles/TestHome") @@ -155,6 +157,9 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(MissingSourceFile MissingSourceFile) SET_TESTS_PROPERTIES(MissingSourceFile PROPERTIES PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c") + IF(CMAKE_Fortran_COMPILER) + ADD_TEST_MACRO(FortranOnly FortranOnly) + ENDIF() ADD_TEST_MACRO(COnly COnly) ADD_TEST_MACRO(CxxOnly CxxOnly) ADD_TEST_MACRO(IPO COnly/COnly) @@ -1879,7 +1884,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # fortran does not work for IDE builds because # CMAKE_STANDARD_LIBRARIES needs to be per language IF(CMAKE_TEST_GENERATOR MATCHES "Make|KDevelop") - INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) IF(CMAKE_Fortran_COMPILER) ADD_TEST(Fortran ${CMAKE_CTEST_COMMAND} --build-and-test diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt new file mode 100644 index 00000000000..3c4f0e7e42b --- /dev/null +++ b/Tests/FortranOnly/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required (VERSION 2.8) +project(FortranOnly Fortran) +message("CTEST_FULL_OUTPUT ") + +# create a library with hello and world functions +add_library(FortranOnlylib hello.f world.f) +# create an executable that calls hello and world +add_executable(FortranOnly testf.f) +target_link_libraries(FortranOnly FortranOnlylib) + +# create a custom command that runs FortranOnly and puts +# the output into the file testfhello.txt +add_custom_command(OUTPUT ${FortranOnly_BINARY_DIR}/testfhello.txt + COMMAND ${FortranOnly_BINARY_DIR}/${CMAKE_CFG_INTDIR}/FortranOnly + > testfhello.txt) +# create a second executable FortranOnly2 that has +# testfhello.txt has an source file so that it will +# run the above custom command. +add_executable(FortranOnly2 testfhello.txt testf.f) +target_link_libraries(FortranOnly2 FortranOnlylib) +# create a custom target to check the content of testfhello.txt +# by running the cmake script checktestf2.cmake +add_custom_target(checktestf2 ALL + COMMAND ${CMAKE_COMMAND} + -P ${FortranOnly_SOURCE_DIR}/checktestf2.cmake) + +# create a custom target that runs FortranOnly exectuable and creates +# a file out.txt that should have hello world in it. +add_custom_target(sayhello ALL + COMMAND ${FortranOnly_BINARY_DIR}/${CMAKE_CFG_INTDIR}/FortranOnly > out.txt +) +# make sure stuff is built in the right order +add_dependencies(checktestf2 FortranOnly2) +add_dependencies(sayhello FortranOnly) +add_dependencies(FortranOnly2 FortranOnly) + +# add a custom target that checkes that out.txt has the correct +# content +add_custom_target(checksayhello ALL + COMMAND ${CMAKE_COMMAND} -P ${FortranOnly_SOURCE_DIR}/checksayhello.cmake + ) +add_dependencies(checksayhello sayhello) diff --git a/Tests/FortranOnly/checksayhello.cmake b/Tests/FortranOnly/checksayhello.cmake new file mode 100644 index 00000000000..5352290ab5e --- /dev/null +++ b/Tests/FortranOnly/checksayhello.cmake @@ -0,0 +1,7 @@ +file(READ out.txt IN) +message("${IN}") +if(IN MATCHES Hello AND IN MATCHES World) + message("Passed") +else() + message(FATAL_ERROR "Hello world not found") +endif() diff --git a/Tests/FortranOnly/checktestf2.cmake b/Tests/FortranOnly/checktestf2.cmake new file mode 100644 index 00000000000..f0e6be32912 --- /dev/null +++ b/Tests/FortranOnly/checktestf2.cmake @@ -0,0 +1,8 @@ +file(READ testfhello.txt IN) +message("${IN}") +if(IN MATCHES Hello AND IN MATCHES World) + message("Passed") +else() + message(FATAL_ERROR "Hello world not found") +endif() +file(WRITE testfhello2.txt ${IN}) diff --git a/Tests/FortranOnly/hello.f b/Tests/FortranOnly/hello.f new file mode 100644 index 00000000000..63e64080de5 --- /dev/null +++ b/Tests/FortranOnly/hello.f @@ -0,0 +1,5 @@ + SUBROUTINE HELLO + + PRINT *, 'Hello' + + END diff --git a/Tests/FortranOnly/testf.f b/Tests/FortranOnly/testf.f new file mode 100644 index 00000000000..4909181084f --- /dev/null +++ b/Tests/FortranOnly/testf.f @@ -0,0 +1,6 @@ + PROGRAM TESTF + + CALL HELLO() + CALL WORLD() + + END diff --git a/Tests/FortranOnly/world.f b/Tests/FortranOnly/world.f new file mode 100644 index 00000000000..deae3fa7236 --- /dev/null +++ b/Tests/FortranOnly/world.f @@ -0,0 +1,5 @@ + SUBROUTINE WORLD + + PRINT *, 'World!' + + END From 91704ef2dee3ad606a6cc0f1e03e6f254d211b8f Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 3 Aug 2011 21:37:01 -0400 Subject: [PATCH 018/539] Tests: Add a KWStyle test, equivalent to the make StyleCheck target --- Tests/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 4bf83b78057..ee38fd09488 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2073,6 +2073,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --test-command IncludeDirectories) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories") + IF(CMAKE_USE_KWSTYLE AND KWSTYLE_EXECUTABLE) + # The "make StyleCheck" command line as a test. If the test fails, look + # for lines like "Error #0 (624) Line length exceed 88 (max=79)" in the + # output to find where the style errors are... + ADD_TEST(KWStyle ${KWSTYLE_EXECUTABLE} + -xml ${CMake_BINARY_DIR}/CMake.kws.xml + -o ${CMake_SOURCE_DIR}/Utilities/KWStyle/CMakeOverwrite.txt + -v + -D ${CMake_BINARY_DIR}/CMakeKWSFiles.txt + ) + SET_TESTS_PROPERTIES(KWStyle PROPERTIES + WORKING_DIRECTORY ${CMake_BINARY_DIR}/Utilities/KWStyle) + ENDIF() ENDIF(BUILD_TESTING) SUBDIRS(CMakeTests) From d87eb350f6b7c810145205fb6819e3174efdcc23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bj=C3=B6rk?= Date: Thu, 9 Jun 2011 10:36:53 +0200 Subject: [PATCH 019/539] Xcode: Quote ',' in Xcode string values (#12259) --- Source/cmXCodeObject.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 71c7c2557b1..30e5076c461 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -241,7 +241,7 @@ void cmXCodeObject::PrintString(std::ostream& os,cmStdString String) // considered special by the Xcode project file parser. bool needQuote = (String.empty() || - String.find_first_of(" <>.+-=@$[]") != String.npos); + String.find_first_of(" <>.+-=@$[],") != String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary. From 8ee9bbbd0ca5aab5bceb2dc9dda041e5745ffc19 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Aug 2011 15:35:59 -0400 Subject: [PATCH 020/539] Do not crash when an imported target depends on a missing target Commit e01cce28 (Allow add_dependencies() on imported targets, 2010-11-19) forgot to check if the dependee exists before using it. --- Source/cmComputeTargetDepends.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index a4ca363a87e..3a0ed06406d 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -276,9 +276,11 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, for(std::set::const_iterator i = utils.begin(); i != utils.end(); ++i) { - cmTarget* transitive_dependee = - dependee->GetMakefile()->FindTargetToUse(i->c_str()); - this->AddTargetDepend(depender_index, transitive_dependee, false); + if(cmTarget* transitive_dependee = + dependee->GetMakefile()->FindTargetToUse(i->c_str())) + { + this->AddTargetDepend(depender_index, transitive_dependee, false); + } } } else From 312d68d5b195255356b444f34be50552bc8981d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bj=C3=B6rk?= Date: Tue, 26 Jul 2011 23:13:42 +0200 Subject: [PATCH 021/539] Xcode: Rearrange CMakeReRun to enable parallel builds by isolating the CMakeReRun steps to a ZERO_CHECK target, as in the Visual Studio generators. Also, honor the value of CMAKE_SUPPRESS_REGENERATION. --- Source/cmGlobalXCodeGenerator.cxx | 45 ++++++++++++++++--------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b3e2e7a8331..fd9dacd1aff 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -335,6 +335,9 @@ cmGlobalXCodeGenerator::PostBuildMakeTarget(std::string const& tName, return out; } +//---------------------------------------------------------------------------- +#define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK" + //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, @@ -366,8 +369,18 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, makecommand.push_back(this->CurrentXCodeHackMakefile.c_str()); makecommand.push_back(""); // placeholder, see below - // Add Re-Run CMake rules - this->CreateReRunCMakeFile(root, gens); + // Add ZERO_CHECK + bool regenerate = !mf->IsOn("CMAKE_SUPPRESS_REGENERATION"); + if (regenerate) + { + this->CreateReRunCMakeFile(root, gens); + std::string file = this->ConvertToRelativeForMake( + this->CurrentReRunCMakeMakefile.c_str()); + cmSystemTools::ReplaceString(file, "\\ ", " "); + mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, true, no_depends, + no_working_directory, + "make", "-f", file.c_str()); + } // now make the allbuild depend on all the non-utility targets // in the project @@ -379,10 +392,17 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, { continue; } + cmTargets& tgts = lg->GetMakefile()->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& target = l->second; + + if (regenerate && (l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)) + { + target.AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); + } + // make all exe, shared libs and modules // run the depend check makefile as a post build rule // this will make sure that when the next target is built @@ -402,8 +422,8 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str()); - } + if(!target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) { allbuild->AddUtility(target.GetName()); @@ -1114,11 +1134,6 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, commands.push_back(*(*i)->GetCustomCommand()); } } - std::vector reruncom; - cmXCodeObject* cmakeReRunPhase = - this->CreateBuildPhase("CMake ReRun", "cmakeReRunPhase", - cmtarget, reruncom); - buildPhases->AddObject(cmakeReRunPhase); // create prebuild phase cmXCodeObject* cmakeRulesBuildPhase = this->CreateBuildPhase("CMake Rules", @@ -1207,20 +1222,6 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, const & commands, const char* name) { - if(strcmp(name, "cmakeReRunPhase") == 0) - { - std::string cdir = this->CurrentMakefile->GetHomeOutputDirectory(); - cdir = this->ConvertToRelativeForMake(cdir.c_str()); - std::string makecmd = "make -C "; - makecmd += cdir; - makecmd += " -f "; - makecmd += - this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile.c_str()); - cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ "); - buildphase->AddAttribute("shellScript", - this->CreateString(makecmd.c_str())); - return; - } // collect multiple outputs of custom commands into a set // which will be used for every configuration From edcdfeae9311ed5f5e9add23345b1ba9f0961982 Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 4 Aug 2011 19:03:24 -0400 Subject: [PATCH 022/539] Documentation: Fix comments in the source code (#10941) Previously, the comments had all been copied and pasted and not fixed up... Now they are fixed up. --- Source/cmBuildCommand.h | 4 ++-- Source/cmBuildNameCommand.h | 4 ++-- Source/cmCMakeMinimumRequired.h | 4 ++-- Source/cmMarkAsAdvancedCommand.h | 4 ++-- Source/cmRemoveCommand.h | 4 ++-- Source/cmSeparateArgumentsCommand.h | 4 ++-- Source/cmSiteNameCommand.h | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h index 703ff882c9f..1d247d2f2d8 100644 --- a/Source/cmBuildCommand.h +++ b/Source/cmBuildCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmBuildCommand - * \brief Build a CMAKE variable + * \brief build_command command * - * cmBuildCommand sets a variable to a value with expansion. + * cmBuildCommand implements the build_command CMake command */ class cmBuildCommand : public cmCommand { diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h index 35c0ae04d65..29a680fcd68 100644 --- a/Source/cmBuildNameCommand.h +++ b/Source/cmBuildNameCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmBuildNameCommand - * \brief BuildName a CMAKE variable + * \brief build_name command * - * cmBuildNameCommand sets a variable to a value with expansion. + * cmBuildNameCommand implements the build_name CMake command */ class cmBuildNameCommand : public cmCommand { diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h index 9bf7ef87fef..112138644e7 100644 --- a/Source/cmCMakeMinimumRequired.h +++ b/Source/cmCMakeMinimumRequired.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmCMakeMinimumRequired - * \brief Build a CMAKE variable + * \brief cmake_minimum_required command * - * cmCMakeMinimumRequired sets a variable to a value with expansion. + * cmCMakeMinimumRequired implements the cmake_minimum_required CMake command */ class cmCMakeMinimumRequired : public cmCommand { diff --git a/Source/cmMarkAsAdvancedCommand.h b/Source/cmMarkAsAdvancedCommand.h index 0a5eb9ec751..26e0a07fdf2 100644 --- a/Source/cmMarkAsAdvancedCommand.h +++ b/Source/cmMarkAsAdvancedCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmMarkAsAdvancedCommand - * \brief MarkAsAdvanced a CMAKE variable + * \brief mark_as_advanced command * - * cmMarkAsAdvancedCommand sets a variable to a value with expansion. + * cmMarkAsAdvancedCommand implements the mark_as_advanced CMake command */ class cmMarkAsAdvancedCommand : public cmCommand { diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h index 87c416f52a8..bae2ee13fb0 100644 --- a/Source/cmRemoveCommand.h +++ b/Source/cmRemoveCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmRemoveCommand - * \brief Set a CMAKE variable + * \brief remove command * - * cmRemoveCommand sets a variable to a value with expansion. + * cmRemoveCommand implements the remove CMake command */ class cmRemoveCommand : public cmCommand { diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h index 10b3c40b67b..736f0662c61 100644 --- a/Source/cmSeparateArgumentsCommand.h +++ b/Source/cmSeparateArgumentsCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmSeparateArgumentsCommand - * \brief SeparateArguments a CMAKE variable + * \brief separate_arguments command * - * cmSeparateArgumentsCommand sets a variable to a value with expansion. + * cmSeparateArgumentsCommand implements the separate_arguments CMake command */ class cmSeparateArgumentsCommand : public cmCommand { diff --git a/Source/cmSiteNameCommand.h b/Source/cmSiteNameCommand.h index 63575693c0a..ac7f426ec58 100644 --- a/Source/cmSiteNameCommand.h +++ b/Source/cmSiteNameCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmSiteNameCommand - * \brief SiteName a CMAKE variable + * \brief site_name command * - * cmSiteNameCommand sets a variable to a value with expansion. + * cmSiteNameCommand implements the site_name CMake command */ class cmSiteNameCommand : public cmCommand { From 208bb9009bda2b41eeee747c34e536f561df8a59 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Fri, 5 Aug 2011 22:42:57 +0200 Subject: [PATCH 023/539] Set UNSUITABLE instead of not COMPATIBLE Alex --- ...asicConfigVersion-AnyNewerVersion.cmake.in | 24 +++++----- ...sicConfigVersion-SameMajorVersion.cmake.in | 45 +++++++++---------- Tests/FindPackageTest/CMakeLists.txt | 11 +++++ 3 files changed, 42 insertions(+), 38 deletions(-) diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in index 30749c47528..469bcdb7484 100644 --- a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in +++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in @@ -10,22 +10,18 @@ set(PACKAGE_VERSION "@CVF_VERSION@") -set(PACKAGE_VERSION_EXACT FALSE) # initialize to FALSE +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() # check that the installed version has the same 32/64bit-ness as the one which is currently searching: if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@") math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - - if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) - set(PACKAGE_VERSION_COMPATIBLE FALSE) - else() - set(PACKAGE_VERSION_COMPATIBLE TRUE) - if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") - set(PACKAGE_VERSION_EXACT TRUE) - endif() - endif() - -endif() \ No newline at end of file + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in index f633ee8b9e5..8d091eaed96 100644 --- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in @@ -12,34 +12,31 @@ set(PACKAGE_VERSION "@CVF_VERSION@") -set(PACKAGE_VERSION_EXACT FALSE) # initialize to FALSE - -# check that the installed version has the same 32/64bit-ness as the one which is currently searching: -if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@") - math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") - set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") - set(PACKAGE_VERSION_COMPATIBLE FALSE) +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) else() - if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) - set(PACKAGE_VERSION_COMPATIBLE FALSE) + if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.") + set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") else() + set(CVF_VERSION_MAJOR "@CVF_VERSION@") + endif() - if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.") - set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") - else() - set(CVF_VERSION_MAJOR "@CVF_VERSION@") - endif() - - if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${CVF_VERSION_MAJOR}") - set(PACKAGE_VERSION_COMPATIBLE TRUE) - else() - set(PACKAGE_VERSION_COMPATIBLE FALSE) - endif() - - if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") - set(PACKAGE_VERSION_EXACT TRUE) - endif() + if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${CVF_VERSION_MAJOR}") + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) endif() + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() + + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@") + math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) endif() diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index ca644403b12..9a4bdfeb5de 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -350,12 +350,16 @@ write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion. VERSION 1.2.3 COMPATIBILITY SameMajorVersion) +set(PACKAGE_VERSION_EXACT FALSE) set(PACKAGE_FIND_VERSION 2.3.4) set(PACKAGE_FIND_VERSION_MAJOR 2) include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) if(PACKAGE_VERSION_COMPATIBLE) message(SEND_ERROR "Found Boo123 with version 1.2.3, but 2.3.4 was requested !") endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() set(PACKAGE_FIND_VERSION 0.0.1) set(PACKAGE_FIND_VERSION_MAJOR 0) @@ -363,6 +367,9 @@ include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) if(PACKAGE_VERSION_COMPATIBLE) message(SEND_ERROR "Found Boo123 with version 1.2.3, but 0.0.1 was requested !") endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() set(PACKAGE_FIND_VERSION 1.0.0) set(PACKAGE_FIND_VERSION_MAJOR 1) @@ -383,3 +390,7 @@ endif() if(NOT PACKAGE_VERSION_EXACT) message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !") endif() + +if(PACKAGE_VERSION_UNSUITABLE) + message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !") +endif() From c9761de7ad853c62aa2d7e0bc0a28bc697586d23 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Fri, 5 Aug 2011 23:01:07 +0200 Subject: [PATCH 024/539] Improve documentation for WriteBasicConfigVersionFile.cmake Alex --- ...BasicConfigVersion-AnyNewerVersion.cmake.in | 3 +-- ...asicConfigVersion-SameMajorVersion.cmake.in | 3 +-- Modules/WriteBasicConfigVersionFile.cmake | 18 +++++++++++------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in index 469bcdb7484..cf53db84a7a 100644 --- a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in +++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in @@ -1,5 +1,4 @@ -# This is a basic file for the new style find_package() search mode, -# i.e. Config-mode. +# This is a basic version file for the Config-mode of find_package(). # It is used by WriteBasicConfigVersionFile.cmake as input file for configure_file() # to create a version-file which can be installed along a config.cmake file. # diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in index 8d091eaed96..2317fdbb370 100644 --- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in @@ -1,5 +1,4 @@ -# This is a basic file for the new style find_package() search mode, -# i.e. Config-mode. +# This is a basic version file for the Config-mode of find_package(). # It is used by WriteBasicConfigVersionFile.cmake as input file for configure_file() # to create a version-file which can be installed along a config.cmake file. # diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake index f0ad6ea6f3b..0b6519d411a 100644 --- a/Modules/WriteBasicConfigVersionFile.cmake +++ b/Modules/WriteBasicConfigVersionFile.cmake @@ -5,23 +5,27 @@ # filename is the output filename, it should be in the build tree. # major.minor.patch is the version number of the project to be installed # The COMPATIBILITY mode AnyNewerVersion means that the installed package version -# will be considered suitable if it is newer or exactly the same as the requested version. +# will be considered compatible if it is newer or exactly the same as the requested version. # If SameMajorVersion is used instead, then the behaviour differs from AnyNewerVersion # in that the major version number must be the same as requested, e.g. version 2.0 will -# not be considered suitable to 1.0 is requested. -# If you project has more elaborated version matching rules, you will need to write your -# own custom ConfigVersion.cmake file, instead of using this macro. +# not be considered compatible if 1.0 is requested. +# If your project has more elaborated version matching rules, you will need to write your +# own custom ConfigVersion.cmake file instead of using this macro. # # Example: # write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake # VERSION 1.2.3 # COMPATIBILITY SameMajorVersion ) # install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake +# ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake # DESTINATION lib/cmake/Foo ) # -# Internally, this macro executes configure_file() on the input file -# Modules/BasicConfigVersion-AnyNewerVersion/SameMajorVersion.cmake.in to -# create the resulting version file. +# Internally, this macro executes configure_file() to create the resulting +# version file. Depending on the COMPATIBLITY, either the file +# BasicConfigVersion-SameMajorVersion.cmake.in or BasicConfigVersion-AnyNewerVersion.cmake.in +# is used. Please note that these two files are internal to CMake and you should +# not call configure_file() on them yourself, but they can be used as starting +# point to create more sophisticted custom ConfigVersion.cmake files. #============================================================================= # Copyright 2008-2011 Alexander Neundorf, From a65011baf109fd0afe759cf3d9e7b6ab7013a805 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 7 Aug 2011 12:02:46 +0200 Subject: [PATCH 025/539] Start work on automoc: add empty cmQtAutomoc class Alex --- Source/CMakeLists.txt | 2 ++ Source/cmQtAutomoc.cxx | 10 ++++++++++ Source/cmQtAutomoc.h | 11 +++++++++++ Source/cmake.cxx | 7 +++++++ 4 files changed, 30 insertions(+) create mode 100644 Source/cmQtAutomoc.cxx create mode 100644 Source/cmQtAutomoc.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 1c942ba4b22..96b3ea06aa3 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -228,6 +228,8 @@ SET(SRCS cmPropertyDefinitionMap.h cmPropertyMap.cxx cmPropertyMap.h + cmQtAutomoc.cxx + cmQtAutomoc.h cmScriptGenerator.h cmScriptGenerator.cxx cmSourceFile.cxx diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx new file mode 100644 index 00000000000..efbfc383295 --- /dev/null +++ b/Source/cmQtAutomoc.cxx @@ -0,0 +1,10 @@ +#include "cmQtAutomoc.h" + +cmQtAutomoc::cmQtAutomoc() +{ +} + + +bool cmQtAutomoc::Run(const char* targetDirectory) +{ +} diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h new file mode 100644 index 00000000000..657b2080577 --- /dev/null +++ b/Source/cmQtAutomoc.h @@ -0,0 +1,11 @@ +#ifndef cmQtAutomoc_h +#define cmQtAutomoc_h + +class cmQtAutomoc +{ +public: + cmQtAutomoc(); + bool Run(const char* targetDirectory); +}; + +#endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 51cc9d4dd6c..47520dff737 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -20,6 +20,7 @@ #include "cmCommand.h" #include "cmFileTimeComparison.h" #include "cmGeneratedFileStream.h" +#include "cmQtAutomoc.h" #include "cmSourceFile.h" #include "cmVersion.h" #include "cmTest.h" @@ -1574,6 +1575,12 @@ int cmake::ExecuteCMakeCommand(std::vector& args) } #endif + else if (args[1] == "cmake_automoc") + { + cmQtAutomoc automoc; + automoc.Run("target directory"); + } + // Tar files else if (args[1] == "tar" && args.size() > 3) { From 30880707c094ac5c0edd85d0857afb6fbae55326 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 13 Jul 2011 02:13:33 +0200 Subject: [PATCH 026/539] Add the GenerateExportMacro with unit tests. Reviewed-by: Marcus D. Hanwell --- Modules/GenerateExportHeader.cmake | 251 ++++++++++++++++++ Modules/exportheader.cmake.in | 30 +++ Tests/CMakeLists.txt | 2 + .../GenerateExportHeader/CMakeLists.txt | 122 +++++++++ .../exportheader_test.cpp | 82 ++++++ .../lib_shared_and_static/CMakeLists.txt | 12 + .../libshared_and_static.cpp | 91 +++++++ .../libshared_and_static.h | 58 ++++ .../lib_shared_and_statictest/CMakeLists.txt | 23 ++ .../libshared/CMakeLists.txt | 6 + .../libshared/libshared.cpp | 91 +++++++ .../libshared/libshared.h | 59 ++++ .../libsharedtest/CMakeLists.txt | 27 ++ .../libstatic/CMakeLists.txt | 8 + .../libstatic/libstatic.cpp | 87 ++++++ .../libstatic/libstatic.h | 54 ++++ .../libstatictest/CMakeLists.txt | 13 + 17 files changed, 1016 insertions(+) create mode 100644 Modules/GenerateExportHeader.cmake create mode 100644 Modules/exportheader.cmake.in create mode 100644 Tests/Module/GenerateExportHeader/CMakeLists.txt create mode 100644 Tests/Module/GenerateExportHeader/exportheader_test.cpp create mode 100644 Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt create mode 100644 Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp create mode 100644 Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h create mode 100644 Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt create mode 100644 Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt create mode 100644 Tests/Module/GenerateExportHeader/libshared/libshared.cpp create mode 100644 Tests/Module/GenerateExportHeader/libshared/libshared.h create mode 100644 Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt create mode 100644 Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt create mode 100644 Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp create mode 100644 Tests/Module/GenerateExportHeader/libstatic/libstatic.h create mode 100644 Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake new file mode 100644 index 00000000000..c7178999bdf --- /dev/null +++ b/Modules/GenerateExportHeader.cmake @@ -0,0 +1,251 @@ + +# - Function for generation of export macros for libraries +# +# This module provides the function GENERATE_EXPORT_HEADER() and the +# accompanying ADD_COMPILER_EXPORT_FLAGS() function. +# +# The GENERATE_EXPORT_HEADER function can be used to generate a file suitable +# for preprocessor inclusion which contains EXPORT macros to be used in +# library classes. +# +# GENERATE_EXPORT_HEADER( LIBRARY_TARGET +# [BASE_NAME ] +# [EXPORT_MACRO_NAME ] +# [EXPORT_FILE_NAME ] +# [DEPRECATED_NAME ] +# [NO_EXPORT_MACRO_NAME ] +# [STATIC_DEFINE ] +# ) +# +# ADD_COMPILER_EXPORT_FLAGS( [FATAL_WARNINGS] ) +# +# By default GENERATE_EXPORT_HEADER() generates macro names in a file name +# determined by the name of the library. The ADD_COMPILER_EXPORT_FLAGS macro adds +# -fvisibility=hidden to CMAKE_CXX_FLAGS if supported, and is a no-op on Windows +# which does not need extra compiler flags for exporting support. +# +# This means that in the simplest case, users of these functions will be equivalent to: +# +# add_compiler_export_flags() +# +# add_library(somelib someclass.cpp) +# +# generate_export_header(somelib) +# +# install(TARGETS somelib DESTINATION ${LIBRARY_INSTALL_DIR}) +# +# install(FILES +# someclass.h +# ${PROJECT_BINARY_DIR}/somelib_export.h DESTINATION ${INCLUDE_INSTALL_DIR} +# ) +# +# And in the ABI header files: +# +# \code +# #include "somelib_export.h" +# +# class SOMELIB_EXPORT SomeClass { +# +# }; +# \endcode +# +# The CMake fragment will generate a file in the ${CMAKE_CURRENT_BUILD_DIR} called +# somelib_export.h containing the macros SOMELIB_EXPORT, SOMELIB_NO_EXPORT, +# SOMELIB_DEPRECATED, SOMELIB_DEPRECATED_EXPORT and SOMELIB_DEPRECATED_NO_EXPORT. +# The resulting file should be installed with other headers in the library. +# +# The BASE_NAME argument can be used to override the file name and the names +# used for the macros +# +# add_library(somelib someclass.cpp) +# generate_export_header(somelib +# BASE_NAME other_name +# ) +# +# Generates a file called other_name_export.h containing the macros +# OTHER_NAME_EXPORT, OTHER_NAME_NO_EXPORT and OTHER_NAME_DEPRECATED etc. +# +# The BASE_NAME may be overridden by specifiying other options in the function. +# For example: +# +# add_library(somelib someclass.cpp) +# generate_export_header(somelib +# EXPORT_MACRO_NAME OTHER_NAME_EXPORT +# ) +# +# creates the macro OTHER_NAME_EXPORT instead of SOMELIB_EXPORT, but other macros +# and the generated file name is as default. +# +# add_library(somelib someclass.cpp) +# generate_export_header(somelib +# DEPRECATED_NAME KDE_DEPRECATED +# ) +# +# creates the macro KDE_DEPRECATED instead of SOMELIB_DEPRECATED. +# +# If LIBRARY_TARGET is a static library, macros are defined without values. +# +# If the same sources are used to create both a shared and a static library, the +# uppercased symbol ${BASE_NAME}_STATIC_DEFINE should be used when building the +# static library +# +# add_library(shared_variant SHARED ${lib_SRCS}) +# add_library(static_variant ${lib_SRCS}) +# +# generate_export_header(shared_variant BASE_NAME libshared_and_static) +# +# set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) +# +# This will cause the export macros to expand to nothing when building the static library. + +include(CMakeParseArguments) +include(CheckCXXCompilerFlag) + +macro(_test_compiler_hidden_visibility) + check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) + check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) + option(USE_COMPILER_HIDDEN_VISIBILITY "Use HIDDEN visibility support if available." ON) + mark_as_advanced(USE_COMPILER_HIDDEN_VISIBILITY) +endmacro() + +set(myDir ${CMAKE_CURRENT_LIST_DIR}) + +macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) + set(DEFINE_DEPRECATED) + set(DEFINE_EXPORT) + set(DEFINE_IMPORT) + set(DEFINE_NO_EXPORT) + + if(WIN32) + set(DEFINE_DEPRECATED "__declspec(deprecated)") + else() + set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))") + endif() + + get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE) + + if(NOT ${type} STREQUAL "STATIC_LIBRARY") + if(WIN32) + set(DEFINE_EXPORT "__declspec(dllexport)") + set(DEFINE_IMPORT "__declspec(dllimport)") + elseif(CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Intel AND UNIX)) + if(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) + set(DEFINE_EXPORT "__attribute__((visibility(\"default\")))") + set(DEFINE_IMPORT "__attribute__((visibility(\"default\")))") + set(DEFINE_NO_EXPORT "__attribute__((visibility(\"hidden\")))") + endif() + endif() + endif() +endmacro() + +macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) + # Option overrides + set(options) + set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME DEPRECATED_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE) + set(multiValueArgs) + + cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(BASE_NAME "${TARGET_LIBRARY}") + + if(_GEH_BASE_NAME) + set(BASE_NAME ${_GEH_BASE_NAME}) + endif() + + string(TOUPPER ${BASE_NAME} BASE_NAME_UPPER) + string(TOLOWER ${BASE_NAME} BASE_NAME_LOWER) + + # Default options + set(EXPORT_MACRO_NAME "${PREFIX}${BASE_NAME_UPPER}_EXPORT") + set(NO_EXPORT_MACRO_NAME "${PREFIX}${BASE_NAME_UPPER}_NO_EXPORT") + set(EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${BASE_NAME_LOWER}_export.h") + set(DEPRECATED_NAME "${PREFIX}${BASE_NAME_UPPER}_DEPRECATED") + set(STATIC_DEFINE "${PREFIX}${BASE_NAME_UPPER}_STATIC_DEFINE") + + if(_GEH_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to GENERATE_EXPORT_HEADER(): \"${_GEH_UNPARSED_ARGUMENTS}\"") + endif() + + if(_GEH_EXPORT_MACRO_NAME) + set(EXPORT_MACRO_NAME ${PREFIX}${_GEH_EXPORT_MACRO_NAME}) + endif() + if(_GEH_EXPORT_FILE_NAME) + if(IS_ABSOLUTE _GEH_EXPORT_FILE_NAME) + set(EXPORT_FILE_NAME ${_GEH_EXPORT_FILE_NAME}) + else() + set(EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${_GEH_EXPORT_FILE_NAME}") + endif() + endif() + if(_GEH_DEPRECATED_NAME) + set(DEPRECATED_NAME ${PREFIX}${_GEH_DEPRECATED_NAME}) + endif() + if(_GEH_NO_EXPORT_MACRO_NAME) + set(NO_EXPORT_MACRO_NAME ${PREFIX}${_GEH_NO_EXPORT_MACRO_NAME}) + endif() + if(_GEH_STATIC_DEFINE) + set(STATIC_DEFINE ${PREFIX}${_GEH_STATIC_DEFINE}) + endif() + + set(INCLUDE_GUARD_NAME "${PREFIX}${EXPORT_MACRO_NAME}_H") + + configure_file(${myDir}/exportheader.cmake.in ${EXPORT_FILE_NAME} @ONLY) +endmacro() + +function(GENERATE_EXPORT_HEADER TARGET_LIBRARY) + get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE) + if(${type} STREQUAL "MODULE") + message(WARNING "This macro should not be used with libraries of type MODULE") + return() + endif() + if(NOT ${type} STREQUAL "STATIC_LIBRARY" AND NOT ${type} STREQUAL "SHARED_LIBRARY") + message(WARNING "This macro can only be used with libraries") + return() + endif() + _test_compiler_hidden_visibility() + _do_set_macro_values(${TARGET_LIBRARY}) + _do_generate_export_header(${TARGET_LIBRARY} ${ARGN}) +endfunction() + +function(add_compiler_export_flags) + + if(NOT CMAKE_COMPILER_IS_GNUCXX OR MINGW) + return() + endif() + + set(options) + set(oneValueArgs FATAL_WARNINGS) + set(multiValueArgs) + + cmake_parse_arguments(_EGHV "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(MESSAGE_TYPE WARNING) + + if(_EGHV_FATAL_WARNINGS) + set(MESSAGE_TYPE FATAL_ERROR) + endif() + + if (CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) + string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") + # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the + # patch level, handle this here: + if(NOT _gcc_version) + string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") + endif() + + if(${_gcc_version} VERSION_LESS "4.2") + return() + endif() + endif() + + _test_compiler_hidden_visibility() + + if(USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR) + set (EXTRA_FLAGS "-fvisibility=hidden") + + if(COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) + set (EXTRA_FLAGS "${EXTRA_FLAGS} -fvisibility-inlines-hidden") + endif() + endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}" PARENT_SCOPE) +endfunction() \ No newline at end of file diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in new file mode 100644 index 00000000000..083e95cbcc1 --- /dev/null +++ b/Modules/exportheader.cmake.in @@ -0,0 +1,30 @@ + +#ifndef @INCLUDE_GUARD_NAME@ +#define @INCLUDE_GUARD_NAME@ + +#ifdef @STATIC_DEFINE@ +# define @EXPORT_MACRO_NAME@ +# define @NO_EXPORT_MACRO_NAME@ +#else +# ifndef @EXPORT_MACRO_NAME@ +# ifdef @TARGET_LIBRARY@_EXPORTS + /* We are building this library */ +# define @EXPORT_MACRO_NAME@ @DEFINE_EXPORT@ +# else + /* We are using this library */ +# define @EXPORT_MACRO_NAME@ @DEFINE_IMPORT@ +# endif +# endif + +# ifndef @NO_EXPORT_MACRO_NAME@ +# define @NO_EXPORT_MACRO_NAME@ @DEFINE_NO_EXPORT@ +# endif +#endif + +#ifndef @DEPRECATED_NAME@ +# define @DEPRECATED_NAME@ @DEFINE_DEPRECATED@ +# define @DEPRECATED_NAME@_EXPORT @EXPORT_MACRO_NAME@ @DEFINE_DEPRECATED@ +# define @DEPRECATED_NAME@_NO_EXPORT @NO_EXPORT_MACRO_NAME@ @DEFINE_DEPRECATED@ +#endif + +#endif // @INCLUDE_GUARD_NAME@ \ No newline at end of file diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 4bf83b78057..eececb020d5 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -221,6 +221,8 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize) + ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader) + ADD_TEST(LinkFlags-prepare ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} --build-and-test diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt new file mode 100644 index 00000000000..2d6eabe06f8 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -0,0 +1,122 @@ +cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR) + +project(GenerateExportHeader) + +set( CMAKE_INCLUDE_CURRENT_DIR ON ) + +macro(TEST_FAIL value msg) + if (${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +macro(TEST_PASS value msg) + if (NOT ${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +# We seem to get race conditions is writing this stuff to the same file at least on MinGW +# So to write to separate source and build directories, we use a count to differentiate. +set (COUNT 0) +macro(_do_build Include Library LibrarySource Source) + + math(EXPR COUNT "${COUNT} + 1" ) + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/src.cpp" "#include \"${Include}\"\n" + "int main() { ${Source}; }\n" + ) + + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/../${LibrarySource}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}") + + if ("${Library}" STREQUAL "static_variant") + set(CONDITIONAL_STATIC_DEFINE "add_definitions(-DLIBSHARED_AND_STATIC_STATIC_DEFINE)\n") + endif() + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt" + "cmake_minimum_required(VERSION 2.8)\n" + + "project(compiletest)\n" + + "set(CMAKE_INCLUDE_CURRENT_DIR ON)\n" + + "include(GenerateExportHeader)\n" + + "add_compiler_export_flags()\n" + + "if(CMAKE_COMPILER_IS_GNUCXX)\n" + " add_definitions(-Werror)\n" + "else()\n" + " if(MSVC)\n" + # Treat deprecation warnings as errors. + " add_definitions(/we4996)\n" + " endif()\n" + "endif()\n" + + "if(MSVC)\n" + " add_definitions(-DCOMPILER_IS_MSVC)\n" + "endif()\n" + + "add_subdirectory(${LibrarySource})\n" + + "include_directories(${LibrarySource} \${CMAKE_CURRENT_BINARY_DIR}/${LibrarySource})\n" + + "${CONDITIONAL_STATIC_DEFINE}" + + "add_executable(compiletest src.cpp)\n" + "target_link_libraries(compiletest ${Library})\n" + ) + + try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/fail${COUNT} + ${CMAKE_CURRENT_BINARY_DIR}/test${COUNT} + compilefail + OUTPUT_VARIABLE Out + ) +endmacro() + +macro(build_fail Include Library LibrarySource Source Message) + _do_build(${Include} ${Library} ${LibrarySource} "${Source}") + test_fail(Result ${Message}) +endmacro() + +macro(build_pass Include Library LibrarySource Source Message) + _do_build(${Include} ${Library} ${LibrarySource} "${Source}") + test_pass(Result ${Message}) +endmacro() + +include(GenerateExportHeader) + +add_compiler_export_flags() + +if (MSVC) + add_definitions(-DCOMPILER_IS_MSVC) +endif() + +set(link_libraries) +macro(macro_add_test_library name) + add_subdirectory(${name}) + include_directories(${name} + ${${name}_BINARY_DIR} # For the export header. + ) + list(APPEND link_libraries ${name}) + add_subdirectory(${name}test) +endmacro() + +macro_add_test_library(libshared) +macro_add_test_library(libstatic) +add_subdirectory(lib_shared_and_static) +add_subdirectory(lib_shared_and_statictest) + +if (CMAKE_COMPILER_IS_GNUCXX) + # We deliberately call deprecated methods, and test for that elsewhere. + # No need to clutter the test output with warnings. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") +endif() + +if(MSVC) + add_definitions(/wd4996) +endif() + +add_executable(GenerateExportHeader exportheader_test.cpp) + +target_link_libraries(GenerateExportHeader ${link_libraries}) diff --git a/Tests/Module/GenerateExportHeader/exportheader_test.cpp b/Tests/Module/GenerateExportHeader/exportheader_test.cpp new file mode 100644 index 00000000000..cfc1a053f55 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/exportheader_test.cpp @@ -0,0 +1,82 @@ + +#include "libshared.h" + +#include "libstatic.h" + +// #define BUILD_FAIL + +#ifndef BUILD_FAIL +#define DOES_NOT_BUILD(function) +#else +#define DOES_NOT_BUILD(function) function +#endif + +int main() +{ + { + Libshared l; + l.libshared(); + l.libshared_exported(); + l.libshared_deprecated(); + l.libshared_not_exported(); + + DOES_NOT_BUILD(l.libshared_excluded();) + } + + { + LibsharedNotExported l; + DOES_NOT_BUILD(l.libshared();) + l.libshared_exported(); + l.libshared_deprecated(); + DOES_NOT_BUILD(l.libshared_not_exported();) + DOES_NOT_BUILD(l.libshared_excluded();) + } + + { + LibsharedExcluded l; + DOES_NOT_BUILD(l.libshared();) + l.libshared_exported(); + l.libshared_deprecated(); + DOES_NOT_BUILD(l.libshared_not_exported();) + DOES_NOT_BUILD(l.libshared_excluded();) + } + + libshared_exported(); + libshared_deprecated(); + DOES_NOT_BUILD(libshared_not_exported();) + DOES_NOT_BUILD(libshared_excluded();) + + { + Libstatic l; + l.libstatic(); + l.libstatic_exported(); + l.libstatic_deprecated(); + l.libstatic_not_exported(); + l.libstatic_excluded(); + } + + { + LibstaticNotExported l; + l.libstatic(); + l.libstatic_exported(); + l.libstatic_deprecated(); + l.libstatic_not_exported(); + l.libstatic_excluded(); + } + + { + LibstaticExcluded l; + l.libstatic(); + l.libstatic_exported(); + l.libstatic_deprecated(); + l.libstatic_not_exported(); + l.libstatic_excluded(); + } + + libstatic_exported(); + libstatic_deprecated(); + libstatic_not_exported(); + libstatic_excluded(); + + return 0; +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt new file mode 100644 index 00000000000..d19b6dc2fd0 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt @@ -0,0 +1,12 @@ +project(shared_and_static) + +set(lib_SRCS + libshared_and_static.cpp +) + +add_library(shared_variant SHARED ${lib_SRCS}) +add_library(static_variant ${lib_SRCS}) + +generate_export_header(shared_variant BASE_NAME libshared_and_static) + +set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp new file mode 100644 index 00000000000..1e072736273 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp @@ -0,0 +1,91 @@ + +#include "libshared_and_static.h" + +int LibsharedAndStatic::libshared_and_static() const +{ + return 0; +} + +int LibsharedAndStatic::libshared_and_static_exported() const +{ + return 0; +} + +int LibsharedAndStatic::libshared_and_static_deprecated() const +{ + return 0; +} + +int LibsharedAndStatic::libshared_and_static_not_exported() const { + return 0; +} + +int LibsharedAndStatic::libshared_and_static_excluded() const { + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static() const +{ + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_exported() const +{ + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_deprecated() const +{ + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_not_exported() const { + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_excluded() const { + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static() const +{ + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_exported() const +{ + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_deprecated() const +{ + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_not_exported() const { + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_excluded() const { + return 0; +} + +int libshared_and_static() { + return 0; +} + +int libshared_and_static_exported() { + return 0; +} + +int libshared_and_static_deprecated() { + return 0; +} + +int libshared_and_static_not_exported() { + return 0; +} + +int libshared_and_static_excluded() { + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h new file mode 100644 index 00000000000..7df76946095 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h @@ -0,0 +1,58 @@ + +#ifndef SHARED_AND_STATIC_H +#define SHARED_AND_STATIC_H + +#include "libshared_and_static_export.h" + +class LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic { +public: + int libshared_and_static() const; + +#ifdef COMPILER_IS_MSVC + int libshared_and_static_exported() const; +#else + int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; +#endif + + int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + + int libshared_and_static_not_exported() const; + + int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; +}; + +class LibsharedAndStaticNotExported { +public: + int libshared_and_static() const; + + int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; + + int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + + int libshared_and_static_not_exported() const; + + int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; +}; + +class LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded { +public: + int libshared_and_static() const; + + int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; + + int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + + int libshared_and_static_not_exported() const; + + int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; +}; + +LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported(); + +LIBSHARED_AND_STATIC_DEPRECATED int libshared_and_static_deprecated(); + +int libshared_and_static_not_exported(); + +int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded(); + +#endif diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt new file mode 100644 index 00000000000..2030de68bf8 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt @@ -0,0 +1,23 @@ + +macro(shared_variant_build_pass Source Message) + build_pass("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +macro(shared_variant_build_fail Source Message) + build_fail("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +macro(static_variant_build_pass Source Message) + build_pass("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +macro(static_variant_build_fail Source Message) + build_fail("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +static_variant_build_pass("return libshared_and_static_exported();" "Failed to build static variant") +shared_variant_build_pass("return libshared_and_static_exported();" "Failed to build shared variant") +shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant") +static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant") +static_variant_build_pass("return libshared_and_static_not_exported();" "Failed to build static not exported variant") +shared_variant_build_fail("return libshared_and_static_not_exported();" "Built shared not exported variant") diff --git a/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt new file mode 100644 index 00000000000..8e4ee2b312d --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt @@ -0,0 +1,6 @@ + +project(libshared) + +add_library(libshared SHARED libshared.cpp) + +generate_export_header(libshared) diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.cpp b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp new file mode 100644 index 00000000000..9812f556916 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp @@ -0,0 +1,91 @@ + +#include "libshared.h" + +int Libshared::libshared() const +{ + return 0; +} + +int Libshared::libshared_exported() const +{ + return 0; +} + +int Libshared::libshared_deprecated() const +{ + return 0; +} + +int Libshared::libshared_not_exported() const { + return 0; +} + +int Libshared::libshared_excluded() const { + return 0; +} + +int LibsharedNotExported::libshared() const +{ + return 0; +} + +int LibsharedNotExported::libshared_exported() const +{ + return 0; +} + +int LibsharedNotExported::libshared_deprecated() const +{ + return 0; +} + +int LibsharedNotExported::libshared_not_exported() const { + return 0; +} + +int LibsharedNotExported::libshared_excluded() const { + return 0; +} + +int LibsharedExcluded::libshared() const +{ + return 0; +} + +int LibsharedExcluded::libshared_exported() const +{ + return 0; +} + +int LibsharedExcluded::libshared_deprecated() const +{ + return 0; +} + +int LibsharedExcluded::libshared_not_exported() const { + return 0; +} + +int LibsharedExcluded::libshared_excluded() const { + return 0; +} + +int libshared() { + return 0; +} + +int libshared_exported() { + return 0; +} + +int libshared_deprecated() { + return 0; +} + +int libshared_not_exported() { + return 0; +} + +int libshared_excluded() { + return 0; +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.h b/Tests/Module/GenerateExportHeader/libshared/libshared.h new file mode 100644 index 00000000000..280e1857191 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libshared/libshared.h @@ -0,0 +1,59 @@ + +#ifndef LIBSHARED_H +#define LIBSHARED_H + +#include "libshared_export.h" + +class LIBSHARED_EXPORT Libshared { +public: + int libshared() const; + +#ifdef COMPILER_IS_MSVC + // Double exporting not possible with MSVC + int libshared_exported() const; +#else + int LIBSHARED_EXPORT libshared_exported() const; +#endif + + int LIBSHARED_DEPRECATED libshared_deprecated() const; + + int libshared_not_exported() const; + + int LIBSHARED_NO_EXPORT libshared_excluded() const; +}; + +class LibsharedNotExported { +public: + int libshared() const; + + int LIBSHARED_EXPORT libshared_exported() const; + + int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const; + + int libshared_not_exported() const; + + int LIBSHARED_NO_EXPORT libshared_excluded() const; +}; + +class LIBSHARED_NO_EXPORT LibsharedExcluded { +public: + int libshared() const; + + int LIBSHARED_EXPORT libshared_exported() const; + + int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const; + + int libshared_not_exported() const; + + int LIBSHARED_NO_EXPORT libshared_excluded() const; +}; + +LIBSHARED_EXPORT int libshared_exported(); + +LIBSHARED_DEPRECATED_EXPORT int libshared_deprecated(); + +int libshared_not_exported(); + +int LIBSHARED_NO_EXPORT libshared_excluded(); + +#endif diff --git a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt new file mode 100644 index 00000000000..7a05205b49c --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt @@ -0,0 +1,27 @@ + +macro(shared_build_pass Source Message) + build_pass("libshared.h" "libshared" "libshared" "${Source}" ${Message}) +endmacro() + +macro(shared_build_fail Source Message) + build_fail("libshared.h" "libshared" "libshared" "${Source}" ${Message}) +endmacro() + +shared_build_pass("Libshared l; return l.libshared_exported();" "Failed to build exported") + +shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") +if (COMPILER_HAS_HIDDEN_VISIBILITY) + shared_build_fail("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") +else() + # There is no MSVC equivalent to hiding symbols. + shared_build_pass("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This is possible on MSVC.") +endif() +shared_build_fail("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method. This should not be possible.") +shared_build_fail("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method. This should not be possible.") +shared_build_fail("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method. This should not be possible.") +shared_build_fail("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method. This should not be possible.") +shared_build_fail("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method. This should not be possible.") +shared_build_fail("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") + +shared_build_fail("return libshared_excluded();" "Built use of excluded function. This should not be possible.") +shared_build_fail("return libshared_not_exported();" "Built use of not-exported function. This should not be possible.") diff --git a/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt new file mode 100644 index 00000000000..8db18271004 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt @@ -0,0 +1,8 @@ + +project(libstatic) + +# Show that the export header has no effect on a static library. + +add_library(libstatic STATIC libstatic.cpp) + +generate_export_header(libstatic) diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp new file mode 100644 index 00000000000..c8b7d4454ce --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp @@ -0,0 +1,87 @@ + +#include "libstatic.h" + +int Libstatic::libstatic() const +{ + return 0; +} + +int Libstatic::libstatic_exported() const +{ + return 0; +} + +int Libstatic::libstatic_deprecated() const +{ + return 0; +} + +int Libstatic::libstatic_not_exported() const { + return 0; +} + +int Libstatic::libstatic_excluded() const { + return 0; +} + +int LibstaticNotExported::libstatic() const +{ + return 0; +} + +int LibstaticNotExported::libstatic_exported() const +{ + return 0; +} + +int LibstaticNotExported::libstatic_deprecated() const +{ + return 0; +} + +int LibstaticNotExported::libstatic_not_exported() const { + return 0; +} + +int LibstaticNotExported::libstatic_excluded() const { + return 0; +} + +int LibstaticExcluded::libstatic() const +{ + return 0; +} + +int LibstaticExcluded::libstatic_exported() const +{ + return 0; +} + +int LibstaticExcluded::libstatic_deprecated() const +{ + return 0; +} + +int LibstaticExcluded::libstatic_not_exported() const { + return 0; +} + +int LibstaticExcluded::libstatic_excluded() const { + return 0; +} + +int libstatic_exported() { + return 0; +} + +int libstatic_deprecated() { + return 0; +} + +int libstatic_not_exported() { + return 0; +} + +int libstatic_excluded() { + return 0; +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.h b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h new file mode 100644 index 00000000000..c6562ecb639 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h @@ -0,0 +1,54 @@ + +#ifndef LIBSTATIC_H +#define LIBSTATIC_H + +#include "libstatic_export.h" + +class LIBSTATIC_EXPORT Libstatic { +public: + int libstatic() const; + + int LIBSTATIC_EXPORT libstatic_exported() const; + + int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + + int libstatic_not_exported() const; + + int LIBSTATIC_NO_EXPORT libstatic_excluded() const; +}; + +class LibstaticNotExported { +public: + int libstatic() const; + + int LIBSTATIC_EXPORT libstatic_exported() const; + + int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + + int libstatic_not_exported() const; + + int LIBSTATIC_NO_EXPORT libstatic_excluded() const; +}; + +class LIBSTATIC_NO_EXPORT LibstaticExcluded { +public: + int libstatic() const; + + int LIBSTATIC_EXPORT libstatic_exported() const; + + int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + + int libstatic_not_exported() const; + + int LIBSTATIC_NO_EXPORT libstatic_excluded() const; +}; + +LIBSTATIC_EXPORT int libstatic_exported(); + +LIBSTATIC_DEPRECATED int libstatic_deprecated(); + +int libstatic_not_exported(); + +int LIBSTATIC_NO_EXPORT libstatic_excluded(); + +#endif diff --git a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt new file mode 100644 index 00000000000..58b875a07c9 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt @@ -0,0 +1,13 @@ + +macro(static_build_pass Source Message) + build_pass("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message}) +endmacro() + +macro(static_build_fail Source Message) + build_fail("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message}) +endmacro() + +static_build_pass("Libstatic l; return l.libstatic_exported();" "Failed to build exported.") + +static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") +static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") From def0a54e0ae20d783aecf2761a4add5f40687cd6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 8 Aug 2011 02:08:10 +0200 Subject: [PATCH 027/539] Handle the case where the user changes the DEFINE_SYMBOL property. This eases porting of KDE code. --- Modules/GenerateExportHeader.cmake | 6 ++++++ Modules/exportheader.cmake.in | 2 +- Tests/Module/GenerateExportHeader/CMakeLists.txt | 2 ++ .../override_symbol/CMakeLists.txt | 11 +++++++++++ .../GenerateExportHeader/override_symbol/main.cpp | 9 +++++++++ .../override_symbol/someclass.cpp | 7 +++++++ .../GenerateExportHeader/override_symbol/someclass.h | 8 ++++++++ 7 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt create mode 100644 Tests/Module/GenerateExportHeader/override_symbol/main.cpp create mode 100644 Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp create mode 100644 Tests/Module/GenerateExportHeader/override_symbol/someclass.h diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index c7178999bdf..3665817f769 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -188,6 +188,12 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) set(INCLUDE_GUARD_NAME "${PREFIX}${EXPORT_MACRO_NAME}_H") + get_target_property(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY} DEFINE_SYMBOL) + + if (NOT EXPORT_IMPORT_CONDITION) + set(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY}_EXPORTS) + endif() + configure_file(${myDir}/exportheader.cmake.in ${EXPORT_FILE_NAME} @ONLY) endmacro() diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in index 083e95cbcc1..62ed3ff9261 100644 --- a/Modules/exportheader.cmake.in +++ b/Modules/exportheader.cmake.in @@ -7,7 +7,7 @@ # define @NO_EXPORT_MACRO_NAME@ #else # ifndef @EXPORT_MACRO_NAME@ -# ifdef @TARGET_LIBRARY@_EXPORTS +# ifdef @EXPORT_IMPORT_CONDITION@ /* We are building this library */ # define @EXPORT_MACRO_NAME@ @DEFINE_EXPORT@ # else diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 2d6eabe06f8..457028092a5 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -107,6 +107,8 @@ macro_add_test_library(libstatic) add_subdirectory(lib_shared_and_static) add_subdirectory(lib_shared_and_statictest) +add_subdirectory(override_symbol) + if (CMAKE_COMPILER_IS_GNUCXX) # We deliberately call deprecated methods, and test for that elsewhere. # No need to clutter the test output with warnings. diff --git a/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt new file mode 100644 index 00000000000..aeeef20eefc --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt @@ -0,0 +1,11 @@ +project(override_symbol) + +add_library(somelib SHARED someclass.cpp) + +set_target_properties(somelib PROPERTIES DEFINE_SYMBOL SOMELIB_MAKEDLL) + +generate_export_header(somelib) + +add_executable(consumer main.cpp) + +target_link_libraries(consumer somelib) diff --git a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp new file mode 100644 index 00000000000..445a6520414 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp @@ -0,0 +1,9 @@ + +#include "someclass.h" + +int main(int, char**) +{ + SomeClass sc; + sc.someMethod(); + return 0; +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp new file mode 100644 index 00000000000..7326b780abc --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp @@ -0,0 +1,7 @@ + +#include "someclass.h" + +void SomeClass::someMethod() const +{ + +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.h b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h new file mode 100644 index 00000000000..ae5e8445408 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h @@ -0,0 +1,8 @@ + +#include "somelib_export.h" + +class SOMELIB_EXPORT SomeClass +{ +public: + void someMethod() const; +}; From ed6be501de960a21fc756d08e9a0a2318f276307 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 8 Aug 2011 12:53:17 -0400 Subject: [PATCH 028/539] Fix CHECK_(C|CXX)_COMPILER_FLAG for Clang (#12394) This compiler warns and returns 0 for unrecognized flags. We fix the compiler flag check macros by looking for a warning in the output. --- Modules/CheckCCompilerFlag.cmake | 1 + Modules/CheckCXXCompilerFlag.cmake | 1 + 2 files changed, 2 insertions(+) diff --git a/Modules/CheckCCompilerFlag.cmake b/Modules/CheckCCompilerFlag.cmake index a390b382069..ec0a773e397 100644 --- a/Modules/CheckCCompilerFlag.cmake +++ b/Modules/CheckCCompilerFlag.cmake @@ -30,6 +30,7 @@ MACRO (CHECK_C_COMPILER_FLAG _FLAG _RESULT) FAIL_REGEX "warning: command line option .* is valid for .* but not for C" # Apple gcc FAIL_REGEX "unrecognized .*option" # GNU + FAIL_REGEX "unknown .*option" # Clang FAIL_REGEX "ignoring unknown option" # MSVC FAIL_REGEX "warning D9002" # MSVC, any lang FAIL_REGEX "[Uu]nknown option" # HP diff --git a/Modules/CheckCXXCompilerFlag.cmake b/Modules/CheckCXXCompilerFlag.cmake index 788bf35b427..f646e78126f 100644 --- a/Modules/CheckCXXCompilerFlag.cmake +++ b/Modules/CheckCXXCompilerFlag.cmake @@ -28,6 +28,7 @@ MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT) CHECK_CXX_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT} # Some compilers do not fail with a bad flag FAIL_REGEX "unrecognized .*option" # GNU + FAIL_REGEX "unknown .*option" # Clang FAIL_REGEX "ignoring unknown option" # MSVC FAIL_REGEX "warning D9002" # MSVC, any lang FAIL_REGEX "[Uu]nknown option" # HP From 896371661504fa0a3b5c7a611dbfc7a4bc44a889 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 9 Aug 2011 00:18:00 +0200 Subject: [PATCH 029/539] Add a newline at the end of the file. Hopefully fix the test execution reported on CDash. --- Tests/Module/GenerateExportHeader/libshared/libshared.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.cpp b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp index 9812f556916..d4041b36d71 100644 --- a/Tests/Module/GenerateExportHeader/libshared/libshared.cpp +++ b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp @@ -88,4 +88,4 @@ int libshared_not_exported() { int libshared_excluded() { return 0; -} \ No newline at end of file +} From 706ed2b1b0376c8f6bce064315d83b564931d811 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 9 Aug 2011 00:18:00 +0200 Subject: [PATCH 030/539] Add a newline at the end of the file. Hopefully fix the test execution reported on CDash. --- Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp index c8b7d4454ce..0710c3e9e9f 100644 --- a/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp +++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp @@ -84,4 +84,4 @@ int libstatic_not_exported() { int libstatic_excluded() { return 0; -} \ No newline at end of file +} From 7690edffd9801c41dcfa4ef2a6213d4883e55c83 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 13 Jul 2011 18:59:51 +0200 Subject: [PATCH 031/539] Replace cmake::GetScriptMode() with GetWorkingMode() GetWorkingMode() returns a new enum WorkingMode, which is one of NORMAL_MODE, SCRIPT_MODE and FIND_PACKAGE_MODE. Alex --- Source/cmGlobalGenerator.cxx | 2 +- Source/cmMakefile.cxx | 8 ++++---- Source/cmake.cxx | 15 +++++++-------- Source/cmake.h | 34 ++++++++++++++++++++++------------ Source/cmakemain.cxx | 10 ++++------ 5 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6c8938e5d34..31035cd5ce2 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -782,7 +782,7 @@ void cmGlobalGenerator::Configure() // so create the map from project name to vector of local generators this->FillProjectMap(); - if ( !this->CMakeInstance->GetScriptMode() ) + if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE) { const char* msg = "Configuring done"; if(cmSystemTools::GetErrorOccuredFlag()) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 163145eb78a..3329a2c4b4e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -384,8 +384,8 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, // Decide whether to invoke the command. if(pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() && - (this->GetCMakeInstance()->GetFindPackageMode() - || !this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable())) + (this->GetCMakeInstance()->GetWorkingMode() != cmake::SCRIPT_MODE + || pcmd->IsScriptable())) { // if trace is one, print out invoke information @@ -413,7 +413,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError()); } result = false; - if ( this->GetCMakeInstance()->GetScriptMode() ) + if ( this->GetCMakeInstance()->GetWorkingMode() != cmake::NORMAL_MODE) { cmSystemTools::SetFatalErrorOccured(); } @@ -424,7 +424,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, this->UsedCommands.push_back(pcmd.release()); } } - else if ( this->GetCMakeInstance()->GetScriptMode() + else if ( this->GetCMakeInstance()->GetWorkingMode() == cmake::SCRIPT_MODE && !pcmd->IsScriptable() ) { std::string error = "Command "; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 5b6286eec9b..8cadc4f757f 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -180,8 +180,7 @@ cmake::cmake() this->GlobalGenerator = 0; this->ProgressCallback = 0; this->ProgressCallbackClientData = 0; - this->ScriptMode = false; - this->FindPackageMode = false; + this->CurrentWorkingMode = NORMAL_MODE; #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch = new cmVariableWatch; @@ -523,7 +522,7 @@ void cmake::ReadListFile(const std::vector& args, (cmSystemTools::GetCurrentWorkingDirectory().c_str()); lg->GetMakefile()->SetStartDirectory (cmSystemTools::GetCurrentWorkingDirectory().c_str()); - if (this->GetScriptMode()) + if (this->GetWorkingMode() != NORMAL_MODE) { std::string file(cmSystemTools::CollapseFullPath(path)); cmSystemTools::ConvertToUnixSlashes(file); @@ -2147,7 +2146,7 @@ int cmake::ActualConfigure() this->CleanupCommandsAndMacros(); int res = 0; - if ( !this->ScriptMode ) + if ( this->GetWorkingMode() == NORMAL_MODE ) { res = this->DoPreConfigureChecks(); } @@ -2335,7 +2334,7 @@ int cmake::ActualConfigure() this->CacheManager->RemoveCacheEntry("CMAKE_EXTRA_GENERATOR"); } // only save the cache if there were no fatal errors - if ( !this->ScriptMode ) + if ( this->GetWorkingMode() == NORMAL_MODE ) { this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); } @@ -2401,7 +2400,7 @@ int cmake::Run(const std::vector& args, bool noconfigure) // set the cmake command this->CMakeCommand = args[0]; - if ( !this->ScriptMode ) + if ( this->GetWorkingMode() == NORMAL_MODE ) { // load the cache if(this->LoadCache() < 0) @@ -2422,7 +2421,7 @@ int cmake::Run(const std::vector& args, bool noconfigure) } // In script mode we terminate after running the script. - if(this->ScriptMode) + if(this->GetWorkingMode() != NORMAL_MODE) { if(cmSystemTools::GetErrorOccuredFlag()) { @@ -2468,7 +2467,7 @@ int cmake::Run(const std::vector& args, bool noconfigure) this->SetStartDirectory(this->GetHomeDirectory()); this->SetStartOutputDirectory(this->GetHomeOutputDirectory()); int ret = this->Configure(); - if (ret || this->ScriptMode) + if (ret || this->GetWorkingMode() != NORMAL_MODE) { #if defined(CMAKE_HAVE_VS_GENERATORS) if(!this->VSSolutionFile.empty() && this->GlobalGenerator) diff --git a/Source/cmake.h b/Source/cmake.h index 7335813bc00..46d375eace5 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -64,6 +64,25 @@ class cmake WARNING, LOG }; + + + /** Describes the working modes of cmake. + * NORMAL_MODE: cmake runs to create project files + * SCRIPT_MODE: in script mode there is no generator and no cache. Also, + * language are not enabled, so add_executable and things do + * not do anything. Started by using -P + * FIND_PACKAGE_MODE: cmake runs in pkg-config like mode, i.e. it just + * searches for a package and prints the results to stdout. + * This is similar to SCRIPT_MODE, but commands like + * add_library() work too, since they may be used e.g. in + * exported target files. Started via --find-package + */ + enum WorkingMode + { + NORMAL_MODE, + SCRIPT_MODE, + FIND_PACKAGE_MODE + }; typedef std::map RegisteredCommandsMap; ///! construct an instance of cmake @@ -274,16 +293,8 @@ class cmake ///! Do all the checks before running configure int DoPreConfigureChecks(); - /** - * Set and get the script mode option. In script mode there is no - * generator and no cache. Also, language are not enabled, so - * add_executable and things do not do anything. - */ - void SetScriptMode(bool mode) { this->ScriptMode = mode; } - bool GetScriptMode() { return this->ScriptMode; } - - void SetFindPackageMode(bool mode) {this->FindPackageMode = mode; } - bool GetFindPackageMode() {return this->FindPackageMode;} + void SetWorkingMode(WorkingMode mode) { this->CurrentWorkingMode = mode; } + WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; } ///! Debug the try compile stuff by not delelting the files bool GetDebugTryCompile(){return this->DebugTryCompile;} @@ -464,8 +475,7 @@ class cmake void* ProgressCallbackClientData; bool Verbose; bool InTryCompile; - bool ScriptMode; - bool FindPackageMode; + WorkingMode CurrentWorkingMode; bool DebugOutput; bool Trace; bool WarnUninitialized; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index ae4529a4428..c744dcd1b9b 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -436,8 +436,7 @@ int do_cmake(int ac, char** av) bool list_all_cached = false; bool list_help = false; bool view_only = false; - bool script_mode = false; - bool find_package_mode = false; + cmake::WorkingMode workingMode = cmake::NORMAL_MODE; std::vector args; for(int i =0; i < ac; ++i) { @@ -485,7 +484,7 @@ int do_cmake(int ac, char** av) } else { - script_mode = true; + workingMode = cmake::SCRIPT_MODE; args.push_back(av[i]); i++; args.push_back(av[i]); @@ -494,7 +493,7 @@ int do_cmake(int ac, char** av) else if (!command && strncmp(av[i], "--find-package", strlen("--find-package")) == 0) { - find_package_mode = true; + workingMode = cmake::FIND_PACKAGE_MODE; args.push_back(av[i]); } else @@ -521,8 +520,7 @@ int do_cmake(int ac, char** av) cmake cm; cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm); cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm); - cm.SetScriptMode(script_mode || find_package_mode); - cm.SetFindPackageMode(find_package_mode); + cm.SetWorkingMode(workingMode); int res = cm.Run(args, view_only); if ( list_cached || list_all_cached ) From b8fdaa1d662b01a167c94f2a9a9efec9dd0ea2d0 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 13 Jul 2011 19:02:08 +0200 Subject: [PATCH 032/539] Fix copyright notice in new CMakeFindPackageMode.cmake Alex --- Modules/CMakeFindPackageMode.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 5842c7aefae..7e954633ba6 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -4,6 +4,19 @@ # NAME = name of the package # QUIET = if TRUE, don't print anything +#============================================================================= +# Copyright 2006-2011 Alexander Neundorf, +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + if(NOT NAME) message(FATAL_ERROR "NAME argument not specified.") endif() From 53edfb206b549f0dd5a014aac054ca82d865bbcd Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 14 Jul 2011 23:53:01 +0200 Subject: [PATCH 033/539] Better support for lib64 and Debian multiarch If CMAKE_SIZEOF_VOID_P is not set from the outside, it checks for the existance of /usr/lib64, and if it exists, SIZEOF_VOID_P is set to 8. For multiarch, if this is debian and CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE has not been set, it globs for the files in /lib, and uses the first one which matches CMAKE_LIBRARY_ARCHITECTURE_REGEX. Alex --- Modules/CMakeFindPackageMode.cmake | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 7e954633ba6..bebf3ab0d33 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -40,9 +40,32 @@ include(CMakeDetermineSystem) # This makes the FIND_XXX() calls work much better include(CMakeSystemSpecificInformation) -# this is ugly, and not enough for the multilib-stuff I guess -if(UNIX AND EXISTS /usr/lib64) - set(CMAKE_SIZEOF_VOID_P 8) +if(UNIX) + + # try to guess whether we have a 64bit system, if it has not been set + # from the outside + if(NOT CMAKE_SIZEOF_VOID_P) + if(EXISTS /usr/lib64) + set(CMAKE_SIZEOF_VOID_P 8) + else() + set(CMAKE_SIZEOF_VOID_P 4) + endif() + endif() + + # guess Debian multiarch if it has not been set: + if(EXISTS /etc/debian_version) + if(NOT CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE ) + file(GLOB filesInLib RELATIVE /lib /lib/*-linux-gnu* ) + list(APPEND filesInLib i386-linux-gnu) + foreach(file ${filesInLib}) + if("${file}" MATCHES "${CMAKE_LIBRARY_ARCHITECTURE_REGEX}") + set(CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE ${file}) + break() + endif() + endforeach() + endif() + endif() + endif() set(CMAKE_${LANGUAGE}_COMPILER "dummy") From b0e357824c0ddf1a57db7742da3d5f3f90af97d2 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 18 Jul 2011 21:40:45 +0200 Subject: [PATCH 034/539] Use the file-utility to test for 64bit if there is no /usr/lib64 Alex --- Modules/CMakeFindPackageMode.cmake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index bebf3ab0d33..3e5cb49a678 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -45,10 +45,18 @@ if(UNIX) # try to guess whether we have a 64bit system, if it has not been set # from the outside if(NOT CMAKE_SIZEOF_VOID_P) + set(CMAKE_SIZEOF_VOID_P 4) if(EXISTS /usr/lib64) set(CMAKE_SIZEOF_VOID_P 8) else() - set(CMAKE_SIZEOF_VOID_P 4) + # use the file utility to check whether itself is 64 bit: + find_program(FILE_EXECUTABLE file) + if(FILE_EXECUTABLE) + execute_process(COMMAND "${FILE_EXECUTABLE}" "${FILE_EXECUTABLE}" OUTPUT_VARIABLE fileOutput ERROR_QUIET) + if("${fileOutput}" MATCHES "64-bit") + set(CMAKE_SIZEOF_VOID_P 8) + endif() + endif() endif() endif() @@ -56,7 +64,6 @@ if(UNIX) if(EXISTS /etc/debian_version) if(NOT CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE ) file(GLOB filesInLib RELATIVE /lib /lib/*-linux-gnu* ) - list(APPEND filesInLib i386-linux-gnu) foreach(file ${filesInLib}) if("${file}" MATCHES "${CMAKE_LIBRARY_ARCHITECTURE_REGEX}") set(CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE ${file}) From b19911ecab8178230ef5f1605e7730f842b39633 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 9 Aug 2011 19:03:16 +0200 Subject: [PATCH 035/539] Add missing licence header. --- Modules/GenerateExportHeader.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 3665817f769..67a16a9320f 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -98,6 +98,20 @@ # # This will cause the export macros to expand to nothing when building the static library. + +#============================================================================= +# Copyright 2011 Stephen Kelly +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + include(CMakeParseArguments) include(CheckCXXCompilerFlag) From 0167ceaf98c78f40532fc187b35440d033ac837e Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 9 Aug 2011 15:13:46 -0400 Subject: [PATCH 036/539] Add more find_path locations for DCMTK header files (#12323) --- Modules/FindDCMTK.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Modules/FindDCMTK.cmake b/Modules/FindDCMTK.cmake index 0ac22f8fc0c..361d09e8bc8 100644 --- a/Modules/FindDCMTK.cmake +++ b/Modules/FindDCMTK.cmake @@ -108,8 +108,10 @@ foreach(dir PATHS ${DCMTK_DIR}/${dir}/include ${DCMTK_DIR}/${dir} - ${DCMTK_DIR}/include/${dir}) - + ${DCMTK_DIR}/include/${dir} + ${DCMTK_DIR}/include/dcmtk/${dir} + ${DCMTK_DIR}/${dir}/include/dcmtk/${dir} + ) mark_as_advanced(DCMTK_${dir}_INCLUDE_DIR) if(DCMTK_${dir}_INCLUDE_DIR) From 431c8eb44cc148ae49e043e2cebfa143bfca0387 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 10 Aug 2011 02:28:26 +0200 Subject: [PATCH 037/539] Add macros GETTEXT_PROCESS_POT() and GETTEXT_PROCESS_PO_FILES() These macros (functions actually) can be used to process pot and po files. Patch prepared by Raphael Kubo da Costa. Alex --- Modules/FindGettext.cmake | 98 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 91 insertions(+), 7 deletions(-) diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index 9398b547331..3ef141d3dc0 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -11,9 +11,22 @@ # given input po files into the binary output mo file. If the # ALL option is used, the translations will also be created when # building the default target. +# GETTEXT_PROCESS_POT( [ALL] [INSTALL_DESTINATION ] LANGUAGES ... ) +# Process the given pot file to mo files. +# If INSTALL_DESTINATION is given then automatically install rules will be created, +# the language subdirectory will be taken into account (by default use share/locale/). +# If ALL is specified, the pot file is processed when building the all traget. +# It creates a custom target "potfile". +# GETTEXT_PROCESS_PO_FILES( [ALL] [INSTALL_DESTINATION ] PO_FILES ... ) +# Process the given po files to mo files for the given language. +# If INSTALL_DESTINATION is given then automatically install rules will be created, +# the language subdirectory will be taken into account (by default use share/locale/). +# If ALL is specified, the po files are processed when building the all traget. +# It creates a custom target "pofiles". #============================================================================= # Copyright 2007-2009 Kitware, Inc. +# Copyright 2007 Alexander Neundorf # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -29,6 +42,8 @@ FIND_PROGRAM(GETTEXT_MSGMERGE_EXECUTABLE msgmerge) FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt) +INCLUDE(CMakeParseArguments) + MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) # make it a real variable, so we can modify it here SET(_firstPoFile "${_firstPoFileArg}") @@ -49,14 +64,14 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) GET_FILENAME_COMPONENT(_lang ${_absFile} NAME_WE) SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo) - ADD_CUSTOM_COMMAND( - OUTPUT ${_gmoFile} + ADD_CUSTOM_COMMAND( + OUTPUT ${_gmoFile} COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile} - DEPENDS ${_absPotFile} ${_absFile} + DEPENDS ${_absPotFile} ${_absFile} ) - INSTALL(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) + INSTALL(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) SET(_gmoFiles ${_gmoFiles} ${_gmoFile}) ENDFOREACH (_currentPoFile ) @@ -65,6 +80,78 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) ENDMACRO(GETTEXT_CREATE_TRANSLATIONS ) + +FUNCTION(GETTEXT_PROCESS_POT_FILE _potFile) + SET(_gmoFiles) + SET(_options ALL) + SET(_oneValueArgs INSTALL_DESTINATION) + SET(_multiValueArgs LANGUAGES) + + CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + + GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE) + GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE) + + FOREACH (_lang ${_parsedArguments_LANGUAGES}) + SET(_poFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.po") + SET(_gmoFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo") + + ADD_CUSTOM_COMMAND( + OUTPUT "${_poFile}" + COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_poFile} ${_absPotFile} + DEPENDS ${_absPotFile} + ) + + ADD_CUSTOM_COMMAND( + OUTPUT "${_gmoFile}" + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_poFile} + DEPENDS ${_absPotFile} ${_poFile} + ) + + IF(_parsedArguments_INSTALL_DESTINATION) + INSTALL(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) + ENDIF(_parsedArguments_INSTALL_DESTINATION) + LIST(APPEND _gmoFiles ${_gmoFile}) + ENDFOREACH (_lang ) + + IF(_parsedArguments_ALL) + ADD_CUSTOM_TARGET(potfiles ALL DEPENDS ${_gmoFiles}) + ELSE(_parsedArguments_ALL) + ADD_CUSTOM_TARGET(potfiles DEPENDS ${_gmoFiles}) + ENDIF(_parsedArguments_ALL) +ENDFUNCTION(GETTEXT_PROCESS_POT_FILE) + + +FUNCTION(GETTEXT_PROCESS_PO_FILES _lang) + SET(_options ALL) + SET(_oneValueArgs INSTALL_DESTINATION) + SET(_multiValueArgs PO_FILES) + SET(_gmoFiles) + + CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + + FOREACH(_current_PO_FILE ${_parsedArguments_PO_FILES}) + GET_FILENAME_COMPONENT(_basename ${_current_PO_FILE} NAME_WE) + SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo) + ADD_CUSTOM_COMMAND(OUTPUT ${_gmoFile} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + DEPENDS ${_current_PO_FILE} + ) + + IF(_parsedArguments_INSTALL_DESTINATION) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${_basename}.mo) + ENDIF(_parsedArguments_INSTALL_DESTINATION) + LIST(APPEND _gmoFiles ${_gmoFile}) + ENDFOREACH(_current_PO_FILE) + + IF(_parsedArguments_ALL) + ADD_CUSTOM_TARGET(pofiles ALL DEPENDS ${_gmoFiles}) + ELSE(_parsedArguments_ALL) + ADD_CUSTOM_TARGET(pofiles DEPENDS ${_gmoFiles}) + ENDIF(_parsedArguments_ALL) +ENDFUNCTION(GETTEXT_PROCESS_PO_FILES) + IF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE ) SET(GETTEXT_FOUND TRUE) ELSE (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE ) @@ -73,6 +160,3 @@ ELSE (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE ) MESSAGE(FATAL_ERROR "GetText not found") ENDIF (GetText_REQUIRED) ENDIF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE ) - - - From bebb2bcd2330ee7dd4c3f35276dcc8615b81645f Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 10 Aug 2011 02:35:58 +0200 Subject: [PATCH 038/539] Support REQUIRED in FindGettext.cmake (using FPHSA.cmake) Alex --- Modules/FindGettext.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index 3ef141d3dc0..0f11234baa5 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -42,6 +42,9 @@ FIND_PROGRAM(GETTEXT_MSGMERGE_EXECUTABLE msgmerge) FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt) +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext REQUIRED_VARS GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE) + INCLUDE(CMakeParseArguments) MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) From 4718233a37f0180b1716db31df090a3f649e854a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 10:24:04 +0200 Subject: [PATCH 039/539] Remove the fatal_warnings option which is no longer used. --- Modules/GenerateExportHeader.cmake | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 67a16a9320f..659b32ab92d 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -232,18 +232,6 @@ function(add_compiler_export_flags) return() endif() - set(options) - set(oneValueArgs FATAL_WARNINGS) - set(multiValueArgs) - - cmake_parse_arguments(_EGHV "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - set(MESSAGE_TYPE WARNING) - - if(_EGHV_FATAL_WARNINGS) - set(MESSAGE_TYPE FATAL_ERROR) - endif() - if (CMAKE_COMPILER_IS_GNUCXX) exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") From 3b188c833b1d349dd610d5f5c929804d34b1967f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 10:26:16 +0200 Subject: [PATCH 040/539] Test for features, not specific compilers. --- Modules/GenerateExportHeader.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 659b32ab92d..73ed5e2ee6d 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -228,7 +228,9 @@ endfunction() function(add_compiler_export_flags) - if(NOT CMAKE_COMPILER_IS_GNUCXX OR MINGW) + _test_compiler_hidden_visibility() + + if(NOT (USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY) OR MINGW) return() endif() @@ -246,8 +248,6 @@ function(add_compiler_export_flags) endif() endif() - _test_compiler_hidden_visibility() - if(USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR) set (EXTRA_FLAGS "-fvisibility=hidden") From c7a937b71258d063bdcd0249b927bcd987ab3273 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 10:28:15 +0200 Subject: [PATCH 041/539] Simplify. We already know we have hidden visibility at this point. --- Modules/GenerateExportHeader.cmake | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 73ed5e2ee6d..6ee7bd72b69 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -248,12 +248,10 @@ function(add_compiler_export_flags) endif() endif() - if(USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY AND NOT _GCC_COMPILED_WITH_BAD_ALLOCATOR) - set (EXTRA_FLAGS "-fvisibility=hidden") + set (EXTRA_FLAGS "-fvisibility=hidden") - if(COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) - set (EXTRA_FLAGS "${EXTRA_FLAGS} -fvisibility-inlines-hidden") - endif() + if(COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) + set (EXTRA_FLAGS "${EXTRA_FLAGS} -fvisibility-inlines-hidden") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}" PARENT_SCOPE) endfunction() \ No newline at end of file From 3574b759160bc4609fb799862e75a33b25c932e7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 10:32:58 +0200 Subject: [PATCH 042/539] Simplify the compiler feature check --- Modules/GenerateExportHeader.cmake | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 6ee7bd72b69..978a9244587 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -142,12 +142,10 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) if(WIN32) set(DEFINE_EXPORT "__declspec(dllexport)") set(DEFINE_IMPORT "__declspec(dllimport)") - elseif(CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Intel AND UNIX)) - if(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) - set(DEFINE_EXPORT "__attribute__((visibility(\"default\")))") - set(DEFINE_IMPORT "__attribute__((visibility(\"default\")))") - set(DEFINE_NO_EXPORT "__attribute__((visibility(\"hidden\")))") - endif() + elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) + set(DEFINE_EXPORT "__attribute__((visibility(\"default\")))") + set(DEFINE_IMPORT "__attribute__((visibility(\"default\")))") + set(DEFINE_NO_EXPORT "__attribute__((visibility(\"hidden\")))") endif() endif() endmacro() From d123bce1ebb9ef8406272fece45e44b66b3df11a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 10:33:14 +0200 Subject: [PATCH 043/539] Add some debug output. Hopefully this shows up in continuous test output. --- Modules/GenerateExportHeader.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 978a9244587..7e644b1f9d4 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -229,6 +229,7 @@ function(add_compiler_export_flags) _test_compiler_hidden_visibility() if(NOT (USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY) OR MINGW) + message(WARNING "Compiler doesn't have hidden visibility") return() endif() @@ -242,6 +243,7 @@ function(add_compiler_export_flags) endif() if(${_gcc_version} VERSION_LESS "4.2") + message(WARNING "GCC version older than 4.2") return() endif() endif() From 6aca0e257be36949299b28cbfa12225269e28a03 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 10:41:38 +0200 Subject: [PATCH 044/539] Short-circuit the tests on unsupported compilers. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 457028092a5..52fe79f6baa 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -88,6 +88,12 @@ include(GenerateExportHeader) add_compiler_export_flags() +if(NOT ((USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY) OR WIN32)) + message(WARNING "Compiler does not support export feature") + return() +endif() + + if (MSVC) add_definitions(-DCOMPILER_IS_MSVC) endif() From ffaa127b191a6be0463160dd433b513ce28d8fe9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 11:34:31 +0200 Subject: [PATCH 045/539] Test expected no-op instead of aborting the build. Aborting causes make clean to fail if the executable is not created. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 52fe79f6baa..4f40b925951 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -76,7 +76,10 @@ endmacro() macro(build_fail Include Library LibrarySource Source Message) _do_build(${Include} ${Library} ${LibrarySource} "${Source}") - test_fail(Result ${Message}) + if((USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY) OR WIN32) + test_fail(Result ${Message}) + endif() + test_pass(Result ${Message}) endmacro() macro(build_pass Include Library LibrarySource Source Message) @@ -88,12 +91,6 @@ include(GenerateExportHeader) add_compiler_export_flags() -if(NOT ((USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY) OR WIN32)) - message(WARNING "Compiler does not support export feature") - return() -endif() - - if (MSVC) add_definitions(-DCOMPILER_IS_MSVC) endif() From 44430379b778b71f59d36c52870e5256ab456fd6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 13:41:47 +0200 Subject: [PATCH 046/539] Fix tests with clang. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 4f40b925951..fd541dc82e8 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -44,7 +44,7 @@ macro(_do_build Include Library LibrarySource Source) "add_compiler_export_flags()\n" - "if(CMAKE_COMPILER_IS_GNUCXX)\n" + "if(CMAKE_COMPILER_IS_GNUCXXOR OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang))\n" " add_definitions(-Werror)\n" "else()\n" " if(MSVC)\n" @@ -76,10 +76,11 @@ endmacro() macro(build_fail Include Library LibrarySource Source Message) _do_build(${Include} ${Library} ${LibrarySource} "${Source}") - if((USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY) OR WIN32) + if((USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY) OR WIN32 OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) test_fail(Result ${Message}) - endif() + else() test_pass(Result ${Message}) + endif() endmacro() macro(build_pass Include Library LibrarySource Source Message) @@ -112,7 +113,7 @@ add_subdirectory(lib_shared_and_statictest) add_subdirectory(override_symbol) -if (CMAKE_COMPILER_IS_GNUCXX) +if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) # We deliberately call deprecated methods, and test for that elsewhere. # No need to clutter the test output with warnings. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") From 002ddf253c75b88b9eb6b3f4540511178092e903 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 14:58:00 +0200 Subject: [PATCH 047/539] Fix typo and tests failing as a result. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index fd541dc82e8..140b3991979 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -44,7 +44,7 @@ macro(_do_build Include Library LibrarySource Source) "add_compiler_export_flags()\n" - "if(CMAKE_COMPILER_IS_GNUCXXOR OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang))\n" + "if(CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang))\n" " add_definitions(-Werror)\n" "else()\n" " if(MSVC)\n" From 61726f867eef69bea9237fb0b20c29b1ab3e35c1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 15:16:28 +0200 Subject: [PATCH 048/539] Only run the failure tests with gcc >= 4.2 --- .../Module/GenerateExportHeader/CMakeLists.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 140b3991979..63740878866 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -74,9 +74,24 @@ macro(_do_build Include Library LibrarySource Source) ) endmacro() +if (CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) + string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") + # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the + # patch level, handle this here: + if(NOT _gcc_version) + string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") + endif() + + if(${_gcc_version} VERSION_LESS "4.2") + set(GCC_IS_LESS_THAN_4_2 TRUE) + message(WARNING "GCC version older than 4.2. Actual version: ${_gcc_version}") + endif() +endif() + macro(build_fail Include Library LibrarySource Source Message) _do_build(${Include} ${Library} ${LibrarySource} "${Source}") - if((USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY) OR WIN32 OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) + if(NOT GCC_IS_LESS_THAN_4_2 AND (USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY) OR WIN32 OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) test_fail(Result ${Message}) else() test_pass(Result ${Message}) From af443b830b550454cf9bdd21a49183eb6e4ba22e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 21:01:42 +0200 Subject: [PATCH 049/539] Set the CMAKE_RUNTIME_OUTPUT_DIRECTORY for windows builds. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 63740878866..0cc67a9aa25 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -40,6 +40,8 @@ macro(_do_build Include Library LibrarySource Source) "set(CMAKE_INCLUDE_CURRENT_DIR ON)\n" + "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \${CMAKE_CURRENT_BINARY_DIR})\n" + "include(GenerateExportHeader)\n" "add_compiler_export_flags()\n" @@ -111,6 +113,8 @@ if (MSVC) add_definitions(-DCOMPILER_IS_MSVC) endif() +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set(link_libraries) macro(macro_add_test_library name) add_subdirectory(${name}) From cff94935982def7302cca11d521bf55587b8ebf7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 21:13:33 +0200 Subject: [PATCH 050/539] Only set the COMPILER_HAS_HIDDEN_VISIBILITY if GCC >= 4.2 Hearsay has it that before that version it didn't work properly. Hopefully this will fix more dashboard builds. --- Modules/GenerateExportHeader.cmake | 41 ++++++++++--------- .../GenerateExportHeader/CMakeLists.txt | 17 +------- 2 files changed, 23 insertions(+), 35 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 7e644b1f9d4..cb7b0d84fde 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -116,10 +116,28 @@ include(CMakeParseArguments) include(CheckCXXCompilerFlag) macro(_test_compiler_hidden_visibility) - check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) - check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) - option(USE_COMPILER_HIDDEN_VISIBILITY "Use HIDDEN visibility support if available." ON) - mark_as_advanced(USE_COMPILER_HIDDEN_VISIBILITY) + + if (CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) + string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") + # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the + # patch level, handle this here: + if(NOT _gcc_version) + string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") + endif() + + if(${_gcc_version} VERSION_LESS "4.2") + set(GCC_TOO_OLD TRUE) + message(WARNING "GCC version older than 4.2") + endif() + endif() + + if (NOT GCC_TOO_OLD) + check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) + check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) + option(USE_COMPILER_HIDDEN_VISIBILITY "Use HIDDEN visibility support if available." ON) + mark_as_advanced(USE_COMPILER_HIDDEN_VISIBILITY) + endif() endmacro() set(myDir ${CMAKE_CURRENT_LIST_DIR}) @@ -233,21 +251,6 @@ function(add_compiler_export_flags) return() endif() - if (CMAKE_COMPILER_IS_GNUCXX) - exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) - string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") - # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the - # patch level, handle this here: - if(NOT _gcc_version) - string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") - endif() - - if(${_gcc_version} VERSION_LESS "4.2") - message(WARNING "GCC version older than 4.2") - return() - endif() - endif() - set (EXTRA_FLAGS "-fvisibility=hidden") if(COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 0cc67a9aa25..064b9e3b18b 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -76,24 +76,9 @@ macro(_do_build Include Library LibrarySource Source) ) endmacro() -if (CMAKE_COMPILER_IS_GNUCXX) - exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) - string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") - # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the - # patch level, handle this here: - if(NOT _gcc_version) - string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") - endif() - - if(${_gcc_version} VERSION_LESS "4.2") - set(GCC_IS_LESS_THAN_4_2 TRUE) - message(WARNING "GCC version older than 4.2. Actual version: ${_gcc_version}") - endif() -endif() - macro(build_fail Include Library LibrarySource Source Message) _do_build(${Include} ${Library} ${LibrarySource} "${Source}") - if(NOT GCC_IS_LESS_THAN_4_2 AND (USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY) OR WIN32 OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) + if(COMPILER_HAS_HIDDEN_VISIBILITY OR WIN32 OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) test_fail(Result ${Message}) else() test_pass(Result ${Message}) From bab4a22036a988f49e1b711d092416c18cc16870 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 21:28:42 +0200 Subject: [PATCH 051/539] Disable all export macros on Borland. --- Modules/GenerateExportHeader.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index cb7b0d84fde..1395f15b45f 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -148,7 +148,7 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) set(DEFINE_IMPORT) set(DEFINE_NO_EXPORT) - if(WIN32) + if(WIN32 AND NOT (${CMAKE_CXX_COMPILER_ID} MATCHES Borland)) set(DEFINE_DEPRECATED "__declspec(deprecated)") else() set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))") @@ -157,7 +157,7 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE) if(NOT ${type} STREQUAL "STATIC_LIBRARY") - if(WIN32) + if(WIN32 AND NOT (${CMAKE_CXX_COMPILER_ID} MATCHES Borland)) set(DEFINE_EXPORT "__declspec(dllexport)") set(DEFINE_IMPORT "__declspec(dllimport)") elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) From fc3772edc9efc924f9d76c630719914c556e1d4e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 21:43:16 +0200 Subject: [PATCH 052/539] Another attempt to fix the tests on Borland. --- Modules/GenerateExportHeader.cmake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 1395f15b45f..1578365d134 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -148,8 +148,10 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) set(DEFINE_IMPORT) set(DEFINE_NO_EXPORT) - if(WIN32 AND NOT (${CMAKE_CXX_COMPILER_ID} MATCHES Borland)) - set(DEFINE_DEPRECATED "__declspec(deprecated)") + if(WIN32) + if (${CMAKE_CXX_COMPILER_ID} MATCHES Borland) + set(DEFINE_DEPRECATED "__declspec(deprecated)") + endif() else() set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))") endif() @@ -157,9 +159,11 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE) if(NOT ${type} STREQUAL "STATIC_LIBRARY") - if(WIN32 AND NOT (${CMAKE_CXX_COMPILER_ID} MATCHES Borland)) - set(DEFINE_EXPORT "__declspec(dllexport)") - set(DEFINE_IMPORT "__declspec(dllimport)") + if(WIN32) + if (NOT (${CMAKE_CXX_COMPILER_ID} MATCHES Borland)) + set(DEFINE_EXPORT "__declspec(dllexport)") + set(DEFINE_IMPORT "__declspec(dllimport)") + endif() elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) set(DEFINE_EXPORT "__attribute__((visibility(\"default\")))") set(DEFINE_IMPORT "__attribute__((visibility(\"default\")))") From b4434591fb70a424510a331b68d5f472da93fcf6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 21:50:06 +0200 Subject: [PATCH 053/539] Use the correct project name compiletest not compilefail Should fix windows VS solution based builds. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 064b9e3b18b..eb19afbc826 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -71,7 +71,7 @@ macro(_do_build Include Library LibrarySource Source) try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/fail${COUNT} ${CMAKE_CURRENT_BINARY_DIR}/test${COUNT} - compilefail + compiletest OUTPUT_VARIABLE Out ) endmacro() From 50460ea9de40d7c8ef631bbdb5d44b9aa4c14718 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 21:53:58 +0200 Subject: [PATCH 054/539] Fix off-by-not in test for Borland. --- Modules/GenerateExportHeader.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 1578365d134..5ecb80744ec 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -149,7 +149,7 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) set(DEFINE_NO_EXPORT) if(WIN32) - if (${CMAKE_CXX_COMPILER_ID} MATCHES Borland) + if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland) set(DEFINE_DEPRECATED "__declspec(deprecated)") endif() else() From 7924c1d6a8db87ded487e744ba3e8881e8336d00 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 22:19:39 +0200 Subject: [PATCH 055/539] Another attempt at fixing Borland. Apparently it still needs to be exported, but only declspec(deprecated) does not work. --- Modules/GenerateExportHeader.cmake | 6 ++---- .../lib_shared_and_statictest/CMakeLists.txt | 9 +++++++-- .../GenerateExportHeader/libsharedtest/CMakeLists.txt | 6 +++++- .../GenerateExportHeader/libstatictest/CMakeLists.txt | 4 +++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 5ecb80744ec..c921d8913ed 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -160,10 +160,8 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) if(NOT ${type} STREQUAL "STATIC_LIBRARY") if(WIN32) - if (NOT (${CMAKE_CXX_COMPILER_ID} MATCHES Borland)) - set(DEFINE_EXPORT "__declspec(dllexport)") - set(DEFINE_IMPORT "__declspec(dllimport)") - endif() + set(DEFINE_EXPORT "__declspec(dllexport)") + set(DEFINE_IMPORT "__declspec(dllimport)") elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) set(DEFINE_EXPORT "__attribute__((visibility(\"default\")))") set(DEFINE_IMPORT "__attribute__((visibility(\"default\")))") diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt index 2030de68bf8..d25eed07f80 100644 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt @@ -17,7 +17,12 @@ endmacro() static_variant_build_pass("return libshared_and_static_exported();" "Failed to build static variant") shared_variant_build_pass("return libshared_and_static_exported();" "Failed to build shared variant") -shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant") -static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant") +if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland) + shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant") + static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant") +else() + shared_variant_build_pass("return libshared_and_static_deprecated();" "Built shared deprecated variant") + static_variant_build_pass("return libshared_and_static_deprecated();" "Built static deprecated variant") +endif() static_variant_build_pass("return libshared_and_static_not_exported();" "Failed to build static not exported variant") shared_variant_build_fail("return libshared_and_static_not_exported();" "Built shared not exported variant") diff --git a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt index 7a05205b49c..9edc53fcba1 100644 --- a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt @@ -9,7 +9,11 @@ endmacro() shared_build_pass("Libshared l; return l.libshared_exported();" "Failed to build exported") -shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") +if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland) + shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") +else() + shared_build_pass("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") +endif() if (COMPILER_HAS_HIDDEN_VISIBILITY) shared_build_fail("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") else() diff --git a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt index 58b875a07c9..a41b168a6f2 100644 --- a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt @@ -9,5 +9,7 @@ endmacro() static_build_pass("Libstatic l; return l.libstatic_exported();" "Failed to build exported.") -static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") +if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland) + static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") +endif() static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") From 7fa559232e6bca09c0f24c0a3da2a83a5c395be3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 10 Aug 2011 23:57:04 +0200 Subject: [PATCH 056/539] Add some debug output to narrow down deprecation test issues Particularly Borland and VS7.0 seem to still be failing. --- Modules/GenerateExportHeader.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index c921d8913ed..9dd8f4a2ed9 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -149,7 +149,9 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) set(DEFINE_NO_EXPORT) if(WIN32) + message("Compiler is ${CMAKE_CXX_COMPILER_ID}") if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland) + message("Deprecation macro enabled.") set(DEFINE_DEPRECATED "__declspec(deprecated)") endif() else() From 3f7e03643d5437ec494956f2678c7b3c905d8250 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 11 Aug 2011 00:18:33 +0200 Subject: [PATCH 057/539] Export deprecated free methods too. That way they can be linked to even after being deprecated. --- .../lib_shared_and_static/libshared_and_static.h | 2 +- Tests/Module/GenerateExportHeader/libstatic/libstatic.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h index 7df76946095..400d66471aa 100644 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h @@ -49,7 +49,7 @@ class LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded { LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported(); -LIBSHARED_AND_STATIC_DEPRECATED int libshared_and_static_deprecated(); +LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated(); int libshared_and_static_not_exported(); diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.h b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h index c6562ecb639..cd68cdc784a 100644 --- a/Tests/Module/GenerateExportHeader/libstatic/libstatic.h +++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h @@ -45,7 +45,7 @@ class LIBSTATIC_NO_EXPORT LibstaticExcluded { LIBSTATIC_EXPORT int libstatic_exported(); -LIBSTATIC_DEPRECATED int libstatic_deprecated(); +LIBSTATIC_DEPRECATED_EXPORT int libstatic_deprecated(); int libstatic_not_exported(); From 1c6b41bee7fb1e2b85be4ab3497889ab72089f69 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 11 Aug 2011 00:19:20 +0200 Subject: [PATCH 058/539] Remember to surround the other deprecated test in the Borland check. --- .../Module/GenerateExportHeader/libstatictest/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt index a41b168a6f2..168cae80038 100644 --- a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt @@ -11,5 +11,8 @@ static_build_pass("Libstatic l; return l.libstatic_exported();" "Failed to build if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland) static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") + static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") +else() + static_build_pass("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") + static_build_pass("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") endif() -static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") From 66a4bd0cfb41abc7713506590443073e7da67ef6 Mon Sep 17 00:00:00 2001 From: Alexey Ozeritsky Date: Thu, 11 Aug 2011 12:07:00 +0400 Subject: [PATCH 059/539] fixed: search of acml libraries --- Modules/FindBLAS.cmake | 72 ++++++++++++++++++++++------------------ Modules/FindLAPACK.cmake | 30 ++++------------- 2 files changed, 46 insertions(+), 56 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index ae4a13f504e..37355bf93cd 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -57,7 +57,7 @@ else() endif(BLAS_FIND_REQUIRED) endif( ) -macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _threads) +macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _optional) # This macro checks for the existence of the combination of fortran libraries # given by _list. If the combination is found, this macro checks (using the # Check_Fortran_Function_Exists macro) whether can link against that library @@ -69,41 +69,39 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _threads) # N.B. _prefix is the prefix applied to the names of all cached variables that # are generated internally and marked advanced by this macro. +list(GET _optional 0 _thread) +list(GET _optional 1 _libdir) + set(_libraries_work TRUE) set(${LIBRARIES}) set(_combined_name) +if (NOT _libdir) + if (WIN32) + set(_libdir ENV LIB) + elseif (APPLE) + set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH) + else () + set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH) + endif () +endif () foreach(_library ${_list}) set(_combined_name ${_combined_name}_${_library}) if(_libraries_work) - if ( WIN32 ) - if(BLA_STATIC) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") - endif(BLA_STATIC) - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS ENV LIB - ) - endif ( WIN32 ) - - if ( APPLE ) - if(BLA_STATIC) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") - endif(BLA_STATIC) + if (BLA_STATIC) + if (WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") + endif ( WIN32 ) + if (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") + else (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so") + endif (APPLE) + endif (BLA_STATIC) find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH - ) - - else ( APPLE ) - if(BLA_STATIC) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so") - endif(BLA_STATIC) - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH - ) - endif( APPLE ) + NAMES ${_library} + PATHS ${_libdir} + ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) @@ -311,15 +309,25 @@ if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR ST if( _BLAS_VENDOR STREQUAL "ACML_MP" ) foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS} ) - _BLAS_LOCATE_AND_TEST( ${_BLAS_VENDOR} "acml_mp;acml_mv" "" ) - if( BLAS_${_BLAS_VENDOR}_FOUND ) + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) break() endif() endforeach() else() #if( _BLAS_VENDOR STREQUAL "ACML" ) foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} ) - _BLAS_LOCATE_AND_TEST( ${_BLAS_VENDOR} "acml;acml_mv" "" ) - if( BLAS_${_BLAS_VENDOR}_FOUND ) + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml_mp;acml_mv" "" ${BLAS_ACML_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) break() endif() endforeach() diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index bf454067722..c57b2e9543e 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -148,31 +148,13 @@ if(BLAS_FOUND) set(BLA_VENDOR "All") endif(NOT BLA_VENDOR) endif ($ENV{BLA_VENDOR} MATCHES ".+") + #acml lapack - if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "acml;acml_mv" - "" - "" - ) - endif(NOT LAPACK_LIBRARIES) - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "acml_mp;acml_mv" - "" - "" - ) - endif(NOT LAPACK_LIBRARIES) - endif (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") + if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR STREQUAL "All") + if (BLAS_LIBRARIES MATCHES ".+acml.+") + set (LAPACK_LIBRARIES ${BLAS_LIBRARIES}) + endif () + endif (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR STREQUAL "All") # Apple LAPACK library? if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") From 91b76e2ab9ed286f20609ab2a0161e4e8c1f507e Mon Sep 17 00:00:00 2001 From: Alexey Ozeritsky Date: Thu, 11 Aug 2011 12:23:49 +0400 Subject: [PATCH 060/539] gotoblas supported --- Modules/FindBLAS.cmake | 16 +++++++++++++++- Modules/FindLAPACK.cmake | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 37355bf93cd..4431778094b 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -22,7 +22,7 @@ # BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK ########## ### List of vendors (BLA_VENDOR) valid in this module -## ATLAS, PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,Intel10_32 (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,lp thread model, lp64 model), +## Goto,ATLAS PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,Intel10_32 (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,lp thread model, lp64 model), ## Intel( older versions of mkl 32 and 64 bit), ACML,ACML_MP,Apple, NAS, Generic # C/CXX should be enabled to use Intel mkl @@ -137,6 +137,20 @@ else ($ENV{BLA_VENDOR} MATCHES ".+") endif(NOT BLA_VENDOR) endif ($ENV{BLA_VENDOR} MATCHES ".+") +if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "goto2" + "" + ) + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index c57b2e9543e..12191020222 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -149,6 +149,21 @@ if(BLAS_FOUND) endif(NOT BLA_VENDOR) endif ($ENV{BLA_VENDOR} MATCHES ".+") +if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "goto2" + "${BLAS_LIBRARIES}" + "" + ) + endif(NOT LAPACK_LIBRARIES) +endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + + #acml lapack if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR STREQUAL "All") if (BLAS_LIBRARIES MATCHES ".+acml.+") From 399f415b1558397e51502914ae36b6d055668eeb Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 11 Aug 2011 10:28:50 +0200 Subject: [PATCH 061/539] Only set the deprecated attribute if hidden visibilty is enabled. This is what is tested in the unit test. If it makes sense, another option can be added later. --- Modules/GenerateExportHeader.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 9dd8f4a2ed9..0b93941d946 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -155,7 +155,9 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) set(DEFINE_DEPRECATED "__declspec(deprecated)") endif() else() - set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))") + if(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) + set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))") + endif() endif() get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE) From 1f3be450486c9f3eb140a58fb9bf0f5ef4c858ab Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 11 Aug 2011 10:39:51 +0200 Subject: [PATCH 062/539] Make sure the hidden visibility variables never get set on MINGW. --- Modules/GenerateExportHeader.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 0b93941d946..322439be7f5 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -132,7 +132,7 @@ macro(_test_compiler_hidden_visibility) endif() endif() - if (NOT GCC_TOO_OLD) + if (NOT GCC_TOO_OLD AND NOT MINGW) check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) option(USE_COMPILER_HIDDEN_VISIBILITY "Use HIDDEN visibility support if available." ON) @@ -252,7 +252,7 @@ function(add_compiler_export_flags) _test_compiler_hidden_visibility() - if(NOT (USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY) OR MINGW) + if(NOT (USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY)) message(WARNING "Compiler doesn't have hidden visibility") return() endif() From 750b67c5a1957f5fa2c7a483050f0ef0959c9924 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 11 Aug 2011 10:53:58 +0200 Subject: [PATCH 063/539] Don't use hidden visibility on non-mingw windows either. --- Modules/GenerateExportHeader.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 322439be7f5..92b943368ba 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -132,7 +132,7 @@ macro(_test_compiler_hidden_visibility) endif() endif() - if (NOT GCC_TOO_OLD AND NOT MINGW) + if (NOT GCC_TOO_OLD AND NOT WIN32) check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) option(USE_COMPILER_HIDDEN_VISIBILITY "Use HIDDEN visibility support if available." ON) From 1590d5fe4f95a800635ba9078e822d742a96dc18 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 11 Aug 2011 10:54:21 +0200 Subject: [PATCH 064/539] Don't export methods on already exported classes. This is always a mistake. --- .../lib_shared_and_static/libshared_and_static.h | 4 ---- Tests/Module/GenerateExportHeader/libshared/libshared.h | 5 ----- Tests/Module/GenerateExportHeader/libstatic/libstatic.h | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h index 400d66471aa..049bfe9c4d0 100644 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h @@ -8,11 +8,7 @@ class LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic { public: int libshared_and_static() const; -#ifdef COMPILER_IS_MSVC int libshared_and_static_exported() const; -#else - int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; -#endif int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.h b/Tests/Module/GenerateExportHeader/libshared/libshared.h index 280e1857191..3d9bbff4fd6 100644 --- a/Tests/Module/GenerateExportHeader/libshared/libshared.h +++ b/Tests/Module/GenerateExportHeader/libshared/libshared.h @@ -8,12 +8,7 @@ class LIBSHARED_EXPORT Libshared { public: int libshared() const; -#ifdef COMPILER_IS_MSVC - // Double exporting not possible with MSVC int libshared_exported() const; -#else - int LIBSHARED_EXPORT libshared_exported() const; -#endif int LIBSHARED_DEPRECATED libshared_deprecated() const; diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.h b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h index cd68cdc784a..cc7a35b4eb8 100644 --- a/Tests/Module/GenerateExportHeader/libstatic/libstatic.h +++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h @@ -8,7 +8,7 @@ class LIBSTATIC_EXPORT Libstatic { public: int libstatic() const; - int LIBSTATIC_EXPORT libstatic_exported() const; + int libstatic_exported() const; int LIBSTATIC_DEPRECATED libstatic_deprecated() const; From 9554e1013ef5d9971092ed0cd45daf59b8a6bd87 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 11 Aug 2011 18:17:12 +0200 Subject: [PATCH 065/539] Split the deprecated available check from setting macro values. --- Modules/GenerateExportHeader.cmake | 22 +++++++++++++++---- .../lib_shared_and_statictest/CMakeLists.txt | 2 +- .../libsharedtest/CMakeLists.txt | 2 +- .../libstatictest/CMakeLists.txt | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 92b943368ba..f690655cd3b 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -140,6 +140,20 @@ macro(_test_compiler_hidden_visibility) endif() endmacro() +macro(_test_compiler_has_deprecated) + if (WIN32) + if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland) + set(COMPILER_HAS_DEPRECATED TRUE) + endif() + else() + # TODO: Test properly for this + if(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) + set(COMPILER_HAS_DEPRECATED TRUE) + endif() + endif() + set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED}" CACHE INTERNAL "Compiler support for a deprecated attribute") +endmacro() + set(myDir ${CMAKE_CURRENT_LIST_DIR}) macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) @@ -149,13 +163,11 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) set(DEFINE_NO_EXPORT) if(WIN32) - message("Compiler is ${CMAKE_CXX_COMPILER_ID}") - if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland) - message("Deprecation macro enabled.") + if (COMPILER_HAS_DEPRECATED) set(DEFINE_DEPRECATED "__declspec(deprecated)") endif() else() - if(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) + if(COMPILER_HAS_DEPRECATED) set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))") endif() endif() @@ -244,6 +256,7 @@ function(GENERATE_EXPORT_HEADER TARGET_LIBRARY) return() endif() _test_compiler_hidden_visibility() + _test_compiler_has_deprecated() _do_set_macro_values(${TARGET_LIBRARY}) _do_generate_export_header(${TARGET_LIBRARY} ${ARGN}) endfunction() @@ -251,6 +264,7 @@ endfunction() function(add_compiler_export_flags) _test_compiler_hidden_visibility() + _test_compiler_has_deprecated() if(NOT (USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY)) message(WARNING "Compiler doesn't have hidden visibility") diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt index d25eed07f80..1401eec38ff 100644 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt @@ -17,7 +17,7 @@ endmacro() static_variant_build_pass("return libshared_and_static_exported();" "Failed to build static variant") shared_variant_build_pass("return libshared_and_static_exported();" "Failed to build shared variant") -if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland) +if (COMPILER_HAS_DEPRECATED) shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant") static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant") else() diff --git a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt index 9edc53fcba1..b763036e692 100644 --- a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt @@ -9,7 +9,7 @@ endmacro() shared_build_pass("Libshared l; return l.libshared_exported();" "Failed to build exported") -if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland) +if (COMPILER_HAS_DEPRECATED) shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") else() shared_build_pass("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") diff --git a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt index 168cae80038..14ca05b4c79 100644 --- a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt @@ -9,7 +9,7 @@ endmacro() static_build_pass("Libstatic l; return l.libstatic_exported();" "Failed to build exported.") -if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland) +if (COMPILER_HAS_DEPRECATED) static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") else() From e1f7ee3de71fc0e7a34bf05ec2cf4ec586ff9e32 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 11 Aug 2011 18:18:19 +0200 Subject: [PATCH 066/539] Test for compiler features, instead of for specific platforms. --- Modules/GenerateExportHeader.cmake | 38 +++++++++++-------- .../GenerateExportHeader/CMakeLists.txt | 4 +- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index f690655cd3b..578d71f3211 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -115,6 +115,20 @@ include(CMakeParseArguments) include(CheckCXXCompilerFlag) + +# TODO: Install this macro separately? +macro(_check_cxx_compiler_attribute _ATTRIBUTE _RESULT) + check_cxx_source_compiles("${_ATTRIBUTE} int somefunc() { return 0; } int main() { return somefunc();}" ${_RESULT} + # Some compilers do not fail with a bad flag + FAIL_REGEX "unrecognized .*option" # GNU + FAIL_REGEX "ignoring unknown option" # MSVC + FAIL_REGEX "warning D9002" # MSVC, any lang + FAIL_REGEX "[Uu]nknown option" # HP + FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro + FAIL_REGEX "command option .* is not recognized" # XL + ) +endmacro() + macro(_test_compiler_hidden_visibility) if (CMAKE_COMPILER_IS_GNUCXX) @@ -141,15 +155,11 @@ macro(_test_compiler_hidden_visibility) endmacro() macro(_test_compiler_has_deprecated) - if (WIN32) - if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland) - set(COMPILER_HAS_DEPRECATED TRUE) - endif() + _check_cxx_compiler_attribute("__declspec(deprecated)" COMPILER_HAS_DEPRECATED_DECLSPEC) + if(COMPILER_HAS_DEPRECATED_DECLSPEC) + set(COMPILER_HAS_DEPRECATED ${COMPILER_HAS_DEPRECATED_DECLSPEC}) else() - # TODO: Test properly for this - if(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) - set(COMPILER_HAS_DEPRECATED TRUE) - endif() + _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED) endif() set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED}" CACHE INTERNAL "Compiler support for a deprecated attribute") endmacro() @@ -162,14 +172,10 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) set(DEFINE_IMPORT) set(DEFINE_NO_EXPORT) - if(WIN32) - if (COMPILER_HAS_DEPRECATED) - set(DEFINE_DEPRECATED "__declspec(deprecated)") - endif() - else() - if(COMPILER_HAS_DEPRECATED) - set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))") - endif() + if (COMPILER_HAS_DEPRECATED_DECLSPEC) + set(DEFINE_DEPRECATED "__declspec(deprecated)") + elseif(COMPILER_HAS_DEPRECATED) + set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))") endif() get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index eb19afbc826..05d151933b7 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -49,7 +49,7 @@ macro(_do_build Include Library LibrarySource Source) "if(CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang))\n" " add_definitions(-Werror)\n" "else()\n" - " if(MSVC)\n" + " if(MSVC AND COMPILER_HAS_DEPRECATED)\n" # Treat deprecation warnings as errors. " add_definitions(/we4996)\n" " endif()\n" @@ -123,7 +123,7 @@ if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") endif() -if(MSVC) +if(MSVC AND COMPILER_HAS_DEPRECATED) add_definitions(/wd4996) endif() From bf0737526419936915a9f2c14f06bff556d1fcd4 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 10 Aug 2011 01:51:38 +0200 Subject: [PATCH 067/539] Add a cmake.m4 for using cmake in autoconf projects instead of pkgconfig This file has been written today from scratch by Matthias Kretz and it BSD-licensed. Alex --- Modules/CMakeFindPackageMode.cmake | 2 +- Utilities/CMakeLists.txt | 1 + Utilities/cmake.m4 | 53 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 Utilities/cmake.m4 diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 3e5cb49a678..3e7376c8af3 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -1,4 +1,4 @@ -# COMPILER_ID = GNU/Intel/etc. +# COMPILER_ID = GNU/Intel/Clang/MSVC, etc. # LANGUAGE = C/CXX/Fortan/ASM # MODE = EXIST/COMPILE/LINK # NAME = name of the package diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 8b3e7f65893..85db3679e56 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -126,6 +126,7 @@ ADD_CUSTOM_COMMAND( INSTALL_FILES(${CMAKE_MAN_DIR}/man1 FILES ${MAN_FILES}) INSTALL_FILES(${CMAKE_DOC_DIR} FILES ${HTML_FILES} ${TEXT_FILES}) +INSTALL_FILES(share/aclocal FILES cmake.m4) # Drive documentation generation. ADD_CUSTOM_TARGET(documentation ALL DEPENDS ${DOC_FILES} ${CMake_BINARY_DIR}/Docs/cmake.txt ) diff --git a/Utilities/cmake.m4 b/Utilities/cmake.m4 new file mode 100644 index 00000000000..a374a3bfbf0 --- /dev/null +++ b/Utilities/cmake.m4 @@ -0,0 +1,53 @@ +dnl ============================================================================ +dnl CMake - Cross Platform Makefile Generator +dnl Copyright 2011 Matthias Kretz, kretz@kde.org +dnl +dnl Distributed under the OSI-approved BSD License (the "License"); +dnl see accompanying file Copyright.txt for details. +dnl +dnl This software is distributed WITHOUT ANY WARRANTY; without even the +dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +dnl See the License for more information. +dnl ============================================================================ + +AC_DEFUN([CMAKE_FIND_BINARY], +[AC_ARG_VAR([CMAKE_BINARY], [path to the cmake binary])dnl + +if test "x$ac_cv_env_CMAKE_BINARY_set" != "xset"; then + AC_PATH_TOOL([CMAKE_BINARY], [cmake])dnl +fi +])dnl + +# $1: package name +# $2: language (e.g. C/CXX/Fortran) +# $3: The compiler ID, defaults to GNU. +# Possible values are: GNU, Intel, Clang, SunPro, HP, XL, VisualAge, PGI, +# PathScale, Cray, SCO, MIPSpro, MSVC +# $4: optional extra arguments to cmake, e.g. "-DCMAKE_SIZEOF_VOID_P=8" +# $5: optional path to cmake binary +AC_DEFUN([CMAKE_FIND_PACKAGE], [ +AC_REQUIRE([CMAKE_FIND_BINARY])dnl + +AC_ARG_VAR([$1][_][$2][FLAGS], [$2 compiler flags for $1. This overrides the cmake output])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1. This overrides the cmake output])dnl + +failed=false +AC_MSG_CHECKING([for $1]) +if test -n "$1[]_$2[]FLAGS"; then + $1[]_$2[]FLAGS=`$CMAKE_BINARY --find-package "-DNAME=$1" "-DCOMPILER_ID=m4_default([$3], [GNU])" "-DLANGUAGE=$2" -DMODE=COMPILE $4` || failed=true +fi +if test -n "$1[]_LIBS"; then + $1[]_LIBS=`$CMAKE_BINARY --find-package "-DNAME=$1" "-DCOMPILER_ID=m4_default([$3], [GNU])" "-DLANGUAGE=$2" -DMODE=LINK $4` || failed=true +fi + +if $failed; then + unset $1[]_$2[]FLAGS + unset $1[]_LIBS + + AC_MSG_RESULT([no]) + $6 +else + AC_MSG_RESULT([yes]) + $5 +fi[]dnl +]) From d3ae0fff7dea00775f8c6e8bed59a494f102999c Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 10 Aug 2011 02:05:33 +0200 Subject: [PATCH 068/539] Improve documentation for --find-package mode Alex --- Modules/CMakeFindPackageMode.cmake | 16 ++++++++++------ Source/cmakemain.cxx | 4 +++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 3e7376c8af3..2ce4fe61ed8 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -1,8 +1,12 @@ -# COMPILER_ID = GNU/Intel/Clang/MSVC, etc. -# LANGUAGE = C/CXX/Fortan/ASM -# MODE = EXIST/COMPILE/LINK -# NAME = name of the package -# QUIET = if TRUE, don't print anything +# This file is executed by cmake when invoked with --find-package. +# It expects that the following variables are set using -D: +# NAME = name of the package +# COMPILER_ID = the CMake compiler ID for which the result is, i.e. GNU/Intel/Clang/MSVC, etc. +# LANGUAGE = language for which the result will be used, i.e. C/CXX/Fortan/ASM +# MODE = EXIST : only check for existance of the given package +# COMPILE : print the flags needed for compiling an object file which uses the given package +# LINK : print the flags needed for linking when using the given package +# QUIET = if TRUE, don't print anything #============================================================================= # Copyright 2006-2011 Alexander Neundorf, @@ -18,7 +22,7 @@ # License text for the above reference.) if(NOT NAME) - message(FATAL_ERROR "NAME argument not specified.") + message(FATAL_ERROR "Name of the package to be searched not specified. Set the CMake variable NAME, e.g. -DNAME=JPEG .") endif() if(NOT COMPILER_ID) diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index c744dcd1b9b..828d2aaa2eb 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -104,7 +104,9 @@ static const char * cmDocumentationOptions[][3] = "before the -P argument."}, {"--find-package", "Run in pkg-config like mode.", "Search a package using find_package() and print the resulting flags " - "to stdout. "}, + "to stdout. This can be used to use cmake instead of pkg-config to find " + "installed libraries in plain Makefile-based projects or in " + "autoconf-based projects (via share/aclocal/cmake.m4)."}, {"--graphviz=[file]", "Generate graphviz of dependencies.", "Generate a graphviz input file that will contain all the library and " "executable dependencies in the project."}, From 9fc87c6343a5d448f04d7a9397beb95e3b85178e Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 11 Aug 2011 23:27:19 +0200 Subject: [PATCH 069/539] Add a test for the new --find-package mode Alex --- Tests/CMakeLists.txt | 2 ++ .../CMakeLists.txt | 22 +++++++++++++++++++ Tests/FindPackageModeMakefileTest/Makefile.in | 8 +++++++ Tests/FindPackageModeMakefileTest/main.cpp | 8 +++++++ 4 files changed, 40 insertions(+) create mode 100644 Tests/FindPackageModeMakefileTest/CMakeLists.txt create mode 100644 Tests/FindPackageModeMakefileTest/Makefile.in create mode 100644 Tests/FindPackageModeMakefileTest/main.cpp diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2ad9a7759c8..a75b3df8ffe 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -46,6 +46,8 @@ IF(BUILD_TESTING) ADD_SUBDIRECTORY(CMakeLib) + ADD_SUBDIRECTORY(FindPackageModeMakefileTest) + # Collect a list of all test build directories. SET(TEST_BUILD_DIRS) diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt new file mode 100644 index 00000000000..0be3783dcbc --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -0,0 +1,22 @@ + +if("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Intel + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES XL + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES SunPro) + + find_package(PNG) + + # the test program links against the png lib, so test first whether it exists + if(PNG_FOUND) + + get_target_property(cmakeExecutable cmake LOCATION) + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) + + add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile -C ${CMAKE_CURRENT_BINARY_DIR} ) + + endif() + +endif() diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in new file mode 100644 index 00000000000..5105d994915 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -0,0 +1,8 @@ +all: clean pngtest + +pngtest: main.o + "@CMAKE_CXX_COMPILER@" -c `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE` main.cpp + "@CMAKE_CXX_COMPILER@" -o pngtest main.o `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK` + +clean: + rm -f *.o pngtest diff --git a/Tests/FindPackageModeMakefileTest/main.cpp b/Tests/FindPackageModeMakefileTest/main.cpp new file mode 100644 index 00000000000..b78542700fb --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/main.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + printf("PNG copyright: %s\n", png_get_copyright(NULL)); + return 0; +} From fd15b5e1c425b0e2cb418e87a115215b0aa7501a Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 11 Aug 2011 23:32:30 +0200 Subject: [PATCH 070/539] Only run the test if we are using a makefile generator under UNIX Alex --- Tests/FindPackageModeMakefileTest/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index 0be3783dcbc..f0faab93dff 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -8,7 +8,7 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU find_package(PNG) # the test program links against the png lib, so test first whether it exists - if(PNG_FOUND) + if(PNG_FOUND AND UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") get_target_property(cmakeExecutable cmake LOCATION) From 78a6e1c1224bbeb92f44dd681cc914030bbf8c82 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 11 Aug 2011 18:18:19 +0200 Subject: [PATCH 071/539] Exclude the XL compiler from the hidden-visibility test. --- Modules/GenerateExportHeader.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 578d71f3211..05f36f38653 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -146,7 +146,10 @@ macro(_test_compiler_hidden_visibility) endif() endif() - if (NOT GCC_TOO_OLD AND NOT WIN32) + # Exclude XL here because it misinterprets -fvisibility=hidden even though + # the check_cxx_compiler_flag passes + # http://www.cdash.org/CDash/testDetails.php?test=109109951&build=1419259 + if (NOT GCC_TOO_OLD AND NOT WIN32 AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES XL) check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) option(USE_COMPILER_HIDDEN_VISIBILITY "Use HIDDEN visibility support if available." ON) From df4615e3380cda2bf29d3dfdcfd26b020a64e707 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 12 Aug 2011 00:21:13 +0200 Subject: [PATCH 072/539] Add the COMPILER_HAS_DEPRECATED only if it has a declspec variant _check_cxx_compiler_attribute does it in the alternative. --- Modules/GenerateExportHeader.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 05f36f38653..c833a014d6e 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -160,11 +160,10 @@ endmacro() macro(_test_compiler_has_deprecated) _check_cxx_compiler_attribute("__declspec(deprecated)" COMPILER_HAS_DEPRECATED_DECLSPEC) if(COMPILER_HAS_DEPRECATED_DECLSPEC) - set(COMPILER_HAS_DEPRECATED ${COMPILER_HAS_DEPRECATED_DECLSPEC}) + set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED_DECLSPEC}" CACHE INTERNAL "Compiler support for a deprecated attribute") else() _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED) endif() - set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED}" CACHE INTERNAL "Compiler support for a deprecated attribute") endmacro() set(myDir ${CMAKE_CURRENT_LIST_DIR}) From 856bdb317bc0d38327a7a9c7e9105ee1cd39f18a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 12 Aug 2011 00:30:31 +0200 Subject: [PATCH 073/539] Don't change the expected build result based on the platform. Hopefully the compiler feature tests will cover those cases. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 05d151933b7..febf90f4196 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -78,11 +78,7 @@ endmacro() macro(build_fail Include Library LibrarySource Source Message) _do_build(${Include} ${Library} ${LibrarySource} "${Source}") - if(COMPILER_HAS_HIDDEN_VISIBILITY OR WIN32 OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) - test_fail(Result ${Message}) - else() - test_pass(Result ${Message}) - endif() + test_fail(Result ${Message}) endmacro() macro(build_pass Include Library LibrarySource Source Message) From 9aab2aa77f12a938ef4a819ebb9830a1918f65ce Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 12 Aug 2011 10:42:16 +0200 Subject: [PATCH 074/539] Expect the tests to pass if hidden visibilty is not enabled. --- .../lib_shared_and_statictest/CMakeLists.txt | 7 ++++- .../libsharedtest/CMakeLists.txt | 29 ++++++++++++++----- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt index 1401eec38ff..28d6c65c6e7 100644 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt @@ -25,4 +25,9 @@ else() static_variant_build_pass("return libshared_and_static_deprecated();" "Built static deprecated variant") endif() static_variant_build_pass("return libshared_and_static_not_exported();" "Failed to build static not exported variant") -shared_variant_build_fail("return libshared_and_static_not_exported();" "Built shared not exported variant") + +if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) + shared_variant_build_fail("return libshared_and_static_not_exported();" "Built shared not exported variant") +else() + shared_variant_build_pass("return libshared_and_static_not_exported();" "Built shared not exported variant") +endif() diff --git a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt index b763036e692..288089ef697 100644 --- a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt @@ -20,12 +20,25 @@ else() # There is no MSVC equivalent to hiding symbols. shared_build_pass("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This is possible on MSVC.") endif() -shared_build_fail("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method. This should not be possible.") -shared_build_fail("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method. This should not be possible.") -shared_build_fail("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method. This should not be possible.") -shared_build_fail("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method. This should not be possible.") -shared_build_fail("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method. This should not be possible.") -shared_build_fail("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") -shared_build_fail("return libshared_excluded();" "Built use of excluded function. This should not be possible.") -shared_build_fail("return libshared_not_exported();" "Built use of not-exported function. This should not be possible.") +if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) + shared_build_fail("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method. This should not be possible.") + shared_build_fail("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method. This should not be possible.") + shared_build_fail("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method. This should not be possible.") + shared_build_fail("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method. This should not be possible.") + shared_build_fail("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method. This should not be possible.") + shared_build_fail("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") + + shared_build_fail("return libshared_excluded();" "Built use of excluded function. This should not be possible.") + shared_build_fail("return libshared_not_exported();" "Built use of not-exported function. This should not be possible.") +else() + shared_build_pass("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method.") + shared_build_pass("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method.") + shared_build_pass("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method.") + shared_build_pass("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method.") + shared_build_pass("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method.") + shared_build_pass("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method.") + + shared_build_pass("return libshared_excluded();" "Built use of excluded function.") + shared_build_pass("return libshared_not_exported();" "Built use of not-exported function.") +endif() From 01e9e983e31dcd33bd5991b67e131e80e37f86e1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 12 Aug 2011 10:47:08 +0200 Subject: [PATCH 075/539] Test -Werror instead of enabling it per compiler. Maybe the Intel compiler supports it too. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index febf90f4196..b3f646f163f 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -46,7 +46,9 @@ macro(_do_build Include Library LibrarySource Source) "add_compiler_export_flags()\n" - "if(CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang))\n" + "check_cxx_compiler_flag(-Werror HAS_WERROR_FLAG)\n" + + "if(HAS_WERROR_FLAG)\n" " add_definitions(-Werror)\n" "else()\n" " if(MSVC AND COMPILER_HAS_DEPRECATED)\n" From fb88c6e32ad78895c45b4651748e45a388a81cb0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 12 Aug 2011 11:39:21 +0200 Subject: [PATCH 076/539] Add some messaging output to make remaining issues findable. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index b3f646f163f..a310eb9481f 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -98,6 +98,10 @@ endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +message("#### COMPILER_HAS_DEPRECATED: " ${COMPILER_HAS_DEPRECATED}) +message("#### COMPILER_HAS_HIDDEN_VISIBILITY: " ${COMPILER_HAS_HIDDEN_VISIBILITY}) +message("#### WIN32: " ${WIN32}) + set(link_libraries) macro(macro_add_test_library name) add_subdirectory(${name}) From ac22e2a8790e507d7600e0876585424db70f785b Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 12 Aug 2011 17:08:35 -0400 Subject: [PATCH 077/539] VS9: Add include_directories to midl command lines Makes VS 7, 8 and 9 generators consistent with the VS 10 generator. Adds the "AdditionalIncludeDirectories" attribute at the vcproj level so that all idl files inherit the /I command line args. --- Source/cmLocalVisualStudio7Generator.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 3e76f592dbf..223e7866fb5 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -825,6 +825,13 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, tool = "VFMIDLTool"; } fout << "\t\t\tConvertToXMLOutputPath(i->c_str()); + fout << ipath << ";"; + } + fout << "\"\n"; fout << "\t\t\t\tMkTypLibCompatible=\"FALSE\"\n"; if( this->PlatformName == "x64" ) { From af4c58b3bd92f69cce195c3e491d40071b8d0b08 Mon Sep 17 00:00:00 2001 From: Alexey Ozeritsky Date: Sat, 13 Aug 2011 17:02:15 +0400 Subject: [PATCH 078/539] ACML-GPU supported --- Modules/FindBLAS.cmake | 54 +++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 4431778094b..7bad9596048 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -23,7 +23,7 @@ ########## ### List of vendors (BLA_VENDOR) valid in this module ## Goto,ATLAS PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,Intel10_32 (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,lp thread model, lp64 model), -## Intel( older versions of mkl 32 and 64 bit), ACML,ACML_MP,Apple, NAS, Generic +## Intel( older versions of mkl 32 and 64 bit), ACML,ACML_MP,ACML_GPU,Apple, NAS, Generic # C/CXX should be enabled to use Intel mkl #============================================================================= @@ -57,7 +57,7 @@ else() endif(BLAS_FIND_REQUIRED) endif( ) -macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _optional) +macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) # This macro checks for the existence of the combination of fortran libraries # given by _list. If the combination is found, this macro checks (using the # Check_Fortran_Function_Exists macro) whether can link against that library @@ -69,8 +69,7 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _optional) # N.B. _prefix is the prefix applied to the names of all cached variables that # are generated internally and marked advanced by this macro. -list(GET _optional 0 _thread) -list(GET _optional 1 _libdir) +set(_libdir ${ARGN}) set(_libraries_work TRUE) set(${LIBRARIES}) @@ -267,15 +266,24 @@ if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") endif (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") #BLAS in acml library? -if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR STREQUAL "All") -# the patch from Chuck Atkins: - if( ((_BLAS_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR - ((_BLAS_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) ) +if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") + if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR + ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR + ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS)) + ) + # try to find acml in "standard" paths if( WIN32 ) file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" ) else() file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" ) endif() + if( WIN32 ) + file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" ) + else() + file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" ) + endif() + list(GET _ACML_ROOT 0 _ACML_ROOT) + list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT) if( _ACML_ROOT ) get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH ) if( SIZEOF_INTEGER EQUAL 8 ) @@ -309,7 +317,7 @@ if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR ST set( _ACML_COMPILER64 "gfortran64" ) endif() - if( _BLAS_VENDOR STREQUAL "ACML_MP" ) + if( BLA_VENDOR STREQUAL "ACML_MP" ) set(_ACML_MP_LIB_DIRS "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib" "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" ) @@ -319,10 +327,12 @@ if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR ST "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" ) endif() endif() + elseif(BLAS_${BLA_VENDOR}_LIB_DIRS) + set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS}) endif() - if( _BLAS_VENDOR STREQUAL "ACML_MP" ) - foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS} ) + if( BLA_VENDOR STREQUAL "ACML_MP" ) + foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS}) check_fortran_libraries ( BLAS_LIBRARIES BLAS @@ -333,6 +343,18 @@ if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR ST break() endif() endforeach() + elseif( BLA_VENDOR STREQUAL "ACML_GPU" ) + foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS}) + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml_mp;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) + break() + endif() + endforeach() else() #if( _BLAS_VENDOR STREQUAL "ACML" ) foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} ) check_fortran_libraries ( @@ -368,6 +390,16 @@ if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR ST "" ) endif(NOT BLAS_LIBRARIES) + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml;acml_mv;CALBLAS" + "" + ) + endif(NOT BLAS_LIBRARIES) endif () # ACML # Apple BLAS library? From d5e603026b9bfde90742483df322e0c168407fef Mon Sep 17 00:00:00 2001 From: Alexey Ozeritsky Date: Sat, 13 Aug 2011 18:50:57 +0400 Subject: [PATCH 079/539] ACML-GPU supportede --- Modules/FindLAPACK.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 12191020222..80fe8671fd0 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -165,11 +165,11 @@ endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") #acml lapack - if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR STREQUAL "All") + if (BLA_VENDOR STREQUAL "ACML.*" OR BLA_VENDOR STREQUAL "All") if (BLAS_LIBRARIES MATCHES ".+acml.+") set (LAPACK_LIBRARIES ${BLAS_LIBRARIES}) endif () - endif (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR STREQUAL "All") + endif () # Apple LAPACK library? if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") From c448b09ad39c35b129d7b91710bea4f26fabdfe4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 13 Aug 2011 22:20:54 +0200 Subject: [PATCH 080/539] Perform the -Werror test only once. This way, the output of the test should be visible on CDash. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index a310eb9481f..46ab88514d3 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR) project(GenerateExportHeader) +include(CheckCXXCompilerFlag) + set( CMAKE_INCLUDE_CURRENT_DIR ON ) macro(TEST_FAIL value msg) @@ -16,6 +18,8 @@ macro(TEST_PASS value msg) endif () endmacro() +check_cxx_compiler_flag(-Werror HAS_WERROR_FLAG) + # We seem to get race conditions is writing this stuff to the same file at least on MinGW # So to write to separate source and build directories, we use a count to differentiate. set (COUNT 0) @@ -46,9 +50,7 @@ macro(_do_build Include Library LibrarySource Source) "add_compiler_export_flags()\n" - "check_cxx_compiler_flag(-Werror HAS_WERROR_FLAG)\n" - - "if(HAS_WERROR_FLAG)\n" + "if(${HAS_WERROR_FLAG})\n" " add_definitions(-Werror)\n" "else()\n" " if(MSVC AND COMPILER_HAS_DEPRECATED)\n" @@ -101,6 +103,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) message("#### COMPILER_HAS_DEPRECATED: " ${COMPILER_HAS_DEPRECATED}) message("#### COMPILER_HAS_HIDDEN_VISIBILITY: " ${COMPILER_HAS_HIDDEN_VISIBILITY}) message("#### WIN32: " ${WIN32}) +message("#### HAS_WERROR_FLAG: " ${HAS_WERROR_FLAG}) set(link_libraries) macro(macro_add_test_library name) From aed84517c942a4c40f493fcf997cdf6a047349f8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 13 Aug 2011 22:33:30 +0200 Subject: [PATCH 081/539] Test for deprecated attribute before declspec. The attribute seems more common, and some compilers seem to silently ignore the declspec. --- Modules/GenerateExportHeader.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index c833a014d6e..044e2b439c7 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -158,11 +158,11 @@ macro(_test_compiler_hidden_visibility) endmacro() macro(_test_compiler_has_deprecated) - _check_cxx_compiler_attribute("__declspec(deprecated)" COMPILER_HAS_DEPRECATED_DECLSPEC) - if(COMPILER_HAS_DEPRECATED_DECLSPEC) - set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED_DECLSPEC}" CACHE INTERNAL "Compiler support for a deprecated attribute") + _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED_ATTR) + if(COMPILER_HAS_DEPRECATED_ATTR) + set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED_ATTR}" CACHE INTERNAL "Compiler support for a deprecated attribute") else() - _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED) + _check_cxx_compiler_attribute("__declspec(deprecated)" COMPILER_HAS_DEPRECATED) endif() endmacro() From c41c68bfa437d4ea1b2ae5153f6f20430c47d902 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 13 Aug 2011 23:06:01 +0200 Subject: [PATCH 082/539] Try to error on deprecated on Intel and SunCC. --- .../GenerateExportHeader/CMakeLists.txt | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 46ab88514d3..dc7268942b0 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -20,6 +20,27 @@ endmacro() check_cxx_compiler_flag(-Werror HAS_WERROR_FLAG) +if(HAS_WERROR_FLAG) + set(ERROR_FLAG "-Werror") +else() + # MSVC + # And intel on windows? + # http://software.intel.com/en-us/articles/how-to-handle-warnings-message-in-compiler/?wapkw=%28compiler+warning+message%29 + check_cxx_compiler_flag("/WX" HAS_WX_FLAG) + if(HAS_WX_FLAG) + set(ERROR_FLAG "/WX") + else() + # Sun CC + # http://www.acsu.buffalo.edu/~charngda/sunstudio.html + check_cxx_compiler_flag("-errwarn=%all" HAS_ERRWARN_ALL) + if (HAS_ERRWARN_ALL) + set(ERROR_FLAG "-errwarn=%all") + else() + endif() + endif() +endif() + + # We seem to get race conditions is writing this stuff to the same file at least on MinGW # So to write to separate source and build directories, we use a count to differentiate. set (COUNT 0) @@ -50,13 +71,8 @@ macro(_do_build Include Library LibrarySource Source) "add_compiler_export_flags()\n" - "if(${HAS_WERROR_FLAG})\n" - " add_definitions(-Werror)\n" - "else()\n" - " if(MSVC AND COMPILER_HAS_DEPRECATED)\n" - # Treat deprecation warnings as errors. - " add_definitions(/we4996)\n" - " endif()\n" + "if(NOT \"${ERROR_FLAG}\" STREQUAL \"\")\n" + " add_definitions(${ERROR_FLAG})\n" "endif()\n" "if(MSVC)\n" From 2aeab4f973144fe859d5751e969512a92ae08d96 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 13 Aug 2011 23:30:35 +0200 Subject: [PATCH 083/539] Borland can't do deprecated. --- Modules/GenerateExportHeader.cmake | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 044e2b439c7..5b42b7761c6 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -158,11 +158,15 @@ macro(_test_compiler_hidden_visibility) endmacro() macro(_test_compiler_has_deprecated) - _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED_ATTR) - if(COMPILER_HAS_DEPRECATED_ATTR) - set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED_ATTR}" CACHE INTERNAL "Compiler support for a deprecated attribute") + if("${CMAKE_CXX_COMPILER_ID}" MATCHES Borland) + set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL "Compiler support for a deprecated attribute") else() - _check_cxx_compiler_attribute("__declspec(deprecated)" COMPILER_HAS_DEPRECATED) + _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED_ATTR) + if(COMPILER_HAS_DEPRECATED_ATTR) + set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED_ATTR}" CACHE INTERNAL "Compiler support for a deprecated attribute") + else() + _check_cxx_compiler_attribute("__declspec(deprecated)" COMPILER_HAS_DEPRECATED) + endif() endif() endmacro() From 97392a7dd3ca141285e22507bfdae6c640512e76 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 14 Aug 2011 15:37:24 +0200 Subject: [PATCH 084/539] Fixup forgotten part of aed84517c942a4c40f493fcf997cdf6a047349f8 --- Modules/GenerateExportHeader.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 5b42b7761c6..758eb251477 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -178,10 +178,10 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) set(DEFINE_IMPORT) set(DEFINE_NO_EXPORT) - if (COMPILER_HAS_DEPRECATED_DECLSPEC) - set(DEFINE_DEPRECATED "__declspec(deprecated)") - elseif(COMPILER_HAS_DEPRECATED) + if (COMPILER_HAS_DEPRECATED_ATTR) set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))") + elseif(COMPILER_HAS_DEPRECATED) + set(DEFINE_DEPRECATED "__declspec(deprecated)") endif() get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE) From 6bb4ca3802d2fc83f1072adfde6f1075aa2992c4 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 14 Aug 2011 15:38:24 +0200 Subject: [PATCH 085/539] The makefile for the test was kindof wrong Alex --- Tests/FindPackageModeMakefileTest/Makefile.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in index 5105d994915..5e42305b83b 100644 --- a/Tests/FindPackageModeMakefileTest/Makefile.in +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -1,7 +1,9 @@ all: clean pngtest -pngtest: main.o +main.o: main.cpp "@CMAKE_CXX_COMPILER@" -c `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE` main.cpp + +pngtest: main.o "@CMAKE_CXX_COMPILER@" -o pngtest main.o `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK` clean: From d1c0a5fce6c9adccd1abf6b41ba448976ef895d0 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 7 Aug 2011 17:16:00 +0200 Subject: [PATCH 086/539] Start implementing skeleton for automoc in cmake Alex --- Source/cmQtAutomoc.cxx | 80 ++++++++++++++++++++++++++++++++++++++++++ Source/cmQtAutomoc.h | 18 ++++++++++ Source/cmake.cxx | 3 +- 3 files changed, 100 insertions(+), 1 deletion(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index efbfc383295..26d359df94b 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -1,3 +1,8 @@ +#include "cmGlobalGenerator.h" +#include "cmLocalGenerator.h" +#include "cmMakefile.h" +#include "cmSystemTools.h" + #include "cmQtAutomoc.h" cmQtAutomoc::cmQtAutomoc() @@ -6,5 +11,80 @@ cmQtAutomoc::cmQtAutomoc() bool cmQtAutomoc::Run(const char* targetDirectory) +{ + cmake cm; + cmGlobalGenerator* gg = this->CreateGlobalGenerator(&cm, targetDirectory); + cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile(); + + this->ReadAutomocInfoFile(makefile, targetDirectory); + this->ReadOldMocDefinitionsFile(makefile, targetDirectory); + + delete gg; + gg = NULL; + makefile = NULL; + + if (this->QtMajorVersion == "4") + { + this->RunAutomocQt4(); + } + + this->WriteOldMocDefinitionsFile(targetDirectory); +} + + +cmGlobalGenerator* cmQtAutomoc::CreateGlobalGenerator(cmake* cm, + const char* targetDirectory) +{ + cmGlobalGenerator* gg = new cmGlobalGenerator(); + gg->SetCMakeInstance(cm); + + cmLocalGenerator* lg = gg->CreateLocalGenerator(); + lg->GetMakefile()->SetHomeOutputDirectory(targetDirectory); + lg->GetMakefile()->SetStartOutputDirectory(targetDirectory); + lg->GetMakefile()->SetHomeDirectory(targetDirectory); + lg->GetMakefile()->SetStartDirectory(targetDirectory); + gg->SetCurrentLocalGenerator(lg); + + return gg; +} + + +bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, + const char* targetDirectory) +{ + std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); + cmSystemTools::ConvertToUnixSlashes(filename); + filename += "/AutomocInfo.cmake"; + + if (!makefile->ReadListFile(0, filename.c_str())) + { + cmSystemTools::Error("Error processing file:", filename.c_str()); + } + return true; +} + + +bool cmQtAutomoc::ReadOldMocDefinitionsFile(cmMakefile* makefile, + const char* targetDirectory) +{ + std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); + cmSystemTools::ConvertToUnixSlashes(filename); + filename += "/AutomocOldMocDefinitions.cmake"; + + if (!makefile->ReadListFile(0, filename.c_str())) + { + cmSystemTools::Error("Error processing file:", filename.c_str()); + } + return true; +} + + +bool cmQtAutomoc::RunAutomocQt4() +{ + return true; +} + + +void cmQtAutomoc::WriteOldMocDefinitionsFile(const char* targetDirectory) { } diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index 657b2080577..d6f809c68c1 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -1,11 +1,29 @@ #ifndef cmQtAutomoc_h #define cmQtAutomoc_h +class cmGlobalGenerator; +class cmMakefile; + class cmQtAutomoc { public: cmQtAutomoc(); bool Run(const char* targetDirectory); + +private: + cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, + const char* targetDirectory); + + bool ReadAutomocInfoFile(cmMakefile* makefile, + const char* targetDirectory); + bool ReadOldMocDefinitionsFile(cmMakefile* makefile, + const char* targetDirectory); + void WriteOldMocDefinitionsFile(const char* targetDirectory); + + bool RunAutomocQt4(); + + std::string QtMajorVersion; + }; #endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 47520dff737..06229e0c758 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1578,7 +1578,8 @@ int cmake::ExecuteCMakeCommand(std::vector& args) else if (args[1] == "cmake_automoc") { cmQtAutomoc automoc; - automoc.Run("target directory"); + automoc.Run(args[2].c_str()); + return 0; } // Tar files From 10d8c446d5893446eaf4bd6e295fb6ea0d83d7f4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 14 Aug 2011 15:42:31 +0200 Subject: [PATCH 087/539] Disable testing of deprecated macros. It is not possible to test for it sanely across multiple ancient compilers supported by cmake. --- .../lib_shared_and_statictest/CMakeLists.txt | 14 +++++++------- .../libsharedtest/CMakeLists.txt | 10 +++++----- .../libstatictest/CMakeLists.txt | 14 +++++++------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt index 28d6c65c6e7..207534d6ef9 100644 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt @@ -17,13 +17,13 @@ endmacro() static_variant_build_pass("return libshared_and_static_exported();" "Failed to build static variant") shared_variant_build_pass("return libshared_and_static_exported();" "Failed to build shared variant") -if (COMPILER_HAS_DEPRECATED) - shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant") - static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant") -else() - shared_variant_build_pass("return libshared_and_static_deprecated();" "Built shared deprecated variant") - static_variant_build_pass("return libshared_and_static_deprecated();" "Built static deprecated variant") -endif() +# if (COMPILER_HAS_DEPRECATED) +# shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant") +# static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant") +# else() +# shared_variant_build_pass("return libshared_and_static_deprecated();" "Built shared deprecated variant") +# static_variant_build_pass("return libshared_and_static_deprecated();" "Built static deprecated variant") +# endif() static_variant_build_pass("return libshared_and_static_not_exported();" "Failed to build static not exported variant") if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) diff --git a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt index 288089ef697..a5804fcfbad 100644 --- a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt @@ -9,11 +9,11 @@ endmacro() shared_build_pass("Libshared l; return l.libshared_exported();" "Failed to build exported") -if (COMPILER_HAS_DEPRECATED) - shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") -else() - shared_build_pass("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") -endif() +# if (COMPILER_HAS_DEPRECATED) +# shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") +# else() +# shared_build_pass("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") +# endif() if (COMPILER_HAS_HIDDEN_VISIBILITY) shared_build_fail("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") else() diff --git a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt index 14ca05b4c79..eb6bb874ce6 100644 --- a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt @@ -9,10 +9,10 @@ endmacro() static_build_pass("Libstatic l; return l.libstatic_exported();" "Failed to build exported.") -if (COMPILER_HAS_DEPRECATED) - static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") - static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") -else() - static_build_pass("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") - static_build_pass("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") -endif() +# if (COMPILER_HAS_DEPRECATED) +# static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") +# static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") +# else() +# static_build_pass("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") +# static_build_pass("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") +# endif() From d65689a3bd059b2f70e11644e43df4251c71987e Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 8 Aug 2011 15:20:13 +0200 Subject: [PATCH 088/539] Add actual automoc code from automoc It already works :-) Needs more refactoring, e.g. using the cmake facilities to turn a string into a vector etc. Also still missing is the part which creates the custom target. Alex --- Source/cmQtAutomoc.cxx | 566 ++++++++++++++++++++++++++++++++++++++++- Source/cmQtAutomoc.h | 29 +++ 2 files changed, 589 insertions(+), 6 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 26d359df94b..7fac2f20eaf 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -5,7 +5,13 @@ #include "cmQtAutomoc.h" + +#define TRACE_LINE() printf(" %s %d\n", __PRETTY_FUNCTION__, __LINE__) + cmQtAutomoc::cmQtAutomoc() +:Verbose(true) +,RunMocFailed(false) +,GenerateAll(false) { } @@ -19,9 +25,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory) this->ReadAutomocInfoFile(makefile, targetDirectory); this->ReadOldMocDefinitionsFile(makefile, targetDirectory); - delete gg; - gg = NULL; - makefile = NULL; + this->Init(); if (this->QtMajorVersion == "4") { @@ -29,6 +33,11 @@ bool cmQtAutomoc::Run(const char* targetDirectory) } this->WriteOldMocDefinitionsFile(targetDirectory); + + delete gg; + gg = NULL; + makefile = NULL; + } @@ -59,7 +68,22 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, if (!makefile->ReadListFile(0, filename.c_str())) { cmSystemTools::Error("Error processing file:", filename.c_str()); + return false; } + + this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR"); + this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); + this->IncludeProjectDirsBefore = makefile->IsOn("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"); + this->Srcdir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR"); + this->Builddir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); + this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE"); + this->MocCompileDefinitionsStr = makefile->GetSafeDefinition("AM_MOC_COMPILE_DEFINITIONS"); + this->MocDefinitionsStr = makefile->GetSafeDefinition("AM_MOC_DEFINITIONS"); + this->MocIncludesStr = makefile->GetSafeDefinition("AM_MOC_INCLUDES"); + this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); + this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR"); + this->TargetName = makefile->GetSafeDefinition("AM_TARGET_NAME"); + return true; } @@ -71,20 +95,550 @@ bool cmQtAutomoc::ReadOldMocDefinitionsFile(cmMakefile* makefile, cmSystemTools::ConvertToUnixSlashes(filename); filename += "/AutomocOldMocDefinitions.cmake"; - if (!makefile->ReadListFile(0, filename.c_str())) + if (makefile->ReadListFile(0, filename.c_str())) { - cmSystemTools::Error("Error processing file:", filename.c_str()); + this->OldMocDefinitionsStr = + makefile->GetSafeDefinition("AM_OLD_MOC_DEFINITIONS"); } return true; } +void cmQtAutomoc::WriteOldMocDefinitionsFile(const char* targetDirectory) +{ + std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); + cmSystemTools::ConvertToUnixSlashes(filename); + filename += "/AutomocOldMocDefinitions.cmake"; + + std::fstream outfile; + outfile.open(filename.c_str(), + std::ios_base::out | std::ios_base::trunc); + outfile << "set(AM_OLD_MOC_DEFINITIONS \"" + << this->Join(this->MocDefinitions, ' ') << "\")\n"; + + outfile.close(); +} + + +void cmQtAutomoc::Init() +{ + this->OutMocCppFilename = this->Builddir; + this->OutMocCppFilename += this->TargetName; + this->OutMocCppFilename += ".cpp"; + + std::vector cdefList; + cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList); + if (!cdefList.empty()) + { + for(std::vector::const_iterator it = cdefList.begin(); + it != cdefList.end(); + ++it) + { + this->MocDefinitions.push_back("-D" + (*it)); + } + } + else + { + std::string tmpMocDefs = this->MocDefinitionsStr; + cmSystemTools::ReplaceString(tmpMocDefs, " ", ";"); + + std::vector defList; + cmSystemTools::ExpandListArgument(tmpMocDefs, defList); + + for(std::vector::const_iterator it = defList.begin(); + it != defList.end(); + ++it) + { + if (this->StartsWith(*it, "-D")) + { + this->MocDefinitions.push_back(*it); + } + } + } + + std::vector incPaths; + cmSystemTools::ExpandListArgument(this->MocIncludesStr, incPaths); + + std::set frameworkPaths; + for(std::vector::const_iterator it = incPaths.begin(); + it != incPaths.end(); + ++it) + { + const std::string &path = *it; + this->MocIncludes.push_back("-I" + path); + if (this->EndsWith(path, ".framework/Headers")) + { + // Go up twice to get to the framework root + std::vector pathComponents; + cmsys::SystemTools::SplitPath(path.c_str(), pathComponents); + std::string frameworkPath =cmsys::SystemTools::JoinPath( + pathComponents.begin(), pathComponents.end() - 2); + frameworkPaths.insert(frameworkPath); + } + } + + for (std::set::const_iterator it = frameworkPaths.begin(); + it != frameworkPaths.end(); ++it) + { + this->MocIncludes.push_back("-F"); + this->MocIncludes.push_back(*it); + } + + + if (this->IncludeProjectDirsBefore) + { + const std::string &binDir = "-I" + this->ProjectBinaryDir; + + const std::string srcDir = "-I" + this->ProjectSourceDir; + + std::list sortedMocIncludes; + std::list::iterator it = this->MocIncludes.begin(); + while (it != this->MocIncludes.end()) + { + if (this->StartsWith(*it, binDir)) + { + sortedMocIncludes.push_back(*it); + it = this->MocIncludes.erase(it); + } + else + { + ++it; + } + } + it = this->MocIncludes.begin(); + while (it != this->MocIncludes.end()) + { + if (this->StartsWith(*it, srcDir)) + { + sortedMocIncludes.push_back(*it); + it = this->MocIncludes.erase(it); + } + else + { + ++it; + } + } + sortedMocIncludes.insert(sortedMocIncludes.end(), + this->MocIncludes.begin(), this->MocIncludes.end()); + this->MocIncludes = sortedMocIncludes; + } + +} + + bool cmQtAutomoc::RunAutomocQt4() { + if (!cmsys::SystemTools::FileExists(this->OutMocCppFilename.c_str()) + || (this->OldMocDefinitionsStr != this->Join(this->MocDefinitions, ' '))) + { + this->GenerateAll = true; + } + + // the program goes through all .cpp files to see which moc files are included. It is not really + // interesting how the moc file is named, but what file the moc is created from. Once a moc is + // included the same moc may not be included in the _automoc.cpp file anymore. OTOH if there's a + // header containing Q_OBJECT where no corresponding moc file is included anywhere a + // moc_.cpp file is created and included in the _automoc.cpp file. + std::map includedMocs; // key = moc source filepath, value = moc output filepath + std::map notIncludedMocs; // key = moc source filepath, value = moc output filename + + cmsys::RegularExpression mocIncludeRegExp( + "[\n][ \t]*#[ \t]*include[ \t]+" + "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); + cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); + std::list headerExtensions; +#if defined(_WIN32) + // not case sensitive + headerExtensions.push_back(".h"); + headerExtensions.push_back(".hpp"); + headerExtensions.push_back(".hxx"); +#elif defined(__APPLE__) + headerExtensions.push_back(".h"); + headerExtensions.push_back(".hpp"); + headerExtensions.push_back(".hxx"); + + // detect case-sensitive filesystem + long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE); + if (caseSensitive == 1) + { + headerExtensions.push_back(".H"); + } +#else + headerExtensions.push_back(".h"); + headerExtensions.push_back(".hpp"); + headerExtensions.push_back(".hxx"); + headerExtensions.push_back(".H"); +#endif + + std::vector sourceFiles; + cmSystemTools::ExpandListArgument(this->Sources, sourceFiles); + + for (std::vector::const_iterator it = sourceFiles.begin(); + it != sourceFiles.end(); + ++it) + { + const std::string &absFilename = *it; + if (this->Verbose) + { + printf("Checking -%s-\n", absFilename.c_str()); + } + std::string extension = absFilename.substr(absFilename.find_last_of('.')); + + if (extension == ".cpp" || extension == ".cc" || extension == ".mm" + || extension == ".cxx" || extension == ".C") + { + const std::string contentsString = this->ReadAll(absFilename); + if (contentsString.empty()) + { + std::cerr << "automoc4: empty source file: " << absFilename << std::endl; + continue; + } + const std::string absPath = cmsys::SystemTools::GetFilenamePath( + cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; + + int matchOffset = 0; + if (!mocIncludeRegExp.find(contentsString.c_str())) + { + // no moc #include, look whether we need to create a moc from the .h nevertheless + //std::cout << "no moc #include in the .cpp file"; + const std::string basename = + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); + for(std::list::const_iterator ext = + headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string headername = absPath + basename + (*ext); + if (cmsys::SystemTools::FileExists(headername.c_str()) + && includedMocs.find(headername) == includedMocs.end() + && notIncludedMocs.find(headername) == notIncludedMocs.end()) + { + const std::string currentMoc = "moc_" + basename + ".cpp"; + const std::string contents = this->ReadAll(headername); + if (qObjectRegExp.find(contents)) + { + //std::cout << "header contains Q_OBJECT macro"; + notIncludedMocs[headername] = currentMoc; + } + break; + } + } + for(std::list::const_iterator ext = + headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string privateHeaderName = absPath+basename+"_p"+(*ext); + if (cmsys::SystemTools::FileExists(privateHeaderName.c_str()) + && includedMocs.find(privateHeaderName) == includedMocs.end() + && notIncludedMocs.find(privateHeaderName) == notIncludedMocs.end()) + { + const std::string currentMoc = "moc_" + basename + "_p.cpp"; + const std::string contents = this->ReadAll(privateHeaderName); + if (qObjectRegExp.find(contents)) + { + //std::cout << "header contains Q_OBJECT macro"; + notIncludedMocs[privateHeaderName] = currentMoc; + } + break; + } + } + } + else + { + // for every moc include in the file + do + { + const std::string currentMoc = mocIncludeRegExp.match(1); + //std::cout << "found moc include: " << currentMoc << std::endl; + + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(currentMoc); + const bool moc_style = this->StartsWith(basename, "moc_"); + + // If the moc include is of the moc_foo.cpp style we expect the Q_OBJECT class + // declaration in a header file. + // If the moc include is of the foo.moc style we need to look for a Q_OBJECT + // macro in the current source file, if it contains the macro we generate the + // moc file from the source file, else from the header. + // + // TODO: currently any .moc file name will be used if the source contains + // Q_OBJECT + if (moc_style || !qObjectRegExp.find(contentsString)) + { + if (moc_style) + { + // basename should be the part of the moc filename used for finding the + // correct header, so we need to remove the moc_ part + basename = basename.substr(4); + } + + bool headerFound = false; + for(std::list::const_iterator ext = + headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string &sourceFilePath = absPath + basename + (*ext); + if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) + { + headerFound = true; + includedMocs[sourceFilePath] = currentMoc; + notIncludedMocs.erase(sourceFilePath); + break; + } + } + if (!headerFound) + { + // the moc file is in a subdir => look for the header in the same subdir + if (currentMoc.find_first_of('/') != std::string::npos) + { + const std::string &filepath = absPath + + cmsys::SystemTools::GetFilenamePath(currentMoc) + + '/' + basename; + + for(std::list::const_iterator ext = + headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string &sourceFilePath = filepath + (*ext); + if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) + { + headerFound = true; + includedMocs[sourceFilePath] = currentMoc; + notIncludedMocs.erase(sourceFilePath); + break; + } + } + if (!headerFound) + { + std::cerr << "automoc4: The file \"" << absFilename << + "\" includes the moc file \"" << currentMoc << "\", but neither \"" << + absPath + basename + '{' + this->Join(headerExtensions, ',') + "}\" nor \"" << + filepath + '{' + this->Join(headerExtensions, ',') + '}' << + "\" exist." << std::endl; + ::exit(EXIT_FAILURE); + } + } + else + { + std::cerr << "automoc4: The file \"" << absFilename << + "\" includes the moc file \"" << currentMoc << "\", but \"" << + absPath + basename + '{' + this->Join(headerExtensions, ',') + '}' << + "\" does not exist." << std::endl; + ::exit(EXIT_FAILURE); + } + } + } + else + { + includedMocs[absFilename] = currentMoc; + notIncludedMocs.erase(absFilename); + } + matchOffset += mocIncludeRegExp.end(); + } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); + } + } + else if (extension == ".h" || extension == ".hpp" + || extension == ".hxx" || extension == ".H") + { + if (includedMocs.find(absFilename) == includedMocs.end() + && notIncludedMocs.find(absFilename) == notIncludedMocs.end()) + { + // if this header is not getting processed yet and is explicitly mentioned for the + // automoc the moc is run unconditionally on the header and the resulting file is + // included in the _automoc.cpp file (unless there's a .cpp file later on that + // includes the moc from this header) + const std::string currentMoc = "moc_" + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename) + ".cpp"; + notIncludedMocs[absFilename] = currentMoc; + } + } + else + { + if (this->Verbose) + { + std::cout << "automoc4: ignoring file '" << absFilename << "' with unknown suffix" << std::endl; + } + } + } + + // run moc on all the moc's that are #included in source files + for(std::map::const_iterator it = includedMocs.begin(); + it != includedMocs.end(); + ++it) + { + this->GenerateMoc(it->first, it->second); + } + + std::stringstream outStream(std::stringstream::out); + outStream << "/* This file is autogenerated, do not edit*/\n"; + + bool automocCppChanged = false; + if (notIncludedMocs.empty()) + { + outStream << "enum some_compilers { need_more_than_nothing };\n"; + } + else + { + // run moc on the remaining headers and include them in the _automoc.cpp file + for(std::map::const_iterator it = notIncludedMocs.begin(); + it != notIncludedMocs.end(); + ++it) + { + bool mocSuccess = this->GenerateMoc(it->first, it->second); + if (mocSuccess) + { + automocCppChanged = true; + } + outStream << "#include \"" << it->second << "\"\n"; + } + } + + if (this->RunMocFailed) + { + // if any moc process failed we don't want to touch the _automoc.cpp file so that + // automoc4 is rerun until the issue is fixed + std::cerr << "returning failed.."<< std::endl; + return false; + } + outStream.flush(); + std::string automocSource = outStream.str(); + if (!automocCppChanged) + { + // compare contents of the _automoc.cpp file + const std::string oldContents = this->ReadAll(this->OutMocCppFilename); + if (oldContents == automocSource) + { + // nothing changed: don't touch the _automoc.cpp file + return true; + } + } + // either the contents of the _automoc.cpp file or one of the mocs included by it have changed + + // source file that includes all remaining moc files (_automoc.cpp file) + std::fstream outfile; + outfile.open(this->OutMocCppFilename.c_str(), + std::ios_base::out | std::ios_base::trunc); + outfile << automocSource; + outfile.close(); + return true; } -void cmQtAutomoc::WriteOldMocDefinitionsFile(const char* targetDirectory) +bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, + const std::string& mocFileName) +{ + //std::cout << "AutoMoc::generateMoc" << sourceFile << mocFileName << std::endl; + const std::string mocFilePath = this->Builddir + mocFileName; + int sourceNewerThanMoc = 0; + bool success = cmsys::SystemTools::FileTimeCompare(sourceFile.c_str(), + mocFilePath.c_str(), + &sourceNewerThanMoc); + if (this->GenerateAll || !success || sourceNewerThanMoc >= 0) + { + // make sure the directory for the resulting moc file exists + std::string mocDir = mocFilePath.substr(0, mocFilePath.rfind('/')); + if (!cmsys::SystemTools::FileExists(mocDir.c_str(), false)) + { + cmsys::SystemTools::MakeDirectory(mocDir.c_str()); + } + +/* if (this->Verbose) + { + echoColor("Generating " + mocFilePath + " from " + sourceFile); + } + else + { + echoColor("Generating " + mocFileName); + }*/ + + std::vector command; + command.push_back(this->MocExecutable); + for (std::list::const_iterator it = this->MocIncludes.begin(); + it != this->MocIncludes.end(); + ++it) + { + command.push_back(*it); + } + for(std::list::const_iterator it=this->MocDefinitions.begin(); + it != this->MocDefinitions.end(); + ++it) + { + command.push_back(*it); + } +#ifdef _WIN32 + command.push_back("-DWIN32"); +#endif + command.push_back("-o"); + command.push_back(mocFilePath); + command.push_back(sourceFile); + + if (this->Verbose) + { + for(int i=0; iRunMocFailed = true; + cmSystemTools::RemoveFile(mocFilePath.c_str()); + } + return true; + } + return false; +} + + +std::string cmQtAutomoc::Join(const std::list& lst,char separator) +{ + if (lst.empty()) + { + return ""; + } + + std::string result; + for (std::list::const_iterator it = lst.begin(); + it != lst.end(); + ++it) + { + result += (*it) + separator; + } + result.erase(result.end() - 1); + return result; +} + + +bool cmQtAutomoc::StartsWith(const std::string& str, const std::string& with) +{ + return (str.substr(0, with.length()) == with); +} + + +bool cmQtAutomoc::EndsWith(const std::string& str, const std::string& with) +{ + if (with.length() > (str.length())) + { + return false; + } + return (str.substr(str.length() - with.length(), with.length()) == with); +} + + +std::string cmQtAutomoc::ReadAll(const std::string& filename) { + std::ifstream file(filename.c_str()); + std::stringstream stream; + stream << file.rdbuf(); + file.close(); + return stream.str(); } diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index d6f809c68c1..0dafd4aec56 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -21,8 +21,37 @@ class cmQtAutomoc void WriteOldMocDefinitionsFile(const char* targetDirectory); bool RunAutomocQt4(); + bool GenerateMoc(const std::string& sourceFile, + const std::string& mocFileName); + void Init(); + + std::string Join(const std::list& lst, char separator); + bool EndsWith(const std::string& str, const std::string& with); + bool StartsWith(const std::string& str, const std::string& with); + std::string ReadAll(const std::string& filename); std::string QtMajorVersion; + std::string Sources; + bool IncludeProjectDirsBefore; + std::string Srcdir; + std::string Builddir; + std::string MocExecutable; + std::string MocCompileDefinitionsStr; + std::string MocDefinitionsStr; + std::string MocIncludesStr; + std::string ProjectBinaryDir; + std::string ProjectSourceDir; + std::string TargetName; + + std::string OldMocDefinitionsStr; + + std::string OutMocCppFilename; + std::list MocIncludes; + std::list MocDefinitions; + + bool Verbose; + bool RunMocFailed; + bool GenerateAll; }; From de91feb367c127294a56b492799c4bf042954fd8 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 9 Aug 2011 09:11:53 +0200 Subject: [PATCH 089/539] Remove the need to check for .h/.cxx during buildtime Instead it now relies on cmake time to put that information correctly into AutomocInfo.cmake Alex --- Source/cmQtAutomoc.cxx | 286 ++++++++++++++++++++--------------------- Source/cmQtAutomoc.h | 1 + 2 files changed, 143 insertions(+), 144 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 7fac2f20eaf..5494b2aa590 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -73,6 +73,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR"); this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); + this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); this->IncludeProjectDirsBefore = makefile->IsOn("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"); this->Srcdir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR"); this->Builddir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); @@ -282,184 +283,181 @@ bool cmQtAutomoc::RunAutomocQt4() { printf("Checking -%s-\n", absFilename.c_str()); } - std::string extension = absFilename.substr(absFilename.find_last_of('.')); - if (extension == ".cpp" || extension == ".cc" || extension == ".mm" - || extension == ".cxx" || extension == ".C") + const std::string contentsString = this->ReadAll(absFilename); + if (contentsString.empty()) { - const std::string contentsString = this->ReadAll(absFilename); - if (contentsString.empty()) - { - std::cerr << "automoc4: empty source file: " << absFilename << std::endl; - continue; - } - const std::string absPath = cmsys::SystemTools::GetFilenamePath( - cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; + std::cerr << "automoc4: empty source file: " << absFilename << std::endl; + continue; + } + const std::string absPath = cmsys::SystemTools::GetFilenamePath( + cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; - int matchOffset = 0; - if (!mocIncludeRegExp.find(contentsString.c_str())) + int matchOffset = 0; + if (!mocIncludeRegExp.find(contentsString.c_str())) + { + // no moc #include, look whether we need to create a moc from the .h nevertheless + //std::cout << "no moc #include in the .cpp file"; + const std::string basename = + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); + for(std::list::const_iterator ext = + headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) { - // no moc #include, look whether we need to create a moc from the .h nevertheless - //std::cout << "no moc #include in the .cpp file"; - const std::string basename = - cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); - for(std::list::const_iterator ext = - headerExtensions.begin(); - ext != headerExtensions.end(); - ++ext) + const std::string headername = absPath + basename + (*ext); + if (cmsys::SystemTools::FileExists(headername.c_str()) + && includedMocs.find(headername) == includedMocs.end() + && notIncludedMocs.find(headername) == notIncludedMocs.end()) { - const std::string headername = absPath + basename + (*ext); - if (cmsys::SystemTools::FileExists(headername.c_str()) - && includedMocs.find(headername) == includedMocs.end() - && notIncludedMocs.find(headername) == notIncludedMocs.end()) + const std::string currentMoc = "moc_" + basename + ".cpp"; + const std::string contents = this->ReadAll(headername); + if (qObjectRegExp.find(contents)) { - const std::string currentMoc = "moc_" + basename + ".cpp"; - const std::string contents = this->ReadAll(headername); - if (qObjectRegExp.find(contents)) - { - //std::cout << "header contains Q_OBJECT macro"; - notIncludedMocs[headername] = currentMoc; - } - break; + //std::cout << "header contains Q_OBJECT macro"; + notIncludedMocs[headername] = currentMoc; } + break; } - for(std::list::const_iterator ext = - headerExtensions.begin(); - ext != headerExtensions.end(); - ++ext) + } + for(std::list::const_iterator ext = + headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string privateHeaderName = absPath+basename+"_p"+(*ext); + if (cmsys::SystemTools::FileExists(privateHeaderName.c_str()) + && includedMocs.find(privateHeaderName) == includedMocs.end() + && notIncludedMocs.find(privateHeaderName) == notIncludedMocs.end()) { - const std::string privateHeaderName = absPath+basename+"_p"+(*ext); - if (cmsys::SystemTools::FileExists(privateHeaderName.c_str()) - && includedMocs.find(privateHeaderName) == includedMocs.end() - && notIncludedMocs.find(privateHeaderName) == notIncludedMocs.end()) + const std::string currentMoc = "moc_" + basename + "_p.cpp"; + const std::string contents = this->ReadAll(privateHeaderName); + if (qObjectRegExp.find(contents)) { - const std::string currentMoc = "moc_" + basename + "_p.cpp"; - const std::string contents = this->ReadAll(privateHeaderName); - if (qObjectRegExp.find(contents)) - { - //std::cout << "header contains Q_OBJECT macro"; - notIncludedMocs[privateHeaderName] = currentMoc; - } - break; + //std::cout << "header contains Q_OBJECT macro"; + notIncludedMocs[privateHeaderName] = currentMoc; } + break; } } - else + } + else + { + // for every moc include in the file + do { - // for every moc include in the file - do + const std::string currentMoc = mocIncludeRegExp.match(1); + //std::cout << "found moc include: " << currentMoc << std::endl; + + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(currentMoc); + const bool moc_style = this->StartsWith(basename, "moc_"); + + // If the moc include is of the moc_foo.cpp style we expect the Q_OBJECT class + // declaration in a header file. + // If the moc include is of the foo.moc style we need to look for a Q_OBJECT + // macro in the current source file, if it contains the macro we generate the + // moc file from the source file, else from the header. + // + // TODO: currently any .moc file name will be used if the source contains + // Q_OBJECT + if (moc_style || !qObjectRegExp.find(contentsString)) { - const std::string currentMoc = mocIncludeRegExp.match(1); - //std::cout << "found moc include: " << currentMoc << std::endl; - - std::string basename = cmsys::SystemTools:: - GetFilenameWithoutLastExtension(currentMoc); - const bool moc_style = this->StartsWith(basename, "moc_"); - - // If the moc include is of the moc_foo.cpp style we expect the Q_OBJECT class - // declaration in a header file. - // If the moc include is of the foo.moc style we need to look for a Q_OBJECT - // macro in the current source file, if it contains the macro we generate the - // moc file from the source file, else from the header. - // - // TODO: currently any .moc file name will be used if the source contains - // Q_OBJECT - if (moc_style || !qObjectRegExp.find(contentsString)) + if (moc_style) { - if (moc_style) - { - // basename should be the part of the moc filename used for finding the - // correct header, so we need to remove the moc_ part - basename = basename.substr(4); - } + // basename should be the part of the moc filename used for finding the + // correct header, so we need to remove the moc_ part + basename = basename.substr(4); + } - bool headerFound = false; - for(std::list::const_iterator ext = - headerExtensions.begin(); - ext != headerExtensions.end(); - ++ext) + bool headerFound = false; + for(std::list::const_iterator ext = + headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string &sourceFilePath = absPath + basename + (*ext); + if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) { - const std::string &sourceFilePath = absPath + basename + (*ext); - if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) - { - headerFound = true; - includedMocs[sourceFilePath] = currentMoc; - notIncludedMocs.erase(sourceFilePath); - break; - } + headerFound = true; + includedMocs[sourceFilePath] = currentMoc; + notIncludedMocs.erase(sourceFilePath); + break; } - if (!headerFound) + } + if (!headerFound) + { + // the moc file is in a subdir => look for the header in the same subdir + if (currentMoc.find_first_of('/') != std::string::npos) { - // the moc file is in a subdir => look for the header in the same subdir - if (currentMoc.find_first_of('/') != std::string::npos) + const std::string &filepath = absPath + + cmsys::SystemTools::GetFilenamePath(currentMoc) + + '/' + basename; + + for(std::list::const_iterator ext = + headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) { - const std::string &filepath = absPath - + cmsys::SystemTools::GetFilenamePath(currentMoc) - + '/' + basename; - - for(std::list::const_iterator ext = - headerExtensions.begin(); - ext != headerExtensions.end(); - ++ext) - { - const std::string &sourceFilePath = filepath + (*ext); - if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) - { - headerFound = true; - includedMocs[sourceFilePath] = currentMoc; - notIncludedMocs.erase(sourceFilePath); - break; - } - } - if (!headerFound) + const std::string &sourceFilePath = filepath + (*ext); + if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) { - std::cerr << "automoc4: The file \"" << absFilename << - "\" includes the moc file \"" << currentMoc << "\", but neither \"" << - absPath + basename + '{' + this->Join(headerExtensions, ',') + "}\" nor \"" << - filepath + '{' + this->Join(headerExtensions, ',') + '}' << - "\" exist." << std::endl; - ::exit(EXIT_FAILURE); + headerFound = true; + includedMocs[sourceFilePath] = currentMoc; + notIncludedMocs.erase(sourceFilePath); + break; } } - else + if (!headerFound) { std::cerr << "automoc4: The file \"" << absFilename << - "\" includes the moc file \"" << currentMoc << "\", but \"" << - absPath + basename + '{' + this->Join(headerExtensions, ',') + '}' << - "\" does not exist." << std::endl; + "\" includes the moc file \"" << currentMoc << "\", but neither \"" << + absPath + basename + '{' + this->Join(headerExtensions, ',') + "}\" nor \"" << + filepath + '{' + this->Join(headerExtensions, ',') + '}' << + "\" exist." << std::endl; ::exit(EXIT_FAILURE); } } + else + { + std::cerr << "automoc4: The file \"" << absFilename << + "\" includes the moc file \"" << currentMoc << "\", but \"" << + absPath + basename + '{' + this->Join(headerExtensions, ',') + '}' << + "\" does not exist." << std::endl; + ::exit(EXIT_FAILURE); + } } - else - { - includedMocs[absFilename] = currentMoc; - notIncludedMocs.erase(absFilename); - } - matchOffset += mocIncludeRegExp.end(); - } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); - } + } + else + { + includedMocs[absFilename] = currentMoc; + notIncludedMocs.erase(absFilename); + } + matchOffset += mocIncludeRegExp.end(); + } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); } - else if (extension == ".h" || extension == ".hpp" - || extension == ".hxx" || extension == ".H") + } + + std::vector headerFiles; + cmSystemTools::ExpandListArgument(this->Headers, headerFiles); + for (std::vector::const_iterator it = headerFiles.begin(); + it != headerFiles.end(); + ++it) + { + const std::string &absFilename = *it; + if (this->Verbose) { - if (includedMocs.find(absFilename) == includedMocs.end() - && notIncludedMocs.find(absFilename) == notIncludedMocs.end()) - { - // if this header is not getting processed yet and is explicitly mentioned for the - // automoc the moc is run unconditionally on the header and the resulting file is - // included in the _automoc.cpp file (unless there's a .cpp file later on that - // includes the moc from this header) - const std::string currentMoc = "moc_" + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename) + ".cpp"; - notIncludedMocs[absFilename] = currentMoc; - } + printf("Checking -%s-\n", absFilename.c_str()); } - else + if (includedMocs.find(absFilename) == includedMocs.end() + && notIncludedMocs.find(absFilename) == notIncludedMocs.end()) { - if (this->Verbose) - { - std::cout << "automoc4: ignoring file '" << absFilename << "' with unknown suffix" << std::endl; - } + // if this header is not getting processed yet and is explicitly mentioned for the + // automoc the moc is run unconditionally on the header and the resulting file is + // included in the _automoc.cpp file (unless there's a .cpp file later on that + // includes the moc from this header) + const std::string currentMoc = "moc_" + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename) + ".cpp"; + notIncludedMocs[absFilename] = currentMoc; } } diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index 0dafd4aec56..891b47a5534 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -32,6 +32,7 @@ class cmQtAutomoc std::string QtMajorVersion; std::string Sources; + std::string Headers; bool IncludeProjectDirsBefore; std::string Srcdir; std::string Builddir; From 126c6ead7707ac29f3b2fa779752025c7cc0da32 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 9 Aug 2011 09:18:37 +0200 Subject: [PATCH 090/539] Add the cmake module required currently for automoc Alex --- Modules/Automoc.cmake | 158 ++++++++++++++++++++++++++++++ Modules/AutomocInfo.cmake.in | 13 +++ Source/cmAddExecutableCommand.cxx | 30 +++++- Source/cmQtAutomoc.cxx | 126 ++++++++++++++++++++++++ Source/cmQtAutomoc.h | 6 ++ Source/cmake.cxx | 7 ++ Source/cmake.h | 1 + 7 files changed, 340 insertions(+), 1 deletion(-) create mode 100644 Modules/Automoc.cmake create mode 100644 Modules/AutomocInfo.cmake.in diff --git a/Modules/Automoc.cmake b/Modules/Automoc.cmake new file mode 100644 index 00000000000..1e77c96b5c4 --- /dev/null +++ b/Modules/Automoc.cmake @@ -0,0 +1,158 @@ + +# AUTOMOC4_MOC_HEADERS( header1.h header2.h ...) +# Use this to add more header files to be processed with automoc4. +# +# AUTOMOC4_ADD_EXECUTABLE( src1 src2 ...) +# This macro does the same as ADD_EXECUTABLE, but additionally +# adds automoc4 handling for all source files. +# +# AUTOMOC4_ADD_LIBRARY( src1 src2 ...) +# This macro does the same as ADD_LIBRARY, but additionally +# adds automoc4 handling for all source files. + +# Internal helper macro, may change or be removed anytime: +# _ADD_AUTOMOC4_TARGET( ) +# +# Since version 0.9.88: +# The following two macros are only to be used for KDE4 projects +# and do something which makes sure automoc4 works for KDE. Don't +# use them anywhere else. See kdelibs/cmake/modules/KDE4Macros.cmake. +# _AUTOMOC4_KDE4_PRE_TARGET_HANDLING( ) +# _AUTOMOC4_KDE4_POST_TARGET_HANDLING() + +# Copyright (C) 2007 Matthias Kretz +# Copyright (C) 2008-2009 Alexander Neundorf +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +macro (AUTOMOC4_MOC_HEADERS _target_NAME) + set (_headers_to_moc) + foreach (_current_FILE ${ARGN}) + get_filename_component(_suffix "${_current_FILE}" EXT) + if (".h" STREQUAL "${_suffix}" OR ".hpp" STREQUAL "${_suffix}" OR ".hxx" STREQUAL "${_suffix}" OR ".H" STREQUAL "${_suffix}") + list(APPEND _headers_to_moc ${_current_FILE}) + else (".h" STREQUAL "${_suffix}" OR ".hpp" STREQUAL "${_suffix}" OR ".hxx" STREQUAL "${_suffix}" OR ".H" STREQUAL "${_suffix}") + message(STATUS "AUTOMOC4_MOC_HEADERS: ignoring non-header file ${_current_FILE}") + endif (".h" STREQUAL "${_suffix}" OR ".hpp" STREQUAL "${_suffix}" OR ".hxx" STREQUAL "${_suffix}" OR ".H" STREQUAL "${_suffix}") + endforeach (_current_FILE) + # need to create moc_.cpp file using automoc4 + # and add it to the target + if(_headers_to_moc) + set(_automoc4_headers_${_target_NAME} "${_headers_to_moc}") + endif(_headers_to_moc) +endmacro (AUTOMOC4_MOC_HEADERS) + + +macro(_ADD_AUTOMOC4_TARGET _target_NAME _SRCS) + set(_moc_files) + set(_moc_headers) + + # first list all explicitly set headers + foreach(_header_to_moc ${_automoc4_headers_${_target_NAME}} ) + get_filename_component(_abs_header ${_header_to_moc} ABSOLUTE) + list(APPEND _moc_headers ${_abs_header}) + endforeach(_header_to_moc) + + # now add all the sources for the automoc + foreach (_current_FILE ${${_SRCS}}) + get_filename_component(_abs_current_FILE "${_current_FILE}" ABSOLUTE) + get_source_file_property(_skip "${_abs_current_FILE}" SKIP_AUTOMOC) + get_source_file_property(_generated "${_abs_current_FILE}" GENERATED) + + if(NOT _generated AND NOT _skip) + get_filename_component(_suffix "${_current_FILE}" EXT) + # skip every source file that's not C++ + if(_suffix STREQUAL ".cpp" OR _suffix STREQUAL ".cc" OR _suffix STREQUAL ".cxx" OR _suffix STREQUAL ".C" OR _suffix STREQUAL ".mm") + list(APPEND _moc_files ${_abs_current_FILE}) + endif(_suffix STREQUAL ".cpp" OR _suffix STREQUAL ".cc" OR _suffix STREQUAL ".cxx" OR _suffix STREQUAL ".C" OR _suffix STREQUAL ".mm") + endif(NOT _generated AND NOT _skip) + endforeach (_current_FILE) + + if(_moc_files OR _moc_headers) + set(_automoc_source "${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}.cpp") + get_directory_property(_moc_incs INCLUDE_DIRECTORIES) + get_directory_property(_moc_defs DEFINITIONS) + get_directory_property(_moc_cdefs COMPILE_DEFINITIONS) + + # configure_file replaces _moc_files, _moc_incs, _moc_cdefs and _moc_defs + set(_automocTargetDir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target_NAME}.dir/" ) + set(AM_TARGET_NAME ${_target_NAME}) + configure_file(${CMAKE_ROOT}/Modules/AutomocInfo.cmake.in ${_automocTargetDir}/AutomocInfo.cmake @ONLY) + + add_custom_target(${_target_NAME} + COMMAND ${CMAKE_COMMAND} -E cmake_automoc "${_automocTargetDir}" ) + + set_source_files_properties(${_automoc_source} PROPERTIES GENERATED TRUE) + get_directory_property(_extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES) + list(APPEND _extra_clean_files "${_automoc_source}") + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${_extra_clean_files}") + set(${_SRCS} ${_automoc_source} ${${_SRCS}}) + endif(_moc_files OR _moc_headers) +endmacro(_ADD_AUTOMOC4_TARGET) + + +macro(AUTOMOC4_ADD_EXECUTABLE _target_NAME) + set(_SRCS ${ARGN}) + + set(_add_executable_param) + foreach(_argName "WIN32" "MACOSX_BUNDLE" "EXCLUDE_FROM_ALL") + list(FIND _SRCS ${_argName} _index) + if(_index GREATER -1) + list(APPEND _add_executable_param ${_argName}) + list(REMOVE_AT _SRCS ${_index}) + endif(_index GREATER -1) + endforeach(_argName) + + _add_automoc4_target("${_target_NAME}_automoc" _SRCS) + add_executable(${_target_NAME} ${_add_executable_param} ${_SRCS}) + add_dependencies(${_target_NAME} "${_target_NAME}_automoc") + +endmacro(AUTOMOC4_ADD_EXECUTABLE) + + +macro(AUTOMOC4_ADD_LIBRARY _target_NAME) + set(_SRCS ${ARGN}) + + set(_add_executable_param) + foreach(_argName "STATIC" "SHARED" "MODULE" "EXCLUDE_FROM_ALL") + list(FIND _SRCS ${_argName} _index) + if(_index GREATER -1) + list(APPEND _add_executable_param ${_argName}) + list(REMOVE_AT _SRCS ${_index}) + endif(_index GREATER -1) + endforeach(_argName) + + _add_automoc4_target("${_target_NAME}_automoc" _SRCS) + add_library(${_target_NAME} ${_add_executable_param} ${_SRCS}) + add_dependencies(${_target_NAME} "${_target_NAME}_automoc") +endmacro(AUTOMOC4_ADD_LIBRARY) + + +macro(_AUTOMOC4_KDE4_PRE_TARGET_HANDLING _target _srcs) + _add_automoc4_target("${_target}_automoc" ${_srcs}) +endmacro(_AUTOMOC4_KDE4_PRE_TARGET_HANDLING) + + +macro(_AUTOMOC4_KDE4_POST_TARGET_HANDLING _target) + add_dependencies(${_target} "${_target}_automoc") +endmacro(_AUTOMOC4_KDE4_POST_TARGET_HANDLING) diff --git a/Modules/AutomocInfo.cmake.in b/Modules/AutomocInfo.cmake.in new file mode 100644 index 00000000000..2dc3aa2b3de --- /dev/null +++ b/Modules/AutomocInfo.cmake.in @@ -0,0 +1,13 @@ +set(AM_SOURCES "@_moc_files@" ) +set(AM_HEADERS "@_moc_headers@" ) +set(AM_MOC_COMPILE_DEFINITIONS "@_moc_compile_defs@") +set(AM_MOC_DEFINITIONS "@_moc_defs@") +set(AM_MOC_INCLUDES "@_moc_incs@") +set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@") +set(AM_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@/") +set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/") +set(AM_QT_MOC_EXECUTABLE "@QT_MOC_EXECUTABLE@") +set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/") +set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/") +set(AM_QT_VERSION_MAJOR "@QT_VERSION_MAJOR@" ) +set(AM_TARGET_NAME "@_moc_target_name@") diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index a625c47e8c1..9710d205277 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -10,6 +10,7 @@ See the License for more information. ============================================================================*/ #include "cmAddExecutableCommand.h" +#include "cmQtAutomoc.h" // cmExecutableCommand bool cmAddExecutableCommand @@ -29,6 +30,7 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) bool use_macbundle = false; bool excludeFromAll = false; bool importTarget = false; + bool doAutomoc = false; while ( s != args.end() ) { if (*s == "WIN32") @@ -41,6 +43,11 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) ++s; use_macbundle = true; } + else if ( *s == "AUTOMOC" ) + { + ++s; + doAutomoc = true; + } else if(*s == "EXCLUDE_FROM_ALL") { ++s; @@ -58,12 +65,18 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) } // Special modifiers are not allowed with IMPORTED signature. - if(importTarget && (use_win32 || use_macbundle || excludeFromAll)) + if(importTarget + && (use_win32 || use_macbundle || excludeFromAll || doAutomoc)) { if(use_win32) { this->SetError("may not be given WIN32 for an IMPORTED target."); } + else if(doAutomoc) + { + this->SetError( + "may not be given AUTOMOC for an IMPORTED target."); + } else if(use_macbundle) { this->SetError( @@ -113,6 +126,14 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) } std::vector srclists(s, args.end()); + cmQtAutomoc* automoc = 0; + if ( doAutomoc ) + { + automoc = new cmQtAutomoc; + automoc->SetupAutomocTarget(this->Makefile, exename.c_str(), srclists); + } + + cmTarget* tgt = this->Makefile->AddExecutable(exename.c_str(), srclists, excludeFromAll); if ( use_win32 ) @@ -124,5 +145,12 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) tgt->SetProperty("MACOSX_BUNDLE", "ON"); } + if ( automoc ) + { + automoc->AddTargetDependency(this->Makefile, tgt); + delete automoc; + automoc = 0; + } + return true; } diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 5494b2aa590..1431551d461 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -1,6 +1,7 @@ #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmSourceFile.h" #include "cmSystemTools.h" #include "cmQtAutomoc.h" @@ -16,6 +17,131 @@ cmQtAutomoc::cmQtAutomoc() } +void cmQtAutomoc::SetupAutomocTarget(cmMakefile* makefile, + const char* targetName, + std::vector& srcs) +{ + // don't do anything if there is no Qt4: + std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); + if (qtMajorVersion != "4") + { + return; + } + + std::string automocTargetName = targetName; + automocTargetName += "_automoc"; + + std::string targetDir = makefile->GetCurrentOutputDirectory(); + targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory(); + targetDir += "/"; + targetDir += automocTargetName; + targetDir += ".dir/"; + + cmCustomCommandLine currentLine; + currentLine.push_back(makefile->GetCMakeInstance()->GetCMakeCommand()); + currentLine.push_back("-E"); + currentLine.push_back("cmake_automoc"); + currentLine.push_back(targetDir); + + cmCustomCommandLines commandLines; + commandLines.push_back(currentLine); + + std::string workingDirectory = cmSystemTools::CollapseFullPath( + "", makefile->GetCurrentOutputDirectory()); + + std::vector depends; + + cmTarget* target = makefile->AddUtilityCommand(automocTargetName.c_str(), + true, + workingDirectory.c_str(), depends, + commandLines, false, "Automoc target"); + + std::string _moc_files; + std::string _moc_headers; + const char* sepFiles = ""; + const char* sepHeaders = ""; + for(std::vector::const_iterator fileIt = srcs.begin(); + fileIt != srcs.end(); + ++fileIt) + { + std::string absFile = cmSystemTools::CollapseFullPath( + fileIt->c_str(), makefile->GetCurrentDirectory()); + + bool skip = false; + bool generated = false; + cmSourceFile* sf = makefile->GetSource(absFile.c_str()); + if (sf) + { + skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); + generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); + } + + if ((skip==false) && (generated == false)) + { + std::string ext = cmSystemTools::GetFilenameExtension(fileIt->c_str()); + cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat(ext.c_str()); + if (fileType == cmSystemTools::CXX_FILE_FORMAT) + { + _moc_files += sepFiles; + _moc_files += absFile; + sepFiles = ";"; + } + else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) + { + _moc_headers += sepHeaders; + _moc_headers += absFile; + sepHeaders = ";"; + } + } + } + + std::string _moc_incs = makefile->GetProperty("INCLUDE_DIRECTORIES"); + std::string _moc_defs = makefile->GetProperty("DEFINITIONS"); + std::string _moc_compile_defs = makefile->GetProperty("COMPILE_DEFINITIONS"); + // forget the variables added here afterwards again: + cmMakefile::ScopePushPop varScope(makefile); + static_cast(varScope); + + makefile->AddDefinition("_moc_target_name", automocTargetName.c_str()); + makefile->AddDefinition("_moc_incs", _moc_incs.c_str()); + makefile->AddDefinition("_moc_defs", _moc_defs.c_str()); + makefile->AddDefinition("_moc_compile_defs", _moc_compile_defs.c_str()); + makefile->AddDefinition("_moc_files", _moc_files.c_str()); + makefile->AddDefinition("_moc_headers", _moc_headers.c_str()); + + const char* cmakeRoot = makefile->GetDefinition("CMAKE_ROOT"); + std::string inputFile = cmakeRoot; + inputFile += "/Modules/AutomocInfo.cmake.in"; + std::string outputFile = targetDir; + outputFile += "/AutomocInfo.cmake"; + makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), + false, true, false); + + std::string mocCppFile = makefile->GetCurrentOutputDirectory(); + mocCppFile += "/"; + mocCppFile += automocTargetName; + mocCppFile += ".cpp"; + makefile->GetOrCreateSource(mocCppFile.c_str(), true); + srcs.push_back(mocCppFile); + +} + + +void cmQtAutomoc::AddTargetDependency(cmMakefile* makefile, cmTarget* target) +{ + // don't do anything if there is no Qt4: + std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); + if (qtMajorVersion != "4") + { + return; + } + + std::string automocTargetName = target->GetName(); + automocTargetName += "_automoc"; + target->AddUtility(automocTargetName.c_str()); +} + + bool cmQtAutomoc::Run(const char* targetDirectory) { cmake cm; diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index 891b47a5534..e5736107948 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -10,6 +10,12 @@ class cmQtAutomoc cmQtAutomoc(); bool Run(const char* targetDirectory); + void SetupAutomocTarget(cmMakefile* makefile, + const char* targetName, + std::vector& srcs); + + void AddTargetDependency(cmMakefile* makefile, cmTarget* target); + private: cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, const char* targetDirectory); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 06229e0c758..c5eff1c7ee9 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2927,6 +2927,13 @@ const char* cmake::GetCPackCommand() return this->CPackCommand.c_str(); } + +const char* cmake::GetCMakeCommand() +{ + return this->CMakeCommand.c_str(); +} + + void cmake::MarkCliAsUsed(const std::string& variable) { this->UsedCliVariables[variable] = true; diff --git a/Source/cmake.h b/Source/cmake.h index f2a2ae32195..09f6c376ed0 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -301,6 +301,7 @@ class cmake */ const char* GetCTestCommand(); const char* GetCPackCommand(); + const char* GetCMakeCommand(); // Do we want debug output during the cmake run. bool GetDebugOutput() { return this->DebugOutput; } From 83b730cd1aeeafc05473d163e13fb5489817c149 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 10 Aug 2011 19:51:07 +0200 Subject: [PATCH 091/539] Add AUTOMOC to the add_library() command Alex --- Source/cmAddLibraryCommand.cxx | 50 ++++++++++++++++++++++++++-------- Source/cmMakefile.cxx | 3 +- Source/cmMakefile.h | 2 +- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index f522cee9ec2..2e0604eb6ab 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -12,6 +12,7 @@ #include "cmAddLibraryCommand.h" #include "cmake.h" +#include "cmQtAutomoc.h" // cmLibraryCommand bool cmAddLibraryCommand @@ -31,13 +32,14 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) } bool excludeFromAll = false; bool importTarget = false; - + bool doAutomoc = false; + std::vector::const_iterator s = args.begin(); std::string libName = *s; ++s; - + // If the second argument is "SHARED" or "STATIC", then it controls // the type of library. Otherwise, it is treated as a source or // source list name. There may be two keyword arguments, check for them @@ -79,6 +81,11 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) ++s; importTarget = true; } + else if (*s == "AUTOMOC") + { + ++s; + doAutomoc = true; + } else { break; @@ -103,16 +110,23 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) type = cmTarget::STATIC_LIBRARY; } - // The IMPORTED signature requires a type to be specified explicitly. - if(importTarget && !haveSpecifiedType) - { - this->SetError("called with IMPORTED argument but no library type."); - return false; - } - // Handle imported target creation. if(importTarget) { + // The IMPORTED signature requires a type to be specified explicitly. + if (!haveSpecifiedType) + { + this->SetError("called with IMPORTED argument but no library type."); + return false; + } + + // Don't run automoc on an imported library + if (doAutomoc) + { + this->SetError("cannot be called with AUTOMOC for an IMPORTED library."); + return false; + } + // Make sure the target does not already exist. if(this->Makefile->FindTargetToUse(libName.c_str())) { @@ -164,8 +178,22 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) ++s; } - this->Makefile->AddLibrary(libName.c_str(), type, srclists, - excludeFromAll); + cmQtAutomoc* automoc = 0; + if ( doAutomoc ) + { + automoc = new cmQtAutomoc; + automoc->SetupAutomocTarget(this->Makefile, libName.c_str(), srclists); + } + + cmTarget* tgt =this->Makefile->AddLibrary(libName.c_str(), type, srclists, + excludeFromAll); + + if ( automoc ) + { + automoc->AddTargetDependency(this->Makefile, tgt); + delete automoc; + automoc = 0; + } return true; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a5cdee4cc16..45165e57138 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1886,7 +1886,7 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target) } -void cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, +cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, const std::vector &srcs, bool excludeFromAll) { @@ -1909,6 +1909,7 @@ void cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, } target->AddSources(srcs); this->AddGlobalLinkInformation(lname, *target); + return target; } cmTarget* cmMakefile::AddExecutable(const char *exeName, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index c01bb5d8a36..618f4f39122 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -325,7 +325,7 @@ class cmMakefile /** * Set the name of the library. */ - void AddLibrary(const char *libname, cmTarget::TargetType type, + cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type, const std::vector &srcs, bool excludeFromAll = false); From 735a5bb321ff7b92bebe2769e98a1d6317e88d27 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 10 Aug 2011 20:45:22 +0200 Subject: [PATCH 092/539] Fix line lengths Alex --- Source/cmQtAutomoc.cxx | 109 +++++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 49 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 1431551d461..64f6e5fcb1f 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -7,8 +7,6 @@ #include "cmQtAutomoc.h" -#define TRACE_LINE() printf(" %s %d\n", __PRETTY_FUNCTION__, __LINE__) - cmQtAutomoc::cmQtAutomoc() :Verbose(true) ,RunMocFailed(false) @@ -79,7 +77,8 @@ void cmQtAutomoc::SetupAutomocTarget(cmMakefile* makefile, if ((skip==false) && (generated == false)) { std::string ext = cmSystemTools::GetFilenameExtension(fileIt->c_str()); - cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat(ext.c_str()); + cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat( + ext.c_str()); if (fileType == cmSystemTools::CXX_FILE_FORMAT) { _moc_files += sepFiles; @@ -200,11 +199,13 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR"); this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); - this->IncludeProjectDirsBefore = makefile->IsOn("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"); + this->IncludeProjectDirsBefore = makefile->IsOn( + "AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"); this->Srcdir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR"); this->Builddir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE"); - this->MocCompileDefinitionsStr = makefile->GetSafeDefinition("AM_MOC_COMPILE_DEFINITIONS"); + this->MocCompileDefinitionsStr = makefile->GetSafeDefinition( + "AM_MOC_COMPILE_DEFINITIONS"); this->MocDefinitionsStr = makefile->GetSafeDefinition("AM_MOC_DEFINITIONS"); this->MocIncludesStr = makefile->GetSafeDefinition("AM_MOC_INCLUDES"); this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); @@ -361,13 +362,18 @@ bool cmQtAutomoc::RunAutomocQt4() this->GenerateAll = true; } - // the program goes through all .cpp files to see which moc files are included. It is not really - // interesting how the moc file is named, but what file the moc is created from. Once a moc is - // included the same moc may not be included in the _automoc.cpp file anymore. OTOH if there's a - // header containing Q_OBJECT where no corresponding moc file is included anywhere a - // moc_.cpp file is created and included in the _automoc.cpp file. - std::map includedMocs; // key = moc source filepath, value = moc output filepath - std::map notIncludedMocs; // key = moc source filepath, value = moc output filename + // the program goes through all .cpp files to see which moc files are + // included. It is not really interesting how the moc file is named, but + // what file the moc is created from. Once a moc is included the same moc + // may not be included in the _automoc.cpp file anymore. OTOH if there's a + // header containing Q_OBJECT where no corresponding moc file is included + // anywhere a moc_.cpp file is created and included in + // the _automoc.cpp file. + + // key = moc source filepath, value = moc output filepath + std::map includedMocs; + // key = moc source filepath, value = moc output filename + std::map notIncludedMocs; cmsys::RegularExpression mocIncludeRegExp( "[\n][ \t]*#[ \t]*include[ \t]+" @@ -422,8 +428,8 @@ bool cmQtAutomoc::RunAutomocQt4() int matchOffset = 0; if (!mocIncludeRegExp.find(contentsString.c_str())) { - // no moc #include, look whether we need to create a moc from the .h nevertheless - //std::cout << "no moc #include in the .cpp file"; + // no moc #include, look whether we need to create a moc from + // the .h nevertheless const std::string basename = cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); for(std::list::const_iterator ext = @@ -453,8 +459,8 @@ bool cmQtAutomoc::RunAutomocQt4() { const std::string privateHeaderName = absPath+basename+"_p"+(*ext); if (cmsys::SystemTools::FileExists(privateHeaderName.c_str()) - && includedMocs.find(privateHeaderName) == includedMocs.end() - && notIncludedMocs.find(privateHeaderName) == notIncludedMocs.end()) + && includedMocs.find(privateHeaderName) == includedMocs.end() + && notIncludedMocs.find(privateHeaderName) == notIncludedMocs.end()) { const std::string currentMoc = "moc_" + basename + "_p.cpp"; const std::string contents = this->ReadAll(privateHeaderName); @@ -479,20 +485,19 @@ bool cmQtAutomoc::RunAutomocQt4() GetFilenameWithoutLastExtension(currentMoc); const bool moc_style = this->StartsWith(basename, "moc_"); - // If the moc include is of the moc_foo.cpp style we expect the Q_OBJECT class - // declaration in a header file. - // If the moc include is of the foo.moc style we need to look for a Q_OBJECT - // macro in the current source file, if it contains the macro we generate the - // moc file from the source file, else from the header. - // - // TODO: currently any .moc file name will be used if the source contains + // If the moc include is of the moc_foo.cpp style we expect + // the Q_OBJECT class declaration in a header file. + // If the moc include is of the foo.moc style we need to look for + // a Q_OBJECT macro in the current source file, if it contains the + // macro we generate the moc file from the source file, else from the + // header. // Q_OBJECT if (moc_style || !qObjectRegExp.find(contentsString)) { if (moc_style) { - // basename should be the part of the moc filename used for finding the - // correct header, so we need to remove the moc_ part + // basename should be the part of the moc filename used for + // finding the correct header, so we need to remove the moc_ part basename = basename.substr(4); } @@ -513,7 +518,8 @@ bool cmQtAutomoc::RunAutomocQt4() } if (!headerFound) { - // the moc file is in a subdir => look for the header in the same subdir + // the moc file is in a subdir => look for the header in the + // same subdir if (currentMoc.find_first_of('/') != std::string::npos) { const std::string &filepath = absPath @@ -536,20 +542,23 @@ bool cmQtAutomoc::RunAutomocQt4() } if (!headerFound) { - std::cerr << "automoc4: The file \"" << absFilename << - "\" includes the moc file \"" << currentMoc << "\", but neither \"" << - absPath + basename + '{' + this->Join(headerExtensions, ',') + "}\" nor \"" << - filepath + '{' + this->Join(headerExtensions, ',') + '}' << - "\" exist." << std::endl; + std::cerr << "automoc4: The file \"" << absFilename + << "\" includes the moc file \"" << currentMoc + << "\", but neither \"" << absPath << basename + << '{' << this->Join(headerExtensions, ',') + << "}\" nor \"" << filepath << '{' + << this->Join(headerExtensions, ',') << '}' + << "\" exist." << std::endl; ::exit(EXIT_FAILURE); } } else { - std::cerr << "automoc4: The file \"" << absFilename << - "\" includes the moc file \"" << currentMoc << "\", but \"" << - absPath + basename + '{' + this->Join(headerExtensions, ',') + '}' << - "\" does not exist." << std::endl; + std::cerr << "automoc4: The file \"" << absFilename + << "\" includes the moc file \"" << currentMoc + << "\", but \"" << absPath << basename << '{' + << this->Join(headerExtensions, ',') << '}' + << "\" does not exist." << std::endl; ::exit(EXIT_FAILURE); } } @@ -578,17 +587,20 @@ bool cmQtAutomoc::RunAutomocQt4() if (includedMocs.find(absFilename) == includedMocs.end() && notIncludedMocs.find(absFilename) == notIncludedMocs.end()) { - // if this header is not getting processed yet and is explicitly mentioned for the - // automoc the moc is run unconditionally on the header and the resulting file is - // included in the _automoc.cpp file (unless there's a .cpp file later on that - // includes the moc from this header) - const std::string currentMoc = "moc_" + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename) + ".cpp"; + // if this header is not getting processed yet and is explicitly + // mentioned for the automoc the moc is run unconditionally on the + // header and the resulting file is included in the _automoc.cpp file + // (unless there's a .cpp file later on that includes the moc from + // this header) + const std::string currentMoc = "moc_" + cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFilename) + ".cpp"; notIncludedMocs[absFilename] = currentMoc; } } // run moc on all the moc's that are #included in source files - for(std::map::const_iterator it = includedMocs.begin(); + for(std::map::const_iterator + it = includedMocs.begin(); it != includedMocs.end(); ++it) { @@ -605,8 +617,10 @@ bool cmQtAutomoc::RunAutomocQt4() } else { - // run moc on the remaining headers and include them in the _automoc.cpp file - for(std::map::const_iterator it = notIncludedMocs.begin(); + // run moc on the remaining headers and include them in + // the _automoc.cpp file + for(std::map::const_iterator + it = notIncludedMocs.begin(); it != notIncludedMocs.end(); ++it) { @@ -621,8 +635,6 @@ bool cmQtAutomoc::RunAutomocQt4() if (this->RunMocFailed) { - // if any moc process failed we don't want to touch the _automoc.cpp file so that - // automoc4 is rerun until the issue is fixed std::cerr << "returning failed.."<< std::endl; return false; } @@ -638,7 +650,6 @@ bool cmQtAutomoc::RunAutomocQt4() return true; } } - // either the contents of the _automoc.cpp file or one of the mocs included by it have changed // source file that includes all remaining moc files (_automoc.cpp file) std::fstream outfile; @@ -654,7 +665,6 @@ bool cmQtAutomoc::RunAutomocQt4() bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, const std::string& mocFileName) { - //std::cout << "AutoMoc::generateMoc" << sourceFile << mocFileName << std::endl; const std::string mocFilePath = this->Builddir + mocFileName; int sourceNewerThanMoc = 0; bool success = cmsys::SystemTools::FileTimeCompare(sourceFile.c_str(), @@ -710,10 +720,11 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, std::string output; int retVal = 0; - const bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); + bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); if (!result || retVal) { - std::cerr << "automoc4: process for " << mocFilePath << " failed:\n" << output << std::endl; + std::cerr << "automoc4: process for " << mocFilePath << " failed:\n" + << output << std::endl; this->RunMocFailed = true; cmSystemTools::RemoveFile(mocFilePath.c_str()); } From ace121534de464bc7da35694a93cfb8ccc3effb6 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 10 Aug 2011 21:00:53 +0200 Subject: [PATCH 093/539] Move code for parsing a cpp-file from the big loop to separate function Alex --- Source/cmQtAutomoc.cxx | 365 ++++++++++++++++++++--------------------- Source/cmQtAutomoc.h | 4 + 2 files changed, 186 insertions(+), 183 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 64f6e5fcb1f..5bfb928e32d 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -375,33 +375,6 @@ bool cmQtAutomoc::RunAutomocQt4() // key = moc source filepath, value = moc output filename std::map notIncludedMocs; - cmsys::RegularExpression mocIncludeRegExp( - "[\n][ \t]*#[ \t]*include[ \t]+" - "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); - cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); - std::list headerExtensions; -#if defined(_WIN32) - // not case sensitive - headerExtensions.push_back(".h"); - headerExtensions.push_back(".hpp"); - headerExtensions.push_back(".hxx"); -#elif defined(__APPLE__) - headerExtensions.push_back(".h"); - headerExtensions.push_back(".hpp"); - headerExtensions.push_back(".hxx"); - - // detect case-sensitive filesystem - long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE); - if (caseSensitive == 1) - { - headerExtensions.push_back(".H"); - } -#else - headerExtensions.push_back(".h"); - headerExtensions.push_back(".hpp"); - headerExtensions.push_back(".hxx"); - headerExtensions.push_back(".H"); -#endif std::vector sourceFiles; cmSystemTools::ExpandListArgument(this->Sources, sourceFiles); @@ -415,162 +388,7 @@ bool cmQtAutomoc::RunAutomocQt4() { printf("Checking -%s-\n", absFilename.c_str()); } - - const std::string contentsString = this->ReadAll(absFilename); - if (contentsString.empty()) - { - std::cerr << "automoc4: empty source file: " << absFilename << std::endl; - continue; - } - const std::string absPath = cmsys::SystemTools::GetFilenamePath( - cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; - - int matchOffset = 0; - if (!mocIncludeRegExp.find(contentsString.c_str())) - { - // no moc #include, look whether we need to create a moc from - // the .h nevertheless - const std::string basename = - cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); - for(std::list::const_iterator ext = - headerExtensions.begin(); - ext != headerExtensions.end(); - ++ext) - { - const std::string headername = absPath + basename + (*ext); - if (cmsys::SystemTools::FileExists(headername.c_str()) - && includedMocs.find(headername) == includedMocs.end() - && notIncludedMocs.find(headername) == notIncludedMocs.end()) - { - const std::string currentMoc = "moc_" + basename + ".cpp"; - const std::string contents = this->ReadAll(headername); - if (qObjectRegExp.find(contents)) - { - //std::cout << "header contains Q_OBJECT macro"; - notIncludedMocs[headername] = currentMoc; - } - break; - } - } - for(std::list::const_iterator ext = - headerExtensions.begin(); - ext != headerExtensions.end(); - ++ext) - { - const std::string privateHeaderName = absPath+basename+"_p"+(*ext); - if (cmsys::SystemTools::FileExists(privateHeaderName.c_str()) - && includedMocs.find(privateHeaderName) == includedMocs.end() - && notIncludedMocs.find(privateHeaderName) == notIncludedMocs.end()) - { - const std::string currentMoc = "moc_" + basename + "_p.cpp"; - const std::string contents = this->ReadAll(privateHeaderName); - if (qObjectRegExp.find(contents)) - { - //std::cout << "header contains Q_OBJECT macro"; - notIncludedMocs[privateHeaderName] = currentMoc; - } - break; - } - } - } - else - { - // for every moc include in the file - do - { - const std::string currentMoc = mocIncludeRegExp.match(1); - //std::cout << "found moc include: " << currentMoc << std::endl; - - std::string basename = cmsys::SystemTools:: - GetFilenameWithoutLastExtension(currentMoc); - const bool moc_style = this->StartsWith(basename, "moc_"); - - // If the moc include is of the moc_foo.cpp style we expect - // the Q_OBJECT class declaration in a header file. - // If the moc include is of the foo.moc style we need to look for - // a Q_OBJECT macro in the current source file, if it contains the - // macro we generate the moc file from the source file, else from the - // header. - // Q_OBJECT - if (moc_style || !qObjectRegExp.find(contentsString)) - { - if (moc_style) - { - // basename should be the part of the moc filename used for - // finding the correct header, so we need to remove the moc_ part - basename = basename.substr(4); - } - - bool headerFound = false; - for(std::list::const_iterator ext = - headerExtensions.begin(); - ext != headerExtensions.end(); - ++ext) - { - const std::string &sourceFilePath = absPath + basename + (*ext); - if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) - { - headerFound = true; - includedMocs[sourceFilePath] = currentMoc; - notIncludedMocs.erase(sourceFilePath); - break; - } - } - if (!headerFound) - { - // the moc file is in a subdir => look for the header in the - // same subdir - if (currentMoc.find_first_of('/') != std::string::npos) - { - const std::string &filepath = absPath - + cmsys::SystemTools::GetFilenamePath(currentMoc) - + '/' + basename; - - for(std::list::const_iterator ext = - headerExtensions.begin(); - ext != headerExtensions.end(); - ++ext) - { - const std::string &sourceFilePath = filepath + (*ext); - if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) - { - headerFound = true; - includedMocs[sourceFilePath] = currentMoc; - notIncludedMocs.erase(sourceFilePath); - break; - } - } - if (!headerFound) - { - std::cerr << "automoc4: The file \"" << absFilename - << "\" includes the moc file \"" << currentMoc - << "\", but neither \"" << absPath << basename - << '{' << this->Join(headerExtensions, ',') - << "}\" nor \"" << filepath << '{' - << this->Join(headerExtensions, ',') << '}' - << "\" exist." << std::endl; - ::exit(EXIT_FAILURE); - } - } - else - { - std::cerr << "automoc4: The file \"" << absFilename - << "\" includes the moc file \"" << currentMoc - << "\", but \"" << absPath << basename << '{' - << this->Join(headerExtensions, ',') << '}' - << "\" does not exist." << std::endl; - ::exit(EXIT_FAILURE); - } - } - } - else - { - includedMocs[absFilename] = currentMoc; - notIncludedMocs.erase(absFilename); - } - matchOffset += mocIncludeRegExp.end(); - } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); - } + this->ParseCppFile(absFilename, includedMocs, notIncludedMocs); } std::vector headerFiles; @@ -662,6 +480,187 @@ bool cmQtAutomoc::RunAutomocQt4() } +void cmQtAutomoc::ParseCppFile(const std::string& absFilename, + std::map& includedMocs, + std::map& notIncludedMocs) +{ + cmsys::RegularExpression mocIncludeRegExp( + "[\n][ \t]*#[ \t]*include[ \t]+" + "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); + cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); + std::list headerExtensions; + headerExtensions.push_back(".h"); + headerExtensions.push_back(".hpp"); + headerExtensions.push_back(".hxx"); +#if defined(_WIN32) + // not case sensitive, don't add ".H" +#elif defined(__APPLE__) + // detect case-sensitive filesystem + long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE); + if (caseSensitive == 1) + { + headerExtensions.push_back(".H"); + } +#else + headerExtensions.push_back(".H"); +#endif + + const std::string contentsString = this->ReadAll(absFilename); + if (contentsString.empty()) + { + std::cerr << "automoc4: empty source file: " << absFilename << std::endl; + return; + } + const std::string absPath = cmsys::SystemTools::GetFilenamePath( + cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; + + int matchOffset = 0; + if (!mocIncludeRegExp.find(contentsString.c_str())) + { + // no moc #include, look whether we need to create a moc from + // the .h nevertheless + const std::string basename = + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); + for(std::list::const_iterator ext = headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string headername = absPath + basename + (*ext); + if (cmsys::SystemTools::FileExists(headername.c_str()) + && includedMocs.find(headername) == includedMocs.end() + && notIncludedMocs.find(headername) == notIncludedMocs.end()) + { + const std::string currentMoc = "moc_" + basename + ".cpp"; + const std::string contents = this->ReadAll(headername); + if (qObjectRegExp.find(contents)) + { + //std::cout << "header contains Q_OBJECT macro"; + notIncludedMocs[headername] = currentMoc; + } + break; + } + } + for(std::list::const_iterator ext = headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string privateHeaderName = absPath+basename+"_p"+(*ext); + if (cmsys::SystemTools::FileExists(privateHeaderName.c_str()) + && includedMocs.find(privateHeaderName) == includedMocs.end() + && notIncludedMocs.find(privateHeaderName) == notIncludedMocs.end()) + { + const std::string currentMoc = "moc_" + basename + "_p.cpp"; + const std::string contents = this->ReadAll(privateHeaderName); + if (qObjectRegExp.find(contents)) + { + //std::cout << "header contains Q_OBJECT macro"; + notIncludedMocs[privateHeaderName] = currentMoc; + } + break; + } + } + } + else + { + // for every moc include in the file + do + { + const std::string currentMoc = mocIncludeRegExp.match(1); + //std::cout << "found moc include: " << currentMoc << std::endl; + + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(currentMoc); + const bool moc_style = this->StartsWith(basename, "moc_"); + + // If the moc include is of the moc_foo.cpp style we expect + // the Q_OBJECT class declaration in a header file. + // If the moc include is of the foo.moc style we need to look for + // a Q_OBJECT macro in the current source file, if it contains the + // macro we generate the moc file from the source file, else from the + // header. + // Q_OBJECT + if (moc_style || !qObjectRegExp.find(contentsString)) + { + if (moc_style) + { + // basename should be the part of the moc filename used for + // finding the correct header, so we need to remove the moc_ part + basename = basename.substr(4); + } + + bool headerFound = false; + for(std::list::const_iterator ext = + headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string &sourceFilePath = absPath + basename + (*ext); + if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) + { + headerFound = true; + includedMocs[sourceFilePath] = currentMoc; + notIncludedMocs.erase(sourceFilePath); + break; + } + } + if (!headerFound) + { + // the moc file is in a subdir => look for the header in the + // same subdir + if (currentMoc.find_first_of('/') != std::string::npos) + { + const std::string &filepath = absPath + + cmsys::SystemTools::GetFilenamePath(currentMoc) + + '/' + basename; + + for(std::list::const_iterator ext = + headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string &sourceFilePath = filepath + (*ext); + if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) + { + headerFound = true; + includedMocs[sourceFilePath] = currentMoc; + notIncludedMocs.erase(sourceFilePath); + break; + } + } + if (!headerFound) + { + std::cerr << "automoc4: The file \"" << absFilename + << "\" includes the moc file \"" << currentMoc + << "\", but neither \"" << absPath << basename + << '{' << this->Join(headerExtensions, ',') + << "}\" nor \"" << filepath << '{' + << this->Join(headerExtensions, ',') << '}' + << "\" exist." << std::endl; + ::exit(EXIT_FAILURE); + } + } + else + { + std::cerr << "automoc4: The file \"" << absFilename + << "\" includes the moc file \"" << currentMoc + << "\", but \"" << absPath << basename << '{' + << this->Join(headerExtensions, ',') << '}' + << "\" does not exist." << std::endl; + ::exit(EXIT_FAILURE); + } + } + } + else + { + includedMocs[absFilename] = currentMoc; + notIncludedMocs.erase(absFilename); + } + matchOffset += mocIncludeRegExp.end(); + } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); + } +} + + bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, const std::string& mocFileName) { diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index e5736107948..edb66f02510 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -29,6 +29,10 @@ class cmQtAutomoc bool RunAutomocQt4(); bool GenerateMoc(const std::string& sourceFile, const std::string& mocFileName); + void ParseCppFile(const std::string& absFilename, + std::map& includedMocs, + std::map& notIncludedMocs); + void Init(); std::string Join(const std::list& lst, char separator); From 93032953afb5bd939dceb3ce427f4b6fa50e2450 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 10 Aug 2011 23:49:30 +0200 Subject: [PATCH 094/539] Initialize verbose based onb the env.var. Alex --- Source/cmQtAutomoc.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 5bfb928e32d..2add7c0a14f 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -8,7 +8,7 @@ cmQtAutomoc::cmQtAutomoc() -:Verbose(true) +:Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0) ,RunMocFailed(false) ,GenerateAll(false) { From ddb517d014bf2245b38a0b56c9b7e98e6aaf7988 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 14 Aug 2011 16:43:04 +0200 Subject: [PATCH 095/539] Color output when running moc Alex --- Source/cmQtAutomoc.cxx | 30 ++++++++++++++++++++++-------- Source/cmQtAutomoc.h | 1 + 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 2add7c0a14f..6e8c77e7c25 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -4,14 +4,31 @@ #include "cmSourceFile.h" #include "cmSystemTools.h" +# include + #include "cmQtAutomoc.h" cmQtAutomoc::cmQtAutomoc() :Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0) +,ColorOutput(true) ,RunMocFailed(false) ,GenerateAll(false) { + + std::string colorEnv = ""; + cmsys::SystemTools::GetEnv("COLOR", colorEnv); + if(!colorEnv.empty()) + { + if(cmSystemTools::IsOn(colorEnv.c_str())) + { + this->ColorOutput = true; + } + else + { + this->ColorOutput = false; + } + } } @@ -678,14 +695,11 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, cmsys::SystemTools::MakeDirectory(mocDir.c_str()); } -/* if (this->Verbose) - { - echoColor("Generating " + mocFilePath + " from " + sourceFile); - } - else - { - echoColor("Generating " + mocFileName); - }*/ + std::string msg = "Generating "; + msg += mocFileName; + cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue + |cmsysTerminal_Color_ForegroundBold, + msg.c_str(), true, this->ColorOutput); std::vector command; command.push_back(this->MocExecutable); diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index edb66f02510..af773664c23 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -61,6 +61,7 @@ class cmQtAutomoc std::list MocDefinitions; bool Verbose; + bool ColorOutput; bool RunMocFailed; bool GenerateAll; From 72caf4d1787bc464f68954853a4edc3cf169a5f0 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 14 Aug 2011 17:06:34 +0200 Subject: [PATCH 096/539] Add the generated automoc.cpp file to the cleaned files Alex --- Source/cmQtAutomoc.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 6e8c77e7c25..316d82411de 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -140,6 +140,8 @@ void cmQtAutomoc::SetupAutomocTarget(cmMakefile* makefile, makefile->GetOrCreateSource(mocCppFile.c_str(), true); srcs.push_back(mocCppFile); + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + mocCppFile.c_str(), false); } From 58b7fe65453f1d4b25537950de2277af2951fd85 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 14 Aug 2011 17:17:01 +0200 Subject: [PATCH 097/539] Use cout instead of printf() Alex --- Source/cmQtAutomoc.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 316d82411de..b03e9cf4525 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -405,7 +405,7 @@ bool cmQtAutomoc::RunAutomocQt4() const std::string &absFilename = *it; if (this->Verbose) { - printf("Checking -%s-\n", absFilename.c_str()); + std::cout << "AUTOMOC: Checking " << absFilename << std::endl; } this->ParseCppFile(absFilename, includedMocs, notIncludedMocs); } @@ -419,7 +419,7 @@ bool cmQtAutomoc::RunAutomocQt4() const std::string &absFilename = *it; if (this->Verbose) { - printf("Checking -%s-\n", absFilename.c_str()); + std::cout << "AUTOMOC: Checking " << absFilename << std::endl; } if (includedMocs.find(absFilename) == includedMocs.end() && notIncludedMocs.find(absFilename) == notIncludedMocs.end()) @@ -527,7 +527,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, const std::string contentsString = this->ReadAll(absFilename); if (contentsString.empty()) { - std::cerr << "automoc4: empty source file: " << absFilename << std::endl; + std::cerr << "AUTOMOC: empty source file: " << absFilename << std::endl; return; } const std::string absPath = cmsys::SystemTools::GetFilenamePath( @@ -648,7 +648,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, } if (!headerFound) { - std::cerr << "automoc4: The file \"" << absFilename + std::cerr << "AUTOMOC: The file \"" << absFilename << "\" includes the moc file \"" << currentMoc << "\", but neither \"" << absPath << basename << '{' << this->Join(headerExtensions, ',') @@ -660,7 +660,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, } else { - std::cerr << "automoc4: The file \"" << absFilename + std::cerr << "AUTOMOC: The file \"" << absFilename << "\" includes the moc file \"" << currentMoc << "\", but \"" << absPath << basename << '{' << this->Join(headerExtensions, ',') << '}' @@ -728,9 +728,9 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, { for(int i=0; iRunMocFailed = true; cmSystemTools::RemoveFile(mocFilePath.c_str()); From cfad24a36beb5fbf6d0e5ae8c730b9da651a3488 Mon Sep 17 00:00:00 2001 From: Alexey Ozeritsky Date: Mon, 15 Aug 2011 17:52:40 +0400 Subject: [PATCH 098/539] fixed: search of ATLAS library for C/C++-only projects --- Modules/FindBLAS.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 7bad9596048..dc9ab374ca3 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -138,7 +138,7 @@ endif ($ENV{BLA_VENDOR} MATCHES ".+") if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) - # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) + # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) check_fortran_libraries( BLAS_LIBRARIES BLAS @@ -156,9 +156,9 @@ if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") check_fortran_libraries( BLAS_LIBRARIES BLAS - cblas_dgemm + dgemm "" - "cblas;f77blas;atlas" + "f77blas;atlas" "" ) endif(NOT BLAS_LIBRARIES) From aecfc1fd1045fef4af58a16782c2272dd5825aa5 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 00:08:43 +0200 Subject: [PATCH 099/539] Fix test on OpenBSD with BSD make BSD make doesn't seem to support -C, so do not use it, According to the documentation the working directory is set to CMAKE_CURRENT_BINARY_DIR anyway, so it should work just the same. Alex --- Tests/FindPackageModeMakefileTest/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index f0faab93dff..d2c6be9c971 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -15,7 +15,7 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) - add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile -C ${CMAKE_CURRENT_BINARY_DIR} ) + add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile ) endif() From e589589ab18daabc863061fac515adc2b1ae8d55 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 00:22:17 +0200 Subject: [PATCH 100/539] Rename helper macros print_compile_flags() to set_compile_flags_var() The same for print_link_flags(), it is now set_link_flags_var(). Both macros don't print anything anymore, this was only in the beginning. Alex --- Modules/CMakeFindPackageMode.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index 2ce4fe61ed8..e4d085dd50f 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -84,7 +84,7 @@ set(CMAKE_${LANGUAGE}_COMPILER_ID "${COMPILER_ID}") include(CMake${LANGUAGE}Information) -function(print_compile_flags _packageName) +function(set_compile_flags_var _packageName) string(TOUPPER "${_packageName}" PACKAGE_NAME) # Check the following variables: # FOO_INCLUDE_DIRS @@ -125,7 +125,7 @@ function(print_compile_flags _packageName) endfunction() -function(print_link_flags _packageName) +function(set_link_flags_var _packageName) string(TOUPPER "${_packageName}" PACKAGE_NAME) # Check the following variables: # FOO_LIBRARIES @@ -160,9 +160,9 @@ if(${NAME}_FOUND OR ${UPPERCASE_NAME}_FOUND) if("${MODE}" STREQUAL "EXIST") # do nothing elseif("${MODE}" STREQUAL "COMPILE") - print_compile_flags(${NAME}) + set_compile_flags_var(${NAME}) elseif("${MODE}" STREQUAL "LINK") - print_link_flags(${NAME}) + set_link_flags_var(${NAME}) else("${MODE}" STREQUAL "LINK") message(FATAL_ERROR "Invalid mode argument ${MODE} given.") endif() From e552ae7cfd8d6b3dce51f61258ce4854db7c7fbc Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 00:30:07 +0200 Subject: [PATCH 101/539] Dont check for -isysroot and -mmacosx-version on OSX in --find-package mode Alex --- Modules/CMakeFindPackageMode.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index e4d085dd50f..a8674aad378 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -40,6 +40,12 @@ endif() include(CMakeDetermineSystem) +# short-cut some tests on Darwin, see Darwin-GNU.cmake: +if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin AND "${COMPILER_ID}" MATCHES GNU) + set(${CMAKE_${LANGUAGE}_HAS_ISYSROOT} 0 ) + set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "") +endif() + # Also load the system specific file, which sets up e.g. the search paths. # This makes the FIND_XXX() calls work much better include(CMakeSystemSpecificInformation) From ec6982dc8cad04c72a6ab78b7f115ece65e812bd Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 00:40:59 +0200 Subject: [PATCH 102/539] Disable any STATUS output in --find-package mode Any STATUS output will be fed directly to the compiler, which will not understand any status messages. Error messages are fine, since they are errors and it is ok if the compiler fails in such cases. Alex --- Source/cmMakefile.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3329a2c4b4e..b94db48d696 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3022,8 +3022,15 @@ cmCacheManager *cmMakefile::GetCacheManager() const void cmMakefile::DisplayStatus(const char* message, float s) { - this->GetLocalGenerator()->GetGlobalGenerator() - ->GetCMakeInstance()->UpdateProgress(message, s); + cmake* cm = this->GetLocalGenerator()->GetGlobalGenerator() + ->GetCMakeInstance(); + if (cm->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) + { + // don't output any STATUS message in FIND_PACKAGE_MODE, since they will + // directly be fed to the compiler, which will be confused. + return; + } + cm->UpdateProgress(message, s); } std::string cmMakefile::GetModulesFile(const char* filename) From 9672b332b15a0ba66b929e28fdac2f5d854d9b99 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 16 Aug 2011 01:13:10 +0200 Subject: [PATCH 103/539] Don't enable deprecated on HP. --- Modules/GenerateExportHeader.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 758eb251477..c15a5bec910 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -158,7 +158,7 @@ macro(_test_compiler_hidden_visibility) endmacro() macro(_test_compiler_has_deprecated) - if("${CMAKE_CXX_COMPILER_ID}" MATCHES Borland) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES Borland OR "${CMAKE_CXX_COMPILER_ID}" MATCHES HP) set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL "Compiler support for a deprecated attribute") else() _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED_ATTR) From f84c7db5928dcb4a46c3f8d51d910e4ad4367113 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 16 Aug 2011 01:17:26 +0200 Subject: [PATCH 104/539] Don't enable deprecated on old GCC Hopefully a fix for http://www.cdash.org/CDash/testDetails.php?test=109688480&build=1432057 --- Modules/GenerateExportHeader.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index c15a5bec910..f3a18361935 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -158,7 +158,7 @@ macro(_test_compiler_hidden_visibility) endmacro() macro(_test_compiler_has_deprecated) - if("${CMAKE_CXX_COMPILER_ID}" MATCHES Borland OR "${CMAKE_CXX_COMPILER_ID}" MATCHES HP) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES Borland OR "${CMAKE_CXX_COMPILER_ID}" MATCHES HP OR GCC_TOO_OLD) set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL "Compiler support for a deprecated attribute") else() _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED_ATTR) From f4264960551d088d3a0f1eea3049d2d8ecfd285b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 16 Aug 2011 01:19:37 +0200 Subject: [PATCH 105/539] Exclude cygwin from the hidden visibility feature. --- Modules/GenerateExportHeader.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index f3a18361935..f73748c3836 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -149,7 +149,7 @@ macro(_test_compiler_hidden_visibility) # Exclude XL here because it misinterprets -fvisibility=hidden even though # the check_cxx_compiler_flag passes # http://www.cdash.org/CDash/testDetails.php?test=109109951&build=1419259 - if (NOT GCC_TOO_OLD AND NOT WIN32 AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES XL) + if (NOT GCC_TOO_OLD AND NOT WIN32 AND NOT CYGWIN AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES XL) check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) option(USE_COMPILER_HIDDEN_VISIBILITY "Use HIDDEN visibility support if available." ON) From 1ae3365e9f4126688d57137648e190ca5f4ef8dc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 16 Aug 2011 01:21:59 +0200 Subject: [PATCH 106/539] Exclude PGI from exports and deprecated. --- Modules/GenerateExportHeader.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index f73748c3836..7a4b6d3129b 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -149,7 +149,7 @@ macro(_test_compiler_hidden_visibility) # Exclude XL here because it misinterprets -fvisibility=hidden even though # the check_cxx_compiler_flag passes # http://www.cdash.org/CDash/testDetails.php?test=109109951&build=1419259 - if (NOT GCC_TOO_OLD AND NOT WIN32 AND NOT CYGWIN AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES XL) + if (NOT GCC_TOO_OLD AND NOT WIN32 AND NOT CYGWIN AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES XL AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI) check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) option(USE_COMPILER_HIDDEN_VISIBILITY "Use HIDDEN visibility support if available." ON) @@ -158,7 +158,7 @@ macro(_test_compiler_hidden_visibility) endmacro() macro(_test_compiler_has_deprecated) - if("${CMAKE_CXX_COMPILER_ID}" MATCHES Borland OR "${CMAKE_CXX_COMPILER_ID}" MATCHES HP OR GCC_TOO_OLD) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES Borland OR "${CMAKE_CXX_COMPILER_ID}" MATCHES HP OR GCC_TOO_OLD OR "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI) set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL "Compiler support for a deprecated attribute") else() _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED_ATTR) From 24d9b7d7452bfd9b3d7cea670a3a5a2e9f5b2f16 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 01:26:02 +0200 Subject: [PATCH 107/539] Remove trailing whitespace Alex --- Source/cmAddLibraryCommand.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 2e0604eb6ab..a581ea14a33 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -92,11 +92,11 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) } } - /* ideally we should check whether for the linker language of the target + /* ideally we should check whether for the linker language of the target CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to - STATIC. But at this point we know only the name of the target, but not + STATIC. But at this point we know only the name of the target, but not yet its linker language. */ - if ((type != cmTarget::STATIC_LIBRARY) && + if ((type != cmTarget::STATIC_LIBRARY) && (this->Makefile->GetCMakeInstance()->GetPropertyAsBool( "TARGET_SUPPORTS_SHARED_LIBS") == false)) { @@ -172,9 +172,9 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) } std::vector srclists; - while (s != args.end()) + while (s != args.end()) { - srclists.push_back(*s); + srclists.push_back(*s); ++s; } @@ -194,7 +194,7 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) delete automoc; automoc = 0; } - + return true; } From c27607baf860b6c57db84f21a298ad8257ff7153 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 01:27:30 +0200 Subject: [PATCH 108/539] Refactor SetupAutomocTarget() so it can be run after creating the target This makes it easier to move it from InitialPass() to some other location, e.g. FinalPass() or something else. Alex --- Source/cmAddExecutableCommand.cxx | 15 ++------ Source/cmAddLibraryCommand.cxx | 14 ++------ Source/cmQtAutomoc.cxx | 57 ++++++++++++------------------- Source/cmQtAutomoc.h | 6 +--- 4 files changed, 28 insertions(+), 64 deletions(-) diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 9710d205277..ef75b3b06f4 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -126,14 +126,6 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) } std::vector srclists(s, args.end()); - cmQtAutomoc* automoc = 0; - if ( doAutomoc ) - { - automoc = new cmQtAutomoc; - automoc->SetupAutomocTarget(this->Makefile, exename.c_str(), srclists); - } - - cmTarget* tgt = this->Makefile->AddExecutable(exename.c_str(), srclists, excludeFromAll); if ( use_win32 ) @@ -145,11 +137,10 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) tgt->SetProperty("MACOSX_BUNDLE", "ON"); } - if ( automoc ) + if ( doAutomoc ) { - automoc->AddTargetDependency(this->Makefile, tgt); - delete automoc; - automoc = 0; + cmQtAutomoc automoc; + automoc.SetupAutomocTarget(tgt); } return true; diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index a581ea14a33..f0b2e0d43a0 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -178,21 +178,13 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) ++s; } - cmQtAutomoc* automoc = 0; - if ( doAutomoc ) - { - automoc = new cmQtAutomoc; - automoc->SetupAutomocTarget(this->Makefile, libName.c_str(), srclists); - } - cmTarget* tgt =this->Makefile->AddLibrary(libName.c_str(), type, srclists, excludeFromAll); - if ( automoc ) + if ( doAutomoc ) { - automoc->AddTargetDependency(this->Makefile, tgt); - delete automoc; - automoc = 0; + cmQtAutomoc automoc; + automoc.SetupAutomocTarget(tgt); } return true; diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index b03e9cf4525..6dbc9e14742 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -32,10 +32,10 @@ cmQtAutomoc::cmQtAutomoc() } -void cmQtAutomoc::SetupAutomocTarget(cmMakefile* makefile, - const char* targetName, - std::vector& srcs) +void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) { + cmMakefile* makefile = target->GetMakefile(); + const char* targetName = target->GetName(); // don't do anything if there is no Qt4: std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); if (qtMajorVersion != "4") @@ -43,6 +43,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmMakefile* makefile, return; } + // create a custom target for running automoc at buildtime: std::string automocTargetName = targetName; automocTargetName += "_automoc"; @@ -66,34 +67,32 @@ void cmQtAutomoc::SetupAutomocTarget(cmMakefile* makefile, std::vector depends; - cmTarget* target = makefile->AddUtilityCommand(automocTargetName.c_str(), - true, + cmTarget* mocTarget = makefile->AddUtilityCommand(automocTargetName.c_str(), + true, workingDirectory.c_str(), depends, commandLines, false, "Automoc target"); + target->AddUtility(automocTargetName.c_str()); + // configure a file to get all information to automoc at buildtime: std::string _moc_files; std::string _moc_headers; const char* sepFiles = ""; const char* sepHeaders = ""; - for(std::vector::const_iterator fileIt = srcs.begin(); - fileIt != srcs.end(); + + const std::vector& srcFiles = target->GetSourceFiles(); + + for(std::vector::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); ++fileIt) { - std::string absFile = cmSystemTools::CollapseFullPath( - fileIt->c_str(), makefile->GetCurrentDirectory()); - - bool skip = false; - bool generated = false; - cmSourceFile* sf = makefile->GetSource(absFile.c_str()); - if (sf) - { - skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); - generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); - } + cmSourceFile* sf = *fileIt; + std::string absFile = sf->GetFullPath(); + bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); + bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); if ((skip==false) && (generated == false)) { - std::string ext = cmSystemTools::GetFilenameExtension(fileIt->c_str()); + std::string ext = sf->GetExtension(); cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat( ext.c_str()); if (fileType == cmSystemTools::CXX_FILE_FORMAT) @@ -137,29 +136,15 @@ void cmQtAutomoc::SetupAutomocTarget(cmMakefile* makefile, mocCppFile += "/"; mocCppFile += automocTargetName; mocCppFile += ".cpp"; - makefile->GetOrCreateSource(mocCppFile.c_str(), true); - srcs.push_back(mocCppFile); + cmSourceFile* mocCppSource = makefile->GetOrCreateSource(mocCppFile.c_str(), + true); + target->AddSourceFile(mocCppSource); makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", mocCppFile.c_str(), false); } -void cmQtAutomoc::AddTargetDependency(cmMakefile* makefile, cmTarget* target) -{ - // don't do anything if there is no Qt4: - std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); - if (qtMajorVersion != "4") - { - return; - } - - std::string automocTargetName = target->GetName(); - automocTargetName += "_automoc"; - target->AddUtility(automocTargetName.c_str()); -} - - bool cmQtAutomoc::Run(const char* targetDirectory) { cmake cm; diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index af773664c23..4fd90416130 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -10,11 +10,7 @@ class cmQtAutomoc cmQtAutomoc(); bool Run(const char* targetDirectory); - void SetupAutomocTarget(cmMakefile* makefile, - const char* targetName, - std::vector& srcs); - - void AddTargetDependency(cmMakefile* makefile, cmTarget* target); + void SetupAutomocTarget(cmTarget* target); private: cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, From cbaac2a587d8457b69d832e2c63de8fb755ec64d Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 01:44:13 +0200 Subject: [PATCH 109/539] Remove trailing whitespace Alex --- Source/cmGlobalGenerator.cxx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 2eae01e6886..f37b0549d8f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -269,7 +269,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, cmOStringStream windowsVersionString; windowsVersionString << osvi.dwMajorVersion << "." << osvi.dwMinorVersion; windowsVersionString.str(); - mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", + mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", windowsVersionString.str().c_str()); #endif // Read the DetermineSystem file @@ -618,8 +618,8 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf) if (sscanf(linkerPref, "%d", &preference)!=1) { // backward compatibility: before 2.6 LINKER_PREFERENCE - // was either "None" or "Prefered", and only the first character was - // tested. So if there is a custom language out there and it is + // was either "None" or "Prefered", and only the first character was + // tested. So if there is a custom language out there and it is // "Prefered", set its preference high if (linkerPref[0]=='P') { @@ -1019,9 +1019,9 @@ void cmGlobalGenerator::CheckLocalGenerators() if(notFoundMap.size()) { std::string notFoundVars; - for(std::map::const_iterator + for(std::map::const_iterator ii = notFoundMap.begin(); - ii != notFoundMap.end(); + ii != notFoundMap.end(); ++ii) { notFoundVars += ii->first; @@ -1057,7 +1057,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, { this->FirstTimeProgress = 0.95f; } - this->CMakeInstance->UpdateProgress("Configuring", + this->CMakeInstance->UpdateProgress("Configuring", this->FirstTimeProgress); } @@ -1161,7 +1161,7 @@ int cmGlobalGenerator::Build( { outputPtr = &outputBuffer; } - + // should we do a clean first? if (clean) { @@ -1199,7 +1199,7 @@ int cmGlobalGenerator::Build( // now build std::string makeCommand = this->GenerateBuildCommand(makeCommandCSTR, projectName, - extraOptions, target, + extraOptions, target, config, false, fast); if(output) { @@ -1272,8 +1272,8 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) if(this->FirstTimeProgress > 0.95f) { this->FirstTimeProgress = 0.95f; - } - this->CMakeInstance->UpdateProgress("Configuring", + } + this->CMakeInstance->UpdateProgress("Configuring", this->FirstTimeProgress); return; } @@ -1296,8 +1296,8 @@ void cmGlobalGenerator::AddInstallComponent(const char* component) } } -void cmGlobalGenerator::AddTargetToExports(const char* exportSetName, - cmTarget* target, +void cmGlobalGenerator::AddTargetToExports(const char* exportSetName, + cmTarget* target, cmInstallTargetGenerator* archive, cmInstallTargetGenerator* runTime, cmInstallTargetGenerator* library, @@ -1331,7 +1331,7 @@ void cmGlobalGenerator::ClearExportSets() const std::vector* cmGlobalGenerator::GetExportSet( const char* name) const { - std::map >::const_iterator + std::map >::const_iterator exportSetIt = this->ExportSets.find(name); if (exportSetIt != this->ExportSets.end()) { @@ -1443,7 +1443,7 @@ void cmGlobalGenerator::GetEnabledLanguages(std::vector& lang) int cmGlobalGenerator::GetLinkerPreference(const char* lang) { - std::map::const_iterator it = + std::map::const_iterator it = this->LanguageToLinkerPreference.find(lang); if (it != this->LanguageToLinkerPreference.end()) { From 50cd6cef925a53dfbbb820ae7343981dcf00f36c Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 01:45:05 +0200 Subject: [PATCH 110/539] Move automoc processing from add_executable/library to cmGlobalGenerator Now automoc is enabled by setting the AUTOMOC target property to true, instead of using the AUTOMOC keyword in add_executable() or add_library() Alex --- Source/cmAddExecutableCommand.cxx | 20 +------------------ Source/cmAddLibraryCommand.cxx | 23 +--------------------- Source/cmGlobalGenerator.cxx | 32 +++++++++++++++++++++++++++++++ Source/cmGlobalGenerator.h | 2 ++ 4 files changed, 36 insertions(+), 41 deletions(-) diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index ef75b3b06f4..bac243039af 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -10,7 +10,6 @@ See the License for more information. ============================================================================*/ #include "cmAddExecutableCommand.h" -#include "cmQtAutomoc.h" // cmExecutableCommand bool cmAddExecutableCommand @@ -30,7 +29,6 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) bool use_macbundle = false; bool excludeFromAll = false; bool importTarget = false; - bool doAutomoc = false; while ( s != args.end() ) { if (*s == "WIN32") @@ -43,11 +41,6 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) ++s; use_macbundle = true; } - else if ( *s == "AUTOMOC" ) - { - ++s; - doAutomoc = true; - } else if(*s == "EXCLUDE_FROM_ALL") { ++s; @@ -66,17 +59,12 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) // Special modifiers are not allowed with IMPORTED signature. if(importTarget - && (use_win32 || use_macbundle || excludeFromAll || doAutomoc)) + && (use_win32 || use_macbundle || excludeFromAll)) { if(use_win32) { this->SetError("may not be given WIN32 for an IMPORTED target."); } - else if(doAutomoc) - { - this->SetError( - "may not be given AUTOMOC for an IMPORTED target."); - } else if(use_macbundle) { this->SetError( @@ -137,11 +125,5 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) tgt->SetProperty("MACOSX_BUNDLE", "ON"); } - if ( doAutomoc ) - { - cmQtAutomoc automoc; - automoc.SetupAutomocTarget(tgt); - } - return true; } diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index f0b2e0d43a0..efa29e6c996 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -12,7 +12,6 @@ #include "cmAddLibraryCommand.h" #include "cmake.h" -#include "cmQtAutomoc.h" // cmLibraryCommand bool cmAddLibraryCommand @@ -32,7 +31,6 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) } bool excludeFromAll = false; bool importTarget = false; - bool doAutomoc = false; std::vector::const_iterator s = args.begin(); @@ -81,11 +79,6 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) ++s; importTarget = true; } - else if (*s == "AUTOMOC") - { - ++s; - doAutomoc = true; - } else { break; @@ -120,13 +113,6 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) return false; } - // Don't run automoc on an imported library - if (doAutomoc) - { - this->SetError("cannot be called with AUTOMOC for an IMPORTED library."); - return false; - } - // Make sure the target does not already exist. if(this->Makefile->FindTargetToUse(libName.c_str())) { @@ -178,14 +164,7 @@ ::InitialPass(std::vector const& args, cmExecutionStatus &) ++s; } - cmTarget* tgt =this->Makefile->AddLibrary(libName.c_str(), type, srclists, - excludeFromAll); - - if ( doAutomoc ) - { - cmQtAutomoc automoc; - automoc.SetupAutomocTarget(tgt); - } + this->Makefile->AddLibrary(libName.c_str(), type, srclists, excludeFromAll); return true; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f37b0549d8f..3016f5a6806 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -18,6 +18,7 @@ #include "cmExternalMakefileProjectGenerator.h" #include "cmake.h" #include "cmMakefile.h" +#include "cmQtAutomoc.h" #include "cmSourceFile.h" #include "cmVersion.h" #include "cmExportInstallFileGenerator.h" @@ -832,6 +833,10 @@ void cmGlobalGenerator::Generate() return; } + // Iterate through all targets and set up automoc for those which have + // the AUTOMOC property set + this->CreateAutomocTargets(); + // For each existing cmLocalGenerator unsigned int i; @@ -950,6 +955,33 @@ bool cmGlobalGenerator::CheckTargets() return true; } +//---------------------------------------------------------------------------- +void cmGlobalGenerator::CreateAutomocTargets() +{ + for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) + { + cmTargets& targets = + this->LocalGenerators[i]->GetMakefile()->GetTargets(); + for(cmTargets::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + cmTarget& target = ti->second; + if(target.GetType() == cmTarget::EXECUTABLE || + target.GetType() == cmTarget::STATIC_LIBRARY || + target.GetType() == cmTarget::SHARED_LIBRARY || + target.GetType() == cmTarget::MODULE_LIBRARY) + { + if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported()) + { + cmQtAutomoc automoc; + automoc.SetupAutomocTarget(&target); + } + } + } + } +} + + void cmGlobalGenerator::CheckLocalGenerators() { std::map notFoundMap; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index b7b1bff8227..88eb8b61a62 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -282,6 +282,8 @@ class cmGlobalGenerator virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); bool CheckTargets(); + void CreateAutomocTargets(); + // Fill the ProjectMap, this must be called after LocalGenerators // has been populated. From d045fd4ec5d88658988c8878b313b2bf7924f40f Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 02:00:36 +0200 Subject: [PATCH 111/539] Nicer progress message for the automoc target Alex --- Source/cmQtAutomoc.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 6dbc9e14742..e8c4baa243a 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -66,11 +66,13 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) "", makefile->GetCurrentOutputDirectory()); std::vector depends; + std::string automocComment = "Automoc for target "; + automocComment += targetName; cmTarget* mocTarget = makefile->AddUtilityCommand(automocTargetName.c_str(), true, - workingDirectory.c_str(), depends, - commandLines, false, "Automoc target"); + workingDirectory.c_str(), depends, + commandLines, false, automocComment.c_str()); target->AddUtility(automocTargetName.c_str()); // configure a file to get all information to automoc at buildtime: From bf8ef778a317fd7cd82bcc658fc734bf3f29911e Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 02:10:45 +0200 Subject: [PATCH 112/539] Add a test for automoc The files are taken from the Qt examples. They are BSD licensed, so it should be fine. I only edited main.cpp to use both widgets. Alex --- Tests/CMakeLists.txt | 18 ++ Tests/QtAutomoc/CMakeLists.txt | 20 ++ Tests/QtAutomoc/calwidget.cpp | 424 +++++++++++++++++++++++++++++++++ Tests/QtAutomoc/calwidget.h | 121 ++++++++++ Tests/QtAutomoc/codeeditor.cpp | 153 ++++++++++++ Tests/QtAutomoc/codeeditor.h | 99 ++++++++ Tests/QtAutomoc/main.cpp | 58 +++++ 7 files changed, 893 insertions(+) create mode 100644 Tests/QtAutomoc/CMakeLists.txt create mode 100644 Tests/QtAutomoc/calwidget.cpp create mode 100644 Tests/QtAutomoc/calwidget.h create mode 100644 Tests/QtAutomoc/codeeditor.cpp create mode 100644 Tests/QtAutomoc/codeeditor.h create mode 100644 Tests/QtAutomoc/main.cpp diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 4bf83b78057..30549b67106 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -840,6 +840,24 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment") + IF(NOT QT4_FOUND) + FIND_PACKAGE(Qt4) + IF(QT4_FOUND) + ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutomoc" + "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project QtAutomoc + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --force-new-ctest-process + --test-command ${CMAKE_CTEST_COMMAND} -V + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc") + ENDIF() + ENDIF(NOT QT4_FOUND) + ADD_TEST(ExternalProject ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/ExternalProject" diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt new file mode 100644 index 00000000000..4a5ff1099ba --- /dev/null +++ b/Tests/QtAutomoc/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 2.8) + +project(QtAutomoc) + +find_package(Qt4 REQUIRED) + +include(UseQt4) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +add_definitions(-DFOO) + +# create an executable and a library target, both requiring automoc: +add_library(codeeditorLib STATIC codeeditor.cpp) + +add_executable(foo main.cpp calwidget.cpp ) + +set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE) + +target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} ) diff --git a/Tests/QtAutomoc/calwidget.cpp b/Tests/QtAutomoc/calwidget.cpp new file mode 100644 index 00000000000..24f3b4efe2d --- /dev/null +++ b/Tests/QtAutomoc/calwidget.cpp @@ -0,0 +1,424 @@ +/**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + + #include + + #include "calwidget.h" + + Window::Window() + { + createPreviewGroupBox(); + createGeneralOptionsGroupBox(); + createDatesGroupBox(); + createTextFormatsGroupBox(); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(previewGroupBox, 0, 0); + layout->addWidget(generalOptionsGroupBox, 0, 1); + layout->addWidget(datesGroupBox, 1, 0); + layout->addWidget(textFormatsGroupBox, 1, 1); + layout->setSizeConstraint(QLayout::SetFixedSize); + setLayout(layout); + + previewLayout->setRowMinimumHeight(0, calendar->sizeHint().height()); + previewLayout->setColumnMinimumWidth(0, calendar->sizeHint().width()); + + setWindowTitle(tr("Calendar Widget")); + } + + void Window::localeChanged(int index) + { + calendar->setLocale(localeCombo->itemData(index).toLocale()); + } + + void Window::firstDayChanged(int index) + { + calendar->setFirstDayOfWeek(Qt::DayOfWeek( + firstDayCombo->itemData(index).toInt())); + } + + void Window::selectionModeChanged(int index) + { + calendar->setSelectionMode(QCalendarWidget::SelectionMode( + selectionModeCombo->itemData(index).toInt())); + } + + void Window::horizontalHeaderChanged(int index) + { + calendar->setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat( + horizontalHeaderCombo->itemData(index).toInt())); + } + + void Window::verticalHeaderChanged(int index) + { + calendar->setVerticalHeaderFormat(QCalendarWidget::VerticalHeaderFormat( + verticalHeaderCombo->itemData(index).toInt())); + } + + void Window::selectedDateChanged() + { + currentDateEdit->setDate(calendar->selectedDate()); + } + + void Window::minimumDateChanged(const QDate &date) + { + calendar->setMinimumDate(date); + maximumDateEdit->setDate(calendar->maximumDate()); + } + + void Window::maximumDateChanged(const QDate &date) + { + calendar->setMaximumDate(date); + minimumDateEdit->setDate(calendar->minimumDate()); + } + + void Window::weekdayFormatChanged() + { + QTextCharFormat format; + + format.setForeground(qvariant_cast( + weekdayColorCombo->itemData(weekdayColorCombo->currentIndex()))); + calendar->setWeekdayTextFormat(Qt::Monday, format); + calendar->setWeekdayTextFormat(Qt::Tuesday, format); + calendar->setWeekdayTextFormat(Qt::Wednesday, format); + calendar->setWeekdayTextFormat(Qt::Thursday, format); + calendar->setWeekdayTextFormat(Qt::Friday, format); + } + + void Window::weekendFormatChanged() + { + QTextCharFormat format; + + format.setForeground(qvariant_cast( + weekendColorCombo->itemData(weekendColorCombo->currentIndex()))); + calendar->setWeekdayTextFormat(Qt::Saturday, format); + calendar->setWeekdayTextFormat(Qt::Sunday, format); + } + + void Window::reformatHeaders() + { + QString text = headerTextFormatCombo->currentText(); + QTextCharFormat format; + + if (text == tr("Bold")) { + format.setFontWeight(QFont::Bold); + } else if (text == tr("Italic")) { + format.setFontItalic(true); + } else if (text == tr("Green")) { + format.setForeground(Qt::green); + } + calendar->setHeaderTextFormat(format); + } + + void Window::reformatCalendarPage() + { + if (firstFridayCheckBox->isChecked()) { + QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1); + while (firstFriday.dayOfWeek() != Qt::Friday) + firstFriday = firstFriday.addDays(1); + QTextCharFormat firstFridayFormat; + firstFridayFormat.setForeground(Qt::blue); + calendar->setDateTextFormat(firstFriday, firstFridayFormat); + } + + //May First in Red takes precedence + if (mayFirstCheckBox->isChecked()) { + const QDate mayFirst(calendar->yearShown(), 5, 1); + QTextCharFormat mayFirstFormat; + mayFirstFormat.setForeground(Qt::red); + calendar->setDateTextFormat(mayFirst, mayFirstFormat); + } + } + + void Window::createPreviewGroupBox() + { + previewGroupBox = new QGroupBox(tr("Preview")); + + calendar = new QCalendarWidget; + calendar->setMinimumDate(QDate(1900, 1, 1)); + calendar->setMaximumDate(QDate(3000, 1, 1)); + calendar->setGridVisible(true); + + connect(calendar, SIGNAL(currentPageChanged(int,int)), + this, SLOT(reformatCalendarPage())); + + previewLayout = new QGridLayout; + previewLayout->addWidget(calendar, 0, 0, Qt::AlignCenter); + previewGroupBox->setLayout(previewLayout); + } + + void Window::createGeneralOptionsGroupBox() + { + generalOptionsGroupBox = new QGroupBox(tr("General Options")); + + localeCombo = new QComboBox; + int curLocaleIndex = -1; + int index = 0; + for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) { + QLocale::Language lang = static_cast(_lang); + QList countries = QLocale::countriesForLanguage(lang); + for (int i = 0; i < countries.count(); ++i) { + QLocale::Country country = countries.at(i); + QString label = QLocale::languageToString(lang); + label += QLatin1Char('/'); + label += QLocale::countryToString(country); + QLocale locale(lang, country); + if (this->locale().language() == lang && this->locale().country() == country) + curLocaleIndex = index; + localeCombo->addItem(label, locale); + ++index; + } + } + if (curLocaleIndex != -1) + localeCombo->setCurrentIndex(curLocaleIndex); + localeLabel = new QLabel(tr("&Locale")); + localeLabel->setBuddy(localeCombo); + + firstDayCombo = new QComboBox; + firstDayCombo->addItem(tr("Sunday"), Qt::Sunday); + firstDayCombo->addItem(tr("Monday"), Qt::Monday); + firstDayCombo->addItem(tr("Tuesday"), Qt::Tuesday); + firstDayCombo->addItem(tr("Wednesday"), Qt::Wednesday); + firstDayCombo->addItem(tr("Thursday"), Qt::Thursday); + firstDayCombo->addItem(tr("Friday"), Qt::Friday); + firstDayCombo->addItem(tr("Saturday"), Qt::Saturday); + + firstDayLabel = new QLabel(tr("Wee&k starts on:")); + firstDayLabel->setBuddy(firstDayCombo); + + selectionModeCombo = new QComboBox; + selectionModeCombo->addItem(tr("Single selection"), + QCalendarWidget::SingleSelection); + selectionModeCombo->addItem(tr("None"), QCalendarWidget::NoSelection); + + selectionModeLabel = new QLabel(tr("&Selection mode:")); + selectionModeLabel->setBuddy(selectionModeCombo); + + gridCheckBox = new QCheckBox(tr("&Grid")); + gridCheckBox->setChecked(calendar->isGridVisible()); + + navigationCheckBox = new QCheckBox(tr("&Navigation bar")); + navigationCheckBox->setChecked(true); + + horizontalHeaderCombo = new QComboBox; + horizontalHeaderCombo->addItem(tr("Single letter day names"), + QCalendarWidget::SingleLetterDayNames); + horizontalHeaderCombo->addItem(tr("Short day names"), + QCalendarWidget::ShortDayNames); + horizontalHeaderCombo->addItem(tr("None"), + QCalendarWidget::NoHorizontalHeader); + horizontalHeaderCombo->setCurrentIndex(1); + + horizontalHeaderLabel = new QLabel(tr("&Horizontal header:")); + horizontalHeaderLabel->setBuddy(horizontalHeaderCombo); + + verticalHeaderCombo = new QComboBox; + verticalHeaderCombo->addItem(tr("ISO week numbers"), + QCalendarWidget::ISOWeekNumbers); + verticalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoVerticalHeader); + + verticalHeaderLabel = new QLabel(tr("&Vertical header:")); + verticalHeaderLabel->setBuddy(verticalHeaderCombo); + + connect(localeCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(localeChanged(int))); + connect(firstDayCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(firstDayChanged(int))); + connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(selectionModeChanged(int))); + connect(gridCheckBox, SIGNAL(toggled(bool)), + calendar, SLOT(setGridVisible(bool))); + connect(navigationCheckBox, SIGNAL(toggled(bool)), + calendar, SLOT(setNavigationBarVisible(bool))); + connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(horizontalHeaderChanged(int))); + connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(verticalHeaderChanged(int))); + + QHBoxLayout *checkBoxLayout = new QHBoxLayout; + checkBoxLayout->addWidget(gridCheckBox); + checkBoxLayout->addStretch(); + checkBoxLayout->addWidget(navigationCheckBox); + + QGridLayout *outerLayout = new QGridLayout; + outerLayout->addWidget(localeLabel, 0, 0); + outerLayout->addWidget(localeCombo, 0, 1); + outerLayout->addWidget(firstDayLabel, 1, 0); + outerLayout->addWidget(firstDayCombo, 1, 1); + outerLayout->addWidget(selectionModeLabel, 2, 0); + outerLayout->addWidget(selectionModeCombo, 2, 1); + outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2); + outerLayout->addWidget(horizontalHeaderLabel, 4, 0); + outerLayout->addWidget(horizontalHeaderCombo, 4, 1); + outerLayout->addWidget(verticalHeaderLabel, 5, 0); + outerLayout->addWidget(verticalHeaderCombo, 5, 1); + generalOptionsGroupBox->setLayout(outerLayout); + + firstDayChanged(firstDayCombo->currentIndex()); + selectionModeChanged(selectionModeCombo->currentIndex()); + horizontalHeaderChanged(horizontalHeaderCombo->currentIndex()); + verticalHeaderChanged(verticalHeaderCombo->currentIndex()); + } + + void Window::createDatesGroupBox() + { + datesGroupBox = new QGroupBox(tr("Dates")); + + minimumDateEdit = new QDateEdit; + minimumDateEdit->setDisplayFormat("MMM d yyyy"); + minimumDateEdit->setDateRange(calendar->minimumDate(), + calendar->maximumDate()); + minimumDateEdit->setDate(calendar->minimumDate()); + + minimumDateLabel = new QLabel(tr("&Minimum Date:")); + minimumDateLabel->setBuddy(minimumDateEdit); + + currentDateEdit = new QDateEdit; + currentDateEdit->setDisplayFormat("MMM d yyyy"); + currentDateEdit->setDate(calendar->selectedDate()); + currentDateEdit->setDateRange(calendar->minimumDate(), + calendar->maximumDate()); + + currentDateLabel = new QLabel(tr("&Current Date:")); + currentDateLabel->setBuddy(currentDateEdit); + + maximumDateEdit = new QDateEdit; + maximumDateEdit->setDisplayFormat("MMM d yyyy"); + maximumDateEdit->setDateRange(calendar->minimumDate(), + calendar->maximumDate()); + maximumDateEdit->setDate(calendar->maximumDate()); + + maximumDateLabel = new QLabel(tr("Ma&ximum Date:")); + maximumDateLabel->setBuddy(maximumDateEdit); + + connect(currentDateEdit, SIGNAL(dateChanged(QDate)), + calendar, SLOT(setSelectedDate(QDate))); + connect(calendar, SIGNAL(selectionChanged()), + this, SLOT(selectedDateChanged())); + connect(minimumDateEdit, SIGNAL(dateChanged(QDate)), + this, SLOT(minimumDateChanged(QDate))); + connect(maximumDateEdit, SIGNAL(dateChanged(QDate)), + this, SLOT(maximumDateChanged(QDate))); + + QGridLayout *dateBoxLayout = new QGridLayout; + dateBoxLayout->addWidget(currentDateLabel, 1, 0); + dateBoxLayout->addWidget(currentDateEdit, 1, 1); + dateBoxLayout->addWidget(minimumDateLabel, 0, 0); + dateBoxLayout->addWidget(minimumDateEdit, 0, 1); + dateBoxLayout->addWidget(maximumDateLabel, 2, 0); + dateBoxLayout->addWidget(maximumDateEdit, 2, 1); + dateBoxLayout->setRowStretch(3, 1); + + datesGroupBox->setLayout(dateBoxLayout); + } + + void Window::createTextFormatsGroupBox() + { + textFormatsGroupBox = new QGroupBox(tr("Text Formats")); + + weekdayColorCombo = createColorComboBox(); + weekdayColorCombo->setCurrentIndex( + weekdayColorCombo->findText(tr("Black"))); + + weekdayColorLabel = new QLabel(tr("&Weekday color:")); + weekdayColorLabel->setBuddy(weekdayColorCombo); + + weekendColorCombo = createColorComboBox(); + weekendColorCombo->setCurrentIndex( + weekendColorCombo->findText(tr("Red"))); + + weekendColorLabel = new QLabel(tr("Week&end color:")); + weekendColorLabel->setBuddy(weekendColorCombo); + + headerTextFormatCombo = new QComboBox; + headerTextFormatCombo->addItem(tr("Bold")); + headerTextFormatCombo->addItem(tr("Italic")); + headerTextFormatCombo->addItem(tr("Plain")); + + headerTextFormatLabel = new QLabel(tr("&Header text:")); + headerTextFormatLabel->setBuddy(headerTextFormatCombo); + + firstFridayCheckBox = new QCheckBox(tr("&First Friday in blue")); + + mayFirstCheckBox = new QCheckBox(tr("May &1 in red")); + + connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(weekdayFormatChanged())); + connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(weekendFormatChanged())); + connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(QString)), + this, SLOT(reformatHeaders())); + connect(firstFridayCheckBox, SIGNAL(toggled(bool)), + this, SLOT(reformatCalendarPage())); + connect(mayFirstCheckBox, SIGNAL(toggled(bool)), + this, SLOT(reformatCalendarPage())); + + QHBoxLayout *checkBoxLayout = new QHBoxLayout; + checkBoxLayout->addWidget(firstFridayCheckBox); + checkBoxLayout->addStretch(); + checkBoxLayout->addWidget(mayFirstCheckBox); + + QGridLayout *outerLayout = new QGridLayout; + outerLayout->addWidget(weekdayColorLabel, 0, 0); + outerLayout->addWidget(weekdayColorCombo, 0, 1); + outerLayout->addWidget(weekendColorLabel, 1, 0); + outerLayout->addWidget(weekendColorCombo, 1, 1); + outerLayout->addWidget(headerTextFormatLabel, 2, 0); + outerLayout->addWidget(headerTextFormatCombo, 2, 1); + outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2); + textFormatsGroupBox->setLayout(outerLayout); + + weekdayFormatChanged(); + weekendFormatChanged(); + reformatHeaders(); + reformatCalendarPage(); + } + +QComboBox *Window::createColorComboBox() + { + QComboBox *comboBox = new QComboBox; + comboBox->addItem(tr("Red"), Qt::red); + comboBox->addItem(tr("Blue"), Qt::blue); + comboBox->addItem(tr("Black"), Qt::black); + comboBox->addItem(tr("Magenta"), Qt::magenta); + return comboBox; + } + +//#include "moc_calwidget.cpp" diff --git a/Tests/QtAutomoc/calwidget.h b/Tests/QtAutomoc/calwidget.h new file mode 100644 index 00000000000..8447389370e --- /dev/null +++ b/Tests/QtAutomoc/calwidget.h @@ -0,0 +1,121 @@ + /**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + +#ifndef WINDOW_H +#define WINDOW_H + +#include + + class QCalendarWidget; + class QCheckBox; + class QComboBox; + class QDate; + class QDateEdit; + class QGridLayout; + class QGroupBox; + class QLabel; + + class Window : public QWidget + { + Q_OBJECT + + public: + Window(); + + private slots: + void localeChanged(int index); + void firstDayChanged(int index); + void selectionModeChanged(int index); + void horizontalHeaderChanged(int index); + void verticalHeaderChanged(int index); + void selectedDateChanged(); + void minimumDateChanged(const QDate &date); + void maximumDateChanged(const QDate &date); + void weekdayFormatChanged(); + void weekendFormatChanged(); + void reformatHeaders(); + void reformatCalendarPage(); + + private: + void createPreviewGroupBox(); + void createGeneralOptionsGroupBox(); + void createDatesGroupBox(); + void createTextFormatsGroupBox(); + QComboBox *createColorComboBox(); + + QGroupBox *previewGroupBox; + QGridLayout *previewLayout; + QCalendarWidget *calendar; + + QGroupBox *generalOptionsGroupBox; + QLabel *localeLabel; + QLabel *firstDayLabel; + QLabel *selectionModeLabel; + QLabel *horizontalHeaderLabel; + QLabel *verticalHeaderLabel; + QComboBox *localeCombo; + QComboBox *firstDayCombo; + QComboBox *selectionModeCombo; + QCheckBox *gridCheckBox; + QCheckBox *navigationCheckBox; + QComboBox *horizontalHeaderCombo; + QComboBox *verticalHeaderCombo; + + QGroupBox *datesGroupBox; + QLabel *currentDateLabel; + QLabel *minimumDateLabel; + QLabel *maximumDateLabel; + QDateEdit *currentDateEdit; + QDateEdit *minimumDateEdit; + QDateEdit *maximumDateEdit; + + QGroupBox *textFormatsGroupBox; + QLabel *weekdayColorLabel; + QLabel *weekendColorLabel; + QLabel *headerTextFormatLabel; + QComboBox *weekdayColorCombo; + QComboBox *weekendColorCombo; + QComboBox *headerTextFormatCombo; + + QCheckBox *firstFridayCheckBox; + QCheckBox *mayFirstCheckBox; + }; + + #endif diff --git a/Tests/QtAutomoc/codeeditor.cpp b/Tests/QtAutomoc/codeeditor.cpp new file mode 100644 index 00000000000..01da062765d --- /dev/null +++ b/Tests/QtAutomoc/codeeditor.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + + #include + + #include "codeeditor.h" + + + CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) + { + lineNumberArea = new LineNumberArea(this); + + connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); + connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); + connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); + + updateLineNumberAreaWidth(0); + highlightCurrentLine(); + } + + + + int CodeEditor::lineNumberAreaWidth() + { + int digits = 1; + int max = qMax(1, blockCount()); + while (max >= 10) { + max /= 10; + ++digits; + } + + int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits; + + return space; + } + + + + void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */) + { + setViewportMargins(lineNumberAreaWidth(), 0, 0, 0); + } + + + + void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) + { + if (dy) + lineNumberArea->scroll(0, dy); + else + lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height()); + + if (rect.contains(viewport()->rect())) + updateLineNumberAreaWidth(0); + } + + + + void CodeEditor::resizeEvent(QResizeEvent *e) + { + QPlainTextEdit::resizeEvent(e); + + QRect cr = contentsRect(); + lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); + } + + + + void CodeEditor::highlightCurrentLine() + { + QList extraSelections; + + if (!isReadOnly()) { + QTextEdit::ExtraSelection selection; + + QColor lineColor = QColor(Qt::yellow).lighter(160); + + selection.format.setBackground(lineColor); + selection.format.setProperty(QTextFormat::FullWidthSelection, true); + selection.cursor = textCursor(); + selection.cursor.clearSelection(); + extraSelections.append(selection); + } + + setExtraSelections(extraSelections); + } + + + + void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) + { + QPainter painter(lineNumberArea); + painter.fillRect(event->rect(), Qt::lightGray); + + + QTextBlock block = firstVisibleBlock(); + int blockNumber = block.blockNumber(); + int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top(); + int bottom = top + (int) blockBoundingRect(block).height(); + + while (block.isValid() && top <= event->rect().bottom()) { + if (block.isVisible() && bottom >= event->rect().top()) { + QString number = QString::number(blockNumber + 1); + painter.setPen(Qt::black); + painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(), + Qt::AlignRight, number); + } + + block = block.next(); + top = bottom; + bottom = top + (int) blockBoundingRect(block).height(); + ++blockNumber; + } + } + +#include "codeeditor.moc" diff --git a/Tests/QtAutomoc/codeeditor.h b/Tests/QtAutomoc/codeeditor.h new file mode 100644 index 00000000000..56e9e79239a --- /dev/null +++ b/Tests/QtAutomoc/codeeditor.h @@ -0,0 +1,99 @@ + /**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + + #ifndef CODEEDITOR_H + #define CODEEDITOR_H + + #include + #include + + class QPaintEvent; + class QResizeEvent; + class QSize; + class QWidget; + + class LineNumberArea; + + + class CodeEditor : public QPlainTextEdit + { + Q_OBJECT + + public: + CodeEditor(QWidget *parent = 0); + + void lineNumberAreaPaintEvent(QPaintEvent *event); + int lineNumberAreaWidth(); + + protected: + void resizeEvent(QResizeEvent *event); + + private slots: + void updateLineNumberAreaWidth(int newBlockCount); + void highlightCurrentLine(); + void updateLineNumberArea(const QRect &, int); + + private: + QWidget *lineNumberArea; + }; + + + class LineNumberArea : public QWidget + { + public: + LineNumberArea(CodeEditor *editor) : QWidget(editor) { + codeEditor = editor; + } + + QSize sizeHint() const { + return QSize(codeEditor->lineNumberAreaWidth(), 0); + } + + protected: + void paintEvent(QPaintEvent *event) { + codeEditor->lineNumberAreaPaintEvent(event); + } + + private: + CodeEditor *codeEditor; + }; + + + #endif diff --git a/Tests/QtAutomoc/main.cpp b/Tests/QtAutomoc/main.cpp new file mode 100644 index 00000000000..7bf4a5d2074 --- /dev/null +++ b/Tests/QtAutomoc/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + +#include + +#include "codeeditor.h" +#include "calwidget.h" + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + CodeEditor editor; + editor.setWindowTitle(QObject::tr("Code Editor Example")); + editor.show(); + + Window w; + w.show(); + + return app.exec(); +} From 77a5c6e0d8c995f56fa1248443de0260384acca3 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 22:05:33 +0200 Subject: [PATCH 113/539] Add documentation for AUTOMOC, add initialization via CMAKE_AUTOMOC Alex --- Source/cmDocumentVariables.cxx | 9 +++++++++ Source/cmTarget.cxx | 25 ++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index ebe2988b57a..26125d9d376 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1084,6 +1084,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm) false, "Variables that Control the Build"); + cm->DefineProperty + ("CMAKE_AUTOMOC", cmProperty::VARIABLE, + "Whether to handle moc automatically for Qt targets.", + "This variable is used to initialize the " + "AUTOMOC property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); + cm->DefineProperty ("CMAKE_DEBUG_POSTFIX", cmProperty::VARIABLE, "See variable CMAKE__POSTFIX.", diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 17a26ccda61..4969b65afe7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -114,6 +114,28 @@ cmTarget::cmTarget() //---------------------------------------------------------------------------- void cmTarget::DefineProperties(cmake *cm) { + cm->DefineProperty + ("AUTOMOC", cmProperty::TARGET, + "Should the target be processed with automoc (for Qt projects).", + "AUTOMOC is a boolean specifying whether CMake will handle " + "the Qt moc preprocessor automatically, i.e. without having to use " + "the QT4_WRAP_CPP() macro. Currently Qt4 is supported. " + "When this property is set to TRUE, CMake will scan the source files " + "at build time and invoke moc accordingly. " + "If an #include statement like #include \"moc_foo.cpp\" is found, " + "the Q_OBJECT class declaration is expected in the header, and moc is " + "run on the header file. " + "If an #include statement like #include \"foo.moc\" is found, " + "then a Q_OBJECT is expected in the current source file and moc " + "is run on the file itself. " + "Additionally, all header files are parsed for Q_OBJECT macros, " + "and if found, moc is also executed on those files. The resulting " + "moc files, which are not included as shown above in any of the source " + "files are included in a generated _automoc.cpp file, " + "which is compiled as part of the target." + "This property is initialized by the value of the variable " + "CMAKE_AUTOMOC if it is set when a target is created."); + cm->DefineProperty ("BUILD_WITH_INSTALL_RPATH", cmProperty::TARGET, "Should build tree targets have install tree rpaths.", @@ -1118,6 +1140,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); this->SetPropertyDefault("OSX_ARCHITECTURES", 0); + this->SetPropertyDefault("AUTOMOC", 0); // Collect the set of configuration types. std::vector configNames; @@ -1420,7 +1443,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) // the fact that the name matched a target was just a coincidence. if(cmSystemTools::FileIsFullPath(dep.c_str())) { - if(t->GetType() >= cmTarget::EXECUTABLE && + if(t->GetType() >= cmTarget::EXECUTABLE && t->GetType() <= cmTarget::MODULE_LIBRARY) { // This is really only for compatibility so we do not need to From 626fc717c6a6fb880053e645b3f12805f60c102a Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 22:31:26 +0200 Subject: [PATCH 114/539] Much improved test, should now be executed on all UNIXes Instead of relying on that some development package is installed on the system, now a tiny library is built, which is the searched and used during the test. Alex --- .../CMakeLists.txt | 24 +++++++++---------- .../FindFoo.cmake.in | 8 +++++++ Tests/FindPackageModeMakefileTest/Makefile.in | 4 ++-- Tests/FindPackageModeMakefileTest/foo.cpp | 4 ++++ Tests/FindPackageModeMakefileTest/foo.h | 6 +++++ Tests/FindPackageModeMakefileTest/main.cpp | 4 ++-- 6 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 Tests/FindPackageModeMakefileTest/FindFoo.cmake.in create mode 100644 Tests/FindPackageModeMakefileTest/foo.cpp create mode 100644 Tests/FindPackageModeMakefileTest/foo.h diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index d2c6be9c971..17f02b4d379 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -1,22 +1,20 @@ -if("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU - OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Intel - OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang - OR "${CMAKE_CXX_COMPILER_ID}" MATCHES XL - OR "${CMAKE_CXX_COMPILER_ID}" MATCHES SunPro) - find_package(PNG) +# the test program links against the png lib, so test first whether it exists +if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") - # the test program links against the png lib, so test first whether it exists - if(PNG_FOUND AND UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") + # build a library which we can search during the test + add_library(foo STATIC foo.cpp) - get_target_property(cmakeExecutable cmake LOCATION) + # configure a FindFoo.cmake so it knows where the library can be found + configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) + # now set up the test: + get_target_property(cmakeExecutable cmake LOCATION) - add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile ) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) - endif() + add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile ) endif() diff --git a/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in b/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in new file mode 100644 index 00000000000..c6230abb877 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in @@ -0,0 +1,8 @@ + +find_library(FOO_LIBRARY NAMES foo HINTS "@CMAKE_CURRENT_BINARY_DIR@" ) +find_path(FOO_INCLUDE_DIR NAMES foo.h HINTS "@CMAKE_CURRENT_SOURCE_DIR@" ) + +set(FOO_LIBRARIES ${FOO_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Foo DEFAULT_MSG FOO_LIBRARY FOO_INCLUDE_DIR ) diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in index 5e42305b83b..6bcd9b69582 100644 --- a/Tests/FindPackageModeMakefileTest/Makefile.in +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -1,10 +1,10 @@ all: clean pngtest main.o: main.cpp - "@CMAKE_CXX_COMPILER@" -c `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE` main.cpp + "@CMAKE_CXX_COMPILER@" -c `"@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE` main.cpp pngtest: main.o - "@CMAKE_CXX_COMPILER@" -o pngtest main.o `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK` + "@CMAKE_CXX_COMPILER@" -o pngtest main.o `"@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK` clean: rm -f *.o pngtest diff --git a/Tests/FindPackageModeMakefileTest/foo.cpp b/Tests/FindPackageModeMakefileTest/foo.cpp new file mode 100644 index 00000000000..6aea22629ab --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/foo.cpp @@ -0,0 +1,4 @@ +int foo() +{ + return 1477; +} diff --git a/Tests/FindPackageModeMakefileTest/foo.h b/Tests/FindPackageModeMakefileTest/foo.h new file mode 100644 index 00000000000..4ec598ad513 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/foo.h @@ -0,0 +1,6 @@ +#ifndef FOO_H +#define FOO_H + +int foo(); + +#endif diff --git a/Tests/FindPackageModeMakefileTest/main.cpp b/Tests/FindPackageModeMakefileTest/main.cpp index b78542700fb..e5f9134ce92 100644 --- a/Tests/FindPackageModeMakefileTest/main.cpp +++ b/Tests/FindPackageModeMakefileTest/main.cpp @@ -1,8 +1,8 @@ #include -#include +#include int main() { - printf("PNG copyright: %s\n", png_get_copyright(NULL)); + printf("foo is: %d\n", foo()); return 0; } From 2963d0b078bf9302cab37d9def16776bde45dd67 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 16 Aug 2011 23:48:01 +0200 Subject: [PATCH 115/539] Fix logic which decides when to execute automoc test Alex --- Tests/CMakeLists.txt | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 30549b67106..7bf4ddb34d8 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -842,22 +842,23 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ IF(NOT QT4_FOUND) FIND_PACKAGE(Qt4) - IF(QT4_FOUND) - ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/QtAutomoc" - "${CMake_BINARY_DIR}/Tests/QtAutomoc" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project QtAutomoc - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc" - --force-new-ctest-process - --test-command ${CMAKE_CTEST_COMMAND} -V - ) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc") - ENDIF() ENDIF(NOT QT4_FOUND) + IF(QT4_FOUND) + ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutomoc" + "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project QtAutomoc + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --force-new-ctest-process + --test-command ${CMAKE_CTEST_COMMAND} -V + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc") + ENDIF() + ADD_TEST(ExternalProject ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/ExternalProject" From 7e6d84568c8c390fc53cbaaf70f6839e3cf4ebd7 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 17 Aug 2011 00:04:47 +0200 Subject: [PATCH 116/539] Automoc.cmake is not needed anymore (actually I thought I had already removed it again) Alex --- Modules/Automoc.cmake | 158 ------------------------------------------ 1 file changed, 158 deletions(-) delete mode 100644 Modules/Automoc.cmake diff --git a/Modules/Automoc.cmake b/Modules/Automoc.cmake deleted file mode 100644 index 1e77c96b5c4..00000000000 --- a/Modules/Automoc.cmake +++ /dev/null @@ -1,158 +0,0 @@ - -# AUTOMOC4_MOC_HEADERS( header1.h header2.h ...) -# Use this to add more header files to be processed with automoc4. -# -# AUTOMOC4_ADD_EXECUTABLE( src1 src2 ...) -# This macro does the same as ADD_EXECUTABLE, but additionally -# adds automoc4 handling for all source files. -# -# AUTOMOC4_ADD_LIBRARY( src1 src2 ...) -# This macro does the same as ADD_LIBRARY, but additionally -# adds automoc4 handling for all source files. - -# Internal helper macro, may change or be removed anytime: -# _ADD_AUTOMOC4_TARGET( ) -# -# Since version 0.9.88: -# The following two macros are only to be used for KDE4 projects -# and do something which makes sure automoc4 works for KDE. Don't -# use them anywhere else. See kdelibs/cmake/modules/KDE4Macros.cmake. -# _AUTOMOC4_KDE4_PRE_TARGET_HANDLING( ) -# _AUTOMOC4_KDE4_POST_TARGET_HANDLING() - -# Copyright (C) 2007 Matthias Kretz -# Copyright (C) 2008-2009 Alexander Neundorf -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -macro (AUTOMOC4_MOC_HEADERS _target_NAME) - set (_headers_to_moc) - foreach (_current_FILE ${ARGN}) - get_filename_component(_suffix "${_current_FILE}" EXT) - if (".h" STREQUAL "${_suffix}" OR ".hpp" STREQUAL "${_suffix}" OR ".hxx" STREQUAL "${_suffix}" OR ".H" STREQUAL "${_suffix}") - list(APPEND _headers_to_moc ${_current_FILE}) - else (".h" STREQUAL "${_suffix}" OR ".hpp" STREQUAL "${_suffix}" OR ".hxx" STREQUAL "${_suffix}" OR ".H" STREQUAL "${_suffix}") - message(STATUS "AUTOMOC4_MOC_HEADERS: ignoring non-header file ${_current_FILE}") - endif (".h" STREQUAL "${_suffix}" OR ".hpp" STREQUAL "${_suffix}" OR ".hxx" STREQUAL "${_suffix}" OR ".H" STREQUAL "${_suffix}") - endforeach (_current_FILE) - # need to create moc_.cpp file using automoc4 - # and add it to the target - if(_headers_to_moc) - set(_automoc4_headers_${_target_NAME} "${_headers_to_moc}") - endif(_headers_to_moc) -endmacro (AUTOMOC4_MOC_HEADERS) - - -macro(_ADD_AUTOMOC4_TARGET _target_NAME _SRCS) - set(_moc_files) - set(_moc_headers) - - # first list all explicitly set headers - foreach(_header_to_moc ${_automoc4_headers_${_target_NAME}} ) - get_filename_component(_abs_header ${_header_to_moc} ABSOLUTE) - list(APPEND _moc_headers ${_abs_header}) - endforeach(_header_to_moc) - - # now add all the sources for the automoc - foreach (_current_FILE ${${_SRCS}}) - get_filename_component(_abs_current_FILE "${_current_FILE}" ABSOLUTE) - get_source_file_property(_skip "${_abs_current_FILE}" SKIP_AUTOMOC) - get_source_file_property(_generated "${_abs_current_FILE}" GENERATED) - - if(NOT _generated AND NOT _skip) - get_filename_component(_suffix "${_current_FILE}" EXT) - # skip every source file that's not C++ - if(_suffix STREQUAL ".cpp" OR _suffix STREQUAL ".cc" OR _suffix STREQUAL ".cxx" OR _suffix STREQUAL ".C" OR _suffix STREQUAL ".mm") - list(APPEND _moc_files ${_abs_current_FILE}) - endif(_suffix STREQUAL ".cpp" OR _suffix STREQUAL ".cc" OR _suffix STREQUAL ".cxx" OR _suffix STREQUAL ".C" OR _suffix STREQUAL ".mm") - endif(NOT _generated AND NOT _skip) - endforeach (_current_FILE) - - if(_moc_files OR _moc_headers) - set(_automoc_source "${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}.cpp") - get_directory_property(_moc_incs INCLUDE_DIRECTORIES) - get_directory_property(_moc_defs DEFINITIONS) - get_directory_property(_moc_cdefs COMPILE_DEFINITIONS) - - # configure_file replaces _moc_files, _moc_incs, _moc_cdefs and _moc_defs - set(_automocTargetDir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target_NAME}.dir/" ) - set(AM_TARGET_NAME ${_target_NAME}) - configure_file(${CMAKE_ROOT}/Modules/AutomocInfo.cmake.in ${_automocTargetDir}/AutomocInfo.cmake @ONLY) - - add_custom_target(${_target_NAME} - COMMAND ${CMAKE_COMMAND} -E cmake_automoc "${_automocTargetDir}" ) - - set_source_files_properties(${_automoc_source} PROPERTIES GENERATED TRUE) - get_directory_property(_extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES) - list(APPEND _extra_clean_files "${_automoc_source}") - set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${_extra_clean_files}") - set(${_SRCS} ${_automoc_source} ${${_SRCS}}) - endif(_moc_files OR _moc_headers) -endmacro(_ADD_AUTOMOC4_TARGET) - - -macro(AUTOMOC4_ADD_EXECUTABLE _target_NAME) - set(_SRCS ${ARGN}) - - set(_add_executable_param) - foreach(_argName "WIN32" "MACOSX_BUNDLE" "EXCLUDE_FROM_ALL") - list(FIND _SRCS ${_argName} _index) - if(_index GREATER -1) - list(APPEND _add_executable_param ${_argName}) - list(REMOVE_AT _SRCS ${_index}) - endif(_index GREATER -1) - endforeach(_argName) - - _add_automoc4_target("${_target_NAME}_automoc" _SRCS) - add_executable(${_target_NAME} ${_add_executable_param} ${_SRCS}) - add_dependencies(${_target_NAME} "${_target_NAME}_automoc") - -endmacro(AUTOMOC4_ADD_EXECUTABLE) - - -macro(AUTOMOC4_ADD_LIBRARY _target_NAME) - set(_SRCS ${ARGN}) - - set(_add_executable_param) - foreach(_argName "STATIC" "SHARED" "MODULE" "EXCLUDE_FROM_ALL") - list(FIND _SRCS ${_argName} _index) - if(_index GREATER -1) - list(APPEND _add_executable_param ${_argName}) - list(REMOVE_AT _SRCS ${_index}) - endif(_index GREATER -1) - endforeach(_argName) - - _add_automoc4_target("${_target_NAME}_automoc" _SRCS) - add_library(${_target_NAME} ${_add_executable_param} ${_SRCS}) - add_dependencies(${_target_NAME} "${_target_NAME}_automoc") -endmacro(AUTOMOC4_ADD_LIBRARY) - - -macro(_AUTOMOC4_KDE4_PRE_TARGET_HANDLING _target _srcs) - _add_automoc4_target("${_target}_automoc" ${_srcs}) -endmacro(_AUTOMOC4_KDE4_PRE_TARGET_HANDLING) - - -macro(_AUTOMOC4_KDE4_POST_TARGET_HANDLING _target) - add_dependencies(${_target} "${_target}_automoc") -endmacro(_AUTOMOC4_KDE4_POST_TARGET_HANDLING) From add30e9008fcb4d5277692958aac7f933539f983 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 17 Aug 2011 00:39:21 +0200 Subject: [PATCH 117/539] Fix build: non-void function must return a value Alex --- Source/cmQtAutomoc.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index e8c4baa243a..7e50064976a 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -168,7 +168,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory) delete gg; gg = NULL; makefile = NULL; - + return true; } From afb3edc18149f48be6e1690c7d9b1c8f6816a056 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 17 Aug 2011 00:49:12 +0200 Subject: [PATCH 118/539] Fix warnings Alex --- Source/cmQtAutomoc.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 7e50064976a..df09f3710ee 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -69,10 +69,9 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) std::string automocComment = "Automoc for target "; automocComment += targetName; - cmTarget* mocTarget = makefile->AddUtilityCommand(automocTargetName.c_str(), - true, - workingDirectory.c_str(), depends, - commandLines, false, automocComment.c_str()); + makefile->AddUtilityCommand(automocTargetName.c_str(), true, + workingDirectory.c_str(), depends, + commandLines, false, automocComment.c_str()); target->AddUtility(automocTargetName.c_str()); // configure a file to get all information to automoc at buildtime: @@ -713,9 +712,11 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, if (this->Verbose) { - for(int i=0; i::const_iterator cmdIt = command.begin(); + cmdIt != command.end(); + ++cmdIt) { - std::cout << command[i] << " "; + std::cout << *cmdIt << " "; } std::cout << std::endl; } From cd70f00ea473a97b3b210fb9fddbc283299d788a Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 17 Aug 2011 01:00:28 +0200 Subject: [PATCH 119/539] Fix #12358: make optionally enabling ASM work again Alex --- Modules/CMakeASMInformation.cmake | 2 +- Modules/CMakeTestASMCompiler.cmake | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index d50f351e503..b5f24203399 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -33,7 +33,7 @@ IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) IF(NOT _INCLUDED_FILE) IF("ASM${ASM_DIALECT}" STREQUAL "ASM") - MESSAGE(FATAL_ERROR "Did not find file Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}") + MESSAGE(STATUS "Warning: Did not find file Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}") ENDIF("ASM${ASM_DIALECT}" STREQUAL "ASM") INCLUDE(Platform/${CMAKE_BASE_NAME} OPTIONAL) ENDIF(NOT _INCLUDED_FILE) diff --git a/Modules/CMakeTestASMCompiler.cmake b/Modules/CMakeTestASMCompiler.cmake index 56cf3325ecc..294511d898b 100644 --- a/Modules/CMakeTestASMCompiler.cmake +++ b/Modules/CMakeTestASMCompiler.cmake @@ -18,8 +18,18 @@ # because otherwise there would have to be a separate assembler source file # for each assembler on every architecture. + +SET(_ASM_COMPILER_WORKS 0) + IF(CMAKE_ASM${ASM_DIALECT}_COMPILER) - SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_WORKS 1 CACHE INTERNAL "") -ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER) - SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_WORKS 0 CACHE INTERNAL "") -ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER) + SET(_ASM_COMPILER_WORKS 1) +ENDIF() + +# when using generic "ASM" support, we must have detected the compiler ID, fail otherwise: +IF("ASM${ASM_DIALECT}" STREQUAL "ASM") + IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + SET(_ASM_COMPILER_WORKS 0) + ENDIF() +ENDIF() + +SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_WORKS ${_ASM_COMPILER_WORKS} CACHE INTERNAL "") From afae7a95a06bf1cbec47b3b4471e5f11a41065cb Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 17 Aug 2011 02:34:23 +0200 Subject: [PATCH 120/539] Start testing expected values for compiler flags. Should help catch unhandled flag warnings so far not handled by check_cxx_compiler_flag FAIL_REGEXen. --- Tests/CMakeLists.txt | 2 + .../CheckCXXCompilerFlag/CMakeLists.txt | 63 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index eececb020d5..aad908cf9d6 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -223,6 +223,8 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader) + ADD_TEST_MACRO(Module.CheckCXXCompilerFlag CheckCXXCompilerFlag) + ADD_TEST(LinkFlags-prepare ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} --build-and-test diff --git a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt new file mode 100644 index 00000000000..70bafb6d7ac --- /dev/null +++ b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 2.8) +project(CheckCXXCompilerFlag) + +macro(TEST_FAIL value msg) + if (${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +macro(TEST_PASS value msg) + if (NOT ${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +if(CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) + string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") + # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the + # patch level, handle this here: + if(NOT _gcc_version) + string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") + endif() +endif() + +if(CMAKE_COMPILER_ID MATCHES Clang) + exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _clang_version_info) + string (REGEX MATCH "version [345]\\.[0-9]" _clang_version "${_clang_version_info}") +endif() + +message("Platform:\n WIN32: ${WIN32}\n UNIX: ${UNIX}\n APPLE: ${APPLE}\n MINGW: ${MINGW}\n CYGWIN: ${CYGWIN}\n" + " MSVC: ${MSVC}\n MSVC60: ${MSVC60}\n MSVC70: ${MSVC70}\n MSVC71: ${MSVC71}\n MSVC80: ${MSVC80}\n MSVC90: ${MSVC90}\n MSVC10: ${MSVC10}\n" + " GCC: ${_gcc_version}\n" + " Clang: ${_clang_version}\n" +) + +include(CheckCXXCompilerFlag) + +check_cxx_compiler_flag(-fvisibility=hidden HAS_HIDDEN_VISIBILITY) + +message("HAS_HIDDEN_VISIBILITY: ${HAS_HIDDEN_VISIBILITY}\n\nCOMPILE OUTPUT:\n${OUTPUT}") + +if(CMAKE_COMPILER_IS_GNUCXX) + test_pass(HAS_HIDDEN_VISIBILITY "GCC should support hidden visibility, but does not.") +else() + message("Unhandled Platform") +endif() + +# +# This is a no-op executable... If this test is going to fail, it fails during +# the configure step while cmake is configuring this CMakeLists.txt file... +# + +file(WRITE + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + "int main() { return 0; } +" +) + +add_executable( + CheckCXXCompilerFlag + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" +) From a9a8b9e8d194eb78cf5fb74fb902a0cf233f8ac0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 17 Aug 2011 02:40:56 +0200 Subject: [PATCH 121/539] Exclude win32 from hidden visibility checks. --- Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt index 70bafb6d7ac..7775e147c20 100644 --- a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt +++ b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt @@ -41,7 +41,9 @@ check_cxx_compiler_flag(-fvisibility=hidden HAS_HIDDEN_VISIBILITY) message("HAS_HIDDEN_VISIBILITY: ${HAS_HIDDEN_VISIBILITY}\n\nCOMPILE OUTPUT:\n${OUTPUT}") if(CMAKE_COMPILER_IS_GNUCXX) - test_pass(HAS_HIDDEN_VISIBILITY "GCC should support hidden visibility, but does not.") + if(NOT WIN32) + test_pass(HAS_HIDDEN_VISIBILITY "GCC should support hidden visibility, but does not.") + endif() else() message("Unhandled Platform") endif() From b6ee2ee03addc4b22dfba6aeae27719c139e0727 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 17 Aug 2011 02:41:28 +0200 Subject: [PATCH 122/539] Comment the test assertion for now At least until I know which gcc versions do not pass. --- Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt index 7775e147c20..8294c8f383d 100644 --- a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt +++ b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt @@ -42,7 +42,7 @@ message("HAS_HIDDEN_VISIBILITY: ${HAS_HIDDEN_VISIBILITY}\n\nCOMPILE OUTPUT:\n${O if(CMAKE_COMPILER_IS_GNUCXX) if(NOT WIN32) - test_pass(HAS_HIDDEN_VISIBILITY "GCC should support hidden visibility, but does not.") +# test_pass(HAS_HIDDEN_VISIBILITY "GCC should support hidden visibility, but does not.") endif() else() message("Unhandled Platform") From 721133dc45d9f15153e6df3ba86f9c2353d93913 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 17 Aug 2011 00:01:04 -0400 Subject: [PATCH 123/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 162039301c3..c8bc9595bdd 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 16) +SET(KWSYS_DATE_STAMP_DAY 17) From a493d1a35305d26e9c360f82b969adde1dfd64ae Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 17 Aug 2011 13:32:20 +0200 Subject: [PATCH 124/539] Test the correct cxx variable. --- Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt index 8294c8f383d..fcffa8778f1 100644 --- a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt +++ b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt @@ -23,7 +23,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) endif() endif() -if(CMAKE_COMPILER_ID MATCHES Clang) +if(CMAKE_CXX_COMPILER_ID MATCHES Clang) exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _clang_version_info) string (REGEX MATCH "version [345]\\.[0-9]" _clang_version "${_clang_version_info}") endif() From aa4f0b6ba813c69e73d66c51ece183e8e97f622b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 17 Aug 2011 13:32:48 +0200 Subject: [PATCH 125/539] Fix the version extraction regex for clang. --- Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt index fcffa8778f1..7d529121503 100644 --- a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt +++ b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt @@ -25,7 +25,7 @@ endif() if(CMAKE_CXX_COMPILER_ID MATCHES Clang) exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _clang_version_info) - string (REGEX MATCH "version [345]\\.[0-9]" _clang_version "${_clang_version_info}") + string (REGEX REPLACE ".*version ([0-9]\\.[0-9]).*" "\\1" _clang_version "${_clang_version_info}") endif() message("Platform:\n WIN32: ${WIN32}\n UNIX: ${UNIX}\n APPLE: ${APPLE}\n MINGW: ${MINGW}\n CYGWIN: ${CYGWIN}\n" From bf73e759413d33f7d2950ecb46530cffebfbd333 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 17 Aug 2011 13:37:57 +0200 Subject: [PATCH 126/539] Hopefully add version extraction for Intel. --- Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt index 7d529121503..0133f8e0767 100644 --- a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt +++ b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt @@ -28,10 +28,16 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Clang) string (REGEX REPLACE ".*version ([0-9]\\.[0-9]).*" "\\1" _clang_version "${_clang_version_info}") endif() +if(CMAKE_CXX_COMPILER_ID MATCHES Intel) + exec_program(${CMAKE_CXX_COMPILER} ARGS -V OUTPUT_VARIABLE _intel_version_info) + string (REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" _intel_version "${_intel_version_info}") +endif() + message("Platform:\n WIN32: ${WIN32}\n UNIX: ${UNIX}\n APPLE: ${APPLE}\n MINGW: ${MINGW}\n CYGWIN: ${CYGWIN}\n" " MSVC: ${MSVC}\n MSVC60: ${MSVC60}\n MSVC70: ${MSVC70}\n MSVC71: ${MSVC71}\n MSVC80: ${MSVC80}\n MSVC90: ${MSVC90}\n MSVC10: ${MSVC10}\n" " GCC: ${_gcc_version}\n" " Clang: ${_clang_version}\n" + " Intel: ${_intel_version}\n" ) include(CheckCXXCompilerFlag) From a147a069a533e24d749412f471aaac911cfdb573 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 17 Aug 2011 14:03:12 +0200 Subject: [PATCH 127/539] Add some settings for non-truncation of test output. --- Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt index 0133f8e0767..fa48a48113b 100644 --- a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt +++ b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 2.8) project(CheckCXXCompilerFlag) +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +set(CMAKE_VERBOSE_MAKEFILE 1) + macro(TEST_FAIL value msg) if (${value}) message (SEND_ERROR "Test fail:" ${msg} ${Out} ) From 71c29d11b3d089dbc9fb403ceed7999419615810 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 17 Aug 2011 17:08:50 +0200 Subject: [PATCH 128/539] Fix bootstrap test with automoc Alex --- Source/cmGlobalGenerator.cxx | 2 ++ Source/cmake.cxx | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3016f5a6806..27acf987790 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -958,6 +958,7 @@ bool cmGlobalGenerator::CheckTargets() //---------------------------------------------------------------------------- void cmGlobalGenerator::CreateAutomocTargets() { +#ifdef CMAKE_BUILD_WITH_CMAKE for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) { cmTargets& targets = @@ -979,6 +980,7 @@ void cmGlobalGenerator::CreateAutomocTargets() } } } +#endif } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index c5eff1c7ee9..99b184463c3 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1573,14 +1573,13 @@ int cmake::ExecuteCMakeCommand(std::vector& args) { return cmake::ExecuteEchoColor(args); } -#endif - else if (args[1] == "cmake_automoc") { cmQtAutomoc automoc; automoc.Run(args[2].c_str()); return 0; } +#endif // Tar files else if (args[1] == "tar" && args.size() > 3) From ab57ff6156a725664fce995a9460de839018405c Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 17 Aug 2011 22:51:57 +0200 Subject: [PATCH 129/539] Make the --find-package test harder Now it is guaranteed that the include paths always contain a space. This should make the cont. build fail. Alex --- Tests/FindPackageModeMakefileTest/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in index 6bcd9b69582..2d4301a3d36 100644 --- a/Tests/FindPackageModeMakefileTest/Makefile.in +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -1,10 +1,10 @@ all: clean pngtest main.o: main.cpp - "@CMAKE_CXX_COMPILER@" -c `"@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE` main.cpp + "@CMAKE_CXX_COMPILER@" -c $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE) main.cpp pngtest: main.o - "@CMAKE_CXX_COMPILER@" -o pngtest main.o `"@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK` + "@CMAKE_CXX_COMPILER@" -o pngtest main.o $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK) clean: rm -f *.o pngtest From 301114994773e62b82965f3082fef6dd23532e60 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 17 Aug 2011 22:53:35 +0200 Subject: [PATCH 130/539] Make the test harder by always having a space in the include dirs The commit message for the previous commit was wrong, it should have been: fix the test by using $(shell ...) syntax instead of backticks in the Makefile. With backticks I couldn't get the quoting right. Printing -I"/some/path with space" did not work, the compiler complained that there is not file "with". Also backslashes in different numbers did not make it work. Alex --- Tests/FindPackageModeMakefileTest/FindFoo.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in b/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in index c6230abb877..dc62bac4164 100644 --- a/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in +++ b/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in @@ -3,6 +3,7 @@ find_library(FOO_LIBRARY NAMES foo HINTS "@CMAKE_CURRENT_BINARY_DIR@" ) find_path(FOO_INCLUDE_DIR NAMES foo.h HINTS "@CMAKE_CURRENT_SOURCE_DIR@" ) set(FOO_LIBRARIES ${FOO_LIBRARY}) +set(FOO_INCLUDE_DIRS "${FOO_INCLUDE_DIR}" "/some/path/with a space/include" ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Foo DEFAULT_MSG FOO_LIBRARY FOO_INCLUDE_DIR ) From 7d693108faa0df924944eb2b5ced210d735d75b1 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 17 Aug 2011 23:44:34 +0200 Subject: [PATCH 131/539] Only enable the test when using GNU make The makefile used in the test uses $(shell ...), which is AFAIK a GNU extension, and will probably not work e.g. with OpenBSD make. According to the FreeBSD make manpage their make has a != assignment, which seems to do something similar, but I don't have such a system around for testing. Also, the point of this test is not to write a portable makefile, but to check whether cmake --find-package prints a correct string. Alex --- .../CMakeLists.txt | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index 17f02b4d379..def8d63ec7a 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -1,20 +1,30 @@ -# the test program links against the png lib, so test first whether it exists if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") - # build a library which we can search during the test - add_library(foo STATIC foo.cpp) + # Test whether the make is GNU make, and only add the test in this case, + # since the configured makefile in this test uses $(shell ...), which + # is AFAIK a GNU make extension. Alex + execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} -v + OUTPUT_VARIABLE makeVersionOutput + TIMEOUT 10) + string(TOUPPER "${makeVersionOutput}" MAKE_VERSION_OUTPUT) + if("${MAKE_VERSION_OUTPUT}" MATCHES ".*GNU MAKE.*") - # configure a FindFoo.cmake so it knows where the library can be found - configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY) + # build a library which we can search during the test + add_library(foo STATIC foo.cpp) - # now set up the test: - get_target_property(cmakeExecutable cmake LOCATION) + # configure a FindFoo.cmake so it knows where the library can be found + configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) + # now set up the test: + get_target_property(cmakeExecutable cmake LOCATION) - add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile ) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) + + add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile ) + + endif() endif() From 678e12448140017f7b64c6307afb53b500910f46 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 18 Aug 2011 00:16:02 +0200 Subject: [PATCH 132/539] Only enable the automoc test after checking that Qt4 works On some systems which contribute nightly builds there were strange errors which seemed to hint that the installed Qt4 is not usable/ not usable with this compiler. So first check whether it works, and only if this was successful, enable the test. Alex --- Tests/CMakeLists.txt | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 7bf4ddb34d8..b1db40d7641 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -845,18 +845,37 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ENDIF(NOT QT4_FOUND) IF(QT4_FOUND) - ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/QtAutomoc" - "${CMake_BINARY_DIR}/Tests/QtAutomoc" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project QtAutomoc - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc" - --force-new-ctest-process - --test-command ${CMAKE_CTEST_COMMAND} -V - ) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc") + # test whether the Qt4 which has been found works, on some machines + # which run nightly builds there were errors like "wrong file format" + # for libQtCore.so. So first check it works, and only if it does add + # the automoc test. + INCLUDE(CheckCXXSourceCompiles) + SET(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") + SET(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + SET(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES}) + SET(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES}) + + CHECK_CXX_SOURCE_COMPILES("#include \n int main() {return (qApp == 0 ? 0 : 1); }\n" + QT4_WORKS_FOR_AUTOMOC_TEST) + + SET(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}") + SET(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}") + + IF(QT4_WORKS_FOR_AUTOMOC_TEST) + ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutomoc" + "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project QtAutomoc + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --force-new-ctest-process + --test-command ${CMAKE_CTEST_COMMAND} -V + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc") + ENDIF() ENDIF() ADD_TEST(ExternalProject ${CMAKE_CTEST_COMMAND} From d7184e0e4dc22163b4564d93634736a145ac2c4d Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 18 Aug 2011 00:01:06 -0400 Subject: [PATCH 133/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index c8bc9595bdd..49876effd6e 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 17) +SET(KWSYS_DATE_STAMP_DAY 18) From 42154ec01cc6250097880c6c13ea5bba88e3a6b0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 18 Aug 2011 13:29:06 +0200 Subject: [PATCH 134/539] Fix up the regex command for Intel. --- Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt index fa48a48113b..77f50060f65 100644 --- a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt +++ b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt @@ -33,7 +33,7 @@ endif() if(CMAKE_CXX_COMPILER_ID MATCHES Intel) exec_program(${CMAKE_CXX_COMPILER} ARGS -V OUTPUT_VARIABLE _intel_version_info) - string (REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" _intel_version "${_intel_version_info}") + string (REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1" _intel_version "${_intel_version_info}") endif() message("Platform:\n WIN32: ${WIN32}\n UNIX: ${UNIX}\n APPLE: ${APPLE}\n MINGW: ${MINGW}\n CYGWIN: ${CYGWIN}\n" From 3ca1df8e59e7d18fffc1d9f39194315b057ececa Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 18 Aug 2011 12:18:30 -0400 Subject: [PATCH 135/539] Use MSBuild when devenv is not around, since VCExpress seems broken. To support Intel Fortran, CMake started using devenv and VCExpress for build tools with VS2010. However, VCExpress does not always work. This change makes CMake use MSBuild when devenv is not found. This should be OK, since Intel Fortran can not be used with VCExpress. --- Modules/CMakeVS10FindMake.cmake | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Modules/CMakeVS10FindMake.cmake b/Modules/CMakeVS10FindMake.cmake index 388203cabb0..695e92f5230 100644 --- a/Modules/CMakeVS10FindMake.cmake +++ b/Modules/CMakeVS10FindMake.cmake @@ -12,14 +12,11 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -# VCExpress does not support cross compiling, which is necessary for Win CE -SET( _CMAKE_MAKE_PROGRAM_NAMES devenv) -IF(NOT CMAKE_CROSSCOMPILING) - SET( _CMAKE_MAKE_PROGRAM_NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} VCExpress) -ENDIF(NOT CMAKE_CROSSCOMPILING) - +# Look for devenv as a build program. We need to use this to support +# Intel Fortran integration into VS. MSBuild can not be used for that case +# since Intel Fortran uses the older devenv file format. FIND_PROGRAM(CMAKE_MAKE_PROGRAM - NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} + NAMES devenv HINTS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VS;EnvironmentDirectory] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup;Dbghelp_path] @@ -34,6 +31,24 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM "/Program Files/Microsoft Visual Studio 10.0/Common7/IDE/" "/Program Files/Microsoft Visual Studio 10/Common7/IDE/" ) + +# if devenv is not found, then use MSBuild. +# it is expected that if devenv is not found, then we are +# dealing with Visual Studio Express. VCExpress has random +# failures when being run as a command line build tool which +# causes the compiler checks and try-compile stuff to fail. MSbuild +# is a better choice for this. However, VCExpress does not support +# cross compiling needed for Win CE. +IF(NOT CMAKE_CROSSCOMPILING) + FIND_PROGRAM(CMAKE_MAKE_PROGRAM + NAMES MSBuild + HINTS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VS;ProductDir] + "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;CLR Version]/" + "c:/WINDOWS/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;CLR Version]/" + "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0;CLR Version]/") +ENDIF() + MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) SET(MSVC10 1) SET(MSVC_VERSION 1600) From 43869188af1648218d506555b2e6ac7e4a92494c Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 18 Aug 2011 18:39:05 +0200 Subject: [PATCH 136/539] Fix line length Alex --- Source/cmake.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8cadc4f757f..cc9dd8f2d82 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -618,7 +618,8 @@ bool cmake::FindPackage(const std::vector& args) libIt != libList.end(); ++libIt) { - mf->AddLinkLibraryForTarget(targetName, libIt->c_str(), cmTarget::GENERAL); + mf->AddLinkLibraryForTarget(targetName, libIt->c_str(), + cmTarget::GENERAL); } From a6ccf3cb6552f8f2b7b6adaf419a278efd085ac3 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 18 Aug 2011 18:43:33 +0200 Subject: [PATCH 137/539] Use $(CXXFLAGS) and $(LDFLAGS) in the --find-package test Makefile This should make the test succeed in the coverage builds, where CXXFLAGS and LDFLAGS are set accordingly. Alex --- Tests/FindPackageModeMakefileTest/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in index 2d4301a3d36..073d82ec78b 100644 --- a/Tests/FindPackageModeMakefileTest/Makefile.in +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -1,10 +1,10 @@ all: clean pngtest main.o: main.cpp - "@CMAKE_CXX_COMPILER@" -c $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE) main.cpp + "@CMAKE_CXX_COMPILER@" $(CXXFLAGS) -c $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE) main.cpp pngtest: main.o - "@CMAKE_CXX_COMPILER@" -o pngtest main.o $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK) + "@CMAKE_CXX_COMPILER@" $(LDFLAGS) -o pngtest main.o $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK) clean: rm -f *.o pngtest From 1879bcc09cb180efec041ccd5b1e42c47b790084 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 18 Aug 2011 18:53:14 +0200 Subject: [PATCH 138/539] Fix build: use std::ios::out|ios::trunc instead of std::ios_base::out Alex --- Source/cmQtAutomoc.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index df09f3710ee..7dd450e0195 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -245,7 +245,7 @@ void cmQtAutomoc::WriteOldMocDefinitionsFile(const char* targetDirectory) std::fstream outfile; outfile.open(filename.c_str(), - std::ios_base::out | std::ios_base::trunc); + std::ios::out | std::ios::trunc); outfile << "set(AM_OLD_MOC_DEFINITIONS \"" << this->Join(this->MocDefinitions, ' ') << "\")\n"; @@ -477,7 +477,7 @@ bool cmQtAutomoc::RunAutomocQt4() // source file that includes all remaining moc files (_automoc.cpp file) std::fstream outfile; outfile.open(this->OutMocCppFilename.c_str(), - std::ios_base::out | std::ios_base::trunc); + std::ios::out | std::ios::trunc); outfile << automocSource; outfile.close(); From 71165e943edb3ba80a0533a640ff6abffb4bcf64 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 18 Aug 2011 19:34:49 +0200 Subject: [PATCH 139/539] Silence warning in automoc: use long instead of int Alex --- Source/cmQtAutomoc.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 7dd450e0195..e5dc3df62a5 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -519,7 +519,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, const std::string absPath = cmsys::SystemTools::GetFilenamePath( cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; - int matchOffset = 0; + long matchOffset = 0; if (!mocIncludeRegExp.find(contentsString.c_str())) { // no moc #include, look whether we need to create a moc from From e78ce44b3598807bd401494d484601d9f43bd8b4 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 18 Aug 2011 19:35:41 +0200 Subject: [PATCH 140/539] Fix automoc with VS builds: apply patch from Bill This patch moves the creation of VS GUIDs from the final pass to AddHelperCommands() and should fix the failing automoc tests with VS. Alex --- Source/cmGlobalVisualStudio7Generator.cxx | 12 ------- Source/cmGlobalVisualStudio7Generator.h | 3 -- Source/cmLocalVisualStudio7Generator.cxx | 44 +++++++++++------------ Source/cmLocalVisualStudio7Generator.h | 1 - 4 files changed, 21 insertions(+), 39 deletions(-) diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 51b89184998..84e7f1bcc97 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -739,18 +739,6 @@ ::GetDocumentation(cmDocumentationEntry& entry) const entry.Full = ""; } -// make sure "special" targets have GUID's -void cmGlobalVisualStudio7Generator::Configure() -{ - cmGlobalGenerator::Configure(); - this->CreateGUID("ALL_BUILD"); - this->CreateGUID("INSTALL"); - this->CreateGUID("RUN_TESTS"); - this->CreateGUID("EDIT_CACHE"); - this->CreateGUID("REBUILD_CACHE"); - this->CreateGUID("PACKAGE"); -} - //---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index b6c84e8ffcd..7f19d8301ca 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -80,9 +80,6 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator void CreateGUID(const char* name); std::string GetGUID(const char* name); - ///! do configure step - virtual void Configure(); - /** Append the subdirectory for the given configuration. */ virtual void AppendDirectoryForConfig(const char* prefix, const char* config, diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 3e76f592dbf..372e6446393 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -68,6 +68,27 @@ void cmLocalVisualStudio7Generator::AddHelperCommands() lang.insert("DEF"); lang.insert("Fortran"); this->CreateCustomTargetsAndCommands(lang); + + // Now create GUIDs for targets + cmTargets &tgts = this->Makefile->GetTargets(); + + cmGlobalVisualStudio7Generator* gg = + static_cast(this->GlobalGenerator); + for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) + { + const char* path = l->second.GetProperty("EXTERNAL_MSPROJECT"); + if(path) + { + this->ReadAndStoreExternalGUID( + l->second.GetName(), path); + } + else + { + gg->CreateGUID(l->first.c_str()); + } + } + + this->FixGlobalTargets(); } @@ -2021,29 +2042,6 @@ void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID( } -void cmLocalVisualStudio7Generator::ConfigureFinalPass() -{ - cmLocalGenerator::ConfigureFinalPass(); - cmTargets &tgts = this->Makefile->GetTargets(); - - cmGlobalVisualStudio7Generator* gg = - static_cast(this->GlobalGenerator); - for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) - { - const char* path = l->second.GetProperty("EXTERNAL_MSPROJECT"); - if(path) - { - this->ReadAndStoreExternalGUID( - l->second.GetName(), path); - } - else - { - gg->CreateGUID(l->first.c_str()); - } - } - -} - //---------------------------------------------------------------------------- std::string cmLocalVisualStudio7Generator ::GetTargetDirectory(cmTarget const& target) const diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 4fdbc582a59..d1b5b0037f9 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -57,7 +57,6 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator void SetVersion8() {this->Version = 8;} void SetVersion9() {this->Version = 9;} void SetPlatformName(const char* n) { this->PlatformName = n;} - virtual void ConfigureFinalPass(); void GetTargetObjectFileDirectories(cmTarget* target, std::vector& dirs); From eb02acb695ed257093af0375a0ca5acbb9034985 Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 18 Aug 2011 16:51:52 -0400 Subject: [PATCH 141/539] VS10: Avoid unnecessary rebuilds for custom commands Thanks to James Bigler for pointing this out on the cmake-developers mailing list... --- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8cba84c550d..551b0adef71 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -437,7 +437,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, (*this->BuildFileStream ) << sep << out; sep = ";"; } - (*this->BuildFileStream ) << ";%(Outputs)\n"; + (*this->BuildFileStream ) << "\n"; } this->WriteString("\n", 2); } From 8971c0d8d287cc0024cc0a5ea12c947adfda207c Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 19 Aug 2011 00:01:13 -0400 Subject: [PATCH 142/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 49876effd6e..c30072a51a6 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 18) +SET(KWSYS_DATE_STAMP_DAY 19) From bda4148a571d969700e018d89a95547908075bec Mon Sep 17 00:00:00 2001 From: Johan Bjork Date: Thu, 18 Aug 2011 18:28:15 +0200 Subject: [PATCH 143/539] Xcode: Remove PREBINDING attribute for Xcode 4 and above PREBINDING is obsolete in Xcode 4 and causes warnings if present. Do not emit it for Xcode >= 4.0 --- Source/cmGlobalXCodeGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index fd9dacd1aff..739679125a8 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1758,7 +1758,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, default: break; } - if(this->XcodeVersion >= 22) + if(this->XcodeVersion >= 22 && this->XcodeVersion < 40) { buildSettings->AddAttribute("PREBINDING", this->CreateString("NO")); From b00463f06c80529f02c489872458345790f6cd48 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 19 Aug 2011 12:30:36 -0400 Subject: [PATCH 144/539] QtAutomoc test: Pass QT_QMAKE_EXECUTABLE ...in case qmake is not in the PATH --- Tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index b1db40d7641..9d8a09151ce 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -872,6 +872,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc" --force-new-ctest-process + --build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} --test-command ${CMAKE_CTEST_COMMAND} -V ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc") From 920a046015799a14374e5c69072aa14f2723fda0 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 19 Aug 2011 14:16:53 -0400 Subject: [PATCH 145/539] QtAutomoc: Eliminate compiler warning --- Source/cmQtAutomoc.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index e5dc3df62a5..ff96e5b9fde 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -519,7 +519,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, const std::string absPath = cmsys::SystemTools::GetFilenamePath( cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; - long matchOffset = 0; + std::string::size_type matchOffset = 0; if (!mocIncludeRegExp.find(contentsString.c_str())) { // no moc #include, look whether we need to create a moc from From 02e2f3e35049f9d09d503bd789e2042b7a2b9e62 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 20 Aug 2011 00:01:04 -0400 Subject: [PATCH 146/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index c30072a51a6..6a72f0f20fe 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 19) +SET(KWSYS_DATE_STAMP_DAY 20) From 7dcbb663157858fe4fc73adce4ad23ffd370bb2e Mon Sep 17 00:00:00 2001 From: David Cole Date: Sat, 20 Aug 2011 12:26:30 -0400 Subject: [PATCH 147/539] KWSys: Remove translation path for "/tmp_mnt/" (#10595) In SystemTools::ClassInitialize, remove call to AddTranslationPath that was originally put in place to "work around an SGI problem." This code precluded using CMake effectively in valid directories under "/tmp_mnt/" --- Source/kwsys/SystemTools.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index c4aff4ac68c..695949a34bc 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -4573,8 +4573,6 @@ void SystemTools::ClassInitialize() // for windows because drive letters need to be maintained. Also, // there are not sym-links and mount points on windows anyway. #if !defined(_WIN32) || defined(__CYGWIN__) - // Work-around an SGI problem by always adding this mapping: - SystemTools::AddTranslationPath("/tmp_mnt/", "/"); // The tmp path is frequently a logical path so always keep it: SystemTools::AddKeepPath("/tmp/"); From fd61be71401ef9e0a241562fc31539273084deff Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 25 Apr 2011 11:33:15 -0400 Subject: [PATCH 148/539] FindThreads: Try pthreads with no special option first (#11333) QNX has the phtread stuff in the standard library. The best way would IMHO be to check if a program that uses pthread_* can be successfully linked without specifying any linker option before trying out the different flags. --- Modules/FindThreads.cmake | 47 +++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index a6c2df89baa..21614fb66d0 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -23,6 +23,7 @@ INCLUDE (CheckIncludeFiles) INCLUDE (CheckLibraryExists) +INCLUDE (CheckSymbolExists) SET(Threads_FOUND FALSE) # Do we have sproc? @@ -44,33 +45,41 @@ ELSE() # SET(CMAKE_HAVE_THREADS_LIBRARY) IF(NOT THREADS_HAVE_PTHREAD_ARG) - - # Do we have -lpthreads - CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE) - IF(CMAKE_HAVE_PTHREADS_CREATE) - SET(CMAKE_THREAD_LIBS_INIT "-lpthreads") + # Check if pthread functions are in normal C library + CHECK_SYMBOL_EXISTS(pthread_create pthread.h CMAKE_HAVE_LIBC_CREATE) + IF(CMAKE_HAVE_LIBC_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "") SET(CMAKE_HAVE_THREADS_LIBRARY 1) SET(Threads_FOUND TRUE) ENDIF() - # Ok, how about -lpthread - CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) - IF(CMAKE_HAVE_PTHREAD_CREATE) - SET(CMAKE_THREAD_LIBS_INIT "-lpthread") - SET(Threads_FOUND TRUE) - SET(CMAKE_HAVE_THREADS_LIBRARY 1) - ENDIF() + IF(NOT CMAKE_HAVE_THREADS_LIBRARY) + # Do we have -lpthreads + CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE) + IF(CMAKE_HAVE_PTHREADS_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lpthreads") + SET(CMAKE_HAVE_THREADS_LIBRARY 1) + SET(Threads_FOUND TRUE) + ENDIF() - IF(CMAKE_SYSTEM MATCHES "SunOS.*") - # On sun also check for -lthread - CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE) - IF(CMAKE_HAVE_THR_CREATE) - SET(CMAKE_THREAD_LIBS_INIT "-lthread") + # Ok, how about -lpthread + CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) + IF(CMAKE_HAVE_PTHREAD_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lpthread") SET(CMAKE_HAVE_THREADS_LIBRARY 1) SET(Threads_FOUND TRUE) ENDIF() - ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*") + IF(CMAKE_SYSTEM MATCHES "SunOS.*") + # On sun also check for -lthread + CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE) + IF(CMAKE_HAVE_THR_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lthread") + SET(CMAKE_HAVE_THREADS_LIBRARY 1) + SET(Threads_FOUND TRUE) + ENDIF() + ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*") + ENDIF(NOT CMAKE_HAVE_THREADS_LIBRARY) ENDIF(NOT THREADS_HAVE_PTHREAD_ARG) IF(NOT CMAKE_HAVE_THREADS_LIBRARY) @@ -111,7 +120,7 @@ ELSE() ENDIF(CMAKE_HAVE_PTHREAD_H) ENDIF() -IF(CMAKE_THREAD_LIBS_INIT) +IF(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE) SET(CMAKE_USE_PTHREADS_INIT 1) SET(Threads_FOUND TRUE) ENDIF() From 3848b397ef6cae97ca28826582c0567cbe5a8ec0 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 21 Aug 2011 00:01:03 -0400 Subject: [PATCH 149/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 6a72f0f20fe..e9ea24bc41a 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 20) +SET(KWSYS_DATE_STAMP_DAY 21) From 29b285c6a1b583f56257f3ca8113d6ce29f5d8d6 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 22 Aug 2011 00:01:03 -0400 Subject: [PATCH 150/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index e9ea24bc41a..dbdb6e2020c 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 21) +SET(KWSYS_DATE_STAMP_DAY 22) From 98472e45c86d0b8592e0a6361d392bfab921b3a0 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 22 Aug 2011 21:23:55 +0200 Subject: [PATCH 151/539] Require the current cmake version in --find-package mode This fixes the problem that otherwise Platforms/CYGWIN.cmake doesn't know whether it should set WIN32 or not. Now it uses always the current behaviour. Alex --- Modules/CMakeFindPackageMode.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index a8674aad378..e0b588537a4 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -37,6 +37,9 @@ if(NOT MODE) message(FATAL_ERROR "MODE argument not specified. Use either EXIST, COMPILE or LINK.") endif() +# require the current version. If we don't do this, Platforms/CYGWIN.cmake complains because +# it doesn't know whether it should set WIN32 or not: +cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} ) include(CMakeDetermineSystem) From 6b3993b0bfaeb18ea93367006a9512ecc7f159b4 Mon Sep 17 00:00:00 2001 From: David Cole Date: Mon, 22 Aug 2011 15:48:26 -0400 Subject: [PATCH 152/539] CheckSymbolExists: Use IMMEDIATE flag for configure_file (#11333) The test "complex" sets the variable CMAKE_BACKWARDS_COMPATIBILITY to 1.4. When that variable is set, configure_file does not default to IMMEDIATE mode processing. And so, the output file likely does not exist yet by the time the next line in the CMakeLists.txt file is processed. When that next line is "try_compile" on that file, this is a problem. Fix the problem by explicitly using IMMEDIATE in the configure_file call. This problem was quite mysterious, as it only showed up on the "complex" test, when the previous commit introduced a CheckSymbolExists call into the FindThreads module. Which is not even explicitly included in the "complex" test... FindThreads gets included indirectly only as a side effect of setting CMAKE_BACKWARDS_COMPATIBILITY to 1.4 and even then it's included indirectly by auto-inclusion of CMakeBackwardCompatibilityC.cmake... Wow. Just wow. --- Modules/CheckSymbolExists.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index be7d65804a0..183b2bbe6b6 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -63,7 +63,7 @@ MACRO(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE) "${CMAKE_CONFIGURABLE_FILE_CONTENT}\nvoid cmakeRequireSymbol(int dummy,...){(void)dummy;}\nint main()\n{\n#ifndef ${SYMBOL}\n cmakeRequireSymbol(0,&${SYMBOL});\n#endif\n return 0;\n}\n") CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" - "${SOURCEFILE}" @ONLY) + "${SOURCEFILE}" @ONLY IMMEDIATE) MESSAGE(STATUS "Looking for ${SYMBOL}") TRY_COMPILE(${VARIABLE} From 59238dc2deb80f3f3d101de9a3945f890981a2c0 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Mon, 22 Aug 2011 21:53:22 +0200 Subject: [PATCH 153/539] Fix --find-package mode on Cygwin, where enable_language(RC) is called In --find-package mode we can't enable a language, since a lot of stuff has not been set up, e.g. which make tool to use. So disable enable_language() in this mode. Alex --- Modules/CMakeFindPackageMode.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake index e0b588537a4..42965773ab4 100644 --- a/Modules/CMakeFindPackageMode.cmake +++ b/Modules/CMakeFindPackageMode.cmake @@ -41,6 +41,12 @@ endif() # it doesn't know whether it should set WIN32 or not: cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} ) +macro(ENABLE_LANGUAGE) + # disable the enable_language() command, otherwise --find-package breaks on Windows. + # On Windows, enable_language(RC) is called in the platform files unconditionally. + # But in --find-package mode, we don't want (and can't) enable any language. +endmacro() + include(CMakeDetermineSystem) # short-cut some tests on Darwin, see Darwin-GNU.cmake: From fe46e7e4866bd1a7678e1381da02df8c9f533aa0 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 23 Aug 2011 00:01:04 -0400 Subject: [PATCH 154/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index dbdb6e2020c..15abe5ad61d 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 22) +SET(KWSYS_DATE_STAMP_DAY 23) From 20980ef56a847fec7922983257fd5be467b689bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Thu, 14 Jul 2011 11:16:00 +0200 Subject: [PATCH 155/539] Search for the installed python interpreter first The old approach to determine the python executeable chooses the newest version from _Python_VERSIONS if no additonal versions are passed. With python it is possible to install different versions side-by-side. Therefore a user can install e.g. python 2.5 and 2.7. Python 2.7 maybe only installed for testing new features and 2.5 for building and running his software. Thus the default installation for the user would be python 2.5 and then returning PYTHON_EXECUTEABLE python2.7 would be wrong. The new approuch searches first for the the default python executable e.g. /usr/bin/python on unix and if it can't be found _Python_VERSIONS is used. --- Modules/FindPythonInterp.cmake | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 46cde437f56..871d66687dc 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -20,6 +20,8 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +find_program(PYTHON_EXECUTABLE NAMES python) + # Set up the versions we know about, in the order we will search. Always add # the user supplied additional versions to the front. set(_Python_VERSIONS @@ -27,19 +29,18 @@ set(_Python_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) # Run first with the Python version in the executable -foreach(_CURRENT_VERSION ${_Python_VERSIONS}) - set(_Python_NAMES python${_CURRENT_VERSION}) - if(WIN32) - list(APPEND _Python_NAMES python) - endif() - find_program(PYTHON_EXECUTABLE - NAMES ${_Python_NAMES} - PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] - ) -endforeach() -# Now without any version if we still haven't found it + if(NOT PYTHON_EXECUTABLE) - find_program(PYTHON_EXECUTABLE NAMES python) + foreach(_CURRENT_VERSION ${_Python_VERSIONS}) + set(_Python_NAMES python${_CURRENT_VERSION}) + if(WIN32) + list(APPEND _Python_NAMES python) + endif() + find_program(PYTHON_EXECUTABLE + NAMES ${_Python_NAMES} + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] + ) + endforeach() endif() From 4fd1e28495e09af154f361602d30a0c5fc998ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Thu, 14 Jul 2011 11:43:47 +0200 Subject: [PATCH 156/539] Determine python version Use PYTHON_EXECUTABLE to determine PYTHON_VERSION_STRING, PYTHON_VERSION_MINOR, PYTHON_VERSION_MAJOR and PYTHON_VERSION_PATCH --- Modules/FindPythonInterp.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 871d66687dc..934602d4fbc 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -43,6 +43,13 @@ if(NOT PYTHON_EXECUTABLE) endforeach() endif() +if(PYTHON_EXECUTABLE) + execute_process(COMMAND "${PYTHON_EXECUTABLE}" --version ERROR_VARIABLE _VERSION OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE) + string(REPLACE "Python " "" PYTHON_VERSION_STRING "${_VERSION}") + string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}") + string(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}") + string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION_STRING}") +endif() # handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if # all listed variables are TRUE From d1795002956f8da746077fffb1c2aa0262063db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Fri, 5 Aug 2011 09:53:39 +0200 Subject: [PATCH 157/539] Update documentation of FindPythonInterp.cmake Document new variables and update also comments in cmake code to explain the current behaviour of FindPythonInterp.cmake module --- Modules/FindPythonInterp.cmake | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 934602d4fbc..7acf7be7e82 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -4,11 +4,17 @@ # # PYTHONINTERP_FOUND - Was the Python executable found # PYTHON_EXECUTABLE - path to the Python interpreter -# Python_ADDITIONAL_VERSIONS - list of additional Python versions to search for # +# PYTHON_VERSION_STRING - Python version found e.g. 2.5.2 +# PYTHON_VERSION_MAJOR - Python major version found e.g. 2 +# PYTHON_VERSION_MINOR - Python minor version found e.g. 5 +# PYTHON_VERSION_PATCH - Python patch version found e.g. 2 +# +# Python_ADDITIONAL_VERSIONS - list of additional Python versions to search for #============================================================================= # Copyright 2005-2010 Kitware, Inc. +# Copyright 2011 Bjoern Ricks # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -20,6 +26,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +# Search for the current active python version first find_program(PYTHON_EXECUTABLE NAMES python) # Set up the versions we know about, in the order we will search. Always add @@ -28,8 +35,7 @@ set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS} 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) -# Run first with the Python version in the executable - +# Search for newest python version if python executable isn't found if(NOT PYTHON_EXECUTABLE) foreach(_CURRENT_VERSION ${_Python_VERSIONS}) set(_Python_NAMES python${_CURRENT_VERSION}) @@ -43,6 +49,7 @@ if(NOT PYTHON_EXECUTABLE) endforeach() endif() +# determine python version string if(PYTHON_EXECUTABLE) execute_process(COMMAND "${PYTHON_EXECUTABLE}" --version ERROR_VARIABLE _VERSION OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE) string(REPLACE "Python " "" PYTHON_VERSION_STRING "${_VERSION}") From 1c2508a569da51041db7345e0c9eb41aa6aaefd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ricks?= Date: Tue, 23 Aug 2011 09:36:17 +0200 Subject: [PATCH 158/539] Use FIND_PACKAGE_HANDLE_STANDARD_ARGS second mode Using the second mode of FIND_PACKAGE_HANDLE_STANDARD_ARGS allows for checking the version number. Now a user can require a minimum version of the python interpreter with find_package(PythonInterp VERSION) --- Modules/FindPythonInterp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 7acf7be7e82..a10ec2371d3 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -61,6 +61,6 @@ endif() # handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if # all listed variables are TRUE include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp DEFAULT_MSG PYTHON_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp REQUIRED_VARS PYTHON_EXECUTABLE VERSION_VAR PYTHON_VERSION_STRING) mark_as_advanced(PYTHON_EXECUTABLE) From 1db6955b06d9f17907fb7e9dff41669260b29779 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 23 Aug 2011 13:33:24 -0400 Subject: [PATCH 159/539] Xcode: Suppress same-old warning again. They changed the wording of it slightly with Xcode 4. --- CTestCustom.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 0047e68ce37..e175d9f0801 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -42,6 +42,7 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION "warning:.*is.*misused, please use.*" "CMakeSetupManifest.xml.*manifest authoring warning.*Unrecognized Element" "cc-3968 CC: WARNING File.*" # "implicit" truncation by static_cast + "ld: warning: directory not found for option .-(F|L)" ) IF(NOT "@CMAKE_GENERATOR@" MATCHES "Xcode") From 32eff0caec8fa896fdbb58d259c5cff2614279c3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 23 Aug 2011 19:49:39 +0200 Subject: [PATCH 160/539] Test for too-old-intel compilers. --- Modules/GenerateExportHeader.cmake | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 7a4b6d3129b..1d4c4822ec7 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -146,10 +146,21 @@ macro(_test_compiler_hidden_visibility) endif() endif() + if(CMAKE_CXX_COMPILER_ID MATCHES Intel) + exec_program(${CMAKE_CXX_COMPILER} ARGS -V OUTPUT_VARIABLE _intel_version_info) + string (REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1" _intel_version "${_intel_version_info}") + + if(${_intel_version} VERSION_LESS "12.0") + set(_INTEL_TOO_OLD TRUE) + message(WARNING "Intel compiler older than 12.0") + endif() + endif() + + # Exclude XL here because it misinterprets -fvisibility=hidden even though # the check_cxx_compiler_flag passes # http://www.cdash.org/CDash/testDetails.php?test=109109951&build=1419259 - if (NOT GCC_TOO_OLD AND NOT WIN32 AND NOT CYGWIN AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES XL AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI) + if (NOT GCC_TOO_OLD AND NOT _INTEL_TOO_OLD AND NOT WIN32 AND NOT CYGWIN AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES XL AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI) check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) option(USE_COMPILER_HIDDEN_VISIBILITY "Use HIDDEN visibility support if available." ON) From e253348ecd8cedc0f5fe640e613b2d19bd5641ae Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 23 Aug 2011 19:49:52 +0200 Subject: [PATCH 161/539] Possibly fix test on HPUX. --- Tests/Module/GenerateExportHeader/exportheader_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Module/GenerateExportHeader/exportheader_test.cpp b/Tests/Module/GenerateExportHeader/exportheader_test.cpp index cfc1a053f55..55c3c1ad658 100644 --- a/Tests/Module/GenerateExportHeader/exportheader_test.cpp +++ b/Tests/Module/GenerateExportHeader/exportheader_test.cpp @@ -79,4 +79,4 @@ int main() libstatic_excluded(); return 0; -} \ No newline at end of file +} From 6adeda9f55ca81b3715dd7512f2cd3c3218bd6ab Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 23 Aug 2011 19:58:42 +0200 Subject: [PATCH 162/539] Possibly fix configuration test on AIX. --- Modules/CheckCXXCompilerFlag.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/CheckCXXCompilerFlag.cmake b/Modules/CheckCXXCompilerFlag.cmake index 788bf35b427..91008c375a3 100644 --- a/Modules/CheckCXXCompilerFlag.cmake +++ b/Modules/CheckCXXCompilerFlag.cmake @@ -33,6 +33,7 @@ MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT) FAIL_REGEX "[Uu]nknown option" # HP FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro FAIL_REGEX "command option .* is not recognized" # XL + FAIL_REGEX "not supported in this configuration; ignored" # AIX ) SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") ENDMACRO (CHECK_CXX_COMPILER_FLAG) From 03d60c7d818584c5c44d2992b6cba1e202cdd498 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 23 Aug 2011 20:04:56 +0200 Subject: [PATCH 163/539] Try to make the macros do almost nothing for Watcom. --- Modules/GenerateExportHeader.cmake | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 1d4c4822ec7..6225f70fa61 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -160,7 +160,13 @@ macro(_test_compiler_hidden_visibility) # Exclude XL here because it misinterprets -fvisibility=hidden even though # the check_cxx_compiler_flag passes # http://www.cdash.org/CDash/testDetails.php?test=109109951&build=1419259 - if (NOT GCC_TOO_OLD AND NOT _INTEL_TOO_OLD AND NOT WIN32 AND NOT CYGWIN AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES XL AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI) + if (NOT GCC_TOO_OLD + AND NOT _INTEL_TOO_OLD + AND NOT WIN32 + AND NOT CYGWIN + AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES XL + AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI + AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom) check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) option(USE_COMPILER_HIDDEN_VISIBILITY "Use HIDDEN visibility support if available." ON) @@ -169,7 +175,11 @@ macro(_test_compiler_hidden_visibility) endmacro() macro(_test_compiler_has_deprecated) - if("${CMAKE_CXX_COMPILER_ID}" MATCHES Borland OR "${CMAKE_CXX_COMPILER_ID}" MATCHES HP OR GCC_TOO_OLD OR "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES Borland + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES HP + OR GCC_TOO_OLD + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom) set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL "Compiler support for a deprecated attribute") else() _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED_ATTR) From 1b031d1a3f236f7c2c301e042bdc22bdfc4064c0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 23 Aug 2011 23:19:31 +0200 Subject: [PATCH 164/539] More consistency in the macro options. --- Modules/GenerateExportHeader.cmake | 12 ++++++------ Modules/exportheader.cmake.in | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 6225f70fa61..0fe69a8bdbf 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -12,7 +12,7 @@ # [BASE_NAME ] # [EXPORT_MACRO_NAME ] # [EXPORT_FILE_NAME ] -# [DEPRECATED_NAME ] +# [DEPRECATED_MACRO_NAME ] # [NO_EXPORT_MACRO_NAME ] # [STATIC_DEFINE ] # ) @@ -78,7 +78,7 @@ # # add_library(somelib someclass.cpp) # generate_export_header(somelib -# DEPRECATED_NAME KDE_DEPRECATED +# DEPRECATED_MACRO_NAME KDE_DEPRECATED # ) # # creates the macro KDE_DEPRECATED instead of SOMELIB_DEPRECATED. @@ -222,7 +222,7 @@ endmacro() macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) # Option overrides set(options) - set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME DEPRECATED_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE) + set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE) set(multiValueArgs) cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -240,7 +240,7 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) set(EXPORT_MACRO_NAME "${PREFIX}${BASE_NAME_UPPER}_EXPORT") set(NO_EXPORT_MACRO_NAME "${PREFIX}${BASE_NAME_UPPER}_NO_EXPORT") set(EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${BASE_NAME_LOWER}_export.h") - set(DEPRECATED_NAME "${PREFIX}${BASE_NAME_UPPER}_DEPRECATED") + set(DEPRECATED_MACRO_NAME "${PREFIX}${BASE_NAME_UPPER}_DEPRECATED") set(STATIC_DEFINE "${PREFIX}${BASE_NAME_UPPER}_STATIC_DEFINE") if(_GEH_UNPARSED_ARGUMENTS) @@ -257,8 +257,8 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) set(EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${_GEH_EXPORT_FILE_NAME}") endif() endif() - if(_GEH_DEPRECATED_NAME) - set(DEPRECATED_NAME ${PREFIX}${_GEH_DEPRECATED_NAME}) + if(_GEH_DEPRECATED_MACRO_NAME) + set(DEPRECATED_MACRO_NAME ${PREFIX}${_GEH_DEPRECATED_MACRO_NAME}) endif() if(_GEH_NO_EXPORT_MACRO_NAME) set(NO_EXPORT_MACRO_NAME ${PREFIX}${_GEH_NO_EXPORT_MACRO_NAME}) diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in index 62ed3ff9261..83a93354e9a 100644 --- a/Modules/exportheader.cmake.in +++ b/Modules/exportheader.cmake.in @@ -21,10 +21,10 @@ # endif #endif -#ifndef @DEPRECATED_NAME@ -# define @DEPRECATED_NAME@ @DEFINE_DEPRECATED@ -# define @DEPRECATED_NAME@_EXPORT @EXPORT_MACRO_NAME@ @DEFINE_DEPRECATED@ -# define @DEPRECATED_NAME@_NO_EXPORT @NO_EXPORT_MACRO_NAME@ @DEFINE_DEPRECATED@ +#ifndef @DEPRECATED_MACRO_NAME@ +# define @DEPRECATED_MACRO_NAME@ @DEFINE_DEPRECATED@ +# define @DEPRECATED_MACRO_NAME@_EXPORT @EXPORT_MACRO_NAME@ @DEFINE_DEPRECATED@ +# define @DEPRECATED_MACRO_NAME@_NO_EXPORT @NO_EXPORT_MACRO_NAME@ @DEFINE_DEPRECATED@ #endif #endif // @INCLUDE_GUARD_NAME@ \ No newline at end of file From e0cc024dc90c74ff504995ce9ccd3671f9bf3db2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 23 Aug 2011 23:26:43 +0200 Subject: [PATCH 165/539] Add missing NO_EXPORT macro variant. --- Modules/GenerateExportHeader.cmake | 13 +++++++++++-- Modules/exportheader.cmake.in | 7 ++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 0fe69a8bdbf..e02811a2878 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -221,8 +221,8 @@ endmacro() macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) # Option overrides - set(options) - set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE) + set(options DEFINE_NO_DEPRECATED) + set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE NO_DEPRECATED_MACRO_NAME) set(multiValueArgs) cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -242,6 +242,7 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) set(EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${BASE_NAME_LOWER}_export.h") set(DEPRECATED_MACRO_NAME "${PREFIX}${BASE_NAME_UPPER}_DEPRECATED") set(STATIC_DEFINE "${PREFIX}${BASE_NAME_UPPER}_STATIC_DEFINE") + set(NO_DEPRECATED_MACRO_NAME "${BASE_NAME_UPPER}_NO_DEPRECATED") if(_GEH_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unknown keywords given to GENERATE_EXPORT_HEADER(): \"${_GEH_UNPARSED_ARGUMENTS}\"") @@ -267,6 +268,14 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) set(STATIC_DEFINE ${PREFIX}${_GEH_STATIC_DEFINE}) endif() + if (_GEH_DEFINE_NO_DEPRECATED) + set(DEFINE_NO_DEPRECATED TRUE) + endif() + + if (_GEH_NO_DEPRECATED_MACRO_NAME) + set(NO_DEPRECATED_MACRO_NAME ${PREFIX}${_GEH_NO_DEPRECATED_MACRO_NAME}) + endif() + set(INCLUDE_GUARD_NAME "${PREFIX}${EXPORT_MACRO_NAME}_H") get_target_property(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY} DEFINE_SYMBOL) diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in index 83a93354e9a..131d3a77dce 100644 --- a/Modules/exportheader.cmake.in +++ b/Modules/exportheader.cmake.in @@ -27,4 +27,9 @@ # define @DEPRECATED_MACRO_NAME@_NO_EXPORT @NO_EXPORT_MACRO_NAME@ @DEFINE_DEPRECATED@ #endif -#endif // @INCLUDE_GUARD_NAME@ \ No newline at end of file +#cmakedefine01 DEFINE_NO_DEPRECATED +#if DEFINE_NO_DEPRECATED +# define @NO_DEPRECATED_MACRO_NAME@ +#endif + +#endif // @INCLUDE_GUARD_NAME@ From ee45a5dd5a1c10e98de4623ba0c17f79ccfcd3d8 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 24 Aug 2011 00:01:04 -0400 Subject: [PATCH 166/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 15abe5ad61d..fa2cab57428 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 23) +SET(KWSYS_DATE_STAMP_DAY 24) From 89108b99eca60cfa71cee9727f3af052f5b9da4c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 24 Aug 2011 19:43:04 +0200 Subject: [PATCH 167/539] Look for errors reported by PGI too. --- Modules/CheckCXXCompilerFlag.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/CheckCXXCompilerFlag.cmake b/Modules/CheckCXXCompilerFlag.cmake index 91008c375a3..77851483a06 100644 --- a/Modules/CheckCXXCompilerFlag.cmake +++ b/Modules/CheckCXXCompilerFlag.cmake @@ -34,6 +34,7 @@ MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT) FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro FAIL_REGEX "command option .* is not recognized" # XL FAIL_REGEX "not supported in this configuration; ignored" # AIX + FAIL_REGEX "File with unknown suffix passed to linker" # PGI ) SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") ENDMACRO (CHECK_CXX_COMPILER_FLAG) From 7ac0ab1f88b66d162a89d055517551b3b7ecd8a6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 24 Aug 2011 19:50:31 +0200 Subject: [PATCH 168/539] Quote paths in case there is a space in one of them. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index dc7268942b0..91414718955 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -65,7 +65,7 @@ macro(_do_build Include Library LibrarySource Source) "set(CMAKE_INCLUDE_CURRENT_DIR ON)\n" - "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \${CMAKE_CURRENT_BINARY_DIR})\n" + "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"\${CMAKE_CURRENT_BINARY_DIR}\")\n" "include(GenerateExportHeader)\n" @@ -79,9 +79,9 @@ macro(_do_build Include Library LibrarySource Source) " add_definitions(-DCOMPILER_IS_MSVC)\n" "endif()\n" - "add_subdirectory(${LibrarySource})\n" + "add_subdirectory(\"${LibrarySource}\")\n" - "include_directories(${LibrarySource} \${CMAKE_CURRENT_BINARY_DIR}/${LibrarySource})\n" + "include_directories(\"${LibrarySource}\" \"\${CMAKE_CURRENT_BINARY_DIR}/${LibrarySource}\")\n" "${CONDITIONAL_STATIC_DEFINE}" From 99b2aabd460d0c508ffa7b21283a0512e322e717 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 24 Aug 2011 19:58:00 +0200 Subject: [PATCH 169/539] Disable the tests for Watcom. They are timing out and showing up on the dashboard. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 91414718955..5372f92ebb3 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -2,6 +2,21 @@ cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR) project(GenerateExportHeader) +# Prevent timeout on Watcom by not running the tests. +if ("${CMAKE_COMPILER_ID}" MATCHES Watcom) + file(WRITE + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + "int main() { return 0; } + " + ) + + add_executable( + GenerateExportHeader + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + ) + return() +endif() + include(CheckCXXCompilerFlag) set( CMAKE_INCLUDE_CURRENT_DIR ON ) From 0ae78b76d544adad4860b66bdd6279fdde07ea34 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 24 Aug 2011 14:06:51 -0400 Subject: [PATCH 170/539] FindPackageMessage: Eliminate new lines in cache entries Fix problem exposed by recent commit to FindPythonInterp. If the find "details" has new lines in it, then replace them with literal "\n" two character sequences so that the string may be saved as a cache entry that can be re-read next time CMake runs. --- Modules/FindPackageMessage.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/FindPackageMessage.cmake b/Modules/FindPackageMessage.cmake index eb398b2aedb..5afee3e3972 100644 --- a/Modules/FindPackageMessage.cmake +++ b/Modules/FindPackageMessage.cmake @@ -34,6 +34,7 @@ FUNCTION(FIND_PACKAGE_MESSAGE pkg msg details) # Avoid printing a message repeatedly for the same find result. IF(NOT ${pkg}_FIND_QUIETLY) + STRING(REPLACE "\n" "\\n" details "${details}") SET(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) IF(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") # The message has not yet been printed. From 36d28f2e6b60b684fa26dc8b906dcf51a5c93a0f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 24 Aug 2011 20:21:30 +0200 Subject: [PATCH 171/539] Fix Compiler id variable name. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 5372f92ebb3..fee836e1df6 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR) project(GenerateExportHeader) # Prevent timeout on Watcom by not running the tests. -if ("${CMAKE_COMPILER_ID}" MATCHES Watcom) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" "int main() { return 0; } From 281f51e063c2f3245d11b085c06a7f4b5fe69fd3 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Wed, 24 Aug 2011 16:08:31 -0400 Subject: [PATCH 172/539] Fix for bug #12413, nmake did not handle targets with + in the name. If you had a + in the name of a target with nmake, it created a variable in the makefile that used + in its name, which is not allowed by nmake. To make the implementation easier, + is now not allowed for any make generators as part of a variable name. --- Source/cmLocalUnixMakefileGenerator3.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 6ab5c2a9942..2eae9d056d4 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1276,6 +1276,7 @@ ::CreateMakeVariable(const char* sin, const char* s2in) // and there are no "." charactors in the string, then return the // unmodified combination. if((!this->MakefileVariableSize && unmodified.find('.') == s.npos) + && (!this->MakefileVariableSize && unmodified.find('+') == s.npos) && (!this->MakefileVariableSize && unmodified.find('-') == s.npos)) { return unmodified; @@ -1297,6 +1298,7 @@ ::CreateMakeVariable(const char* sin, const char* s2in) { cmSystemTools::ReplaceString(ret, ".", "_"); cmSystemTools::ReplaceString(ret, "-", "__"); + cmSystemTools::ReplaceString(ret, "+", "___"); int ni = 0; char buffer[5]; // make sure the _ version is not already used, if From 1834f232a7f782eadd238a78481e3f9086095e97 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 23 Aug 2011 18:22:33 -0400 Subject: [PATCH 173/539] Xcode: Save object id values in CMakeCache.txt (#11690) For project and target objects, save their ids in CMakeCache.txt. Hopefully, that will be enough to allow user settings to be saved across multiple CMake generate operations. Other object types may also need their ids saved: if so, more code than this commit will be necessary... --- Source/cmGlobalXCodeGenerator.cxx | 62 ++++++++++++++++++++++++++++++- Source/cmGlobalXCodeGenerator.h | 4 ++ Source/cmXCodeObject.cxx | 40 ++++++++++---------- Source/cmXCodeObject.h | 4 ++ 4 files changed, 89 insertions(+), 21 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index fd9dacd1aff..cde02b73522 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -489,12 +489,34 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects() delete this->XCodeObjects[i]; } this->XCodeObjects.clear(); + this->XCodeObjectIDs.clear(); this->GroupMap.clear(); this->GroupNameMap.clear(); this->TargetGroup.clear(); this->FileRefs.clear(); } +//---------------------------------------------------------------------------- +void cmGlobalXCodeGenerator::addObject(cmXCodeObject *obj) +{ + if(obj->GetType() == cmXCodeObject::OBJECT) + { + cmStdString id = obj->GetId(); + + // If this is a duplicate id, it's an error: + // + if(this->XCodeObjectIDs.count(id)) + { + cmSystemTools::Error( + "Xcode generator: duplicate object ids not allowed"); + } + + this->XCodeObjectIDs.insert(id); + } + + this->XCodeObjects.push_back(obj); +} + //---------------------------------------------------------------------------- cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype) @@ -508,7 +530,7 @@ cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype) { obj = new cmXCode21Object(ptype, cmXCodeObject::OBJECT); } - this->XCodeObjects.push_back(obj); + this->addObject(obj); return obj; } @@ -517,7 +539,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type) { cmXCodeObject* obj = new cmXCodeObject(cmXCodeObject::None, type); - this->XCodeObjects.push_back(obj); + this->addObject(obj); return obj; } @@ -2040,6 +2062,9 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) } } + target->SetId(this->GetOrCreateId( + cmtarget.GetName(), target->GetId()).c_str()); + return target; } @@ -2188,6 +2213,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, target->AddAttribute("productType", this->CreateString(productType)); } target->SetTarget(&cmtarget); + target->SetId(this->GetOrCreateId( + cmtarget.GetName(), target->GetId()).c_str()); return target; } @@ -2210,6 +2237,26 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t) return 0; } +//---------------------------------------------------------------------------- +std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name, + const char* id) +{ + std::string guidStoreName = name; + guidStoreName += "_GUID_CMAKE"; + const char* storedGUID = + this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str()); + + if(storedGUID) + { + return storedGUID; + } + + this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(), + id, "Stored Xcode object GUID", cmCacheManager::INTERNAL); + + return id; +} + //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target, cmXCodeObject* dependTarget) @@ -2739,6 +2786,12 @@ ::CreateXCodeObjects(cmLocalGenerator* root, this->RootObject = this->CreateObject(cmXCodeObject::PBXProject); this->RootObject->SetComment("Project object"); + + std::string project_id = "PROJECT_"; + project_id += root->GetMakefile()->GetProjectName(); + this->RootObject->SetId(this->GetOrCreateId( + project_id.c_str(), this->RootObject->GetId()).c_str()); + group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); this->RootObject->AddAttribute("mainGroup", this->CreateObjectReference(mainGroup)); @@ -3137,6 +3190,11 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, } this->WriteXCodePBXProj(fout, root, generators); this->ClearXCodeObjects(); + + // Since this call may have created new cache entries, save the cache: + // + root->GetMakefile()->GetCacheManager()->SaveCache( + root->GetMakefile()->GetHomeOutputDirectory()); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 39a5fd7222e..fa55ff08a7d 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -123,6 +123,8 @@ class cmGlobalXCodeGenerator : public cmGlobalGenerator ); cmXCodeObject* FindXCodeTarget(cmTarget*); + std::string GetOrCreateId(const char* name, const char* id); + // create cmXCodeObject from these functions so that memory can be managed // correctly. All objects created are stored in this->XCodeObjects. cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype); @@ -197,9 +199,11 @@ class cmGlobalXCodeGenerator : public cmGlobalGenerator unsigned int XcodeVersion; std::string VersionString; + std::set XCodeObjectIDs; std::vector XCodeObjects; cmXCodeObject* RootObject; private: + void addObject(cmXCodeObject *obj); std::string PostBuildMakeTarget(std::string const& tName, std::string const& configName); cmXCodeObject* MainGroupChildren; diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 30e5076c461..30ade9637d9 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -12,6 +12,8 @@ #include "cmXCodeObject.h" #include "cmSystemTools.h" +#include // CFUUIDCreate + //---------------------------------------------------------------------------- const char* cmXCodeObject::PBXTypeNames[] = { "PBXGroup", "PBXBuildStyle", "PBXProject", "PBXHeadersBuildPhase", @@ -39,35 +41,35 @@ cmXCodeObject::cmXCodeObject(PBXType ptype, Type type) this->PBXTargetDependencyValue = 0; this->Target = 0; this->Object =0; - + this->IsA = ptype; + if(type == OBJECT) { - cmOStringStream str; - str << (void*)this; - str << (void*)this; - str << (void*)this; - this->Id = str.str(); + // Set the Id of an Xcode object to a unique string for each instance. + // However the Xcode user file references certain Ids: for those cases, + // override the generated Id using SetId(). + // + char cUuid[40] = {0}; + CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault); + CFStringRef s = CFUUIDCreateString(kCFAllocatorDefault, uuid); + CFStringGetCString(s, cUuid, sizeof(cUuid), kCFStringEncodingUTF8); + this->Id = cUuid; + CFRelease(s); + CFRelease(uuid); } else { - this->Id = - "Temporary cmake object, should not be refered to in xcode file"; - } - cmSystemTools::ReplaceString(this->Id, "0x", ""); - this->Id = cmSystemTools::UpperCase(this->Id); - if(this->Id.size() < 24) - { - int diff = 24 - this->Id.size(); - for(int i =0; i < diff; ++i) - { - this->Id += "0"; - } + this->Id = + "Temporary cmake object, should not be referred to in Xcode file"; } + + cmSystemTools::ReplaceString(this->Id, "-", ""); if(this->Id.size() > 24) { - this->Id = this->Id.substr(0,24); + this->Id = this->Id.substr(0, 24); } + this->TypeValue = type; if(this->TypeValue == OBJECT) { diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 369fe669d04..2fb96f30ef5 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -83,6 +83,10 @@ class cmXCodeObject { return this->Id.c_str(); } + void SetId(const char* id) + { + this->Id = id; + } cmTarget* GetTarget() { return this->Target; From e8d60d46d109c6efe0f1a59858b543cb33293c74 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 25 Aug 2011 00:01:35 -0400 Subject: [PATCH 174/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index fa2cab57428..2644ba53cec 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 24) +SET(KWSYS_DATE_STAMP_DAY 25) From 3449f6b88c0e8b11c13eae78e0932fd3140dfa89 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 25 Aug 2011 18:29:26 +0200 Subject: [PATCH 175/539] Add quotes in case cmake is installed in a prefix with a space. --- Modules/GenerateExportHeader.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index e02811a2878..8ba26d8702c 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -191,7 +191,7 @@ macro(_test_compiler_has_deprecated) endif() endmacro() -set(myDir ${CMAKE_CURRENT_LIST_DIR}) +set(myDir "${CMAKE_CURRENT_LIST_DIR}") macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) set(DEFINE_DEPRECATED) @@ -284,7 +284,7 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) set(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY}_EXPORTS) endif() - configure_file(${myDir}/exportheader.cmake.in ${EXPORT_FILE_NAME} @ONLY) + configure_file("${myDir}/exportheader.cmake.in" "${EXPORT_FILE_NAME}" @ONLY) endmacro() function(GENERATE_EXPORT_HEADER TARGET_LIBRARY) From 51bc63a7cb524bd9f9942bd0d49491cf9d1e36f8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 25 Aug 2011 18:51:37 +0200 Subject: [PATCH 176/539] Fix the feature of using a specific prefix for macros. --- Modules/GenerateExportHeader.cmake | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 8ba26d8702c..7ed7edcc22e 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -237,19 +237,19 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) string(TOLOWER ${BASE_NAME} BASE_NAME_LOWER) # Default options - set(EXPORT_MACRO_NAME "${PREFIX}${BASE_NAME_UPPER}_EXPORT") - set(NO_EXPORT_MACRO_NAME "${PREFIX}${BASE_NAME_UPPER}_NO_EXPORT") + set(EXPORT_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_EXPORT") + set(NO_EXPORT_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_NO_EXPORT") set(EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${BASE_NAME_LOWER}_export.h") - set(DEPRECATED_MACRO_NAME "${PREFIX}${BASE_NAME_UPPER}_DEPRECATED") - set(STATIC_DEFINE "${PREFIX}${BASE_NAME_UPPER}_STATIC_DEFINE") - set(NO_DEPRECATED_MACRO_NAME "${BASE_NAME_UPPER}_NO_DEPRECATED") + set(DEPRECATED_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_DEPRECATED") + set(STATIC_DEFINE "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_STATIC_DEFINE") + set(NO_DEPRECATED_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_NO_DEPRECATED") if(_GEH_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unknown keywords given to GENERATE_EXPORT_HEADER(): \"${_GEH_UNPARSED_ARGUMENTS}\"") endif() if(_GEH_EXPORT_MACRO_NAME) - set(EXPORT_MACRO_NAME ${PREFIX}${_GEH_EXPORT_MACRO_NAME}) + set(EXPORT_MACRO_NAME ${_GEH_PREFIX_NAME}${_GEH_EXPORT_MACRO_NAME}) endif() if(_GEH_EXPORT_FILE_NAME) if(IS_ABSOLUTE _GEH_EXPORT_FILE_NAME) @@ -259,13 +259,13 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) endif() endif() if(_GEH_DEPRECATED_MACRO_NAME) - set(DEPRECATED_MACRO_NAME ${PREFIX}${_GEH_DEPRECATED_MACRO_NAME}) + set(DEPRECATED_MACRO_NAME ${_GEH_PREFIX_NAME}${_GEH_DEPRECATED_MACRO_NAME}) endif() if(_GEH_NO_EXPORT_MACRO_NAME) - set(NO_EXPORT_MACRO_NAME ${PREFIX}${_GEH_NO_EXPORT_MACRO_NAME}) + set(NO_EXPORT_MACRO_NAME ${_GEH_PREFIX_NAME}${_GEH_NO_EXPORT_MACRO_NAME}) endif() if(_GEH_STATIC_DEFINE) - set(STATIC_DEFINE ${PREFIX}${_GEH_STATIC_DEFINE}) + set(STATIC_DEFINE ${_GEH_PREFIX_NAME}${_GEH_STATIC_DEFINE}) endif() if (_GEH_DEFINE_NO_DEPRECATED) @@ -273,10 +273,10 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) endif() if (_GEH_NO_DEPRECATED_MACRO_NAME) - set(NO_DEPRECATED_MACRO_NAME ${PREFIX}${_GEH_NO_DEPRECATED_MACRO_NAME}) + set(NO_DEPRECATED_MACRO_NAME ${_GEH_PREFIX_NAME}${_GEH_NO_DEPRECATED_MACRO_NAME}) endif() - set(INCLUDE_GUARD_NAME "${PREFIX}${EXPORT_MACRO_NAME}_H") + set(INCLUDE_GUARD_NAME "${EXPORT_MACRO_NAME}_H") get_target_property(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY} DEFINE_SYMBOL) From 8b9b8e1676887a5b35dca0fb39e8538c10b2b00a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 25 Aug 2011 18:56:02 +0200 Subject: [PATCH 177/539] Add documentation about the prefix and no_deprecated options. --- Modules/GenerateExportHeader.cmake | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 7ed7edcc22e..8d6cab986e7 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -15,6 +15,9 @@ # [DEPRECATED_MACRO_NAME ] # [NO_EXPORT_MACRO_NAME ] # [STATIC_DEFINE ] +# [NO_DEPRECATED_MACRO_NAME ] +# [DEFINE_NO_DEPRECATED] +# [PREFIX_NAME ] # ) # # ADD_COMPILER_EXPORT_FLAGS( [FATAL_WARNINGS] ) @@ -97,6 +100,45 @@ # set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) # # This will cause the export macros to expand to nothing when building the static library. +# +# If DEFINE_NO_DEPRECATED is specified, then a macro ${BASE_NAME}_NO_DEPRECATED will be defined +# This macro can be used to remove deprecated code from preprocessor output. +# +# option(EXCLUDE_DEPRECATED "Exclude deprecated parts of the library" FALSE) +# +# if (EXCLUDE_DEPRECATED) +# set(NO_BUILD_DEPRECATED DEFINE_NO_DEPRECATED) +# endif() +# +# generate_export_header(somelib ${NO_BUILD_DEPRECATED}) +# +# And then in somelib: +# +# \code +# class SOMELIB_EXPORT SomeClass +# { +# public: +# #ifndef SOMELIB_NO_DEPRECATED +# SOMELIB_DEPRECATED void oldMethod(); +# #endif +# }; +# +# // ... +# +# #ifndef SOMELIB_NO_DEPRECATED +# void SomeClass::oldMethod() { } +# #endif +# +# \endcode +# +# If PREFIX_NAME is specified, the argument will be used as a prefix to all +# generated macros. +# +# For example: +# +# generate_export_header(somelib PREFIX_NAME VTK_) +# +# Generates the macros VTK_SOMELIB_EXPORT etc. #============================================================================= From 826374a45ac8eb7fef9c41a391b1ca759c5a2b31 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 25 Aug 2011 20:30:58 +0200 Subject: [PATCH 178/539] Remove blank line at the start of the file. A blank line excludes the file from documentation processing. --- Modules/GenerateExportHeader.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 8d6cab986e7..b441f3cd30e 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -1,6 +1,4 @@ - # - Function for generation of export macros for libraries -# # This module provides the function GENERATE_EXPORT_HEADER() and the # accompanying ADD_COMPILER_EXPORT_FLAGS() function. # From 75596e62f9a54c36943be0a89a0ad9874f50bf99 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 25 Aug 2011 20:31:42 +0200 Subject: [PATCH 179/539] Don't start a line with a dash(-) That is a special character in cmake dox. --- Modules/GenerateExportHeader.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index b441f3cd30e..b6901e48e4d 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -21,8 +21,8 @@ # ADD_COMPILER_EXPORT_FLAGS( [FATAL_WARNINGS] ) # # By default GENERATE_EXPORT_HEADER() generates macro names in a file name -# determined by the name of the library. The ADD_COMPILER_EXPORT_FLAGS macro adds -# -fvisibility=hidden to CMAKE_CXX_FLAGS if supported, and is a no-op on Windows +# determined by the name of the library. The ADD_COMPILER_EXPORT_FLAGS macro +# adds -fvisibility=hidden to CMAKE_CXX_FLAGS if supported, and is a no-op on Windows # which does not need extra compiler flags for exporting support. # # This means that in the simplest case, users of these functions will be equivalent to: From 5ca8c565bc3ebabea06bd7de655d9a120a7f008c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 25 Aug 2011 20:38:13 +0200 Subject: [PATCH 180/539] Fix up verbatim code sections of the dox. --- Modules/GenerateExportHeader.cmake | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index b6901e48e4d..0f5c4139f5e 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -28,13 +28,9 @@ # This means that in the simplest case, users of these functions will be equivalent to: # # add_compiler_export_flags() -# # add_library(somelib someclass.cpp) -# # generate_export_header(somelib) -# # install(TARGETS somelib DESTINATION ${LIBRARY_INSTALL_DIR}) -# # install(FILES # someclass.h # ${PROJECT_BINARY_DIR}/somelib_export.h DESTINATION ${INCLUDE_INSTALL_DIR} @@ -42,13 +38,10 @@ # # And in the ABI header files: # -# \code # #include "somelib_export.h" -# # class SOMELIB_EXPORT SomeClass { -# +# ... # }; -# \endcode # # The CMake fragment will generate a file in the ${CMAKE_CURRENT_BUILD_DIR} called # somelib_export.h containing the macros SOMELIB_EXPORT, SOMELIB_NO_EXPORT, @@ -92,9 +85,7 @@ # # add_library(shared_variant SHARED ${lib_SRCS}) # add_library(static_variant ${lib_SRCS}) -# # generate_export_header(shared_variant BASE_NAME libshared_and_static) -# # set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) # # This will cause the export macros to expand to nothing when building the static library. @@ -103,16 +94,13 @@ # This macro can be used to remove deprecated code from preprocessor output. # # option(EXCLUDE_DEPRECATED "Exclude deprecated parts of the library" FALSE) -# # if (EXCLUDE_DEPRECATED) # set(NO_BUILD_DEPRECATED DEFINE_NO_DEPRECATED) # endif() -# # generate_export_header(somelib ${NO_BUILD_DEPRECATED}) # # And then in somelib: # -# \code # class SOMELIB_EXPORT SomeClass # { # public: @@ -121,14 +109,10 @@ # #endif # }; # -# // ... -# # #ifndef SOMELIB_NO_DEPRECATED # void SomeClass::oldMethod() { } # #endif # -# \endcode -# # If PREFIX_NAME is specified, the argument will be used as a prefix to all # generated macros. # From 7bf2c1aa3ecd4921a19391cd9b37d78045a6e65d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 25 Aug 2011 21:39:51 +0200 Subject: [PATCH 181/539] Create moc files in the current binary dir, not the top level. --- Source/cmQtAutomoc.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index ff96e5b9fde..abda47e5d77 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -207,7 +207,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, this->IncludeProjectDirsBefore = makefile->IsOn( "AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"); this->Srcdir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR"); - this->Builddir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); + this->Builddir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_BINARY_DIR"); this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE"); this->MocCompileDefinitionsStr = makefile->GetSafeDefinition( "AM_MOC_COMPILE_DEFINITIONS"); From 0cf4fa578a62dc411e69c59aaaea2a0cf339d24b Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 25 Aug 2011 18:35:54 -0400 Subject: [PATCH 182/539] Xcode4: Requires more quoting of single quote char Specifically in per-target and per-file compiler definition string values. The Preprocessor test now passes on Xcode 4 builds after this commit. --- Source/cmGlobalXCodeGenerator.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index fd9dacd1aff..5f5c1c3f807 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3409,7 +3409,14 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags, { if(*c == '\'') { - flags += "\\\\'"; + if (this->XcodeVersion >= 40) + { + flags += "'\\\\''"; + } + else + { + flags += "\\\\'"; + } } else if(*c == '\\') { From 8508a6986aeb6c895a737df8f968d6ed9201ee2a Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 26 Aug 2011 00:01:19 -0400 Subject: [PATCH 183/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 2644ba53cec..6b6ff78246f 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 25) +SET(KWSYS_DATE_STAMP_DAY 26) From 04b68853d5e2817864f09dfeeab5aa32fb0042f6 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 26 Aug 2011 11:26:04 -0400 Subject: [PATCH 184/539] CMake 2.8.6-rc1 --- CMakeLists.txt | 6 +- ChangeLog.manual | 207 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 210 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf948c2a12b..a0fcabd531b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -416,9 +416,9 @@ ENDIF() # The CMake version number. SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) -SET(CMake_VERSION_PATCH 5) -#SET(CMake_VERSION_TWEAK 0) -#SET(CMake_VERSION_RC 1) +SET(CMake_VERSION_PATCH 6) +SET(CMake_VERSION_TWEAK 0) +SET(CMake_VERSION_RC 1) # Releases define a tweak level. IF(DEFINED CMake_VERSION_TWEAK) diff --git a/ChangeLog.manual b/ChangeLog.manual index a00ce000c81..7c5a588dfb5 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,210 @@ +Changes in CMake 2.8.6-rc1 (since 2.8.5) +-------------------------------------------- +Aaron C. Meadows (1): + FindSubversion: Invoke svn non-interactively (#12304) + +Alex Neundorf (92): + Add a switch to disable a find_package() call completely + Add documentation for the CMAKE_DISABLE_FIND_PACKAGE_ switch + Add a basic test for CMAKE_DISABLE_FIND_PACKAGE_ + Add macros cmake_push/pop_check_state() as discussed on the list. + Fix copyright notice test + Add CheckCXXSymbolExists.cmake, so this can be used also for C++ + Minor fix to try_compile() docs (#12333) + Fix #12342: Add APPEND_STRING option to set_property() + Extend FeatureSummary: add PURPOSE of package and TYPE + FeatureSummary.cmake: remove "comment" field + FeatureSummary.cmake: add INCLUDE_QUIET_PACKAGES keyword + FeatureSummary.cmake: error out when a REQUIRED package is missing + FeatureSummary.cmake: only higher TYPEs can override previous TYPEs + FeatureSummary.cmake: cosmetics + FeatureSummary.cmake: update documentation + Remove debug output from CheckSymbolExists + Don't put files from CMAKE_ROOT into CodeBlocks projects (#12110) + More PATH_SUFFIXES for finding Postgresql and also search catalog/pg_type.h + Use FPHSA(), remove unnecessary stuff and don't recommend link_directories() + Mark the results from find() as advanced + FindPostgreSQL: fix PATH_SUFFIXES, better output for FPHSA + Strip trailing whitespace + FindGIF/FindFreetype.cmake: remove standard search paths from find-calls + FindGif: add giflib4 as one more name for the library under Windows + Add basic version check for giflib + Patch by Campbell Barton: puts definitions into C::B project file + Remove useless line of code + Also put builtin include dirs into CodeBlocks project file + Remove trailing whitespace + Also search for libxkbfile, XSync and SM include dir + Provide macro write_basic_config_version_file() + Add example to documentation + Add some tests for write_basic_config_version_file() + Fix copyright notice + Really fix copyright notice + Set UNSUITABLE instead of not COMPATIBLE + Improve documentation for WriteBasicConfigVersionFile.cmake + Add macros GETTEXT_PROCESS_POT() and GETTEXT_PROCESS_PO_FILES() + Support REQUIRED in FindGettext.cmake (using FPHSA.cmake) + Fix #12358: make optionally enabling ASM work again + Start work on automoc: add empty cmQtAutomoc class + Start implementing skeleton for automoc in cmake + Add actual automoc code from automoc + Remove the need to check for .h/.cxx during buildtime + Add the cmake module required currently for automoc + Add AUTOMOC to the add_library() command + Fix line lengths + Move code for parsing a cpp-file from the big loop to separate function + Initialize verbose based onb the env.var. + Color output when running moc + Add the generated automoc.cpp file to the cleaned files + Use cout instead of printf() + Remove trailing whitespace + Refactor SetupAutomocTarget() so it can be run after creating the target + Remove trailing whitespace + Move automoc processing from add_executable/library to cmGlobalGenerator + Nicer progress message for the automoc target + Add a test for automoc + Add documentation for AUTOMOC, add initialization via CMAKE_AUTOMOC + Fix logic which decides when to execute automoc test + Automoc.cmake is not needed anymore + Fix build: non-void function must return a value + Fix warnings + Fix bootstrap test with automoc + Only enable the automoc test after checking that Qt4 works + Fix build: use std::ios::out|ios::trunc instead of std::ios_base::out + Silence warning in automoc: use long instead of int + Fix automoc with VS builds: apply patch from Bill + Make clLocalGenerator::GetTargetFlags() public + Add find-package mode, which does nothing yet + Implement find-package mode of cmake + Replace cmake::GetScriptMode() with GetWorkingMode() + Fix copyright notice in new CMakeFindPackageMode.cmake + Better support for lib64 and Debian multiarch + Use the file-utility to test for 64bit if there is no /usr/lib64 + Add a cmake.m4 for using cmake in autoconf projects instead of pkgconfig + Improve documentation for --find-package mode + Add a test for the new --find-package mode + Only run the test if we are using a makefile generator under UNIX + The makefile for the test was kindof wrong + Fix test on OpenBSD with BSD make + Rename helper macros print_compile_flags() to set_compile_flags_var() + Dont check for -isysroot and -mmacosx-version on OSX in --find-package mode + Disable any STATUS output in --find-package mode + Much improved test, should now be executed on all UNIXes + Make the --find-package test harder + Make the test harder by always having a space in the include dirs + Only enable the test when using GNU make + Fix line length + Use $(CXXFLAGS) and $(LDFLAGS) in the --find-package test Makefile + Require the current cmake version in --find-package mode + Fix --find-package mode on Cygwin, where enable_language(RC) is called + +Alexey Ozeritsky (5): + fixed: search of acml libraries + gotoblas supported + ACML-GPU supported + ACML-GPU supportede + fixed: search of ATLAS library for C/C++-only projects + +Andreas Schneider (6): + FindJava: Find missing java development executables. + Modules: Added CMake Java support. + Tests: Java tests should test UseJava.cmake + Tests: Check for the new Java exeutable variables. + Java: Use set_property/get_property for target variables. + Java: Fix documentation format and indentation + +Arnaud Gelas (1): + Search for the ASPELL executable + +Bill Hoffman (5): + Only pay for unused variable checking if it is on. + Initial support for Intel Fortran VS2010. + Fix custom commands in VS2010 Fortran projects using CFG_INTDIR and test. + Use MSBuild when devenv is not around, since VCExpress seems broken. + Fix for bug #12413, nmake did not handle targets with + in the name. + +Brad King (13): + MinGW: Remove old workaround and use native echo (#12283) + Document caveat of custom commands in multiple targets (#12311) + cmSystemTools: Remove trailing whitespace + RunSingleCommand: Fix indentation + RunSingleCommand: Avoid assignment in condition + Documentation: WIN32 not defined on Cygwin (#12334) + KWSys: Simplify SystemTools::GetTime implementation (#12261) + KWSys: Avoid conversion warning in SystemTools::GetTime + KWSys: Fix using long long and __int64 with hash_(set|map) + KWSys: __int64 and long long may be same type in specialization + XL: Fix old VisualAge branding of Fortran compiler + Do not crash when an imported target depends on a missing target + Fix CHECK_(C|CXX)_COMPILER_FLAG for Clang (#12394) + +Clinton Stimpson (5): + Add -DQT_NO_DEBUG if no build type is specified so Qt plugins will work. + Add qt4/QtCore to help find Qt headers when cross-compiling. + Qt4: Fix reference of undefined variable when detecting frameworks on Mac OS X + Remove C compiler requirement from FindQt4.cmake + CPack/NSIS: Fix reinstall and multiple install issues when using components. + +David Cole (26): + Begin post-2.8.5 development + Fix Architecture test to work with Xcode 4 + Fix BuildDepends test to work with Xcode 4 + Base architecture choice logic on Xcode version + Use correct default multiple architecture values in test + Add use of EFFECTIVE_PLATFORM_NAME to generated Xcode projects. + Correct KWStyle line too long error + Add fail regex to detect supported warning flags correctly. + Add support for Visual Studio project-specific globals (#8707) + Fix machine-specific UpdateGIT test failures + Ensure libgmp-10.dll is in the PATH for CMakeTestAllGenerators + Watcom: Add -c flag to wlib calls (#12245) + Add Watcom support to InstallRequiredSystemLibraries (#11866) + Watcom: Use correct args for execute_process call (#11866) + CTest: print failed tests in index order (#11746) + Fix line too long style violation + Documentation: Fix comments in the source code (#10941) + Add more find_path locations for DCMTK header files (#12323) + VS9: Add include_directories to midl command lines + KWSys: Remove translation path for "/tmp_mnt/" (#10595) + VS10: Avoid unnecessary rebuilds for custom commands + QtAutomoc test: Pass QT_QMAKE_EXECUTABLE + QtAutomoc: Eliminate compiler warning + CheckSymbolExists: Use IMMEDIATE flag for configure_file (#11333) + Xcode: Suppress same-old warning again. + Xcode: Save object id values in CMakeCache.txt (#11690) + +Johan Björk (5): + Xcode: Remove PREBINDING attribute for Xcode 4 and above + RunSingleCommand: Replace verbose boolean with enum + RunSingleCommand: Add a OUTPUT_NORMAL flag. + Xcode: Quote ',' in Xcode string values (#12259) + Xcode: Rearrange CMakeReRun to enable parallel builds + +Matej Hribernik (2): + VS: Factor Find64BitTools out of Win64 generator to parent + Add VisualStudio 9 and 10 generators for Itanium platform + +Modestas Vainius (1): + multiarch: Treat lib/ as implicit link dir (#12326) + +Oliver Buchtala (3): + Java: Create java_class_filelist only if it does't exist. + Java: Added some dependency magic to avoid recompilations. + Java: Create correct jar archive dependencies. + +Rolf Eike Beer (2): + remove extra output message from FindJava.cmake + FindThreads: Try pthreads with no special option first (#11333) + +Steven Velez (1): + VS10: Add SCC support + +Todd Gamblin (2): + Try regular compiler when no MPI compiler. + Fix issues with removing try_compile input file. + +Will Dicharry (1): + Added HDF5 high level Fortran bindings to available components. + Changes in CMake 2.8.5 (since 2.8.5-rc3) -------------------------------------------- Brad King (1): From a2a0a8e0d5f8ad5e464363b952220f716c8fba14 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 26 Aug 2011 13:51:32 -0400 Subject: [PATCH 185/539] cmake.m4: Use modern signature of install(FILES ...) The older install_files command uses a leading slash in front of the destination directory, whereas the modern signature does not. Use the modern signature since that's what the CMake devs are now used to. --- Utilities/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 85db3679e56..798c1639755 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -126,7 +126,7 @@ ADD_CUSTOM_COMMAND( INSTALL_FILES(${CMAKE_MAN_DIR}/man1 FILES ${MAN_FILES}) INSTALL_FILES(${CMAKE_DOC_DIR} FILES ${HTML_FILES} ${TEXT_FILES}) -INSTALL_FILES(share/aclocal FILES cmake.m4) +INSTALL(FILES cmake.m4 DESTINATION share/aclocal) # Drive documentation generation. ADD_CUSTOM_TARGET(documentation ALL DEPENDS ${DOC_FILES} ${CMake_BINARY_DIR}/Docs/cmake.txt ) From 4a679a9f160a26bead7f54166272a5604cefcce6 Mon Sep 17 00:00:00 2001 From: David Cole Date: Mon, 22 Aug 2011 18:05:30 -0400 Subject: [PATCH 186/539] CMake Release Scripts: Changes for next release candidate... Removed script for dashsun1: machine is now defunct. R.I.P. Added new script for 64-bit universal binary build on dashmacmini5 with x86_64;i386 --- Utilities/Release/create-cmake-release.cmake | 4 ++-- Utilities/Release/dashmacmini2_release.cmake | 2 +- Utilities/Release/dashmacmini5_release.cmake | 20 ++++++++++++++++++++ Utilities/Release/dashsun1_release.cmake | 18 ------------------ 4 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 Utilities/Release/dashmacmini5_release.cmake delete mode 100644 Utilities/Release/dashsun1_release.cmake diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake index 75b00616a9b..c304e677742 100644 --- a/Utilities/Release/create-cmake-release.cmake +++ b/Utilities/Release/create-cmake-release.cmake @@ -7,9 +7,9 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/logs) set(RELEASE_SCRIPTS_BATCH_1 dash2win64_release.cmake # Windows - dashmacmini2_release.cmake # Mac Darwin universal + dashmacmini2_release.cmake # Mac Darwin universal ppc;i386 + dashmacmini5_release.cmake # Mac Darwin64 universal x86_64;i386 magrathea_release.cmake # Linux - dashsun1_release.cmake # SunOS v20n250_aix_release.cmake # AIX 5.3 ferrari_sgi64_release.cmake # IRIX 64 ferrari_sgi_release.cmake # IRIX diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake index d117014f98c..2668d38ab06 100644 --- a/Utilities/Release/dashmacmini2_release.cmake +++ b/Utilities/Release/dashmacmini2_release.cmake @@ -12,7 +12,7 @@ CMAKE_BUILD_TYPE:STRING=Release CMAKE_OSX_ARCHITECTURES:STRING=ppc;i386 CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CPACK_SYSTEM_NAME:STRING=Darwin-universal -BUILD_QtDialog:BOOL:=TRUE +BUILD_QtDialog:BOOL=TRUE QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Software/QtBinUniversal/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/dashmacmini5_release.cmake b/Utilities/Release/dashmacmini5_release.cmake new file mode 100644 index 00000000000..92eebd7349d --- /dev/null +++ b/Utilities/Release/dashmacmini5_release.cmake @@ -0,0 +1,20 @@ +set(PROCESSORS 4) +set(CMAKE_RELEASE_DIRECTORY /Users/kitware/CMakeReleaseDirectory) +# set(USER_OVERRIDE "set(CMAKE_CXX_LINK_EXECUTABLE \\\"gcc -o -shared-libgcc -lstdc++-static\\\")") +set(INSTALL_PREFIX /) +set(HOST dashmacmini5) +set(MAKE_PROGRAM "make") +set(MAKE "${MAKE_PROGRAM} -j5") +set(CPACK_BINARY_GENERATORS "PackageMaker TGZ TZ") +set(CPACK_SOURCE_GENERATORS "TGZ TZ") +set(INITIAL_CACHE " +CMAKE_BUILD_TYPE:STRING=Release +CMAKE_OSX_ARCHITECTURES:STRING=x86_64;i386 +CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.5 +CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE +CPACK_SYSTEM_NAME:STRING=Darwin64-universal +BUILD_QtDialog:BOOL=TRUE +QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.6.4/install/bin/qmake +") +get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) +include(${path}/release_cmake.cmake) diff --git a/Utilities/Release/dashsun1_release.cmake b/Utilities/Release/dashsun1_release.cmake deleted file mode 100644 index f98795d9d30..00000000000 --- a/Utilities/Release/dashsun1_release.cmake +++ /dev/null @@ -1,18 +0,0 @@ -set(PROCESSORS 1) -set(HOST dashsun1) -set(CMAKE_RELEASE_DIRECTORY "/home/kitware/CMakeReleaseDirectory" ) -set(MAKE_PROGRAM "make") -set(USER_MAKE_RULE_FILE - "/home/kitware/CMakeReleaseDirectory/UserMakeRules.cmake") -set(INITIAL_CACHE " -CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE -CMAKE_BUILD_TYPE:STRING=Release -HAVE_LIBDL:INTERNAL=FALSE -CMAKE_EXE_LINKER_FLAGS:STRING=-Bdynamic -ldl -Bstatic -CMAKE_USER_MAKE_RULES_OVERRIDE:STRING=${USER_MAKE_RULE_FILE} -CURSES_LIBRARY:FILEPATH=/usr/lib/libcurses.a -FORM_LIBRARY:FILEPATH=/usr/lib/libform.a") -set(USER_MAKE_RULE_FILE_CONTENTS - "SET(CMAKE_DL_LIBS \\\"-Bdynamic -ldl -Bstatic\\\")") -get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) -include(${path}/release_cmake.cmake) From 0f78d92c0fadfdb128e48867a05dafbb3d8db38c Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 27 Aug 2011 00:01:04 -0400 Subject: [PATCH 187/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 6b6ff78246f..896988c39c5 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 26) +SET(KWSYS_DATE_STAMP_DAY 27) From 356cef21987fccbf265f77800ff7f94cff995fb9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 27 Aug 2011 09:26:26 +0200 Subject: [PATCH 188/539] Make the formatting of feature_summary output a little better. --- Modules/FeatureSummary.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index 570fb7b034c..885762ae97f 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -302,7 +302,7 @@ FUNCTION(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet) IF(includeThisOne) - SET(_currentFeatureText "${_currentFeatureText}\n${_currentFeature}") + SET(_currentFeatureText "${_currentFeatureText}\n * ${_currentFeature}") GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_REQUIRED_VERSION) IF(_info) SET(_currentFeatureText "${_currentFeatureText} (required version ${_info})") From 6a6393c905bd5bdddfaf0eb666ee479eed54ec28 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 27 Aug 2011 09:42:26 +0200 Subject: [PATCH 189/539] Don't use a variable name that might be used in other files. myDir is also used in the Grantlee config file, so if Grantlee was found, this call failed. --- Modules/GenerateExportHeader.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 0f5c4139f5e..4eb67b51556 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -215,7 +215,7 @@ macro(_test_compiler_has_deprecated) endif() endmacro() -set(myDir "${CMAKE_CURRENT_LIST_DIR}") +get_filename_component(_GENERATE_EXPORT_HEADER_MODULE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) set(DEFINE_DEPRECATED) @@ -308,7 +308,7 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) set(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY}_EXPORTS) endif() - configure_file("${myDir}/exportheader.cmake.in" "${EXPORT_FILE_NAME}" @ONLY) + configure_file("${_GENERATE_EXPORT_HEADER_MODULE_DIR}/exportheader.cmake.in" "${EXPORT_FILE_NAME}" @ONLY) endmacro() function(GENERATE_EXPORT_HEADER TARGET_LIBRARY) @@ -343,4 +343,4 @@ function(add_compiler_export_flags) set (EXTRA_FLAGS "${EXTRA_FLAGS} -fvisibility-inlines-hidden") endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}" PARENT_SCOPE) -endfunction() \ No newline at end of file +endfunction() From 195ac0aac1a8e3e02f9951a4a3c0ea2d37a3f68a Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 28 Aug 2011 00:01:12 -0400 Subject: [PATCH 190/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 896988c39c5..a3b19cd881b 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 27) +SET(KWSYS_DATE_STAMP_DAY 28) From b17a6dd55b94179fb87f27255f918a7d82ea57e5 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 29 Aug 2011 00:01:03 -0400 Subject: [PATCH 191/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index a3b19cd881b..879e3f5cbfe 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 28) +SET(KWSYS_DATE_STAMP_DAY 29) From d1697625f8dd279ae5ebd8df887908f28c2f9f40 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sun, 28 Aug 2011 21:58:35 -0700 Subject: [PATCH 192/539] Fix XL compilers on non-AIX machines. Linking broken on non-AIX machines when using XL compilers due to those machines not using the CreateExportList tool. Made use of this tool conditional on finding it. --- Modules/Compiler/XL.cmake | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake index d07890f3902..d2567d51388 100644 --- a/Modules/Compiler/XL.cmake +++ b/Modules/Compiler/XL.cmake @@ -35,14 +35,19 @@ macro(__compiler_xl lang) set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " -E > ") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " -S -o ") - # The compiler front-end passes all object files, archive files, and shared - # library files named on the command line to CreateExportList to create a - # list of all symbols to be exported from the shared library. This causes - # all archive members to be copied into the shared library whether they are - # needed or not. Instead we run the tool ourselves to pass only the object - # files so that we export only the symbols actually provided by the sources. - set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - "${CMAKE_XL_CreateExportList} /objects.exp " - " -Wl,-bE:/objects.exp -o " - ) + # CMAKE_XL_CreateExportList is part of the AIX XL compilers but not the linux ones. + # If we found the tool, we'll use it to create exports, otherwise stick with the regular + # create shared library compile line. + if (CMAKE_XL_CreateExportList) + # The compiler front-end passes all object files, archive files, and shared + # library files named on the command line to CreateExportList to create a + # list of all symbols to be exported from the shared library. This causes + # all archive members to be copied into the shared library whether they are + # needed or not. Instead we run the tool ourselves to pass only the object + # files so that we export only the symbols actually provided by the sources. + set(CMAKE_${lang}_CREATE_SHARED_LIBRARY + "${CMAKE_XL_CreateExportList} /objects.exp " + " -Wl,-bE:/objects.exp -o " + ) + endif() endmacro() From 5993891e8d3092375f4409e8d07f5138a1cb55be Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sun, 28 Aug 2011 21:54:45 -0700 Subject: [PATCH 193/539] Fixed link bugs in BlueGeneP build. - Build wasn't properly using -soname linker args, so installed libraries could depend on relative paths from the build directory. - Consolidated GNU linker args to one place in the BlueGeneP-base platform file, since ld is used by both XL and GNU toolchains on BlueGene. --- Modules/Platform/BlueGeneP-base.cmake | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Modules/Platform/BlueGeneP-base.cmake b/Modules/Platform/BlueGeneP-base.cmake index 2ca920ff0c3..926dbc01e3c 100644 --- a/Modules/Platform/BlueGeneP-base.cmake +++ b/Modules/Platform/BlueGeneP-base.cmake @@ -85,20 +85,23 @@ set(CMAKE_DL_LIBS "dl") macro(__BlueGeneP_set_dynamic_flags compiler_id lang) if (${compiler_id} STREQUAL XL) # Flags for XL compilers if we explicitly detected XL - set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-qpic") # -pic - set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj -qnostaticlink") # -shared - set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") # -rpath - set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-qnostaticlink -qnostaticlink=libgcc") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-qpic") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj -qnostaticlink") + set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-qnostaticlink -qnostaticlink=libgcc") else() # Assume flags for GNU compilers (if the ID is GNU *or* anything else). - set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") # -pic - set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") # -shared - set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") # -rpath - set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-dynamic") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-dynamic") endif() - set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "") # +s, flag for exe link to use shared lib - set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") # : or empty + # Both toolchains use the GNU linker on BG/P, so these options are shared. + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") + set(CMAKE_SHARED_LIBRARY_RPATH_LINK_${lang}_FLAG "-Wl,-rpath-link,") + set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,") + set(CMAKE_EXE_EXPORTS_${lang}_FLAG "-Wl,--export-dynamic") + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "") # +s, flag for exe link to use shared lib + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") # : or empty set(BGP_${lang}_DEFAULT_EXE_FLAGS " -o ") From e01b98ee4d755acc458d69296cedfdf068d074b7 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 17 Aug 2011 09:14:17 +0200 Subject: [PATCH 194/539] Modules: Add support for more java archives in add_jar(). --- Modules/UseJava.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 869394d5490..b78278c71ac 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -262,7 +262,10 @@ function(add_jar _TARGET_NAME) set(_JAVA_CLASS_FILE "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_REL_PATH}/${_JAVA_FILE}.class") set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES} ${_JAVA_CLASS_FILE}) - elseif (_JAVA_EXT MATCHES ".jar") + elseif (_JAVA_EXT MATCHES ".jar" + OR _JAVA_EXT MATCHES ".war" + OR _JAVA_EXT MATCHES ".ear" + OR _JAVA_EXT MATCHES ".sar") list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_SOURCE_FILE}) elseif (_JAVA_EXT STREQUAL "") From a67be31784ca6e2683fb5b86988bc5c81680c07c Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Mon, 29 Aug 2011 08:23:44 -0600 Subject: [PATCH 195/539] qt4: also find QtUiTools when cross compiling with mingw. --- Modules/FindQt4.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 1ebd69db6cf..3b05c2b385f 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -862,10 +862,11 @@ IF (QT_QMAKE_EXECUTABLE AND QTVERSION) ) ENDFOREACH(QT_MODULE) - # QtUiTools not with other frameworks with binary installation (in /usr/lib) - IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) + # QtUiTools is sometimes not in the same directory as the other found libraries + # e.g. on Mac, its never a framework like the others are + IF(QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR}) - ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) + ENDIF(QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) # Set QT_QTDESIGNERCOMPONENTS_LIBRARY FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) From 51beb446c23e73c1c62ba68923218908494a3587 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 30 Aug 2011 00:01:03 -0400 Subject: [PATCH 196/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 879e3f5cbfe..71c231fa5b1 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 29) +SET(KWSYS_DATE_STAMP_DAY 30) From a486c837c81190fe63ee2e6a91c0c43f7b181b9c Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 31 Aug 2011 00:01:09 -0400 Subject: [PATCH 197/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 71c231fa5b1..daa2d685ad0 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 30) +SET(KWSYS_DATE_STAMP_DAY 31) From d6e2a063f0a8f07dad88c0a7974391db5de4d6bd Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 31 Aug 2011 09:52:42 -0400 Subject: [PATCH 198/539] VS: Map per-source Fortran flags to IDE options Fix the VS generator per-source flag parsing to use the Fortran flag map for Fortran sources. --- Source/cmLocalVisualStudio7Generator.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 1f99cba826a..e15dd5ceb96 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1569,8 +1569,15 @@ ::WriteGroup(const cmSourceGroup *sg, cmTarget& target, !fc.CompileDefs.empty() || !fc.CompileDefsConfig.empty()) { - Options fileOptions(this, this->Version, Options::Compiler, - cmLocalVisualStudio7GeneratorFlagTable, + Options::Tool tool = Options::Compiler; + cmVS7FlagTable const* table = + cmLocalVisualStudio7GeneratorFlagTable; + if(this->FortranProject) + { + tool = Options::FortranCompiler; + table = cmLocalVisualStudio7GeneratorFortranFlagTable; + } + Options fileOptions(this, this->Version, tool, table, this->ExtraFlagTable); fileOptions.Parse(fc.CompileFlags.c_str()); fileOptions.AddDefines(fc.CompileDefs.c_str()); From 47a0c7542b07b7db8f466621fff28f47beaad7d0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 31 Aug 2011 09:54:27 -0400 Subject: [PATCH 199/539] VS: Map Fortran free- and fixed-format flags to IDE options Add Intel Fortran flags "-free" and "-fixed" to the table so they appear in the IDE correctly. --- Source/cmLocalVisualStudio7Generator.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index e15dd5ceb96..b6a7c33df73 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -330,6 +330,8 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranFlagTable[] = { {"Preprocess", "fpp", "Run Preprocessor on files", "preprocessYes", 0}, {"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "true", 0}, + {"SourceFileFormat", "fixed", "Use Fixed Format", "fileFormatFixed", 0}, + {"SourceFileFormat", "free", "Use Free Format", "fileFormatFree", 0}, {"DebugInformationFormat", "Zi", "full debug", "debugEnabled", 0}, {"DebugInformationFormat", "debug:full", "full debug", "debugEnabled", 0}, {"DebugInformationFormat", "Z7", "c7 compat", "debugOldStyleInfo", 0}, From 5c0c635a0947aa44a0e3edf65b73c61d9abced2d Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 31 Aug 2011 10:24:43 -0400 Subject: [PATCH 200/539] Fortran: Add support for free- and fixed-form flags Define a "Fortran_FORMAT" target and source file property. Initialize the target property from a "CMAKE_Fortran_FORMAT" variable. Interpret values "FIXED" and "FREE" to indicate the source file format. Append corresponding flags to the compiler command line. --- Modules/Compiler/Absoft-Fortran.cmake | 2 ++ Modules/Compiler/Cray-Fortran.cmake | 2 ++ Modules/Compiler/G95-Fortran.cmake | 2 ++ Modules/Compiler/GNU-Fortran.cmake | 3 ++ Modules/Compiler/HP-Fortran.cmake | 2 ++ Modules/Compiler/Intel-Fortran.cmake | 2 ++ Modules/Compiler/MIPSpro-Fortran.cmake | 2 ++ Modules/Compiler/NAG-Fortran.cmake | 2 ++ Modules/Compiler/PGI-Fortran.cmake | 3 ++ Modules/Compiler/PathScale-Fortran.cmake | 2 ++ Modules/Compiler/SunPro-Fortran.cmake | 2 ++ Modules/Compiler/XL-Fortran.cmake | 3 ++ Source/cmDocumentVariables.cxx | 9 ++++++ Source/cmLocalGenerator.cxx | 25 +++++++++++++++++ Source/cmLocalGenerator.h | 8 ++++++ Source/cmLocalVisualStudio7Generator.cxx | 25 +++++++++++++++++ Source/cmMakefileTargetGenerator.cxx | 35 ++++++++++++++++++++++++ Source/cmMakefileTargetGenerator.h | 2 ++ Source/cmSourceFile.cxx | 9 ++++++ Source/cmTarget.cxx | 12 ++++++++ Tests/Fortran/CMakeLists.txt | 2 ++ Tests/FortranOnly/CMakeLists.txt | 3 ++ Tests/FortranOnly/world.f | 9 +++--- 23 files changed, 161 insertions(+), 5 deletions(-) diff --git a/Modules/Compiler/Absoft-Fortran.cmake b/Modules/Compiler/Absoft-Fortran.cmake index bb7d3dc713f..1bb7b1f823e 100644 --- a/Modules/Compiler/Absoft-Fortran.cmake +++ b/Modules/Compiler/Absoft-Fortran.cmake @@ -6,3 +6,5 @@ SET(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") SET(CMAKE_Fortran_MODDIR_FLAG "-YMOD_OUT_DIR=") SET(CMAKE_Fortran_MODPATH_FLAG "-p") SET(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree") diff --git a/Modules/Compiler/Cray-Fortran.cmake b/Modules/Compiler/Cray-Fortran.cmake index 4f45176d222..5d81bb02c4b 100644 --- a/Modules/Compiler/Cray-Fortran.cmake +++ b/Modules/Compiler/Cray-Fortran.cmake @@ -2,3 +2,5 @@ set(CMAKE_Fortran_VERBOSE_FLAG "-v") set(CMAKE_Fortran_MODOUT_FLAG -em) set(CMAKE_Fortran_MODDIR_FLAG -J) set(CMAKE_Fortran_MODDIR_DEFAULT .) +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-f fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-f free") diff --git a/Modules/Compiler/G95-Fortran.cmake b/Modules/Compiler/G95-Fortran.cmake index cbd4661184c..fd84848b43b 100644 --- a/Modules/Compiler/G95-Fortran.cmake +++ b/Modules/Compiler/G95-Fortran.cmake @@ -5,3 +5,5 @@ set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") set(CMAKE_Fortran_MODDIR_FLAG "-fmod=") set(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") diff --git a/Modules/Compiler/GNU-Fortran.cmake b/Modules/Compiler/GNU-Fortran.cmake index 6e0f5f3d5ce..c710e86985c 100644 --- a/Modules/Compiler/GNU-Fortran.cmake +++ b/Modules/Compiler/GNU-Fortran.cmake @@ -1,6 +1,9 @@ include(Compiler/GNU) __compiler_gnu(Fortran) +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") + # No -DNDEBUG for Fortran. SET(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-Os") SET(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") diff --git a/Modules/Compiler/HP-Fortran.cmake b/Modules/Compiler/HP-Fortran.cmake index 7f7c1289aee..04fb96ea4bf 100644 --- a/Modules/Compiler/HP-Fortran.cmake +++ b/Modules/Compiler/HP-Fortran.cmake @@ -1 +1,3 @@ SET(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "+source=fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "+source=free") diff --git a/Modules/Compiler/Intel-Fortran.cmake b/Modules/Compiler/Intel-Fortran.cmake index f38b32e0e20..467abdcf5e3 100644 --- a/Modules/Compiler/Intel-Fortran.cmake +++ b/Modules/Compiler/Intel-Fortran.cmake @@ -5,3 +5,5 @@ SET(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") SET(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") SET(CMAKE_Fortran_MODDIR_FLAG "-module ") SET(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") diff --git a/Modules/Compiler/MIPSpro-Fortran.cmake b/Modules/Compiler/MIPSpro-Fortran.cmake index 7f7c1289aee..9220d3bf087 100644 --- a/Modules/Compiler/MIPSpro-Fortran.cmake +++ b/Modules/Compiler/MIPSpro-Fortran.cmake @@ -1 +1,3 @@ SET(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixedform") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-freeform") diff --git a/Modules/Compiler/NAG-Fortran.cmake b/Modules/Compiler/NAG-Fortran.cmake index b68c479941e..9a89746b5f2 100644 --- a/Modules/Compiler/NAG-Fortran.cmake +++ b/Modules/Compiler/NAG-Fortran.cmake @@ -30,3 +30,5 @@ endif() 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") diff --git a/Modules/Compiler/PGI-Fortran.cmake b/Modules/Compiler/PGI-Fortran.cmake index 1d2631552aa..aebc7b1c2eb 100644 --- a/Modules/Compiler/PGI-Fortran.cmake +++ b/Modules/Compiler/PGI-Fortran.cmake @@ -1,6 +1,9 @@ include(Compiler/PGI) __compiler_pgi(Fortran) +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-Mnofreeform") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-Mfreeform") + SET(CMAKE_Fortran_FLAGS_INIT "${CMAKE_Fortran_FLAGS_INIT} -Mpreprocess -Kieee") SET(CMAKE_Fortran_FLAGS_DEBUG_INIT "${CMAKE_Fortran_FLAGS_DEBUG_INIT} -Mbounds") diff --git a/Modules/Compiler/PathScale-Fortran.cmake b/Modules/Compiler/PathScale-Fortran.cmake index 20c9d7efb73..e05bf2afc3e 100644 --- a/Modules/Compiler/PathScale-Fortran.cmake +++ b/Modules/Compiler/PathScale-Fortran.cmake @@ -2,3 +2,5 @@ include(Compiler/PathScale) __compiler_pathscale(Fortran) SET(CMAKE_Fortran_MODDIR_FLAG "-module ") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixedform") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-freeform") diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake index a41b45456aa..86d6def3403 100644 --- a/Modules/Compiler/SunPro-Fortran.cmake +++ b/Modules/Compiler/SunPro-Fortran.cmake @@ -1,4 +1,6 @@ SET(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-KPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-G") diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake index d88b3f32f79..e7026f11af5 100644 --- a/Modules/Compiler/XL-Fortran.cmake +++ b/Modules/Compiler/XL-Fortran.cmake @@ -1,6 +1,9 @@ include(Compiler/XL) __compiler_xl(Fortran) +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-qfixed") # [=] +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-qfree") # [=f90|ibm] + SET(CMAKE_Fortran_MODDIR_FLAG "-qmoddir=") SET(CMAKE_Fortran_DEFINE_FLAG "-WF,-D") diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 26125d9d376..f2b01f13827 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1048,6 +1048,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm) false, "Variables that Control the Build"); + cm->DefineProperty + ("CMAKE_Fortran_FORMAT", cmProperty::VARIABLE, + "Set to FIXED or FREE to indicate the Fortran source layout.", + "This variable is used to initialize the Fortran_FORMAT " + "property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); + cm->DefineProperty ("CMAKE_Fortran_MODULE_DIRECTORY", cmProperty::VARIABLE, "Fortran module output directory.", diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7da35eb260f..1d1e8da0190 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2916,6 +2916,31 @@ std::string cmLocalGenerator::EscapeForCMake(const char* str) return result; } +//---------------------------------------------------------------------------- +cmLocalGenerator::FortranFormat +cmLocalGenerator::GetFortranFormat(const char* value) +{ + FortranFormat format = FortranFormatNone; + if(value && *value) + { + std::vector fmt; + cmSystemTools::ExpandListArgument(value, fmt); + for(std::vector::iterator fi = fmt.begin(); + fi != fmt.end(); ++fi) + { + if(*fi == "FIXED") + { + format = FortranFormatFixed; + } + if(*fi == "FREE") + { + format = FortranFormatFree; + } + } + } + return format; +} + //---------------------------------------------------------------------------- std::string cmLocalGenerator::GetTargetDirectory(cmTarget const&) const diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index a204a73d5f3..cfc09dc3216 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -244,6 +244,14 @@ class cmLocalGenerator /** Escape the given string as an argument in a CMake script. */ std::string EscapeForCMake(const char* str); + enum FortranFormat + { + FortranFormatNone, + FortranFormatFixed, + FortranFormatFree + }; + FortranFormat GetFortranFormat(const char* value); + /** Return the directories into which object files will be put. * There maybe more than one for fat binary systems like OSX. */ diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index b6a7c33df73..54175845ef5 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -689,6 +689,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, } } + if(this->FortranProject) + { + switch(this->GetFortranFormat(target.GetProperty("Fortran_FORMAT"))) + { + case FortranFormatFixed: flags += " -fixed"; break; + case FortranFormatFree: flags += " -free"; break; + default: break; + } + } + // Add the target-specific flags. if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS")) { @@ -1363,6 +1373,21 @@ ::cmLocalVisualStudio7GeneratorFCInfo(cmLocalVisualStudio7Generator* lg, fc.CompileFlags = cflags; needfc = true; } + if(lg->FortranProject) + { + switch(lg->GetFortranFormat(sf.GetProperty("Fortran_FORMAT"))) + { + case cmLocalGenerator::FortranFormatFixed: + fc.CompileFlags = "-fixed " + fc.CompileFlags; + needfc = true; + break; + case cmLocalGenerator::FortranFormatFree: + fc.CompileFlags = "-free " + fc.CompileFlags; + needfc = true; + break; + default: break; + } + } if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) { fc.CompileDefs = cdefs; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d0df8f07617..8b911940050 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -501,6 +501,35 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) ); } +//---------------------------------------------------------------------------- +void +cmMakefileTargetGenerator +::AppendFortranFormatFlags(std::string& flags, cmSourceFile& source) +{ + const char* srcfmt = source.GetProperty("Fortran_FORMAT"); + cmLocalGenerator::FortranFormat format = + this->LocalGenerator->GetFortranFormat(srcfmt); + if(format == cmLocalGenerator::FortranFormatNone) + { + const char* tgtfmt = this->Target->GetProperty("Fortran_FORMAT"); + format = this->LocalGenerator->GetFortranFormat(tgtfmt); + } + const char* var = 0; + switch (format) + { + case cmLocalGenerator::FortranFormatFixed: + var = "CMAKE_Fortran_FORMAT_FIXED_FLAG"; break; + case cmLocalGenerator::FortranFormatFree: + var = "CMAKE_Fortran_FORMAT_FREE_FLAG"; break; + default: break; + } + if(var) + { + this->LocalGenerator->AppendFlags( + flags, this->Makefile->GetDefinition(var)); + } +} + //---------------------------------------------------------------------------- void cmMakefileTargetGenerator @@ -562,6 +591,12 @@ ::WriteObjectBuildFile(std::string &obj, } } + // Add Fortran format flags. + if(strcmp(lang, "Fortran") == 0) + { + this->AppendFortranFormatFlags(flags, source); + } + // Add flags from source file properties. if (source.GetProperty("COMPILE_FLAGS")) { diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b68f8bf3b9b..674cd1306e5 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -112,6 +112,8 @@ class cmMakefileTargetGenerator // Return the a string with -F flags on apple std::string GetFrameworkFlags(); + void AppendFortranFormatFlags(std::string& flags, cmSourceFile& source); + // append intertarget dependencies void AppendTargetDepends(std::vector& depends); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index dfa2c0b3fe7..cd94753cb3f 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -436,6 +436,15 @@ void cmSourceFile::DefineProperties(cmake *cm) "is really an object file and should not be compiled. " "It will still be linked into the target though."); + cm->DefineProperty + ("Fortran_FORMAT", cmProperty::SOURCE_FILE, + "Set to FIXED or FREE to indicate the Fortran source layout.", + "This property tells CMake whether a given Fortran source file " + "uses fixed-format or free-format. " + "CMake will pass the corresponding format flag to the compiler. " + "Consider using the target-wide Fortran_FORMAT property if all " + "source files in a target share the same format."); + cm->DefineProperty ("GENERATED", cmProperty::SOURCE_FILE, "Is this source file generated as part of the build process.", diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 4969b65afe7..a7f50f680e3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -918,6 +918,17 @@ void cmTarget::DefineProperties(cmake *cm) "module is loaded. " ); + cm->DefineProperty + ("Fortran_FORMAT", cmProperty::TARGET, + "Set to FIXED or FREE to indicate the Fortran source layout.", + "This property tells CMake whether the Fortran source files " + "in a target use fixed-format or free-format. " + "CMake will pass the corresponding format flag to the compiler. " + "Use the source-specific Fortran_FORMAT property to change the " + "format of a specific source file. " + "If the variable CMAKE_Fortran_FORMAT is set when a target " + "is created its value is used to initialize this property."); + cm->DefineProperty ("Fortran_MODULE_DIRECTORY", cmProperty::TARGET, "Specify output directory for Fortran modules provided by the target.", @@ -1138,6 +1149,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("Fortran_FORMAT", 0); this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); this->SetPropertyDefault("OSX_ARCHITECTURES", 0); this->SetPropertyDefault("AUTOMOC", 0); diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index c216529f429..ba0bdcc78f4 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -161,8 +161,10 @@ if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) add_executable(test_use_in_comment_fixedform test_use_in_comment_fixedform.f) + set_property(SOURCE test_use_in_comment_fixedform.f PROPERTY Fortran_FORMAT FIXED) add_executable(test_use_in_comment_freeform test_use_in_comment_freeform.f90) + set_property(SOURCE test_use_in_comment_freeform.f90 PROPERTY Fortran_FORMAT FREE) add_executable(test_in_interface in_interface/main.f90 diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index 3c4f0e7e42b..d57a8b295a6 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -4,6 +4,9 @@ message("CTEST_FULL_OUTPUT ") # create a library with hello and world functions add_library(FortranOnlylib hello.f world.f) +set_property(TARGET FortranOnlylib PROPERTY Fortran_FORMAT FIXED) +set_property(SOURCE world.f PROPERTY Fortran_FORMAT FREE) + # create an executable that calls hello and world add_executable(FortranOnly testf.f) target_link_libraries(FortranOnly FortranOnlylib) diff --git a/Tests/FortranOnly/world.f b/Tests/FortranOnly/world.f index deae3fa7236..342b2443154 100644 --- a/Tests/FortranOnly/world.f +++ b/Tests/FortranOnly/world.f @@ -1,5 +1,4 @@ - SUBROUTINE WORLD - - PRINT *, 'World!' - - END +! Free-format ".f" file to test Fortran_FORMAT property +SUBROUTINE WORLD + PRINT *, 'World!' +END From 145de0a058553968b082c6d18c5b7d883ac4637f Mon Sep 17 00:00:00 2001 From: Alexey Ozeritsky Date: Wed, 31 Aug 2011 22:04:01 +0400 Subject: [PATCH 201/539] FindBLAS/LAPACK fixes fixed: saving/changing/restoring CMAKE_FIND_LIBRARY_SUFFIXES variable. fixed: BLA_VENDORs "Apple" (Accelerate Framework) and "NAS" (vecLib Framework) fail as 'cblas_dgemm_' doesn't exist. fixed: improve "Generic" detection on Ubuntu (and I assume Debian) (work with libblas3gf and liblapack3gf packages). --- Modules/FindBLAS.cmake | 19 ++++++++---- Modules/FindLAPACK.cmake | 62 ++++++++++++++++++++++------------------ 2 files changed, 48 insertions(+), 33 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index dc9ab374ca3..9d1cf3fcd71 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -42,6 +42,8 @@ include(CheckFunctionExists) include(CheckFortranFunctionExists) +set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + # Check the language being used get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES ) if( _LANGUAGES_ MATCHES Fortran ) @@ -89,13 +91,18 @@ foreach(_library ${_list}) if(_libraries_work) if (BLA_STATIC) if (WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRRAY_SUFFIXES}) endif ( WIN32 ) if (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRRAY_SUFFIXES}) else (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so") + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRRAY_SUFFIXES}) endif (APPLE) + else (BLA_STATIC) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRRAY_SUFFIXES} .so.3gf) + endif () endif (BLA_STATIC) find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} @@ -408,7 +415,7 @@ if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES BLAS - cblas_dgemm + dgemm "" "Accelerate" "" @@ -421,7 +428,7 @@ if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") check_fortran_libraries( BLAS_LIBRARIES BLAS - cblas_dgemm + dgemm "" "vecLib" "" @@ -613,3 +620,5 @@ else(BLA_F95) endif(BLAS_FOUND) endif(NOT BLAS_FIND_QUIETLY) endif(BLA_F95) + +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 80fe8671fd0..240dd977178 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -36,6 +36,8 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) if (NOT _LANGUAGES_ MATCHES Fortran) include(CheckFunctionExists) @@ -46,6 +48,8 @@ endif (NOT _LANGUAGES_ MATCHES Fortran) set(LAPACK_FOUND FALSE) set(LAPACK95_FOUND FALSE) +# TODO: move this stuff to separate module + macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads) # This macro checks for the existence of the combination of fortran libraries # given by _list. If the combination is found, this macro checks (using the @@ -61,38 +65,38 @@ macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads set(_libraries_work TRUE) set(${LIBRARIES}) set(_combined_name) +if (NOT _libdir) + if (WIN32) + set(_libdir ENV LIB) + elseif (APPLE) + set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH) + else () + set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH) + endif () +endif () foreach(_library ${_list}) set(_combined_name ${_combined_name}_${_library}) if(_libraries_work) - IF (WIN32) - if(BLA_STATIC) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") - endif(BLA_STATIC) - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS ENV LIB - ) - ENDIF (WIN32) - - if(APPLE) - if(BLA_STATIC) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so;.dylib") - endif(BLA_STATIC) + if (BLA_STATIC) + if (WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRRAY_SUFFIXES}) + endif ( WIN32 ) + if (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRRAY_SUFFIXES}) + else (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRRAY_SUFFIXES}) + endif (APPLE) + else (BLA_STATIC) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRRAY_SUFFIXES} .so.3gf) + endif () + endif (BLA_STATIC) find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH - ) - else(APPLE) - if(BLA_STATIC) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so") - endif(BLA_STATIC) - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH - ) - endif(APPLE) - + NAMES ${_library} + PATHS ${_libdir} + ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) @@ -165,7 +169,7 @@ endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") #acml lapack - if (BLA_VENDOR STREQUAL "ACML.*" OR BLA_VENDOR STREQUAL "All") + if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") if (BLAS_LIBRARIES MATCHES ".+acml.+") set (LAPACK_LIBRARIES ${BLAS_LIBRARIES}) endif () @@ -297,3 +301,5 @@ else(BLA_F95) endif(LAPACK_FOUND) endif(NOT LAPACK_FIND_QUIETLY) endif(BLA_F95) + +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) From 917ca9f1428efc73b9f23db9e5aa3dccbb15a513 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 1 Sep 2011 00:01:34 -0400 Subject: [PATCH 202/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index daa2d685ad0..4558e2aba7a 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 08) +SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 31) +SET(KWSYS_DATE_STAMP_DAY 01) From 0cc8f05ce5669f78d458c914b17695c5d53a8d52 Mon Sep 17 00:00:00 2001 From: Alexey Ozeritsky Date: Thu, 1 Sep 2011 10:52:20 +0400 Subject: [PATCH 203/539] FindBLAS/LAPACK fixes fixed: CMAKE_FIND_LIBRRAY_SUFFIXES misprint added: ATLAS vendor to FindLAPACK module --- Modules/FindBLAS.cmake | 12 ++++++------ Modules/FindLAPACK.cmake | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 9d1cf3fcd71..9b76d909c15 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -91,17 +91,17 @@ foreach(_library ${_list}) if(_libraries_work) if (BLA_STATIC) if (WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRRAY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) endif ( WIN32 ) if (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRRAY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) else (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRRAY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) endif (APPLE) else (BLA_STATIC) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") # for ubuntu's libblas3gf and liblapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRRAY_SUFFIXES} .so.3gf) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) endif () endif (BLA_STATIC) find_library(${_prefix}_${_library}_LIBRARY @@ -356,7 +356,7 @@ if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") BLAS_LIBRARIES BLAS sgemm - "" "acml_mp;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} + "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} ) if( BLAS_LIBRARIES ) break() @@ -368,7 +368,7 @@ if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") BLAS_LIBRARIES BLAS sgemm - "" "acml_mp;acml_mv" "" ${BLAS_ACML_LIB_DIRS} + "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} ) if( BLAS_LIBRARIES ) break() diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 240dd977178..bccf789c7c8 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -203,7 +203,9 @@ if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") endif ( NOT LAPACK_LIBRARIES ) endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") # Generic LAPACK library? -if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") +if (BLA_VENDOR STREQUAL "Generic" OR + BLA_VENDOR STREQUAL "ATLAS" OR + BLA_VENDOR STREQUAL "All") if ( NOT LAPACK_LIBRARIES ) check_lapack_libraries( LAPACK_LIBRARIES @@ -215,7 +217,7 @@ if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") "" ) endif ( NOT LAPACK_LIBRARIES ) -endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") +endif () #intel lapack if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) From 8e6352f8dbeedff1f529a800173b19d52ff69b6b Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 1 Sep 2011 08:07:36 -0400 Subject: [PATCH 204/539] KWSys: Add hash function for std::string Added hashing fuction for std::string. This adds default support for std::strings to KWSys hashing containers. Author: Bradley Lowekamp Suggested-by: Arnaud Gelas Change-Id: I7e7a0c356b73d19868a3df1db57b702ec7fffe9d --- Source/kwsys/hash_fun.hxx.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/kwsys/hash_fun.hxx.in b/Source/kwsys/hash_fun.hxx.in index 926ec92be88..2a1305ee1df 100644 --- a/Source/kwsys/hash_fun.hxx.in +++ b/Source/kwsys/hash_fun.hxx.in @@ -40,6 +40,7 @@ #include <@KWSYS_NAMESPACE@/Configure.hxx> #include <@KWSYS_NAMESPACE@/FundamentalType.h> #include <@KWSYS_NAMESPACE@/cstddef> // size_t +#include <@KWSYS_NAMESPACE@/stl/string> // string namespace @KWSYS_NAMESPACE@ { @@ -65,6 +66,16 @@ struct hash { size_t operator()(const char* __s) const { return _stl_hash_string(__s); } }; +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION + struct hash<@KWSYS_NAMESPACE@_stl::string> { + size_t operator()(const @KWSYS_NAMESPACE@_stl::string & __s) const { return _stl_hash_string(__s.c_str()); } +}; + +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION + struct hash { + size_t operator()(const @KWSYS_NAMESPACE@_stl::string & __s) const { return _stl_hash_string(__s.c_str()); } +}; + @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION struct hash { size_t operator()(char __x) const { return __x; } From 89f420abdefd387ec600e958f4aef15295b9daa4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 1 Sep 2011 08:20:43 -0400 Subject: [PATCH 205/539] KWSys: Fix std::string hash function for Borland Borland ignores "const" qualifiers in template specializations. --- Source/kwsys/hash_fun.hxx.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/kwsys/hash_fun.hxx.in b/Source/kwsys/hash_fun.hxx.in index 2a1305ee1df..8c5eb6ae34a 100644 --- a/Source/kwsys/hash_fun.hxx.in +++ b/Source/kwsys/hash_fun.hxx.in @@ -71,10 +71,12 @@ struct hash { size_t operator()(const @KWSYS_NAMESPACE@_stl::string & __s) const { return _stl_hash_string(__s.c_str()); } }; +#if !defined(__BORLANDC__) @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION struct hash { size_t operator()(const @KWSYS_NAMESPACE@_stl::string & __s) const { return _stl_hash_string(__s.c_str()); } }; +#endif @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION struct hash { From 0c28b48d9b46415964ddaabf082dbdc059c770c2 Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 1 Sep 2011 08:49:00 -0400 Subject: [PATCH 206/539] CMake: Add SaveCache at the end of successful Generate calls Without this call, recent refactoring changes in the Visual Studio generators yield no GUIDs saved in the cache. Putting the SaveCache here *once* avoids scattering many calls to it in specific generators. --- Source/cmake.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2b8c718e020..86fd0699190 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2531,6 +2531,13 @@ int cmake::Generate() this->ReportUndefinedPropertyAccesses (this->GetProperty("REPORT_UNDEFINED_PROPERTIES")); } + // Save the cache again after a successful Generate so that any internal + // variables created during Generate are saved. (Specifically target GUIDs + // for the Visual Studio and Xcode generators.) + if ( this->GetWorkingMode() == NORMAL_MODE ) + { + this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); + } return 0; } From 28ce8b7a147e315eb4bce4f0ae014e100162aa59 Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 1 Sep 2011 09:29:51 -0400 Subject: [PATCH 207/539] Suppress Qt warning for dashmacmini5 builds Qt 4.7 and earlier produce a "This version of Mac OS X is unsupported" warning on Lion, even though they work fine once built. We'll upgrade this machine to use Qt 4.8 when it's officially released. Until then, suppress this warning so that we don't miss other "more real" warnings on the dashboard. --- CTestCustom.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index e175d9f0801..d11f515f4da 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -43,6 +43,7 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION "CMakeSetupManifest.xml.*manifest authoring warning.*Unrecognized Element" "cc-3968 CC: WARNING File.*" # "implicit" truncation by static_cast "ld: warning: directory not found for option .-(F|L)" + "qglobal.h.*warning.*This version of Mac OS X is unsupported" ) IF(NOT "@CMAKE_GENERATOR@" MATCHES "Xcode") From 57bc42ae91ce373db094e69a6f9900aadbe858fe Mon Sep 17 00:00:00 2001 From: Johan Bjork Date: Sun, 28 Aug 2011 12:24:00 +0200 Subject: [PATCH 208/539] Xcode: Do not emit the ZERO_CHECK target more than once --- Source/cmGlobalXCodeGenerator.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f67b029b309..3e35048f660 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -770,7 +770,8 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, bool cmGlobalXCodeGenerator::SpecialTargetEmitted(std::string const& tname) { if(tname == "ALL_BUILD" || tname == "XCODE_DEPEND_HELPER" || - tname == "install" || tname == "package" || tname == "RUN_TESTS" ) + tname == "install" || tname == "package" || tname == "RUN_TESTS" || + tname == CMAKE_CHECK_BUILD_SYSTEM_TARGET ) { if(this->TargetDoneSet.find(tname) != this->TargetDoneSet.end()) { From 90efed6ee60fde3a1211672854f7e23affa8b983 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 1 Sep 2011 10:52:51 -0400 Subject: [PATCH 209/539] Xcode: Honor Fortran_FORMAT target and source file property Convert the target property to the IFORT_LANG_SRCFMT build setting. Convert the source property to the per-source COMPILER_FLAGS setting. --- Source/cmGlobalXCodeGenerator.cxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f67b029b309..2821827fed6 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -582,6 +582,13 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, { lg->AppendFlags(flags, cmtarget.GetProperty("COMPILE_FLAGS")); } + const char* srcfmt = sf->GetProperty("Fortran_FORMAT"); + switch(this->CurrentLocalGenerator->GetFortranFormat(srcfmt)) + { + case cmLocalGenerator::FortranFormatFixed: flags="-fixed "+flags; break; + case cmLocalGenerator::FortranFormatFree: flags="-free "+flags; break; + default: break; + } lg->AppendFlags(flags, sf->GetProperty("COMPILE_FLAGS")); // Add per-source definitions. @@ -1903,6 +1910,21 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(flags.c_str())); } + // Add Fortran source format attribute if property is set. + const char* format = 0; + const char* tgtfmt = target.GetProperty("Fortran_FORMAT"); + switch(this->CurrentLocalGenerator->GetFortranFormat(tgtfmt)) + { + case cmLocalGenerator::FortranFormatFixed: format = "fixed"; break; + case cmLocalGenerator::FortranFormatFree: format = "free"; break; + default: break; + } + if(format) + { + buildSettings->AddAttribute("IFORT_LANG_SRCFMT", + this->CreateString(format)); + } + // Create the INSTALL_PATH attribute. std::string install_name_dir; if(target.GetType() == cmTarget::SHARED_LIBRARY) From 7da796d1fdd7cca07df733d010cd343f6f8787a9 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sat, 27 Aug 2011 10:48:55 -0700 Subject: [PATCH 210/539] FindBoost: Call find_package with NO_MODULE first FindBoost now attempts to find Boost using find_package(Boost NO_MODULE) before it does a module mode search. User can now set any of these to Boost's install prefix to detect it in module or config mode: - Boost_DIR for consistency with other CMake modules - BOOST_ROOT or BOOSTROOT for adherence to boost convention --- Modules/FindBoost.cmake | 82 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 10 deletions(-) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index c3ac4247d31..5ccbd6b50fe 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -34,7 +34,7 @@ # Boost that contain header files only (e.g. foreach) you do not need to # specify COMPONENTS. # -# You should provide a minimum version number that should be used. If you provide this +# You should provide a minimum version number that should be used. If you provide this # version number and specify the REQUIRED attribute, this module will fail if it # can't find the specified or a later version. If you specify a version number this is # automatically put into the considered list of version numbers and thus doesn't need @@ -92,6 +92,12 @@ # BOOST_ROOT. Defaults to OFF. # [Since CMake 2.8.3] # +# Boost_NO_BOOST_CMAKE Do not do a find_package call in config mode +# before searching for a regular boost install. +# This will avoid finding boost-cmake installs. +# Defaults to OFF. +# [Since CMake 2.8.6] +# # Boost_USE_STATIC_RUNTIME If enabled, searches for boost libraries # linked against a static C++ standard library # ('s' ABI tag). This option should be set to @@ -134,7 +140,7 @@ # unless this is set to TRUE or the REQUIRED # keyword is specified in find_package(). # [Since CMake 2.8.0] -# +# # Boost_COMPILER Set this to the compiler suffix used by Boost # (e.g. "-gcc43") if FindBoost has problems finding # the proper Boost installation @@ -164,13 +170,27 @@ # # These last three variables are available also as environment variables: -# Also, note they are completely UPPERCASE. +# Also, note they are completely UPPERCASE, except Boost_DIR. +# +# Boost_DIR or The preferred installation prefix for searching for +# BOOST_ROOT or BOOSTROOT Boost. Set this if the module has problems finding +# the proper Boost installation. +# +# Note that Boost_DIR behaves exactly as _DIR +# variables are documented to behave in find_package's +# Config mode. That is, if it is set as a -D argument +# to CMake, it must point to the location of the +# BoostConfig.cmake or Boost-config.cmake file. If it +# is set as an environment variable, it must point to +# the root of the boost installation. BOOST_ROOT and +# BOOSTROOT, on the other hand, will point to the root +# in either case. +# +# To prevent falling back on the system paths, set +# Boost_NO_SYSTEM_PATHS to true. # -# BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for -# Boost. Set this if the module has problems finding -# the proper Boost installation. To prevent falling -# back on the system paths, set Boost_NO_SYSTEM_PATHS -# to true. +# To avoid finding boost-cmake installations, set +# Boost_NO_BOOST_CMAKE to true. # # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the # module has problems finding the proper Boost installation @@ -237,6 +257,43 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) + +#------------------------------------------------------------------------------- +# Before we go searching, check whether boost-cmake is avaialble, unless the +# user specifically asked NOT to search for boost-cmake. +# +# If Boost_DIR is set, this behaves as any find_package call would. If not, +# it looks at BOOST_ROOT and BOOSTROOT to find Boost. +# +if (NOT Boost_NO_BOOST_CMAKE) + # If Boost_DIR is not set, look for BOOSTROOT and BOOST_ROOT as alternatives, + # since these are more conventional for Boost. + if ("$ENV{Boost_DIR}" STREQUAL "") + if (NOT "$ENV{BOOST_ROOT}" STREQUAL "") + set(ENV{Boost_DIR} $ENV{BOOST_ROOT}) + elseif (NOT "$ENV{BOOSTROOT}" STREQUAL "") + set(ENV{Boost_DIR} $ENV{BOOSTROOT}) + endif() + endif() + + # Do the same find_package call but look specifically for the CMake version. + # Note that args are passed in the Boost_FIND_xxxxx variables, so there is no + # need to delegate them to this find_package call. + find_package(Boost QUIET NO_MODULE) + + # If we found boost-cmake, then we're done. Print out what we found. + # Otherwise let the rest of the module try to find it. + if (Boost_FOUND) + message("Boost ${Boost_FIND_VERSION} found.") + if (Boost_FIND_COMPONENTS) + message("Found Boost components:") + message(" ${Boost_FIND_COMPONENTS}") + endif() + return() + endif() +endif() + + #------------------------------------------------------------------------------- # FindBoost functions & macros # @@ -287,7 +344,7 @@ macro(_Boost_ADJUST_LIB_VARS basename) set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} ) endif() - + if(Boost_${basename}_LIBRARY) set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library") @@ -372,7 +429,7 @@ endfunction() # # End functions/macros -# +# #------------------------------------------------------------------------------- @@ -516,6 +573,11 @@ else(_boost_IN_CACHE) _Boost_CHECK_SPELLING(Boost_LIBRARYDIR) _Boost_CHECK_SPELLING(Boost_INCLUDEDIR) + # If BOOST_ROOT was defined in the environment, use it. + if (NOT BOOST_ROOT AND NOT $ENV{Boost_DIR} STREQUAL "") + set(BOOST_ROOT $ENV{Boost_DIR}) + endif() + # If BOOST_ROOT was defined in the environment, use it. if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") set(BOOST_ROOT $ENV{BOOST_ROOT}) From 83ce7c4d3cbc8b4277e815f861456ea6f7ec18e3 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 2 Sep 2011 00:01:05 -0400 Subject: [PATCH 211/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 4558e2aba7a..37ec74d9555 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 01) +SET(KWSYS_DATE_STAMP_DAY 02) From 93d8d1992ed94225bb0a5706f0a294524913dccc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 25 Aug 2011 19:01:04 +0200 Subject: [PATCH 212/539] Add some more unit tests. --- .../GenerateExportHeader/CMakeLists.txt | 2 ++ .../nodeprecated/CMakeLists.txt | 26 +++++++++++++++++++ .../nodeprecated/CMakeLists.txt.in | 15 +++++++++++ .../nodeprecated/src/main.cpp | 9 +++++++ .../nodeprecated/src/someclass.cpp | 9 +++++++ .../nodeprecated/src/someclass.h | 10 +++++++ .../prefix/CMakeLists.txt | 15 +++++++++++ .../GenerateExportHeader/prefix/main.cpp | 8 ++++++ .../prefix/useprefixclass.cpp | 7 +++++ .../prefix/useprefixclass.h | 13 ++++++++++ 10 files changed, 114 insertions(+) create mode 100644 Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt create mode 100644 Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in create mode 100644 Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp create mode 100644 Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp create mode 100644 Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h create mode 100644 Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt create mode 100644 Tests/Module/GenerateExportHeader/prefix/main.cpp create mode 100644 Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp create mode 100644 Tests/Module/GenerateExportHeader/prefix/useprefixclass.h diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index fee836e1df6..3edb548e695 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -152,6 +152,8 @@ add_subdirectory(lib_shared_and_static) add_subdirectory(lib_shared_and_statictest) add_subdirectory(override_symbol) +add_subdirectory(nodeprecated) +add_subdirectory(prefix) if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) # We deliberately call deprecated methods, and test for that elsewhere. diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt new file mode 100644 index 00000000000..aeeb13a85d0 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 2.8) + +project(nodeprecated) + +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined) + +configure_file(CMakeLists.txt.in ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined/CMakeLists.txt) +set(DEFINE_NO_DEPRECATED DEFINE_NO_DEPRECATED) +configure_file(CMakeLists.txt.in ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined/CMakeLists.txt) + +try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined_build + ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined + nodeprecated_test + OUTPUT_VARIABLE Out +) + +test_pass(Result "Failed to build without no-deprecated define") + +try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined_build + ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined + nodeprecated_test + OUTPUT_VARIABLE Out +) + +test_fail(Result "Built even with no-deprecated define") \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in new file mode 100644 index 00000000000..d8dc482f3ee --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8) + +project(nodeprecated_test) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include(GenerateExportHeader) + +add_library(nodeprecatedlib SHARED someclass.cpp) + +generate_export_header(nodeprecatedlib @DEFINE_NO_DEPRECATED@) + +add_executable(nodeprecatedconsumer main.cpp) + +target_link_libraries(nodeprecatedconsumer nodeprecatedlib) diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp b/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp new file mode 100644 index 00000000000..445a6520414 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp @@ -0,0 +1,9 @@ + +#include "someclass.h" + +int main(int, char**) +{ + SomeClass sc; + sc.someMethod(); + return 0; +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp new file mode 100644 index 00000000000..a3f41111cf5 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp @@ -0,0 +1,9 @@ + +#include "someclass.h" + +#ifndef NODEPRECATEDLIB_NO_DEPRECATED +void SomeClass::someMethod() const +{ + +} +#endif diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h new file mode 100644 index 00000000000..312a177f185 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h @@ -0,0 +1,10 @@ + +#include "nodeprecatedlib_export.h" + +class NODEPRECATEDLIB_EXPORT SomeClass +{ +public: +#ifndef NODEPRECATEDLIB_NO_DEPRECATED + void someMethod() const; +#endif +}; diff --git a/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt b/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt new file mode 100644 index 00000000000..bd64df283cc --- /dev/null +++ b/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt @@ -0,0 +1,15 @@ +project(use_prefix) + +set(use_prefix_lib_SRCS + useprefixclass.cpp +) + +add_library(use_prefix_lib SHARED useprefixclass.cpp) + +generate_export_header(use_prefix_lib + PREFIX_NAME MYPREFIX_ +) + +add_executable(use_prefix main.cpp) + +target_link_libraries(use_prefix use_prefix_lib) \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/prefix/main.cpp b/Tests/Module/GenerateExportHeader/prefix/main.cpp new file mode 100644 index 00000000000..d04ae3c9c72 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/prefix/main.cpp @@ -0,0 +1,8 @@ + +#include "useprefixclass.h" + +int main(int argc, char **argv) +{ + UsePrefixClass upc; + return upc.someMethod(); +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp new file mode 100644 index 00000000000..8337ab845c8 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp @@ -0,0 +1,7 @@ + +#include "useprefixclass.h" + +int UsePrefixClass::someMethod() const +{ + return 0; +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h new file mode 100644 index 00000000000..f5e31b507d7 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h @@ -0,0 +1,13 @@ + +#ifndef USEPREFIXCLASS_H +#define USEPREFIXCLASS_H + +#include "use_prefix_lib_export.h" + +class MYPREFIX_USE_PREFIX_LIB_EXPORT UsePrefixClass +{ +public: + int someMethod() const; +}; + +#endif From 38aab379629a797e959f93b40ba18e63f14d1f64 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 2 Sep 2011 08:37:05 -0400 Subject: [PATCH 213/539] Set CMAKE__COMPILER_ID for VS generators Currently the VS generators do not support Intel C/C++ .icproj files and the MS tools do not include a Fortran compiler. Therefore we can always set the C and CXX compiler IDs to "MSVC" and the Fortran ID to "Intel". This fixes a regression in support for the Intel Fortran compiler under the VS plugin introduced by commit cd43636c (Modernize Intel compiler info on Windows, 2010-12-16). The commit moved the compiler information into platform files that only load when the proper compiler id is set. It worked for the NMake Makefiles generator but not for the VS IDE generator because it did not set the compiler id. --- Modules/CMakeDetermineCCompiler.cmake | 5 +---- Modules/CMakeDetermineCXXCompiler.cmake | 5 +---- Modules/CMakeDetermineFortranCompiler.cmake | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 06664c10ff9..e2e268fb3c8 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -105,10 +105,7 @@ ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION) IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") SET(CMAKE_C_COMPILER_ID_RUN 1) SET(CMAKE_C_PLATFORM_ID "Windows") - - # TODO: Set the compiler id. It is probably MSVC but - # the user may be using an integrated Intel compiler. - # SET(CMAKE_C_COMPILER_ID "MSVC") + SET(CMAKE_C_COMPILER_ID "MSVC") ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") IF(NOT CMAKE_C_COMPILER_ID_RUN) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index e77672dca62..82983693310 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -117,10 +117,7 @@ ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION) IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") SET(CMAKE_CXX_COMPILER_ID_RUN 1) SET(CMAKE_CXX_PLATFORM_ID "Windows") - - # TODO: Set the compiler id. It is probably MSVC but - # the user may be using an integrated Intel compiler. - # SET(CMAKE_CXX_COMPILER_ID "MSVC") + SET(CMAKE_CXX_COMPILER_ID "MSVC") ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") IF(NOT CMAKE_CXX_COMPILER_ID_RUN) SET(CMAKE_CXX_COMPILER_ID_RUN 1) diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index ed4e98335a8..efcba29cf15 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -146,10 +146,7 @@ MARK_AS_ADVANCED(CMAKE_Fortran_COMPILER) IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") SET(CMAKE_Fortran_COMPILER_ID_RUN 1) SET(CMAKE_Fortran_PLATFORM_ID "Windows") - - # TODO: Set the compiler id. It is probably MSVC but - # the user may be using an integrated Intel compiler. - # SET(CMAKE_Fortran_COMPILER_ID "MSVC") + SET(CMAKE_Fortran_COMPILER_ID "Intel") ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") IF(NOT CMAKE_Fortran_COMPILER_ID_RUN) From f47393c66bb1810a9916fa755bc5830fb9d24d63 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Thu, 1 Sep 2011 21:56:53 +0200 Subject: [PATCH 214/539] CTest: Fix memory leaks on error Credit goes to "cppcheck". Signed-off-by: Thomas Jarosch --- Source/CTest/cmCTestRunTest.cxx | 2 ++ Source/CTest/cmParsePHPCoverage.cxx | 1 + Source/cmCTest.cxx | 2 ++ 3 files changed, 5 insertions(+) diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 60695daa11f..81f18b05c85 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -93,6 +93,7 @@ void cmCTestRunTest::CompressOutput() ret = deflateInit(&strm, -1); //default compression level if (ret != Z_OK) { + delete[] out; return; } @@ -106,6 +107,7 @@ void cmCTestRunTest::CompressOutput() { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error during output " "compression. Sending uncompressed output." << std::endl); + delete[] out; return; } diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx index 32c1ec11038..593b2d1a87f 100644 --- a/Source/CTest/cmParsePHPCoverage.cxx +++ b/Source/CTest/cmParsePHPCoverage.cxx @@ -159,6 +159,7 @@ bool cmParsePHPCoverage::ReadFileInformation(std::ifstream& in) // read open quote if(in.get(c) && c != '"') { + delete[] s; return false; } // read the string data diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 75a564e7886..702ba10addb 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -3096,6 +3096,7 @@ bool cmCTest::CompressString(std::string& str) ret = deflateInit(&strm, -1); //default compression level if (ret != Z_OK) { + delete[] out; return false; } @@ -3109,6 +3110,7 @@ bool cmCTest::CompressString(std::string& str) { cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression." << std::endl); + delete[] out; return false; } From 4868921bc2b5ad85221d51d585bb2116a2826915 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Thu, 1 Sep 2011 21:57:30 +0200 Subject: [PATCH 215/539] Fix file() command descriptor leak on error Credit goes to "cppcheck". Signed-off-by: Thomas Jarosch --- Source/cmFileCommand.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 9a3de9ba949..3b639065e7f 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2982,6 +2982,7 @@ cmFileCommand::HandleUploadCommand(std::vector const& args) std::string errStr = "UPLOAD cannot stat file '"; errStr += filename + "'."; this->SetError(errStr.c_str()); + fclose(fin); return false; } @@ -2991,6 +2992,7 @@ cmFileCommand::HandleUploadCommand(std::vector const& args) if(!curl) { this->SetError("UPLOAD error initializing curl."); + fclose(fin); return false; } From d1751fbf17d2c0e945f696b920fe0cf2a8ad14b2 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Thu, 1 Sep 2011 21:59:57 +0200 Subject: [PATCH 216/539] ccmake: Fix off-by-one memory access error Credit goes to "cppcheck". Signed-off-by: Thomas Jarosch --- Source/CursesDialog/cmCursesLongMessageForm.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index 1c48d8c7c28..0e2cd229fc0 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -68,7 +68,7 @@ void cmCursesLongMessageForm::UpdateStatusBar() } else { - width = cmCursesMainForm::MAX_WIDTH; + width = cmCursesMainForm::MAX_WIDTH-1; } bar[width] = '\0'; From 79701929fb7dc3a8aee913866bc8f9352af57ee7 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 2 Sep 2011 14:20:02 -0400 Subject: [PATCH 217/539] Suppress Qt warning for dashmacmini5 builds The clang and icc compilers see two lines of warning with essentially the same message. But the second line does not say qglobal.h, so remove that part of the warning exclusion regex. See parent commit for further comments regarding this warning exclusion. --- CTestCustom.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index d11f515f4da..0e61da4416d 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -43,7 +43,7 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION "CMakeSetupManifest.xml.*manifest authoring warning.*Unrecognized Element" "cc-3968 CC: WARNING File.*" # "implicit" truncation by static_cast "ld: warning: directory not found for option .-(F|L)" - "qglobal.h.*warning.*This version of Mac OS X is unsupported" + "warning.*This version of Mac OS X is unsupported" ) IF(NOT "@CMAKE_GENERATOR@" MATCHES "Xcode") From cd81da30f7477b5653665608f4de5f4a4a0e1a14 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 2 Sep 2011 14:37:39 -0400 Subject: [PATCH 218/539] FindPackageMessage: Eliminate new lines using REGEX REPLACE Re-fix problem exposed by recent commit to FindPythonInterp. If the find "details" has new lines in it, then replace them with the empty string so that the string may be saved as a cache entry that can be re-read next time CMake runs. Use REGEX REPLACE, and replace with an empty string, eliminating the problem characters, so that we may easily extend this to include additional problem characters in the future if necessary. --- Modules/FindPackageMessage.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindPackageMessage.cmake b/Modules/FindPackageMessage.cmake index 5afee3e3972..48d3472b5da 100644 --- a/Modules/FindPackageMessage.cmake +++ b/Modules/FindPackageMessage.cmake @@ -34,7 +34,7 @@ FUNCTION(FIND_PACKAGE_MESSAGE pkg msg details) # Avoid printing a message repeatedly for the same find result. IF(NOT ${pkg}_FIND_QUIETLY) - STRING(REPLACE "\n" "\\n" details "${details}") + STRING(REGEX REPLACE "[\n]" "" details "${details}") SET(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) IF(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") # The message has not yet been printed. From bf14d95946f997b00b2d2f296fc2fa7ade9655c3 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 2 Sep 2011 15:35:06 -0400 Subject: [PATCH 219/539] CMake 2.8.6-rc2 --- CMakeLists.txt | 2 +- ChangeLog.manual | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0fcabd531b..ea4ff0c132d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -418,7 +418,7 @@ SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) SET(CMake_VERSION_PATCH 6) SET(CMake_VERSION_TWEAK 0) -SET(CMake_VERSION_RC 1) +SET(CMake_VERSION_RC 2) # Releases define a tweak level. IF(DEFINED CMake_VERSION_TWEAK) diff --git a/ChangeLog.manual b/ChangeLog.manual index 7c5a588dfb5..aa8ed5761a8 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,100 @@ +Changes in CMake 2.8.6-rc2 (since 2.8.6-rc1) +-------------------------------------------- +Brad King (2): + KWSys: Add hash function for std::string + KWSys: Fix std::string hash function for Borland + +Clinton Stimpson (1): + qt4: also find QtUiTools when cross compiling with mingw. + +David Cole (3): + Xcode4: Requires more quoting of single quote char + cmake.m4: Use modern signature of install(FILES ...) + CMake Release Scripts: Changes for next release candidate... + +David Faure (1): + Don't use a variable name that might be used in other files. + +Stephen Kelly (73): + Create moc files in the current binary dir, not the top level. + Make the formatting of feature_summary output a little better. + Add the GenerateExportMacro with unit tests. + Handle the case where the user changes the DEFINE_SYMBOL property. + Add a newline at the end of the file. + Add a newline at the end of the file. + Add missing licence header. + Remove the fatal_warnings option which is no longer used. + Test for features, not specific compilers. + Simplify. We already know we have hidden visibility at this point. + Simplify the compiler feature check + Add some debug output. + Short-circuit the tests on unsupported compilers. + Test expected no-op instead of aborting the build. + Fix tests with clang. + Fix typo and tests failing as a result. + Only run the failure tests with gcc >= 4.2 + Set the CMAKE_RUNTIME_OUTPUT_DIRECTORY for windows builds. + Only set the COMPILER_HAS_HIDDEN_VISIBILITY if GCC >= 4.2 + Disable all export macros on Borland. + Another attempt to fix the tests on Borland. + Use the correct project name compiletest not compilefail + Fix off-by-not in test for Borland. + Another attempt at fixing Borland. + Add some debug output to narrow down deprecation test issues + Export deprecated free methods too. + Remember to surround the other deprecated test in the Borland check. + Only set the deprecated attribute if hidden visibilty is enabled. + Make sure the hidden visibility variables never get set on MINGW. + Don't use hidden visibility on non-mingw windows either. + Don't export methods on already exported classes. + Split the deprecated available check from setting macro values. + Test for compiler features, instead of for specific platforms. + Exclude the XL compiler from the hidden-visibility test. + Add the COMPILER_HAS_DEPRECATED only if it has a declspec variant + Don't change the expected build result based on the platform. + Expect the tests to pass if hidden visibilty is not enabled. + Test -Werror instead of enabling it per compiler. + Add some messaging output to make remaining issues findable. + Perform the -Werror test only once. + Test for deprecated attribute before declspec. + Try to error on deprecated on Intel and SunCC. + Borland can't do deprecated. + Fixup forgotten part of aed84517c942a4c40f493fcf997cdf6a047349f8 + Disable testing of deprecated macros. + Don't enable deprecated on HP. + Don't enable deprecated on old GCC + Exclude cygwin from the hidden visibility feature. + Exclude PGI from exports and deprecated. + Start testing expected values for compiler flags. + Exclude win32 from hidden visibility checks. + Comment the test assertion for now + Test the correct cxx variable. + Fix the version extraction regex for clang. + Hopefully add version extraction for Intel. + Add some settings for non-truncation of test output. + Fix up the regex command for Intel. + Test for too-old-intel compilers. + Possibly fix test on HPUX. + Possibly fix configuration test on AIX. + Try to make the macros do almost nothing for Watcom. + More consistency in the macro options. + Add missing NO_EXPORT macro variant. + Look for errors reported by PGI too. + Quote paths in case there is a space in one of them. + Disable the tests for Watcom. + Fix Compiler id variable name. + Add quotes in case cmake is installed in a prefix with a space. + Fix the feature of using a specific prefix for macros. + Add documentation about the prefix and no_deprecated options. + Remove blank line at the start of the file. + Don't start a line with a dash(-) + Fix up verbatim code sections of the dox. + +Todd Gamblin (3): + FindBoost: Call find_package with NO_MODULE first + Fix XL compilers on non-AIX machines. + Fixed link bugs in BlueGeneP build. + Changes in CMake 2.8.6-rc1 (since 2.8.5) -------------------------------------------- Aaron C. Meadows (1): From 405bcd8def3c0a15d0005638e838623180a333cd Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 3 Sep 2011 00:01:12 -0400 Subject: [PATCH 220/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 37ec74d9555..d2f51291647 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 02) +SET(KWSYS_DATE_STAMP_DAY 03) From 99d8ca624dfd728f28443334bee4074318472145 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 4 Sep 2011 00:01:04 -0400 Subject: [PATCH 221/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index d2f51291647..0352fbd9405 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 03) +SET(KWSYS_DATE_STAMP_DAY 04) From dbd776dde7710a0bf1af1ca9c3554d9025502a31 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 4 Sep 2011 22:06:02 +0200 Subject: [PATCH 222/539] Don't put what some compilers consider junk at the end of the line. --- Modules/exportheader.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in index 131d3a77dce..80a879d7e04 100644 --- a/Modules/exportheader.cmake.in +++ b/Modules/exportheader.cmake.in @@ -32,4 +32,4 @@ # define @NO_DEPRECATED_MACRO_NAME@ #endif -#endif // @INCLUDE_GUARD_NAME@ +#endif From 48ba9b2f197cde7f309b9ef3770e1bf003a7e8e8 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 5 Sep 2011 00:01:04 -0400 Subject: [PATCH 223/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 0352fbd9405..5cb5fc97136 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 04) +SET(KWSYS_DATE_STAMP_DAY 05) From e05e0f1d2c63353e25675df5430e1cbcd909cf93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bj=C3=B6rk?= Date: Sat, 27 Aug 2011 20:17:00 +0200 Subject: [PATCH 224/539] Xcode: No spaces in makefile target names (#12370) Don't use spaces for target names in the makefiles. --- Source/cmGlobalXCodeGenerator.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 02a95fed1fa..0f2ee9bad5f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -327,7 +327,9 @@ std::string cmGlobalXCodeGenerator::PostBuildMakeTarget(std::string const& tName, std::string const& configName) { - std::string out = "PostBuild." + tName; + std::string target = tName; + cmSystemTools::ReplaceString(target, " ", "_"); + std::string out = "PostBuild." + target; if(this->XcodeVersion > 20) { out += "." + configName; From b0f6a975870ab37a74557252908e91acfecbc59d Mon Sep 17 00:00:00 2001 From: Eric NOULARD Date: Mon, 5 Sep 2011 20:22:00 +0200 Subject: [PATCH 225/539] CPack fix #12366 components RPM packages have the same package name fix based on the patch provided by winfriedd --- Modules/CPackRPM.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 729d8dfbce8..5826542d789 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -569,7 +569,7 @@ IF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY "# -*- rpm-spec -*- BuildRoot: \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@ Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ -Name: \@CPACK_RPM_PACKAGE_NAME\@ +Name: \@CPACK_RPM_PACKAGE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_NAME\@ Version: \@CPACK_RPM_PACKAGE_VERSION\@ Release: \@CPACK_RPM_PACKAGE_RELEASE\@ License: \@CPACK_RPM_PACKAGE_LICENSE\@ From eb4af16298a9b456c0fd8df6e20727ce7f6f422c Mon Sep 17 00:00:00 2001 From: Johannes Stallkamp Date: Thu, 9 Jun 2011 14:15:43 +0200 Subject: [PATCH 226/539] CTest: Fixed valgrind output parsing (#12260) Previous code was missing some matches in the output. This commit fixes the regular expressions used for output matching to detect numbers reported with commas in them, too. --- Source/CTest/cmCTestMemCheckHandler.cxx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 06124491ade..f0a98f9fd87 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -672,30 +672,30 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( cmsys::RegularExpression vgFMM( "== .*Mismatched free\\(\\) / delete / delete \\[\\]"); cmsys::RegularExpression vgMLK1( - "== .*[0-9][0-9]* bytes in [0-9][0-9]* blocks are definitely lost" - " in loss record [0-9][0-9]* of [0-9]"); + "== .*[0-9,]+ bytes in [0-9,]+ blocks are definitely lost" + " in loss record [0-9,]+ of [0-9,]+"); cmsys::RegularExpression vgMLK2( - "== .*[0-9][0-9]* \\([0-9]*,?[0-9]* direct, [0-9]*,?[0-9]* indirect\\)" - " bytes in [0-9][0-9]* blocks are definitely lost" - " in loss record [0-9][0-9]* of [0-9]"); + "== .*[0-9,]+ \\([0-9,]+ direct, [0-9,]+ indirect\\)" + " bytes in [0-9,]+ blocks are definitely lost" + " in loss record [0-9,]+ of [0-9,]+"); cmsys::RegularExpression vgPAR( "== .*Syscall param .* contains unaddressable byte\\(s\\)"); cmsys::RegularExpression vgMPK1( - "== .*[0-9][0-9]* bytes in [0-9][0-9]* blocks are possibly lost in" - " loss record [0-9][0-9]* of [0-9]"); + "== .*[0-9,]+ bytes in [0-9,]+ blocks are possibly lost in" + " loss record [0-9,]+ of [0-9,]+"); cmsys::RegularExpression vgMPK2( - "== .*[0-9][0-9]* bytes in [0-9][0-9]* blocks are still reachable" - " in loss record [0-9][0-9]* of [0-9]"); + "== .*[0-9,]+ bytes in [0-9,]+ blocks are still reachable" + " in loss record [0-9,]+ of [0-9,]+"); cmsys::RegularExpression vgUMC( "== .*Conditional jump or move depends on uninitialised value\\(s\\)"); cmsys::RegularExpression vgUMR1( - "== .*Use of uninitialised value of size [0-9][0-9]*"); - cmsys::RegularExpression vgUMR2("== .*Invalid read of size [0-9][0-9]*"); + "== .*Use of uninitialised value of size [0-9,]+"); + cmsys::RegularExpression vgUMR2("== .*Invalid read of size [0-9,]+"); cmsys::RegularExpression vgUMR3("== .*Jump to the invalid address "); cmsys::RegularExpression vgUMR4("== .*Syscall param .* contains " "uninitialised or unaddressable byte\\(s\\)"); cmsys::RegularExpression vgUMR5("== .*Syscall param .* uninitialised"); - cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9]"); + cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9,]+"); cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is " "locked by a different thread"); std::vector nonValGrindOutput; From 648c4544542ff54b3d5c498f36acae970edf0ae0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 5 Sep 2011 21:58:29 +0200 Subject: [PATCH 227/539] Add features from KDE for arguments to qdbusxml2cpp. --- Modules/Qt4Macros.cmake | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 6d7a3ec21ca..630a0bac1dc 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -216,9 +216,22 @@ MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename) SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp) SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc) - # handling more arguments (as in FindQt4.cmake from KDE4) will come soon, then - # _params will be used for more than just -m - SET(_params -m) + GET_SOURCE_FILE_PROPERTY(_nonamespace ${_interface} NO_NAMESPACE) + IF(_nonamespace) + SET(_params -N -m) + ELSE(_nonamespace) + SET(_params -m) + ENDIF(_nonamespace) + + GET_SOURCE_FILE_PROPERTY(_classname ${_interface} CLASSNAME) + IF(_classname) + SET(_params ${_params} -c ${_classname}) + ENDIF(_classname) + + GET_SOURCE_FILE_PROPERTY(_include ${_interface} INCLUDE) + IF(_include) + SET(_params ${_params} -i ${_include}) + ENDIF(_include) ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile} From f9e527794159844963f6bd67b5627026a0f552a6 Mon Sep 17 00:00:00 2001 From: Eric NOULARD Date: Mon, 5 Sep 2011 22:15:31 +0200 Subject: [PATCH 228/539] CPackRPM fix #12305, include directories in RPM package --- Modules/CPackRPM.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 729d8dfbce8..fa0bc72fbd8 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -491,11 +491,13 @@ ELSE(CPACK_RPM_PACKAGE_COMPONENT) ENDIF(CPACK_RPM_PACKAGE_COMPONENT) # Use files tree to construct files command (spec file) # We should not forget to include symlinks (thus -o -type l) +# We should include directory as well (thus -type d) +# but not the main local dir "." (thus -a -not -name ".") # We must remove the './' due to the local search and escape the # file name by enclosing it between double quotes (thus the sed) # Then we must authorize any man pages extension (adding * at the end) # because rpmbuild may automatically compress those files -EXECUTE_PROCESS(COMMAND find . -type f -o -type l +EXECUTE_PROCESS(COMMAND find . -type f -o -type l -o (-type d -a -not -name ".") COMMAND sed s:.*/man.*/.*:&*: COMMAND sed s/\\.\\\(.*\\\)/\"\\1\"/ WORKING_DIRECTORY "${WDIR}" From 49da3bdb2de4266955330f092b369a7afba0ca9d Mon Sep 17 00:00:00 2001 From: Eric NOULARD Date: Mon, 5 Sep 2011 22:43:45 +0200 Subject: [PATCH 229/539] CPackDeb fix #10325 automagically use fakeroot for DEB if fakeroot is found --- Modules/CPackDeb.cmake | 5 +++++ Source/CPack/cmCPackDebGenerator.cxx | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 90c80a4dc1d..d1c0bbe2320 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -133,6 +133,11 @@ IF(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS) SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) ENDIF(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS) +FIND_PROGRAM(FAKEROOT_EXECUTABLE fakeroot) +IF(FAKEROOT_EXECUTABLE) + SET(CPACK_DEBIAN_FAKEROOT_EXECUTABLE ${FAKEROOT_EXECUTABLE}) +ENDIF(FAKEROOT_EXECUTABLE) + IF(CPACK_DEBIAN_PACKAGE_SHLIBDEPS) # dpkg-shlibdeps is a Debian utility for generating dependency list FIND_PROGRAM(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 8c19bbd961b..b707e96aa46 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -392,7 +392,10 @@ int cmCPackDebGenerator::createDeb() } std::string cmd; - cmd = "\""; + if (NULL != this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE")) { + cmd += this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE"); + } + cmd += " \""; cmd += cmakeExecutable; cmd += "\" -E tar cfz data.tar.gz "; From 5b4528b1f45a2a7d1ef5effe9813b1a2d764ac60 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 6 Sep 2011 00:01:14 -0400 Subject: [PATCH 230/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 5cb5fc97136..f8530162fec 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 05) +SET(KWSYS_DATE_STAMP_DAY 06) From 339a321e66e142edbb0c6228caf368f09b4a072f Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 6 Sep 2011 12:06:36 -0400 Subject: [PATCH 231/539] Tests: Look for "Illegal" or "SegFault" in the output One of the dashmacmini5 runs of this test results in an "Illegal exception" detected instead of a segfault. For the purposes of this test, we're going to say that either is a "crash." --- Tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9f4e8a38c1b..7f83a479395 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1586,7 +1586,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ PASS_REGULAR_EXPRESSION "Failed") ELSE(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake") SET_TESTS_PROPERTIES(CTestTestCrash PROPERTIES - PASS_REGULAR_EXPRESSION "SegFault") + PASS_REGULAR_EXPRESSION "(Illegal|SegFault)") ENDIF(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake") CONFIGURE_FILE( From 98cb017a9deca35cd9a67e03b6bd95064b6d2fb7 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 6 Sep 2011 13:07:52 -0400 Subject: [PATCH 232/539] KWSys: Remove always-true dir_only parameter Its presence confuses, and, since it is always true, is useless. --- Source/kwsys/Glob.cxx | 23 ++++++++++++----------- Source/kwsys/Glob.hxx.in | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index c1f5100997e..b33b926817d 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -215,7 +215,7 @@ kwsys_stl::string Glob::PatternToRegex(const kwsys_stl::string& pattern, //---------------------------------------------------------------------------- void Glob::RecurseDirectory(kwsys_stl::string::size_type start, - const kwsys_stl::string& dir, bool dir_only) + const kwsys_stl::string& dir) { kwsys::Directory d; if ( !d.Load(dir.c_str()) ) @@ -258,7 +258,9 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, fullname = dir + "/" + fname; } - if ( !dir_only || !kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) + bool isDir = kwsys::SystemTools::FileIsDirectory(realname.c_str()); + + if ( !isDir ) { if ( (this->Internals->Expressions.size() > 0) && this->Internals->Expressions[ @@ -267,7 +269,7 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, this->AddFile(this->Internals->Files, realname.c_str()); } } - if ( kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) + else { bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str()); if (!isSymLink || this->RecurseThroughSymlinks) @@ -276,7 +278,7 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, { ++this->FollowedSymlinkCount; } - this->RecurseDirectory(start+1, realname, dir_only); + this->RecurseDirectory(start+1, realname); } } } @@ -284,13 +286,13 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, //---------------------------------------------------------------------------- void Glob::ProcessDirectory(kwsys_stl::string::size_type start, - const kwsys_stl::string& dir, bool dir_only) + const kwsys_stl::string& dir) { //kwsys_ios::cout << "ProcessDirectory: " << dir << kwsys_ios::endl; bool last = ( start == this->Internals->Expressions.size()-1 ); if ( last && this->Recurse ) { - this->RecurseDirectory(start, dir, dir_only); + this->RecurseDirectory(start, dir); return; } @@ -345,7 +347,7 @@ void Glob::ProcessDirectory(kwsys_stl::string::size_type start, // << this->Internals->TextExpressions[start].c_str() << kwsys_ios::endl; //kwsys_ios::cout << "Full name: " << fullname << kwsys_ios::endl; - if ( (!dir_only || !last) && + if ( !last && !kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) { continue; @@ -359,7 +361,7 @@ void Glob::ProcessDirectory(kwsys_stl::string::size_type start, } else { - this->ProcessDirectory(start+1, realname + "/", dir_only); + this->ProcessDirectory(start+1, realname + "/"); } } } @@ -462,12 +464,11 @@ bool Glob::FindFiles(const kwsys_stl::string& inexpr) // Handle network paths if ( skip > 0 ) { - this->ProcessDirectory(0, fexpr.substr(0, skip) + "/", - true); + this->ProcessDirectory(0, fexpr.substr(0, skip) + "/"); } else { - this->ProcessDirectory(0, "/", true); + this->ProcessDirectory(0, "/"); } return true; } diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in index cb050ee28cc..88c343ce006 100644 --- a/Source/kwsys/Glob.hxx.in +++ b/Source/kwsys/Glob.hxx.in @@ -83,12 +83,12 @@ public: protected: //! Process directory void ProcessDirectory(kwsys_stl::string::size_type start, - const kwsys_stl::string& dir, bool dir_only); + const kwsys_stl::string& dir); //! Process last directory, but only when recurse flags is on. That is // effectively like saying: /path/to/file/**/file void RecurseDirectory(kwsys_stl::string::size_type start, - const kwsys_stl::string& dir, bool dir_only); + const kwsys_stl::string& dir); //! Add regular expression void AddExpression(const char* expr); From 527a40f06fc7f0ea6aa9c1fe96fb0fe5611fa633 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 6 Sep 2011 13:12:03 -0400 Subject: [PATCH 233/539] KWSys: Add symlinks to directories as files (#12284) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This behaviour was previously broken; regardless of the RecurseThroughSymLinks value, symlinks to directories were NEVER added as files in the results. When RecurseThroughSymLinks is ON, symlinks to directories should be recursed as if they were the actual directories to gather the files within. However, when RecurseThroughSymLinks is OFF, symlinks to directories should be returned as files in the result. Inspired-by: Johan Björk --- Source/kwsys/Glob.cxx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index b33b926817d..513eb64086c 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -259,26 +259,23 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, } bool isDir = kwsys::SystemTools::FileIsDirectory(realname.c_str()); + bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str()); - if ( !isDir ) + if ( isDir && (!isSymLink || this->RecurseThroughSymlinks) ) { - if ( (this->Internals->Expressions.size() > 0) && - this->Internals->Expressions[ - this->Internals->Expressions.size()-1].find(fname.c_str()) ) + if (isSymLink) { - this->AddFile(this->Internals->Files, realname.c_str()); + ++this->FollowedSymlinkCount; } + this->RecurseDirectory(start+1, realname); } else { - bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str()); - if (!isSymLink || this->RecurseThroughSymlinks) + if ( (this->Internals->Expressions.size() > 0) && + this->Internals->Expressions[ + this->Internals->Expressions.size()-1].find(fname.c_str()) ) { - if (isSymLink) - { - ++this->FollowedSymlinkCount; - } - this->RecurseDirectory(start+1, realname); + this->AddFile(this->Internals->Files, realname.c_str()); } } } From d78bdb27832c91c775ad3782c9eb436dcd6a1e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bj=C3=B6rk?= Date: Sat, 27 Aug 2011 19:35:08 +0200 Subject: [PATCH 234/539] CMake: Write symlinks to directories as files in archives (#12284) Do not recurse through directory symlinks when adding files. Recursing through directory symlinks will generate broken archives, i.e., they will look something like this: foo -> bar/bar foo/Info <- Shouldn't be in archive. bar/bar bar/bar/Info --- Source/cmArchiveWrite.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 25dc8ba4873..eab8a592a98 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -180,7 +180,8 @@ bool cmArchiveWrite::AddPath(const char* path, { return false; } - if(!cmSystemTools::FileIsDirectory(path)) + if(!cmSystemTools::FileIsDirectory(path) || + cmSystemTools::FileIsSymlink(path)) { return true; } From 7b8dcdd17312a7c3ed731743468136b0ea89a6c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bj=C3=B6rk?= Date: Sat, 27 Aug 2011 19:34:37 +0200 Subject: [PATCH 235/539] CPack: Do not recurse through directory symlinks (#12284) ...when building CPack archive-based packages (.tar.gz and similar) Rather, put the symlinks-to-directories into the archive as files, and expect/trust that the things the symlinks point to are also in the archive. --- Source/CPack/cmCPackGenerator.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 0e4acd5561e..083279fdda7 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -1000,6 +1000,7 @@ int cmCPackGenerator::DoPackage() std::string findExpr = tempDirectory; findExpr += "/*"; gl.RecurseOn(); + gl.SetRecurseThroughSymlinks(false); if ( !gl.FindFiles(findExpr) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, From cb22afc02c0524ff2b701b33a29339dde1e80bbd Mon Sep 17 00:00:00 2001 From: Johan Bjork Date: Thu, 18 Aug 2011 19:30:51 +0200 Subject: [PATCH 236/539] Xcode: Honor -g0 to disable debugging (#12377) This commit changes ExtractFlag to remove all occurences of a flag, and only save the last one. (i.e., the dominant one according to GCC rules) --- Source/cmGlobalXCodeGenerator.cxx | 35 ++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 02a95fed1fa..a8a6eb46ead 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1219,19 +1219,30 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } //---------------------------------------------------------------------------- +// This function removes each occurence of the flag and returns the last one +// (i.e., the dominant flag in GCC) std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag, std::string& flags) { std::string retFlag; - std::string::size_type pos = flags.find(flag); - if(pos != flags.npos && (pos ==0 || flags[pos-1]==' ')) + std::string::size_type pos = flags.rfind(flag); + bool saved = false; + while(pos != flags.npos) { - while(pos < flags.size() && flags[pos] != ' ') + if(pos == 0 || flags[pos-1]==' ') { - retFlag += flags[pos]; - flags[pos] = ' '; - pos++; + while(pos < flags.size() && flags[pos] != ' ') + { + if(!saved) + { + retFlag += flags[pos]; + } + flags[pos] = ' '; + pos++; + } } + saved = true; + pos = flags.rfind(flag); } return retFlag; } @@ -1870,7 +1881,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, flags += gflag; } const char* debugStr = "YES"; - if(gflagc.size() ==0 && gflag.size() == 0) + // We can't set the Xcode flag differently depending on the language, + // so put them back in this case. + if( (lang && strcmp(lang, "CXX") == 0) && gflag != gflagc ) + { + cflags += " "; + cflags += gflagc; + flags += " "; + flags += gflag; + debugStr = "NO"; + } + if( gflag == "-g0" || gflag.size() == 0 ) { debugStr = "NO"; } From 96d106a78d1dc634cc635678afa399f1f5e15ff3 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Tue, 6 Sep 2011 08:28:20 -0400 Subject: [PATCH 237/539] CMake: Remove documentation for -E build (#12446) The '-E build build_dir' command was created and documented, but then morphed into '--build build_dir' instead, ... and then the -E documentation was never removed. This commit fixes that oversight. --- Source/cmake.cxx | 1 - Source/cmakemain.cxx | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2b8c718e020..a7924a4088c 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1112,7 +1112,6 @@ void CMakeCommandUsage(const char* program) errorStream << "Usage: " << program << " -E [command] [arguments ...]\n" << "Available commands: \n" - << " build build_dir - build the project in build_dir.\n" << " chdir dir cmd [args]... - run command in a given directory\n" << " compare_files file1 file2 - check if file1 is same as file2\n" << " copy file destination - copy file to destination (either file " diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 9f213a5e134..436236db124 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -72,7 +72,7 @@ static const char * cmDocumentationOptions[][3] = {"-E", "CMake command mode.", "For true platform independence, CMake provides a list of commands " "that can be used on all systems. Run with -E help for the usage " - "information. Commands available are: build, chdir, compare_files, copy, " + "information. Commands available are: chdir, compare_files, copy, " "copy_directory, copy_if_different, echo, echo_append, environment, " "make_directory, md5sum, remove, remove_directory, rename, tar, time, " "touch, touch_nocreate. In addition, some platform specific commands " From 540b25d529a1279f74df0a23140291f9557946db Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 7 Sep 2011 00:01:08 -0400 Subject: [PATCH 238/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index f8530162fec..d3033d92a99 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 06) +SET(KWSYS_DATE_STAMP_DAY 07) From 3a0d63242d959871b8f047e7f7ee1531f113f436 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 7 Sep 2011 19:04:44 -0400 Subject: [PATCH 239/539] KWStyle Test: Activate by default if KWStyle is found Re-arrange the logic to look for KWStyle in the typical install locations and under the Dashboards/Support directory for the typical CMake dashboard machine. If it's there, turn on CMAKE_USE_KWSTYLE by default, thereby activating the KWStyle related custom targets and the KWStyle test. --- Utilities/KWStyle/CMakeLists.txt | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Utilities/KWStyle/CMakeLists.txt b/Utilities/KWStyle/CMakeLists.txt index 4803ffa9867..5b0c84e8b00 100644 --- a/Utilities/KWStyle/CMakeLists.txt +++ b/Utilities/KWStyle/CMakeLists.txt @@ -12,17 +12,34 @@ #----------------------------------------------------------------------------- # CMake uses KWStyle for checking the coding style -OPTION(CMAKE_USE_KWSTYLE "Run KWStyle in order to check for violations of the coding standard." OFF) -MARK_AS_ADVANCED(CMAKE_USE_KWSTYLE) -IF(CMAKE_USE_KWSTYLE) - FIND_PROGRAM(KWSTYLE_EXECUTABLE +# Search for a built-from-source KWStyle under Dashboards/Support on a typical +# dashboard machines: +# +SET(home "$ENV{HOME}") +IF(NOT home) + STRING(REPLACE "\\" "/" home "$ENV{USERPROFILE}") +ENDIF() + +FIND_PROGRAM(KWSTYLE_EXECUTABLE NAMES KWStyle PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware Inc.\\KWStyle 1.0.0]/bin" + "${home}/Dashboards/Support/KWStyle/bin" ) - MARK_AS_ADVANCED(KWSTYLE_EXECUTABLE) +MARK_AS_ADVANCED(KWSTYLE_EXECUTABLE) + +SET(CMAKE_USE_KWSTYLE_DEFAULT OFF) +IF(KWSTYLE_EXECUTABLE) + SET(CMAKE_USE_KWSTYLE_DEFAULT ON) +ENDIF() +OPTION(CMAKE_USE_KWSTYLE + "Add StyleCheck target and KWStyle test: run KWStyle to check for coding standard violations." + ${CMAKE_USE_KWSTYLE_DEFAULT}) +MARK_AS_ADVANCED(CMAKE_USE_KWSTYLE) + +IF(CMAKE_USE_KWSTYLE) OPTION(KWSTYLE_USE_VIM_FORMAT "Set KWStyle to generate errors with a VIM-compatible format." OFF) OPTION(KWSTYLE_USE_MSVC_FORMAT "Set KWStyle to generate errors with a VisualStudio-compatible format." OFF) MARK_AS_ADVANCED(KWSTYLE_USE_VIM_FORMAT) @@ -59,4 +76,3 @@ IF(CMAKE_USE_KWSTYLE) ADD_CUSTOM_TARGET(StyleCheck DEPENDS ${CMake_BINARY_DIR}/KWStyleReport.txt) ENDIF(CMAKE_USE_KWSTYLE) - From 3246dc26651c50cebd99b64ca8fb1a05873f192f Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 8 Sep 2011 00:01:34 -0400 Subject: [PATCH 240/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index d3033d92a99..0599668d7ca 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 07) +SET(KWSYS_DATE_STAMP_DAY 08) From 71402eb25244e5805df54c2f6e62ddd36201dbd6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 8 Sep 2011 14:56:48 -0400 Subject: [PATCH 241/539] FortranCInterface: Compile separate Fortran lib in VerifyC[XX] The Intel Fortran plugin for Visual Studio requires Fortran source files to be compiled in a separate target from C and C++ code. Compile the VerifyFortran.f source file in a separate library and link the main VerifyFortanC executable to it. --- Modules/FortranCInterface/Verify/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/FortranCInterface/Verify/CMakeLists.txt b/Modules/FortranCInterface/Verify/CMakeLists.txt index 052dd599f03..e969f2408ab 100644 --- a/Modules/FortranCInterface/Verify/CMakeLists.txt +++ b/Modules/FortranCInterface/Verify/CMakeLists.txt @@ -24,7 +24,9 @@ include(FortranCInterface) FortranCInterface_HEADER(VerifyFortran.h SYMBOLS VerifyFortran) include_directories(${VerifyFortranC_BINARY_DIR}) -add_executable(VerifyFortranC main.c VerifyC.c VerifyFortran.f ${VerifyCXX}) +add_library(VerifyFortran STATIC VerifyFortran.f) +add_executable(VerifyFortranC main.c VerifyC.c ${VerifyCXX}) +target_link_libraries(VerifyFortranC VerifyFortran) if(NOT VERIFY_CXX) # The entry point (main) is defined in C; link with the C compiler. From 59204e11265eee5f8a482cf52b5daf5d57ed85c7 Mon Sep 17 00:00:00 2001 From: Eric NOULARD Date: Thu, 8 Sep 2011 22:00:34 +0200 Subject: [PATCH 242/539] CPack fix #12449 doc mispelled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CPACK_INSTALL_DIRECTORIES-->CPACK_INSTALLED_DIRECTORIESÅ“ --- Modules/CPack.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index d82de938cfd..2cc27cf1111 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -215,7 +215,7 @@ # # CPACK_INSTALL_COMMANDS - Extra commands to install components. # -# CPACK_INSTALL_DIRECTORIES - Extra directories to install. +# CPACK_INSTALLED_DIRECTORIES - Extra directories to install. # #============================================================================= From 555f589a5a3e9387956d451dc253fa1e3f35adff Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 8 Sep 2011 17:42:49 -0400 Subject: [PATCH 243/539] For VS Intel Fortran IDE builds, add a check to find the Fortran library PATH. To use VS C and Fotran in the same solution, it is required that VS be able to find the Fortran run time libraries as they will be implicitly linked by any Fortran library used by VS C programs. This adds a check into CMakeDetermineCompilerABI using a try-compile to find the correct PATH. --- Modules/CMakeDetermineCompilerABI.cmake | 26 +++++++++++++++++++ .../IntelVSImplicitPath/CMakeLists.txt | 11 ++++++++ .../IntelVSImplicitPath/extract.cmake | 12 +++++++++ .../IntelVSImplicitPath/hello.f | 0 4 files changed, 49 insertions(+) create mode 100644 Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt create mode 100644 Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake create mode 100644 Modules/FortranCInterface/IntelVSImplicitPath/hello.f diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 39d1f17b7d4..528c327b353 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -83,6 +83,32 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Parsed ${lang} implicit link information from above output:\n${log}\n\n") ENDIF() + # for VS IDE Intel Fortran we have to figure out the + # implicit link path for the fortran run time using + # a try-compile + IF("${lang}" MATCHES "Fortran" + AND "${CMAKE_GENERATOR}" MATCHES "Visual Studio") + SET(_desc "Determine Intel Fortran Compiler Implicit Link Path") + MESSAGE(STATUS "${_desc}") + # Build a sample project which reports symbols. + TRY_COMPILE(IFORT_LIB_PATH_COMPILED + ${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath + ${CMAKE_ROOT}/Modules/FortranCInterface/IntelVSImplicitPath + IntelFortranImplicit + CMAKE_FLAGS + "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" + OUTPUT_VARIABLE _output) + FILE(READ + ${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/implict_link.txt + dir) + LIST(APPEND implicit_dirs "${dir}") + FILE(WRITE + "${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/output.txt" + "${_output}") + SET(_desc "Determine Intel Fortran Compiler Implicit Link Path -- done") + MESSAGE(STATUS "${_desc}") + ENDIF() + SET(CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES "${implicit_libs}" PARENT_SCOPE) SET(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE) diff --git a/Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt b/Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt new file mode 100644 index 00000000000..e2a4b3fbd49 --- /dev/null +++ b/Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 2.8) +project(IntelFortranImplicit Fortran) +add_custom_command(OUTPUT ${IntelFortranImplicit_BINARY_DIR}/env.txt + COMMAND set > ${IntelFortranImplicit_BINARY_DIR}/env.txt) +add_library(FortranLib hello.f + ${IntelFortranImplicit_BINARY_DIR}/env.txt) +add_custom_target(ExtractLibPath ALL + COMMAND ${CMAKE_COMMAND} -P ${IntelFortranImplicit_SOURCE_DIR}/extract.cmake + WORKING_DIRECTORY ${IntelFortranImplicit_BINARY_DIR} +) +add_dependencies(ExtractLibPath FortranLib) diff --git a/Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake b/Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake new file mode 100644 index 00000000000..055247cfb6e --- /dev/null +++ b/Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake @@ -0,0 +1,12 @@ +file(STRINGS env.txt LIB REGEX "^LIB=.*$") +string(REPLACE "LIB=" "" LIB "${LIB}" ) +# change LIB from a string to a ; separated list of paths +set(LIB ${LIB}) +# look at each path and try to find ifconsol.lib +foreach( dir ${LIB}) + file(TO_CMAKE_PATH "${dir}" dir) + if(EXISTS "${dir}/ifconsol.lib") + file(WRITE implict_link.txt ${dir}) + return() + endif() +endforeach() diff --git a/Modules/FortranCInterface/IntelVSImplicitPath/hello.f b/Modules/FortranCInterface/IntelVSImplicitPath/hello.f new file mode 100644 index 00000000000..e69de29bb2d From 3ae6060f298e202973fcfdf8d863b3178a107382 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 9 Sep 2011 00:01:24 -0400 Subject: [PATCH 244/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 0599668d7ca..a11cf100d61 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 08) +SET(KWSYS_DATE_STAMP_DAY 09) From b7457de4eab41028a625887d27961a96120cfe1d Mon Sep 17 00:00:00 2001 From: Eric NOULARD Date: Fri, 9 Sep 2011 14:12:35 +0200 Subject: [PATCH 245/539] CPack fix template too --- Templates/CPackConfig.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Templates/CPackConfig.cmake.in b/Templates/CPackConfig.cmake.in index 0406392a5c0..7150feb72a8 100644 --- a/Templates/CPackConfig.cmake.in +++ b/Templates/CPackConfig.cmake.in @@ -5,7 +5,7 @@ # CPACK_INSTALL_CMAKE_PROJECTS - For each project (path, name, component) # CPACK_CMAKE_GENERATOR - CMake Generator used for the projects # CPACK_INSTALL_COMMANDS - Extra commands to install components -# CPACK_INSTALL_DIRECTORIES - Extra directories to install +# CPACK_INSTALLED_DIRECTORIES - Extra directories to install # CPACK_PACKAGE_DESCRIPTION_FILE - Description file for the package # CPACK_PACKAGE_DESCRIPTION_SUMMARY - Summary of the package # CPACK_PACKAGE_EXECUTABLES - List of pairs of executables and labels From 281b93734c306a29b4c2d151e2541178a8a18cc7 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 9 Sep 2011 11:53:38 -0400 Subject: [PATCH 246/539] CMake 2.8.6-rc3 --- CMakeLists.txt | 2 +- ChangeLog.manual | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea4ff0c132d..7b9fd567281 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -418,7 +418,7 @@ SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) SET(CMake_VERSION_PATCH 6) SET(CMake_VERSION_TWEAK 0) -SET(CMake_VERSION_RC 2) +SET(CMake_VERSION_RC 3) # Releases define a tweak level. IF(DEFINED CMake_VERSION_TWEAK) diff --git a/ChangeLog.manual b/ChangeLog.manual index aa8ed5761a8..c8237b939b1 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,61 @@ +Changes in CMake 2.8.6-rc3 (since 2.8.6-rc2) +-------------------------------------------- +Alexey Ozeritsky (2): + FindBLAS/LAPACK fixes + FindBLAS/LAPACK fixes + +Andreas Schneider (1): + Modules: Add support for more java archives in add_jar(). + +Björn Ricks (4): + Search for the installed python interpreter first + Determine python version + Update documentation of FindPythonInterp.cmake + Use FIND_PACKAGE_HANDLE_STANDARD_ARGS second mode + +Brad King (5): + VS: Map per-source Fortran flags to IDE options + VS: Map Fortran free- and fixed-format flags to IDE options + Fortran: Add support for free- and fixed-form flags + Xcode: Honor Fortran_FORMAT target and source file property + Set CMAKE__COMPILER_ID for VS generators + +David Cole (8): + KWSys: Remove always-true dir_only parameter + KWSys: Add symlinks to directories as files (#12284) + FindPackageMessage: Eliminate new lines in cache entries + FindPackageMessage: Eliminate new lines using REGEX REPLACE + CMake: Add SaveCache at the end of successful Generate calls + Suppress Qt warning for dashmacmini5 builds + Suppress Qt warning for dashmacmini5 builds + Tests: Look for "Illegal" or "SegFault" in the output + +Eric NOULARD (2): + CPack fix #12366 components RPM packages have the same package name + CPackRPM fix #12305, include directories in RPM package + +Johan Björk (5): + Xcode: No spaces in makefile target names (#12370) + CMake: Write symlinks to directories as files in archives (#12284) + CPack: Do not recurse through directory symlinks (#12284) + Xcode: Do not emit the ZERO_CHECK target more than once + Xcode: Honor -g0 to disable debugging (#12377) + +Johannes Stallkamp (1): + CTest: Fixed valgrind output parsing (#12260) + +Matt McCormick (1): + CMake: Remove documentation for -E build (#12446) + +Stephen Kelly (2): + Add some more unit tests. + Don't put what some compilers consider junk at the end of the line. + +Thomas Jarosch (3): + CTest: Fix memory leaks on error + Fix file() command descriptor leak on error + ccmake: Fix off-by-one memory access error + Changes in CMake 2.8.6-rc2 (since 2.8.6-rc1) -------------------------------------------- Brad King (2): From 539a822c8c541143ab954d8d355cb9643235d231 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 9 Sep 2011 17:11:57 -0400 Subject: [PATCH 247/539] Enable Fortran tests for IDE builds. --- Tests/CMakeLists.txt | 45 +++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9f4e8a38c1b..a3d1cbfb4ed 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1926,29 +1926,36 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ENDIF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) ENDIF() - # fortran does not work for IDE builds because - # CMAKE_STANDARD_LIBRARIES needs to be per language - IF(CMAKE_TEST_GENERATOR MATCHES "Make|KDevelop") - IF(CMAKE_Fortran_COMPILER) - ADD_TEST(Fortran ${CMAKE_CTEST_COMMAND} + IF(CMAKE_Fortran_COMPILER) + ADD_TEST(Fortran ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Fortran" + "${CMake_BINARY_DIR}/Tests/Fortran" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project testf + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --test-command testf) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") + + # FortranCInterface tests. + IF(UNIX) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY) + ADD_TEST(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags") + ELSE() + ADD_TEST(FortranC ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/Fortran" - "${CMake_BINARY_DIR}/Tests/Fortran" + "${CMake_SOURCE_DIR}/Tests/FortranC" + "${CMake_BINARY_DIR}/Tests/FortranC" --build-generator ${CMAKE_TEST_GENERATOR} - --build-project testf + --build-project FortranC --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config - --test-command testf) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") - - # FortranCInterface tests. - IF(UNIX) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY) - ADD_TEST(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P - ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags") - ENDIF() + --test-command CMakeFiles/FortranCInterface/FortranCInterface) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC") ENDIF() ENDIF() From e27a0e98704a1b364d7ba797d9e91d02e34e29fa Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 10 Sep 2011 00:01:19 -0400 Subject: [PATCH 248/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index a11cf100d61..049c63a4715 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 09) +SET(KWSYS_DATE_STAMP_DAY 10) From 39d5c49f2172705bf092c2f8808b350bd35ddefd Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 11 Sep 2011 00:01:04 -0400 Subject: [PATCH 249/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 049c63a4715..079308d653f 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 10) +SET(KWSYS_DATE_STAMP_DAY 11) From 201173133cb2b35e661a31d45595c717a9610898 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 12 Sep 2011 00:01:04 -0400 Subject: [PATCH 250/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 079308d653f..a47750eb978 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 11) +SET(KWSYS_DATE_STAMP_DAY 12) From 85fd794a1913cc7d43975d405c82fdc60b84671c Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 12 Sep 2011 15:37:22 +0200 Subject: [PATCH 251/539] remove stray brace in CPackDeb documentation --- Modules/CPackDeb.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 90c80a4dc1d..0975c5b5f20 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -20,7 +20,7 @@ # Mandatory : YES # Default : CPACK_PACKAGE_VERSION # The debian package version -# CPACK_DEBIAN_PACKAGE_ARCHITECTURE) +# CPACK_DEBIAN_PACKAGE_ARCHITECTURE # Mandatory : YES # Default : Output of dpkg --print-architecture (or i386 if dpkg is not found) # The debian package architecture From 59a22655765a46c48dc3f45189101f2e9a265776 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 12 Aug 2011 15:55:01 -0400 Subject: [PATCH 252/539] Xcode: Use EFFECTIVE_PLATFORM_NAME reference in ComputeOutputDir Caveats apply: only valid when not overriding default value for output dir *and* there is a CMAKE_XCODE_EFFECTIVE_PLATFORMS value. For now, CMAKE_XCODE_EFFECTIVE_PLATFORMS must be defined in each project, or in the cache for a build. Code relying on value of LOCATION and similar properties may not work if it depends on file existence on disk since CMake will not evaluate $(EFFECTIVE_PLATFORM_NAME). This feature is only enabled for making it easier to build Xcode iOS projects where the developer wants to be able to switch easily between simulator and device builds. --- Source/cmTarget.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 2cb3c011ca4..19ecbf06fd4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3757,8 +3757,12 @@ bool cmTarget::ComputeOutputDir(const char* config, // The generator may add the configuration's subdirectory. if(config && *config) { + const char *platforms = this->Makefile->GetDefinition( + "CMAKE_XCODE_EFFECTIVE_PLATFORMS"); + std::string suffix = + usesDefaultOutputDir && platforms ? "$(EFFECTIVE_PLATFORM_NAME)" : ""; this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> - AppendDirectoryForConfig("/", config, "", out); + AppendDirectoryForConfig("/", config, suffix.c_str(), out); } return usesDefaultOutputDir; From 64c9b318bf6062aa1a451d15af9e7016057168c1 Mon Sep 17 00:00:00 2001 From: David Cole Date: Mon, 12 Sep 2011 13:47:13 -0400 Subject: [PATCH 253/539] Xcode: Add test to demonstrate iOS project in Xcode Presently, this test is only run manually because not all machines have an iOS SDK, complications associated with certificates and code signing, having a device attached, ... If you're setup to do iOS dev work, you can easily run this test manually on your Mac using the Xcode generator and run the result in the simulator or on your attached device. --- Tests/iOSNavApp/CMakeLists.txt | 38 ++ Tests/iOSNavApp/Classes/NavApp3AppDelegate.h | 20 + Tests/iOSNavApp/Classes/NavApp3AppDelegate.m | 88 +++ Tests/iOSNavApp/Classes/RootViewController.h | 14 + Tests/iOSNavApp/Classes/RootViewController.m | 168 ++++++ Tests/iOSNavApp/Info.plist.in | 32 ++ Tests/iOSNavApp/MainWindow.xib | 542 +++++++++++++++++++ Tests/iOSNavApp/NavApp3_Prefix.pch | 14 + Tests/iOSNavApp/RootViewController.xib | 384 +++++++++++++ Tests/iOSNavApp/TotalFunction.c | 14 + Tests/iOSNavApp/TotalFunction.h | 14 + Tests/iOSNavApp/main.m | 17 + 12 files changed, 1345 insertions(+) create mode 100644 Tests/iOSNavApp/CMakeLists.txt create mode 100644 Tests/iOSNavApp/Classes/NavApp3AppDelegate.h create mode 100644 Tests/iOSNavApp/Classes/NavApp3AppDelegate.m create mode 100644 Tests/iOSNavApp/Classes/RootViewController.h create mode 100644 Tests/iOSNavApp/Classes/RootViewController.m create mode 100644 Tests/iOSNavApp/Info.plist.in create mode 100644 Tests/iOSNavApp/MainWindow.xib create mode 100644 Tests/iOSNavApp/NavApp3_Prefix.pch create mode 100644 Tests/iOSNavApp/RootViewController.xib create mode 100644 Tests/iOSNavApp/TotalFunction.c create mode 100644 Tests/iOSNavApp/TotalFunction.h create mode 100644 Tests/iOSNavApp/main.m diff --git a/Tests/iOSNavApp/CMakeLists.txt b/Tests/iOSNavApp/CMakeLists.txt new file mode 100644 index 00000000000..12c3ada3579 --- /dev/null +++ b/Tests/iOSNavApp/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 2.8.5) +project(NavApp3) + +set(CMAKE_OSX_SYSROOT iphoneos4.3) +set(CMAKE_OSX_ARCHITECTURES "armv6;armv7;i386") +set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator") + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/Classes + ) + +add_library(Functions STATIC TotalFunction.c TotalFunction.h) + +set(M_SRCS main.m Classes/NavApp3AppDelegate.m Classes/RootViewController.m) +set(HEADERS Classes/NavApp3AppDelegate.h Classes/RootViewController.h) +set(RESOURCES MainWindow.xib RootViewController.xib) + +add_executable(NavApp3 MACOSX_BUNDLE ${M_SRCS} ${HEADERS} ${RESOURCES}) + +target_link_libraries(NavApp3 + Functions + "-framework CoreGraphics" + "-framework Foundation" + "-framework UIKit" + ) + +set_target_properties(NavApp3 PROPERTIES + MACOSX_BUNDLE_GUI_IDENTIFIER "com.yourcompany.NavApp3" + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in + RESOURCE "${RESOURCES}" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer" + XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym" + XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER YES + XCODE_ATTRIBUTE_GCC_PREFIX_HEADER ${CMAKE_CURRENT_LIST_DIR}/NavApp3_Prefix.pch + XCODE_ATTRIBUTE_INFOPLIST_PREPROCESS YES + XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 3.0 + ) diff --git a/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h new file mode 100644 index 00000000000..f1234fe8b45 --- /dev/null +++ b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h @@ -0,0 +1,20 @@ +// +// NavApp3AppDelegate.h +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import + +@interface NavApp3AppDelegate : NSObject { + + UIWindow *window; + UINavigationController *navigationController; +} + +@property (nonatomic, retain) IBOutlet UIWindow *window; +@property (nonatomic, retain) IBOutlet UINavigationController *navigationController; + +@end diff --git a/Tests/iOSNavApp/Classes/NavApp3AppDelegate.m b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.m new file mode 100644 index 00000000000..c82204c1115 --- /dev/null +++ b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.m @@ -0,0 +1,88 @@ +// +// NavApp3AppDelegate.m +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import "NavApp3AppDelegate.h" +#import "RootViewController.h" + + +@implementation NavApp3AppDelegate + +@synthesize window; +@synthesize navigationController; + + +#pragma mark - +#pragma mark Application lifecycle + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + // Override point for customization after application launch. + // Add the navigation controller's view to the window and display. + [self.window addSubview:navigationController.view]; + [self.window makeKeyAndVisible]; + + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + /* + Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + */ +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + /* + Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + If your application supports background execution, called instead of applicationWillTerminate: when the user quits. + */ +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + /* + Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. + */ +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + /* + Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + */ +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + /* + Called when the application is about to terminate. + See also applicationDidEnterBackground:. + */ +} + + +#pragma mark - +#pragma mark Memory management + +- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { + /* + Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. + */ +} + + +- (void)dealloc { + [navigationController release]; + [window release]; + [super dealloc]; +} + + +@end diff --git a/Tests/iOSNavApp/Classes/RootViewController.h b/Tests/iOSNavApp/Classes/RootViewController.h new file mode 100644 index 00000000000..c5e9c1148a6 --- /dev/null +++ b/Tests/iOSNavApp/Classes/RootViewController.h @@ -0,0 +1,14 @@ +// +// RootViewController.h +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import + +@interface RootViewController : UITableViewController { +} + +@end diff --git a/Tests/iOSNavApp/Classes/RootViewController.m b/Tests/iOSNavApp/Classes/RootViewController.m new file mode 100644 index 00000000000..8a20d89db43 --- /dev/null +++ b/Tests/iOSNavApp/Classes/RootViewController.m @@ -0,0 +1,168 @@ +// +// RootViewController.m +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import "RootViewController.h" + +#include "TotalFunction.h" + + +@implementation RootViewController + + +#pragma mark - +#pragma mark View lifecycle + +/* +- (void)viewDidLoad { + [super viewDidLoad]; + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem; +} +*/ + +/* +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; +} +*/ +/* +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; +} +*/ +/* +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; +} +*/ +/* +- (void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; +} +*/ + +/* + // Override to allow orientations other than the default portrait orientation. +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations. + return (interfaceOrientation == UIInterfaceOrientationPortrait); +} + */ + + +#pragma mark - +#pragma mark Table view data source + +// Customize the number of sections in the table view. +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + + +// Customize the number of rows in the table view. +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + int n = Total("numberOfRows"); + return n; +} + + +// Customize the appearance of table view cells. +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; + } + + // Configure the cell. + cell.textLabel.text = [NSString stringWithFormat:@"%d", [indexPath row]]; + + return cell; +} + + +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + + +/* +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source. + [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } + else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. + } +} +*/ + + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} +*/ + + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + + +#pragma mark - +#pragma mark Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + + /* + <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; + // ... + // Pass the selected object to the new view controller. + [self.navigationController pushViewController:detailViewController animated:YES]; + [detailViewController release]; + */ +} + + +#pragma mark - +#pragma mark Memory management + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Relinquish ownership any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand. + // For example: self.myOutlet = nil; +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/Tests/iOSNavApp/Info.plist.in b/Tests/iOSNavApp/Info.plist.in new file mode 100644 index 00000000000..6ea0f00eeeb --- /dev/null +++ b/Tests/iOSNavApp/Info.plist.in @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDisplayName + NavApp3 + CFBundleExecutable + NavApp3 + CFBundleIconFile + + CFBundleIdentifier + com.yourcompany.NavApp3 + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + NavApp3 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + NSMainNibFile + MainWindow + UISupportedInterfaceOrientations + + + diff --git a/Tests/iOSNavApp/MainWindow.xib b/Tests/iOSNavApp/MainWindow.xib new file mode 100644 index 00000000000..1ff5f67fc10 --- /dev/null +++ b/Tests/iOSNavApp/MainWindow.xib @@ -0,0 +1,542 @@ + + + + 1024 + 10D571 + 786 + 1038.29 + 460.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 112 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + IBCocoaTouchFramework + + + + 1316 + + {320, 480} + + 1 + MSAxIDEAA + + NO + NO + + IBCocoaTouchFramework + YES + + + + + 1 + + IBCocoaTouchFramework + NO + + + 256 + {0, 0} + NO + YES + YES + IBCocoaTouchFramework + + + YES + + + + IBCocoaTouchFramework + + + RootViewController + + + 1 + + IBCocoaTouchFramework + NO + + + + + + + YES + + + delegate + + + + 4 + + + + window + + + + 5 + + + + navigationController + + + + 15 + + + + + YES + + 0 + + + + + + 2 + + + YES + + + + + -1 + + + File's Owner + + + 3 + + + + + -2 + + + + + 9 + + + YES + + + + + + + 11 + + + + + 13 + + + YES + + + + + + 14 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 11.IBPluginDependency + 13.CustomClassName + 13.IBPluginDependency + 2.IBAttributePlaceholdersKey + 2.IBEditorWindowLastContentRect + 2.IBPluginDependency + 3.CustomClassName + 3.IBPluginDependency + 9.IBEditorWindowLastContentRect + 9.IBPluginDependency + + + YES + UIApplication + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + RootViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + YES + + + YES + + + {{673, 376}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + NavApp3AppDelegate + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + {{186, 376}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 16 + + + + YES + + RootViewController + UITableViewController + + IBProjectSource + Classes/RootViewController.h + + + + UIWindow + UIView + + IBUserSource + + + + + NavApp3AppDelegate + NSObject + + YES + + YES + navigationController + window + + + YES + UINavigationController + UIWindow + + + + YES + + YES + navigationController + window + + + YES + + navigationController + UINavigationController + + + window + UIWindow + + + + + IBProjectSource + Classes/NavApp3AppDelegate.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIApplication + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIApplication.h + + + + UIBarButtonItem + UIBarItem + + IBFrameworkSource + UIKit.framework/Headers/UIBarButtonItem.h + + + + UIBarItem + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIBarItem.h + + + + UINavigationBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UINavigationBar.h + + + + UINavigationController + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UINavigationItem + NSObject + + + + UIResponder + NSObject + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UITableViewController + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITableViewController.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + UIWindow + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIWindow.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + NavApp3.xcodeproj + 3 + 112 + + diff --git a/Tests/iOSNavApp/NavApp3_Prefix.pch b/Tests/iOSNavApp/NavApp3_Prefix.pch new file mode 100644 index 00000000000..9919f307653 --- /dev/null +++ b/Tests/iOSNavApp/NavApp3_Prefix.pch @@ -0,0 +1,14 @@ +// +// Prefix header for all source files of the 'NavApp3' target in the 'NavApp3' project +// +#import + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iPhone SDK 3.0 and later." +#endif + + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/Tests/iOSNavApp/RootViewController.xib b/Tests/iOSNavApp/RootViewController.xib new file mode 100644 index 00000000000..12a4831f207 --- /dev/null +++ b/Tests/iOSNavApp/RootViewController.xib @@ -0,0 +1,384 @@ + + + + 784 + 10D541 + 760 + 1038.29 + 460.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 81 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + {320, 247} + + + 3 + MQA + + NO + YES + NO + IBCocoaTouchFramework + NO + 1 + 0 + YES + 44 + 22 + 22 + + + + + YES + + + view + + + + 3 + + + + dataSource + + + + 4 + + + + delegate + + + + 5 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 2 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 2.IBEditorWindowLastContentRect + 2.IBPluginDependency + + + YES + RootViewController + UIResponder + {{144, 609}, {320, 247}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 5 + + + + YES + + RootViewController + UITableViewController + + IBProjectSource + Classes/RootViewController.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSNetServices.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPort.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSStream.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSXMLParser.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIResponder + NSObject + + + + UIScrollView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIScrollView.h + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UITableView + UIScrollView + + IBFrameworkSource + UIKit.framework/Headers/UITableView.h + + + + UITableViewController + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITableViewController.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + NavApp3.xcodeproj + 3 + 81 + + diff --git a/Tests/iOSNavApp/TotalFunction.c b/Tests/iOSNavApp/TotalFunction.c new file mode 100644 index 00000000000..0965a88ac2a --- /dev/null +++ b/Tests/iOSNavApp/TotalFunction.c @@ -0,0 +1,14 @@ +// +// TotalFunction.c +// NavApp3 +// +// Created by David Cole on 8/10/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#include "TotalFunction.h" + +int Total(const char *context) +{ + return 22; +} diff --git a/Tests/iOSNavApp/TotalFunction.h b/Tests/iOSNavApp/TotalFunction.h new file mode 100644 index 00000000000..1301c3d64b8 --- /dev/null +++ b/Tests/iOSNavApp/TotalFunction.h @@ -0,0 +1,14 @@ +// +// TotalFunction.h +// NavApp3 +// +// Created by David Cole on 8/10/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#ifndef NavApp3_TotalFunction_h +#define NavApp3_TotalFunction_h + +int Total(const char *context); + +#endif diff --git a/Tests/iOSNavApp/main.m b/Tests/iOSNavApp/main.m new file mode 100644 index 00000000000..8070c47272b --- /dev/null +++ b/Tests/iOSNavApp/main.m @@ -0,0 +1,17 @@ +// +// main.m +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import + +int main(int argc, char *argv[]) { + + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + int retVal = UIApplicationMain(argc, argv, nil, nil); + [pool release]; + return retVal; +} From c7021203de8a3632d7f33bc812b41e88f5bc86f9 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 13 Sep 2011 00:01:08 -0400 Subject: [PATCH 254/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index a47750eb978..29d31bd1ee6 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 12) +SET(KWSYS_DATE_STAMP_DAY 13) From 2a3441b65ffb0b50cd0c05827b3b5ff877ad32b7 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 14 Sep 2011 00:01:04 -0400 Subject: [PATCH 255/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 29d31bd1ee6..3ad88dc6e85 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 13) +SET(KWSYS_DATE_STAMP_DAY 14) From c336778c528a82d66cd986c642c11156b5da1524 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 14 Sep 2011 10:38:04 -0400 Subject: [PATCH 256/539] CMake: Reference test targets only when BUILD_TESTING is ON You cannot set a property on a target that's not there, and these targets are not there when BUILD_TESTING is OFF. Thanks to Sankhesh Jhaveri for the bug report. --- CMakeLists.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf948c2a12b..788b38677fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,11 +231,13 @@ MACRO (CMAKE_BUILD_UTILITIES) CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}_c "${kwsys_folder}") CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}EncodeExecutable "${kwsys_folder}") CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}ProcessFwd9x "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsC "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsCxx "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestSharedForward "${kwsys_folder}") + if(BUILD_TESTING) + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsC "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsCxx "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestSharedForward "${kwsys_folder}") + endif() #--------------------------------------------------------------------- # Setup third-party libraries. @@ -598,7 +600,9 @@ ADD_SUBDIRECTORY(Source) ADD_SUBDIRECTORY(Utilities) ADD_SUBDIRECTORY(Tests) -CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests") +if(BUILD_TESTING) + CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests") +endif() CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat") CMAKE_SET_TARGET_FOLDER(documentation "Documentation") From fe8dc1138904eb6a2921946b65cc0b8cb5898161 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 14 Sep 2011 12:45:55 -0400 Subject: [PATCH 257/539] Tests: Add the more modern Mac64 nightly build We can remove the older ppc;i386 non-64-bit Mac nightly build in a little while after this one proves itself reliable. --- Tests/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 949df00914e..e5839012d78 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -368,6 +368,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ dash2win64_release.cmake) ADD_NIGHTLY_BUILD_TEST(CMakeNightlyMac dashmacmini2_release.cmake) + ADD_NIGHTLY_BUILD_TEST(CMakeNightlyMac64 + dashmacmini5_release.cmake) ADD_NIGHTLY_BUILD_TEST(CMakeNightlyLinux magrathea_release.cmake) ENDIF(CMAKE_BUILD_NIGHTLY_RELEASES) From a7ce26d837b1c6465c995519ee91e3e0d9190826 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Sep 2011 13:49:40 -0400 Subject: [PATCH 258/539] Move IntelVSImplicitPath project to better location This project is not part of the FortranCInterface module. Make it a sibling instead of a child directory. --- Modules/CMakeDetermineCompilerABI.cmake | 2 +- .../{FortranCInterface => }/IntelVSImplicitPath/CMakeLists.txt | 0 .../{FortranCInterface => }/IntelVSImplicitPath/extract.cmake | 0 Modules/{FortranCInterface => }/IntelVSImplicitPath/hello.f | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename Modules/{FortranCInterface => }/IntelVSImplicitPath/CMakeLists.txt (100%) rename Modules/{FortranCInterface => }/IntelVSImplicitPath/extract.cmake (100%) rename Modules/{FortranCInterface => }/IntelVSImplicitPath/hello.f (100%) diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 528c327b353..6792b7abd0e 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -93,7 +93,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) # Build a sample project which reports symbols. TRY_COMPILE(IFORT_LIB_PATH_COMPILED ${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath - ${CMAKE_ROOT}/Modules/FortranCInterface/IntelVSImplicitPath + ${CMAKE_ROOT}/Modules/IntelVSImplicitPath IntelFortranImplicit CMAKE_FLAGS "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" diff --git a/Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt b/Modules/IntelVSImplicitPath/CMakeLists.txt similarity index 100% rename from Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt rename to Modules/IntelVSImplicitPath/CMakeLists.txt diff --git a/Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake b/Modules/IntelVSImplicitPath/extract.cmake similarity index 100% rename from Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake rename to Modules/IntelVSImplicitPath/extract.cmake diff --git a/Modules/FortranCInterface/IntelVSImplicitPath/hello.f b/Modules/IntelVSImplicitPath/hello.f similarity index 100% rename from Modules/FortranCInterface/IntelVSImplicitPath/hello.f rename to Modules/IntelVSImplicitPath/hello.f From 67fcc838d9e857de2697c2fbe34e40ac095973dc Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Sep 2011 13:59:23 -0400 Subject: [PATCH 259/539] Simplify IntelVSImplicitPath detection project Use the ENV{LIB} variable directly instead of parsing the output of the whole environment from "set". Store the output in a .cmake script and include it from CMakeDetermineCompilerABI instead of using file(READ). --- Modules/CMakeDetermineCompilerABI.cmake | 5 +---- Modules/IntelVSImplicitPath/CMakeLists.txt | 14 +++++--------- Modules/IntelVSImplicitPath/detect.cmake | 9 +++++++++ Modules/IntelVSImplicitPath/extract.cmake | 12 ------------ 4 files changed, 15 insertions(+), 25 deletions(-) create mode 100644 Modules/IntelVSImplicitPath/detect.cmake delete mode 100644 Modules/IntelVSImplicitPath/extract.cmake diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 6792b7abd0e..a808a284dcc 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -98,13 +98,10 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) CMAKE_FLAGS "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" OUTPUT_VARIABLE _output) - FILE(READ - ${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/implict_link.txt - dir) - LIST(APPEND implicit_dirs "${dir}") FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/output.txt" "${_output}") + INCLUDE(${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/output.cmake OPTIONAL) SET(_desc "Determine Intel Fortran Compiler Implicit Link Path -- done") MESSAGE(STATUS "${_desc}") ENDIF() diff --git a/Modules/IntelVSImplicitPath/CMakeLists.txt b/Modules/IntelVSImplicitPath/CMakeLists.txt index e2a4b3fbd49..96dc4e61253 100644 --- a/Modules/IntelVSImplicitPath/CMakeLists.txt +++ b/Modules/IntelVSImplicitPath/CMakeLists.txt @@ -1,11 +1,7 @@ cmake_minimum_required (VERSION 2.8) project(IntelFortranImplicit Fortran) -add_custom_command(OUTPUT ${IntelFortranImplicit_BINARY_DIR}/env.txt - COMMAND set > ${IntelFortranImplicit_BINARY_DIR}/env.txt) -add_library(FortranLib hello.f - ${IntelFortranImplicit_BINARY_DIR}/env.txt) -add_custom_target(ExtractLibPath ALL - COMMAND ${CMAKE_COMMAND} -P ${IntelFortranImplicit_SOURCE_DIR}/extract.cmake - WORKING_DIRECTORY ${IntelFortranImplicit_BINARY_DIR} -) -add_dependencies(ExtractLibPath FortranLib) +add_custom_command( + OUTPUT output.cmake + COMMAND ${CMAKE_COMMAND} -P ${IntelFortranImplicit_SOURCE_DIR}/detect.cmake + ) +add_library(FortranLib hello.f output.cmake) diff --git a/Modules/IntelVSImplicitPath/detect.cmake b/Modules/IntelVSImplicitPath/detect.cmake new file mode 100644 index 00000000000..20753bef498 --- /dev/null +++ b/Modules/IntelVSImplicitPath/detect.cmake @@ -0,0 +1,9 @@ +# look at each path and try to find ifconsol.lib +set(LIB "$ENV{LIB}") +foreach(dir ${LIB}) + file(TO_CMAKE_PATH "${dir}" dir) + if(EXISTS "${dir}/ifconsol.lib") + file(WRITE output.cmake "list(APPEND implicit_dirs \"${dir}\")\n") + break() + endif() +endforeach() diff --git a/Modules/IntelVSImplicitPath/extract.cmake b/Modules/IntelVSImplicitPath/extract.cmake deleted file mode 100644 index 055247cfb6e..00000000000 --- a/Modules/IntelVSImplicitPath/extract.cmake +++ /dev/null @@ -1,12 +0,0 @@ -file(STRINGS env.txt LIB REGEX "^LIB=.*$") -string(REPLACE "LIB=" "" LIB "${LIB}" ) -# change LIB from a string to a ; separated list of paths -set(LIB ${LIB}) -# look at each path and try to find ifconsol.lib -foreach( dir ${LIB}) - file(TO_CMAKE_PATH "${dir}" dir) - if(EXISTS "${dir}/ifconsol.lib") - file(WRITE implict_link.txt ${dir}) - return() - endif() -endforeach() From ec0f23515f92fbdb0f887f6e44c897080e9defd0 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 15 Sep 2011 00:01:24 -0400 Subject: [PATCH 260/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 3ad88dc6e85..dd90c0506bf 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 14) +SET(KWSYS_DATE_STAMP_DAY 15) From 31f43fdb5af80029bc644bffd853c81a25424623 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 15 Sep 2011 16:20:33 +0200 Subject: [PATCH 261/539] Remove trailing whitespace Alex --- Source/cmCoreTryCompile.cxx | 58 ++++++++++++++++++------------------- Source/cmCoreTryCompile.h | 14 ++++----- Source/cmTryRunCommand.cxx | 26 ++++++++--------- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 96a214e751c..dca2fb3d58b 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -22,12 +22,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) // which signature were we called with ? this->SrcFileSignature = false; unsigned int i; - + const char* sourceDirectory = argv[2].c_str(); const char* projectName = 0; const char* targetName = 0; int extraArgs = 0; - + // look for CMAKE_FLAGS and store them std::vector cmakeFlags; for (i = 3; i < argv.size(); ++i) @@ -37,8 +37,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) // CMAKE_FLAGS is the first argument because we need an argv[0] that // is not used, so it matches regular command line parsing which has // the program name as arg 0 - for (; i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" && - argv[i] != "OUTPUT_VARIABLE"; + for (; i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" && + argv[i] != "OUTPUT_VARIABLE"; ++i) { extraArgs++; @@ -73,8 +73,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) if (argv[i] == "COMPILE_DEFINITIONS") { extraArgs++; - for (i = i + 1; i < argv.size() && argv[i] != "CMAKE_FLAGS" && - argv[i] != "OUTPUT_VARIABLE"; + for (i = i + 1; i < argv.size() && argv[i] != "CMAKE_FLAGS" && + argv[i] != "OUTPUT_VARIABLE"; ++i) { extraArgs++; @@ -101,7 +101,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) break; } } - + // do we have a srcfile signature if (argv.size() - extraArgs == 3) { @@ -133,7 +133,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) } // make sure the binary directory exists cmSystemTools::MakeDirectory(this->BinaryDirectory.c_str()); - + // do not allow recursive try Compiles if (this->BinaryDirectory == this->Makefile->GetHomeOutputDirectory()) { @@ -143,7 +143,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return -1; } - + std::string outFileName = this->BinaryDirectory + "/CMakeLists.txt"; // which signature are we using? If we are using var srcfile bindir if (this->SrcFileSignature) @@ -151,7 +151,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) // remove any CMakeCache.txt files so we will have a clean test std::string ccFile = this->BinaryDirectory + "/CMakeCache.txt"; cmSystemTools::RemoveFile(ccFile.c_str()); - + // we need to create a directory and CMakeList file etc... // first create the directories sourceDirectory = this->BinaryDirectory.c_str(); @@ -226,7 +226,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) langFlags += "_FLAGS"; fprintf(fout, "SET(CMAKE_VERBOSE_MAKEFILE 1)\n"); fprintf(fout, "SET(CMAKE_%s_FLAGS \"", lang); - const char* flags = this->Makefile->GetDefinition(langFlags.c_str()); + const char* flags = this->Makefile->GetDefinition(langFlags.c_str()); if(flags) { fprintf(fout, " %s ", flags); @@ -247,10 +247,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) } /* for the TRY_COMPILEs we want to be able to specify the architecture. - So the user can set CMAKE_OSX_ARCHITECTURE to i386;ppc and then set + So the user can set CMAKE_OSX_ARCHITECTURE to i386;ppc and then set CMAKE_TRY_COMPILE_OSX_ARCHITECTURE first to i386 and then to ppc to - have the tests run for each specific architecture. Since - cmLocalGenerator doesn't allow building for "the other" + have the tests run for each specific architecture. Since + cmLocalGenerator doesn't allow building for "the other" architecture only via CMAKE_OSX_ARCHITECTURES. */ if(this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_OSX_ARCHITECTURES")!=0) @@ -286,45 +286,45 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) this->BinaryDirectory.c_str()); /* Create the actual executable. */ fprintf(fout, "ADD_EXECUTABLE(cmTryCompileExec \"%s\")\n",source.c_str()); - fprintf(fout, + fprintf(fout, "TARGET_LINK_LIBRARIES(cmTryCompileExec ${LINK_LIBRARIES})\n"); fclose(fout); projectName = "CMAKE_TRY_COMPILE"; targetName = "cmTryCompileExec"; - // if the source is not in CMakeTmp + // if the source is not in CMakeTmp if(source.find("CMakeTmp") == source.npos) { this->Makefile->AddCMakeDependFile(source.c_str()); } - + } // else the srcdir bindir project target signature else { projectName = argv[3].c_str(); - + if (argv.size() - extraArgs == 5) { targetName = argv[4].c_str(); } } - + bool erroroc = cmSystemTools::GetErrorOccuredFlag(); cmSystemTools::ResetErrorOccuredFlag(); std::string output; // actually do the try compile now that everything is setup - int res = this->Makefile->TryCompile(sourceDirectory, + int res = this->Makefile->TryCompile(sourceDirectory, this->BinaryDirectory.c_str(), - projectName, - targetName, + projectName, + targetName, this->SrcFileSignature, - &cmakeFlags, + &cmakeFlags, &output); if ( erroroc ) { cmSystemTools::SetErrorOccured(); } - + // set the result var to the return value to indicate success or failure this->Makefile->AddCacheDefinition(argv[0].c_str(), (res == 0 ? "TRUE" : "FALSE"), @@ -335,7 +335,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) { this->Makefile->AddDefinition(outputVariable.c_str(), output.c_str()); } - + if (this->SrcFileSignature) { this->FindOutputFile(targetName); @@ -369,7 +369,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) { return; } - + std::string bdir = binDir; if(bdir.find("CMakeTmp") == std::string::npos) { @@ -378,7 +378,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) "CMakeTmp:", binDir); return; } - + cmsys::Directory dir; dir.Load(binDir); size_t fileNum; @@ -388,8 +388,8 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) if (strcmp(dir.GetFile(static_cast(fileNum)),".") && strcmp(dir.GetFile(static_cast(fileNum)),"..")) { - - if(deletedFiles.find( dir.GetFile(static_cast(fileNum))) + + if(deletedFiles.find( dir.GetFile(static_cast(fileNum))) == deletedFiles.end()) { deletedFiles.insert(dir.GetFile(static_cast(fileNum))); diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index e29dde8acdf..5c67f1355f4 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -28,27 +28,27 @@ class cmCoreTryCompile : public cmCommand /** * This is the core code for try compile. It is here so that other * commands, such as TryRun can access the same logic without - * duplication. + * duplication. */ int TryCompileCode(std::vector const& argv); - /** - * This deletes all the files created by TryCompileCode. + /** + * This deletes all the files created by TryCompileCode. * This way we do not have to rely on the timing and * dependencies of makefiles. */ void CleanupFiles(const char* binDir); - /** - * This tries to find the (executable) file created by + /** + * This tries to find the (executable) file created by TryCompileCode. The result is stored in OutputFile. If nothing is found, the error message is stored in FindErrorMessage. */ void FindOutputFile(const char* targetName); - + cmTypeMacro(cmCoreTryCompile, cmCommand); - + std::string BinaryDirectory; std::string OutputFile; std::string FindErrorMessage; diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index c9c4ed538cb..ce402a8fb47 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -49,8 +49,8 @@ ::InitialPass(std::vector const& argv, cmExecutionStatus &) { tryCompile.push_back(argv[i]); } - } - else + } + else { if (argv[i] == "OUTPUT_VARIABLE") { @@ -94,8 +94,8 @@ ::InitialPass(std::vector const& argv, cmExecutionStatus &) // although they could be used together, don't allow it, because // using OUTPUT_VARIABLE makes crosscompiling harder - if (this->OutputVariable.size() - && ((this->RunOutputVariable.size()) + if (this->OutputVariable.size() + && ((this->RunOutputVariable.size()) || (this->CompileOutputVariable.size()))) { cmSystemTools::Error( @@ -141,8 +141,8 @@ ::InitialPass(std::vector const& argv, cmExecutionStatus &) std::string runOutputContents; if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING")) { - this->DoNotRunExecutable(runArgs, - argv[3], + this->DoNotRunExecutable(runArgs, + argv[3], captureRunOutput ? &runOutputContents : 0); } else @@ -153,7 +153,7 @@ ::InitialPass(std::vector const& argv, cmExecutionStatus &) // now put the output into the variables if(this->RunOutputVariable.size()) { - this->Makefile->AddDefinition(this->RunOutputVariable.c_str(), + this->Makefile->AddDefinition(this->RunOutputVariable.c_str(), runOutputContents.c_str()); } @@ -167,7 +167,7 @@ ::InitialPass(std::vector const& argv, cmExecutionStatus &) { runOutputContents = std::string(compileOutput) + runOutputContents; } - this->Makefile->AddDefinition(this->OutputVariable.c_str(), + this->Makefile->AddDefinition(this->OutputVariable.c_str(), runOutputContents.c_str()); } } @@ -212,9 +212,9 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, /* This is only used when cross compiling. Instead of running the executable, two cache variables are created which will hold the results - the executable would have produced. + the executable would have produced. */ -void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, +void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, const std::string& srcFile, std::string* out ) @@ -249,7 +249,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, comment += "Run result of TRY_RUN(), indicates whether the executable " "would have been able to run on its target platform.\n"; comment += detailsString; - this->Makefile->AddCacheDefinition(this->RunResultVariable.c_str(), + this->Makefile->AddCacheDefinition(this->RunResultVariable.c_str(), "PLEASE_FILL_OUT-FAILED_TO_RUN", comment.c_str(), cmCacheManager::STRING); @@ -276,7 +276,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, "would have printed on stdout and stderr on its target platform.\n"; comment += detailsString; - this->Makefile->AddCacheDefinition(internalRunOutputName.c_str(), + this->Makefile->AddCacheDefinition(internalRunOutputName.c_str(), "PLEASE_FILL_OUT-NOTFOUND", comment.c_str(), cmCacheManager::STRING); @@ -294,7 +294,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, if (error) { static bool firstTryRun = true; - std::ofstream file(resultFileName.c_str(), + std::ofstream file(resultFileName.c_str(), firstTryRun ? std::ios::out : std::ios::app); if ( file ) { From c886e312bbd6e26f049215c8bcc821d9597fed8c Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 15 Sep 2011 16:28:35 +0200 Subject: [PATCH 262/539] Improve behaviour of --find-package mode with try_run/try_compile Instead of failing with an error message which says things have not been setup correctly, it now says that try_compile/try_run() are not supported in find_package mode (#12426). Alex --- Source/cmTryCompileCommand.cxx | 9 ++++++++- Source/cmTryRunCommand.cxx | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index 4d39d54567c..546e42fbd24 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -20,6 +20,14 @@ ::InitialPass(std::vector const& argv, cmExecutionStatus &) return false; } + if(this->Makefile->GetCMakeInstance()->GetWorkingMode() == + cmake::FIND_PACKAGE_MODE) + { + cmSystemTools::Error( + "The TRY_COMPILE() command is not supported in --find-package mode."); + return false; + } + this->TryCompileCode(argv); // if They specified clean then we clean up what we can @@ -32,4 +40,3 @@ ::InitialPass(std::vector const& argv, cmExecutionStatus &) } return true; } - diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index ce402a8fb47..9044cf8ffe9 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -22,6 +22,14 @@ ::InitialPass(std::vector const& argv, cmExecutionStatus &) return false; } + if(this->Makefile->GetCMakeInstance()->GetWorkingMode() == + cmake::FIND_PACKAGE_MODE) + { + cmSystemTools::Error( + "The TRY_RUN() command is not supported in --find-package mode."); + return false; + } + // build an arg list for TryCompile and extract the runArgs, std::vector tryCompile; From 7fca32a0bb4fa53ea95fd7f515798c21b59f1542 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 16 Sep 2011 00:01:11 -0400 Subject: [PATCH 263/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index dd90c0506bf..2aac25b9494 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 15) +SET(KWSYS_DATE_STAMP_DAY 16) From d5a0dc4f521310d8e4d2bea411e14f7102a3a35f Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 16 Sep 2011 15:48:41 -0400 Subject: [PATCH 264/539] Release Scripts: Use Qt 4.7.4 on dashmacmini5 (#12460) Also, since dashmacmini5 is newer/faster/better and is also building the source tarballs, remove that responsibility from the dashmacmini2 script. --- Utilities/Release/dashmacmini2_release.cmake | 1 - Utilities/Release/dashmacmini5_release.cmake | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake index 2668d38ab06..115181de293 100644 --- a/Utilities/Release/dashmacmini2_release.cmake +++ b/Utilities/Release/dashmacmini2_release.cmake @@ -6,7 +6,6 @@ set(HOST dashmacmini2) set(MAKE_PROGRAM "make") set(MAKE "${MAKE_PROGRAM} -j2") set(CPACK_BINARY_GENERATORS "PackageMaker TGZ TZ") -set(CPACK_SOURCE_GENERATORS "TGZ TZ") set(INITIAL_CACHE " CMAKE_BUILD_TYPE:STRING=Release CMAKE_OSX_ARCHITECTURES:STRING=ppc;i386 diff --git a/Utilities/Release/dashmacmini5_release.cmake b/Utilities/Release/dashmacmini5_release.cmake index 92eebd7349d..9bb3a98a06d 100644 --- a/Utilities/Release/dashmacmini5_release.cmake +++ b/Utilities/Release/dashmacmini5_release.cmake @@ -14,7 +14,7 @@ CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.5 CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CPACK_SYSTEM_NAME:STRING=Darwin64-universal BUILD_QtDialog:BOOL=TRUE -QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.6.4/install/bin/qmake +QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.7.4/install/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) include(${path}/release_cmake.cmake) From 8dfe74c358c5c5b364341a5fda1a43281d5bcc97 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 16 Sep 2011 16:42:22 -0400 Subject: [PATCH 265/539] libarchive: Fix ssize_t detection with mingwrt 3.20 This version of MinGW defines _SSIZE_T_ for ssize_t. This patch is based on upstream libarchive SVN commit 3649 (Fix build with mingwrt 3.20, 2011-08-27). Inspired-by: Tim Kientzle --- Utilities/cmlibarchive/libarchive/archive.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/cmlibarchive/libarchive/archive.h b/Utilities/cmlibarchive/libarchive/archive.h index 9b918a82bec..8bc612f4b4c 100644 --- a/Utilities/cmlibarchive/libarchive/archive.h +++ b/Utilities/cmlibarchive/libarchive/archive.h @@ -52,7 +52,7 @@ /* These should match the types used in 'struct stat' */ #if defined(_WIN32) && !defined(__CYGWIN__) #define __LA_INT64_T __int64 -# if defined(_SSIZE_T_DEFINED) +# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_) # define __LA_SSIZE_T ssize_t # elif defined(_WIN64) # define __LA_SSIZE_T __int64 From 962a54db5f92f66b3821dd110cd3200d483622bd Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 17 Sep 2011 00:01:11 -0400 Subject: [PATCH 266/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 2aac25b9494..1f8ea8a3dfe 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 16) +SET(KWSYS_DATE_STAMP_DAY 17) From ae331e1864201882cbf0484b8b3ed934791ec6df Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 17 Sep 2011 14:27:24 +0200 Subject: [PATCH 267/539] FindFLEX.cmake: also search the include dir FindFLEX.cmake already searched for the library, but not for the include dir. Do that too. Alex --- Modules/FindFLEX.cmake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index 3cc3da58cd9..6a70b403022 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -5,6 +5,7 @@ # FLEX_EXECUTABLE - the path to the flex executable # FLEX_VERSION - the version of flex # FLEX_LIBRARIES - The flex libraries +# FLEX_INCLUDE_DIRS - The path to the flex headers # # The minimum required version of flex can be specified using the # standard syntax, e.g. FIND_PACKAGE(FLEX 2.5.13) @@ -66,8 +67,14 @@ FIND_PROGRAM(FLEX_EXECUTABLE flex DOC "path to the flex executable") MARK_AS_ADVANCED(FLEX_EXECUTABLE) FIND_LIBRARY(FL_LIBRARY NAMES fl - DOC "path to the fl library") -MARK_AS_ADVANCED(FL_LIBRARY) + DOC "Path to the fl library") + +FIND_PATH(FLEX_INCLUDE_DIR FlexLexer.h + DOC "Path to the flex headers") + +MARK_AS_ADVANCED(FL_LIBRARY FLEX_INCLUDE_DIR) + +SET(FLEX_INCLUDE_DIRS ${FLEX_INCLUDE_DIR}) SET(FLEX_LIBRARIES ${FL_LIBRARY}) IF(FLEX_EXECUTABLE) From f1cd7d289e7e9881a17cbb9de025313a86391be8 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 18 Sep 2011 00:01:05 -0400 Subject: [PATCH 268/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 1f8ea8a3dfe..8373dd53b9b 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 17) +SET(KWSYS_DATE_STAMP_DAY 18) From b7ac63e1c199e72a7af85125030ae369671a02b4 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 18 Sep 2011 12:46:29 +0200 Subject: [PATCH 269/539] Fix typos in FeatureSummary.cmake (#12462) Patch by Yury Kudrashov Alex --- Modules/FeatureSummary.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index 885762ae97f..2a09c41de82 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -2,7 +2,7 @@ # # This module provides the macros feature_summary(), set_package_properties() and # add_feature_info(). -# For compatiblity it also still provides set_package_info(), set_feature_info(), +# For compatibility it also still provides set_package_info(), set_feature_info(), # print_enabled_features() and print_disabled_features(). # # These macros can be used to generate a summary of enabled and disabled @@ -130,13 +130,13 @@ # PURPOSE "Enables odt-export in MyWordProcessor") # # find_package(DBUS) -# set_package_properties(LibXml2 PROPERTIES TYPE RUNTIME +# set_package_properties(DBUS PROPERTIES TYPE RUNTIME # PURPOSE "Necessary to disable the screensaver during a presentation" ) # # ADD_FEATURE_INFO( ) # Use this macro to add information about a feature with the given . # contains whether this feature is enabled or not, -# is a text descibing the feature. +# is a text describing the feature. # The information can be displayed using feature_summary() for ENABLED_FEATURES # and DISABLED_FEATURES respectively. # @@ -344,7 +344,7 @@ FUNCTION(FEATURE_SUMMARY) ENDIF() IF(NOT _FS_WHAT) - MESSAGE(FATAL_ERROR "The call to FEATURE_SUMMAY() doesn't set the required WHAT argument.") + MESSAGE(FATAL_ERROR "The call to FEATURE_SUMMARY() doesn't set the required WHAT argument.") ENDIF() SET(validWhatParts "ENABLED_FEATURES" From 0ba98533d07641cac73a1a5ba4b86e4fb131c126 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 18 Sep 2011 12:51:05 +0200 Subject: [PATCH 270/539] Don't warn when setting a property multiple times to the same value #12464 Patch by Yury Kudryashov Alex --- Modules/FeatureSummary.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index 2a09c41de82..eb10cbc946d 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -209,7 +209,7 @@ FUNCTION(SET_PACKAGE_PROPERTIES _name _props) IF(_SPP_DESCRIPTION) GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION) - IF(_info) + IF(_info AND NOT "${_info}" STREQUAL "${_SPP_DESCRIPTION}") MESSAGE(STATUS "Warning: Property DESCRIPTION for package ${_name} already set to \"${_info}\", overriding it with \"${_SPP_DESCRIPTION}\"") ENDIF() @@ -219,7 +219,7 @@ FUNCTION(SET_PACKAGE_PROPERTIES _name _props) IF(_SPP_URL) GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_name}_URL) - IF(_info) + IF(_info AND NOT "${_info}" STREQUAL "${_SPP_URL}") MESSAGE(STATUS "Warning: Property URL already set to \"${_info}\", overriding it with \"${_SPP_URL}\"") ENDIF() From cfc6e01851b58ba61faecbf085d123294e5a78f4 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 19 Sep 2011 00:01:04 -0400 Subject: [PATCH 271/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 8373dd53b9b..fd3b7f700b5 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 18) +SET(KWSYS_DATE_STAMP_DAY 19) From d6795685ae25f1a9d0d7cda02d639ce8b402f9f9 Mon Sep 17 00:00:00 2001 From: "Marcus D. Hanwell" Date: Mon, 19 Sep 2011 14:04:42 -0400 Subject: [PATCH 272/539] Just code style changes. --- Modules/GenerateExportHeader.cmake | 80 +++++++++++++++++++----------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 4eb67b51556..e1ce16de4a0 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -25,7 +25,8 @@ # adds -fvisibility=hidden to CMAKE_CXX_FLAGS if supported, and is a no-op on Windows # which does not need extra compiler flags for exporting support. # -# This means that in the simplest case, users of these functions will be equivalent to: +# This means that in the simplest case, users of these functions will be +# equivalent to: # # add_compiler_export_flags() # add_library(somelib someclass.cpp) @@ -43,8 +44,8 @@ # ... # }; # -# The CMake fragment will generate a file in the ${CMAKE_CURRENT_BUILD_DIR} called -# somelib_export.h containing the macros SOMELIB_EXPORT, SOMELIB_NO_EXPORT, +# The CMake fragment will generate a file in the ${CMAKE_CURRENT_BUILD_DIR} +# called somelib_export.h containing the macros SOMELIB_EXPORT, SOMELIB_NO_EXPORT, # SOMELIB_DEPRECATED, SOMELIB_DEPRECATED_EXPORT and SOMELIB_DEPRECATED_NO_EXPORT. # The resulting file should be installed with other headers in the library. # @@ -86,11 +87,14 @@ # add_library(shared_variant SHARED ${lib_SRCS}) # add_library(static_variant ${lib_SRCS}) # generate_export_header(shared_variant BASE_NAME libshared_and_static) -# set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) +# set_target_properties(static_variant PROPERTIES +# COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) # -# This will cause the export macros to expand to nothing when building the static library. +# This will cause the export macros to expand to nothing when building the +# static library. # -# If DEFINE_NO_DEPRECATED is specified, then a macro ${BASE_NAME}_NO_DEPRECATED will be defined +# If DEFINE_NO_DEPRECATED is specified, then a macro ${BASE_NAME}_NO_DEPRECATED +# will be defined # This macro can be used to remove deprecated code from preprocessor output. # # option(EXCLUDE_DEPRECATED "Exclude deprecated parts of the library" FALSE) @@ -122,7 +126,6 @@ # # Generates the macros VTK_SOMELIB_EXPORT etc. - #============================================================================= # Copyright 2011 Stephen Kelly # @@ -139,10 +142,10 @@ include(CMakeParseArguments) include(CheckCXXCompilerFlag) - # TODO: Install this macro separately? macro(_check_cxx_compiler_attribute _ATTRIBUTE _RESULT) - check_cxx_source_compiles("${_ATTRIBUTE} int somefunc() { return 0; } int main() { return somefunc();}" ${_RESULT} + check_cxx_source_compiles("${_ATTRIBUTE} int somefunc() { return 0; } + int main() { return somefunc();}" ${_RESULT} # Some compilers do not fail with a bad flag FAIL_REGEX "unrecognized .*option" # GNU FAIL_REGEX "ignoring unknown option" # MSVC @@ -155,13 +158,16 @@ endmacro() macro(_test_compiler_hidden_visibility) - if (CMAKE_COMPILER_IS_GNUCXX) - exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) - string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") + if(CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS --version + OUTPUT_VARIABLE _gcc_version_info) + string(REGEX MATCH "[345]\\.[0-9]\\.[0-9]" + _gcc_version "${_gcc_version_info}") # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the # patch level, handle this here: if(NOT _gcc_version) - string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") + string(REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" + _gcc_version "${_gcc_version_info}") endif() if(${_gcc_version} VERSION_LESS "4.2") @@ -171,8 +177,10 @@ macro(_test_compiler_hidden_visibility) endif() if(CMAKE_CXX_COMPILER_ID MATCHES Intel) - exec_program(${CMAKE_CXX_COMPILER} ARGS -V OUTPUT_VARIABLE _intel_version_info) - string (REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1" _intel_version "${_intel_version_info}") + exec_program(${CMAKE_CXX_COMPILER} ARGS -V + OUTPUT_VARIABLE _intel_version_info) + string(REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1" + _intel_version "${_intel_version_info}") if(${_intel_version} VERSION_LESS "12.0") set(_INTEL_TOO_OLD TRUE) @@ -184,7 +192,7 @@ macro(_test_compiler_hidden_visibility) # Exclude XL here because it misinterprets -fvisibility=hidden even though # the check_cxx_compiler_flag passes # http://www.cdash.org/CDash/testDetails.php?test=109109951&build=1419259 - if (NOT GCC_TOO_OLD + if(NOT GCC_TOO_OLD AND NOT _INTEL_TOO_OLD AND NOT WIN32 AND NOT CYGWIN @@ -192,8 +200,10 @@ macro(_test_compiler_hidden_visibility) AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom) check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) - check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) - option(USE_COMPILER_HIDDEN_VISIBILITY "Use HIDDEN visibility support if available." ON) + check_cxx_compiler_flag(-fvisibility-inlines-hidden + COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) + option(USE_COMPILER_HIDDEN_VISIBILITY + "Use HIDDEN visibility support if available." ON) mark_as_advanced(USE_COMPILER_HIDDEN_VISIBILITY) endif() endmacro() @@ -204,13 +214,17 @@ macro(_test_compiler_has_deprecated) OR GCC_TOO_OLD OR "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom) - set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL "Compiler support for a deprecated attribute") + set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL + "Compiler support for a deprecated attribute") else() - _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED_ATTR) + _check_cxx_compiler_attribute("__attribute__((__deprecated__))" + COMPILER_HAS_DEPRECATED_ATTR) if(COMPILER_HAS_DEPRECATED_ATTR) - set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED_ATTR}" CACHE INTERNAL "Compiler support for a deprecated attribute") + set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED_ATTR}" + CACHE INTERNAL "Compiler support for a deprecated attribute") else() - _check_cxx_compiler_attribute("__declspec(deprecated)" COMPILER_HAS_DEPRECATED) + _check_cxx_compiler_attribute("__declspec(deprecated)" + COMPILER_HAS_DEPRECATED) endif() endif() endmacro() @@ -246,10 +260,13 @@ endmacro() macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) # Option overrides set(options DEFINE_NO_DEPRECATED) - set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE NO_DEPRECATED_MACRO_NAME) + set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME + DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE + NO_DEPRECATED_MACRO_NAME) set(multiValueArgs) - cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN}) set(BASE_NAME "${TARGET_LIBRARY}") @@ -266,7 +283,8 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) set(EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${BASE_NAME_LOWER}_export.h") set(DEPRECATED_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_DEPRECATED") set(STATIC_DEFINE "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_STATIC_DEFINE") - set(NO_DEPRECATED_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_NO_DEPRECATED") + set(NO_DEPRECATED_MACRO_NAME + "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_NO_DEPRECATED") if(_GEH_UNPARSED_ARGUMENTS) message(FATAL_ERROR "Unknown keywords given to GENERATE_EXPORT_HEADER(): \"${_GEH_UNPARSED_ARGUMENTS}\"") @@ -292,23 +310,25 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) set(STATIC_DEFINE ${_GEH_PREFIX_NAME}${_GEH_STATIC_DEFINE}) endif() - if (_GEH_DEFINE_NO_DEPRECATED) + if(_GEH_DEFINE_NO_DEPRECATED) set(DEFINE_NO_DEPRECATED TRUE) endif() - if (_GEH_NO_DEPRECATED_MACRO_NAME) - set(NO_DEPRECATED_MACRO_NAME ${_GEH_PREFIX_NAME}${_GEH_NO_DEPRECATED_MACRO_NAME}) + if(_GEH_NO_DEPRECATED_MACRO_NAME) + set(NO_DEPRECATED_MACRO_NAME + ${_GEH_PREFIX_NAME}${_GEH_NO_DEPRECATED_MACRO_NAME}) endif() set(INCLUDE_GUARD_NAME "${EXPORT_MACRO_NAME}_H") get_target_property(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY} DEFINE_SYMBOL) - if (NOT EXPORT_IMPORT_CONDITION) + if(NOT EXPORT_IMPORT_CONDITION) set(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY}_EXPORTS) endif() - configure_file("${_GENERATE_EXPORT_HEADER_MODULE_DIR}/exportheader.cmake.in" "${EXPORT_FILE_NAME}" @ONLY) + configure_file("${_GENERATE_EXPORT_HEADER_MODULE_DIR}/exportheader.cmake.in" + "${EXPORT_FILE_NAME}" @ONLY) endmacro() function(GENERATE_EXPORT_HEADER TARGET_LIBRARY) From 2d1acfe359852836f3096da0d3262d558ee383d3 Mon Sep 17 00:00:00 2001 From: "Marcus D. Hanwell" Date: Mon, 19 Sep 2011 14:55:19 -0400 Subject: [PATCH 273/539] Don't warn when nothing to do in visibility function. --- Modules/GenerateExportHeader.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index e1ce16de4a0..f2eaf8c467a 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -353,7 +353,7 @@ function(add_compiler_export_flags) _test_compiler_has_deprecated() if(NOT (USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY)) - message(WARNING "Compiler doesn't have hidden visibility") + # Just return if there are no flags to add. return() endif() From 6a10deb670385fb8c5b584807418def67d1e02a1 Mon Sep 17 00:00:00 2001 From: "Marcus D. Hanwell" Date: Mon, 19 Sep 2011 16:42:42 -0400 Subject: [PATCH 274/539] Made ADD_COMPILER_EXPORT_FLAGS into a macro. It adds to the CMAKE_CXX_FLAGS (as before), or populates the supplied optional argument with the CXX_FLAGS for symbol import/export. --- Modules/GenerateExportHeader.cmake | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index f2eaf8c467a..aaeff473d76 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -1,6 +1,6 @@ # - Function for generation of export macros for libraries # This module provides the function GENERATE_EXPORT_HEADER() and the -# accompanying ADD_COMPILER_EXPORT_FLAGS() function. +# accompanying ADD_COMPILER_EXPORT_FLAGS() macro. # # The GENERATE_EXPORT_HEADER function can be used to generate a file suitable # for preprocessor inclusion which contains EXPORT macros to be used in @@ -22,8 +22,11 @@ # # By default GENERATE_EXPORT_HEADER() generates macro names in a file name # determined by the name of the library. The ADD_COMPILER_EXPORT_FLAGS macro -# adds -fvisibility=hidden to CMAKE_CXX_FLAGS if supported, and is a no-op on Windows -# which does not need extra compiler flags for exporting support. +# adds -fvisibility=hidden to CMAKE_CXX_FLAGS if supported, and is a no-op on +# Windows which does not need extra compiler flags for exporting support. You +# may optionally pass a single argument to ADD_COMPILER_EXPORT_FLAGS that will +# be populated with the required CXX_FLAGS required to enable visibility support +# for the compiler/architecture in use. # # This means that in the simplest case, users of these functions will be # equivalent to: @@ -229,7 +232,8 @@ macro(_test_compiler_has_deprecated) endif() endmacro() -get_filename_component(_GENERATE_EXPORT_HEADER_MODULE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_GENERATE_EXPORT_HEADER_MODULE_DIR + "${CMAKE_CURRENT_LIST_FILE}" PATH) macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) set(DEFINE_DEPRECATED) @@ -347,7 +351,7 @@ function(GENERATE_EXPORT_HEADER TARGET_LIBRARY) _do_generate_export_header(${TARGET_LIBRARY} ${ARGN}) endfunction() -function(add_compiler_export_flags) +macro(add_compiler_export_flags) _test_compiler_hidden_visibility() _test_compiler_has_deprecated() @@ -362,5 +366,12 @@ function(add_compiler_export_flags) if(COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) set (EXTRA_FLAGS "${EXTRA_FLAGS} -fvisibility-inlines-hidden") endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}" PARENT_SCOPE) -endfunction() + + # Either return the extra flags needed in the supplied argument, or to the + # CMAKE_CXX_FLAGS if no argument is supplied. + if(ARGV0) + set(${ARGV0} "${EXTRA_FLAGS}") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}") + endif() +endmacro() From 09817e91f9bb03353c49f3c8aa6cb7ad9789fcc7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 19 Sep 2011 14:50:47 -0400 Subject: [PATCH 275/539] Make file(DOWNLOAD) fail on http error If a http server responds with a result code greater than 400 then the data returned from the download probably do not match that expected. Teach file(DOWNLOAD) to fail with an error in this case instead of silently pretending that the download worked. The file(UPLOAD) command already does this. --- Source/cmFileCommand.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 3b639065e7f..f933666ae53 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2753,6 +2753,10 @@ cmFileCommand::HandleDownloadCommand(std::vector const& args) ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); check_curl_result(res, "DOWNLOAD cannot set url: "); + // enable HTTP ERROR parsing + res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); + check_curl_result(res, "DOWNLOAD cannot set http failure option: "); + res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmWriteToFileCallback); check_curl_result(res, "DOWNLOAD cannot set write function: "); From 400c74f3258f9ab481f1c549db91a93337ca098d Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 20 Sep 2011 00:01:04 -0400 Subject: [PATCH 276/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index fd3b7f700b5..df6076f4797 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 19) +SET(KWSYS_DATE_STAMP_DAY 20) From 41e2b1d824033551a63b8a10fb7f16783e0d6caa Mon Sep 17 00:00:00 2001 From: "Marcus D. Hanwell" Date: Tue, 20 Sep 2011 00:16:16 -0400 Subject: [PATCH 277/539] Make add_compiler_export_flags a function again. Making this a macro had unintended issues on (among others) Windows compilers. Moving it back to being a function using PARENT_SCOPE still satisfies the use case where we simply want to obtain the extra flags. --- Modules/GenerateExportHeader.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index aaeff473d76..7df274e4fa8 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -1,6 +1,6 @@ # - Function for generation of export macros for libraries # This module provides the function GENERATE_EXPORT_HEADER() and the -# accompanying ADD_COMPILER_EXPORT_FLAGS() macro. +# accompanying ADD_COMPILER_EXPORT_FLAGS() function. # # The GENERATE_EXPORT_HEADER function can be used to generate a file suitable # for preprocessor inclusion which contains EXPORT macros to be used in @@ -21,7 +21,7 @@ # ADD_COMPILER_EXPORT_FLAGS( [FATAL_WARNINGS] ) # # By default GENERATE_EXPORT_HEADER() generates macro names in a file name -# determined by the name of the library. The ADD_COMPILER_EXPORT_FLAGS macro +# determined by the name of the library. The ADD_COMPILER_EXPORT_FLAGS function # adds -fvisibility=hidden to CMAKE_CXX_FLAGS if supported, and is a no-op on # Windows which does not need extra compiler flags for exporting support. You # may optionally pass a single argument to ADD_COMPILER_EXPORT_FLAGS that will @@ -351,7 +351,7 @@ function(GENERATE_EXPORT_HEADER TARGET_LIBRARY) _do_generate_export_header(${TARGET_LIBRARY} ${ARGN}) endfunction() -macro(add_compiler_export_flags) +function(add_compiler_export_flags) _test_compiler_hidden_visibility() _test_compiler_has_deprecated() @@ -370,8 +370,8 @@ macro(add_compiler_export_flags) # Either return the extra flags needed in the supplied argument, or to the # CMAKE_CXX_FLAGS if no argument is supplied. if(ARGV0) - set(${ARGV0} "${EXTRA_FLAGS}") + set(${ARGV0} "${EXTRA_FLAGS}" PARENT_SCOPE) else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}" PARENT_SCOPE) endif() -endmacro() +endfunction() From cc26a0614a2e81f060deacb538cdc52a2ee01bdd Mon Sep 17 00:00:00 2001 From: Eric NOULARD Date: Tue, 20 Sep 2011 20:21:01 +0200 Subject: [PATCH 278/539] CPackRPM authorize per-component pre/post-[un]install scripts (#0012063) Merged patch from Chip Christian previously based on the one from winfriedd with some small pruning editing by commiter --- Modules/CPackRPM.cmake | 138 ++++++++++++++++++++++++++--------------- 1 file changed, 88 insertions(+), 50 deletions(-) diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index fa4bb05c420..51c8eace247 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -132,24 +132,32 @@ # CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE # Mandatory : NO # Default : - -# May be used to embbed a pre (un)installation script in the spec file. +# May be used to embed a pre (un)installation script in the spec file. # The refered script file(s) will be read and directly # put after the %pre or %preun section +# If CPACK_RPM_COMPONENT_INSTALL is set to ON the (un)install script for +# each component can be overriden with +# CPACK_RPM__PRE_INSTALL_SCRIPT_FILE and +# CPACK_RPM__PRE_UNINSTALL_SCRIPT_FILE # One may verify which scriptlet has been included with # rpm -qp --scripts package.rpm # CPACK_RPM_POST_INSTALL_SCRIPT_FILE # CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE # Mandatory : NO # Default : - -# May be used to embbed a post (un)installation script in the spec file. +# May be used to embed a post (un)installation script in the spec file. # The refered script file(s) will be read and directly # put after the %post or %postun section +# If CPACK_RPM_COMPONENT_INSTALL is set to ON the (un)install script for +# each component can be overriden with +# CPACK_RPM__POST_INSTALL_SCRIPT_FILE and +# CPACK_RPM__POST_UNINSTALL_SCRIPT_FILE # One may verify which scriptlet has been included with # rpm -qp --scripts package.rpm # CPACK_RPM_CHANGELOG_FILE # Mandatory : NO # Default : - -# May be used to embbed a changelog in the spec file. +# May be used to embed a changelog in the spec file. # The refered file will be read and directly put after the %changelog # section. @@ -237,6 +245,17 @@ IF(ALIEN_EXECUTABLE) MESSAGE(STATUS "alien found, we may be on a Debian based distro.") ENDIF(ALIEN_EXECUTABLE) +# Are we packaging components ? +IF(CPACK_RPM_PACKAGE_COMPONENT) + SET(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") + SET(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "/${CPACK_RPM_PACKAGE_COMPONENT}") + SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${CPACK_RPM_PACKAGE_COMPONENT}") +ELSE(CPACK_RPM_PACKAGE_COMPONENT) + SET(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "") + SET(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "") + SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}") +ENDIF(CPACK_RPM_PACKAGE_COMPONENT) + # # Use user-defined RPM specific variables value # or generate reasonable default value from @@ -396,47 +415,77 @@ IF(CPACK_RPM_SPEC_INSTALL_POST) SET(TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}") ENDIF(CPACK_RPM_SPEC_INSTALL_POST) -# CPACK_RPM_POST_INSTALL_SCRIPT_FILE -# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE -# May be used to embbed a post (un)installation script in the spec file. +# CPACK_RPM_POST_INSTALL_SCRIPT_FILE (or CPACK_RPM__POST_INSTALL_SCRIPT_FILE) +# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE (or CPACK_RPM__POST_UNINSTALL_SCRIPT_FILE) +# May be used to embed a post (un)installation script in the spec file. # The refered script file(s) will be read and directly # put after the %post or %postun section -if(CPACK_RPM_POST_INSTALL_SCRIPT_FILE) - if(EXISTS ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) - file(READ ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_POSTINSTALL) - else(EXISTS ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) - message("CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}> does not exists - ignoring") - endif(EXISTS ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) -endif(CPACK_RPM_POST_INSTALL_SCRIPT_FILE) - -if(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE) - if(EXISTS ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) - file(READ ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_POSTUNINSTALL) - else(EXISTS ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) - message("CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}> does not exists - ignoring") - endif(EXISTS ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) -endif(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE) - -# CPACK_RPM_PRE_INSTALL_SCRIPT_FILE -# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE +if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE) + set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE}) + else() + set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) + endif() + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE) + set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE}) + else(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE) + set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) + endif(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE) +else(CPACK_RPM_PACKAGE_COMPONENT) + set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) + set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) +endif(CPACK_RPM_PACKAGE_COMPONENT) +if(CPACK_RPM_POST_INSTALL_READ_FILE) + if(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE}) + file(READ ${CPACK_RPM_POST_INSTALL_READ_FILE} CPACK_RPM_SPEC_POSTINSTALL) + else(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE}) + message("CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_READ_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE}) +endif(CPACK_RPM_POST_INSTALL_READ_FILE) + +if(CPACK_RPM_POST_UNINSTALL_READ_FILE) + if(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE}) + file(READ ${CPACK_RPM_POST_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_POSTUNINSTALL) + else(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE}) + message("CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_READ_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE}) +endif(CPACK_RPM_POST_UNINSTALL_READ_FILE) + +# CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM__PRE_INSTALL_SCRIPT_FILE) +# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM__PRE_UNINSTALL_SCRIPT_FILE) # May be used to embed a pre (un)installation script in the spec file. # The refered script file(s) will be read and directly # put after the %pre or %preun section -if(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE) - if(EXISTS ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) - file(READ ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_PREINSTALL) - else(EXISTS ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) - message("CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}> does not exists - ignoring") - endif(EXISTS ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) -endif(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE) - -if(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE) - if(EXISTS ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) - file(READ ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_PREUNINSTALL) - else(EXISTS ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) - message("CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}> does not exists - ignoring") - endif(EXISTS ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) -endif(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE) +if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE) + set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE}) + else(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE) + set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) + endif(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE) + set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE}) + else(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE) + set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) + endif(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE) +else(CPACK_RPM_PACKAGE_COMPONENT) + set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) + set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) +endif(CPACK_RPM_PACKAGE_COMPONENT) +if(CPACK_RPM_PRE_INSTALL_READ_FILE) + if(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) + file(READ ${CPACK_RPM_PRE_INSTALL_READ_FILE} CPACK_RPM_SPEC_PREINSTALL) + else(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) + message("CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_READ_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) +endif(CPACK_RPM_PRE_INSTALL_READ_FILE) + +if(CPACK_RPM_PRE_UNINSTALL_READ_FILE) + if(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) + file(READ ${CPACK_RPM_PRE_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_PREUNINSTALL) + else(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) + message("CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_READ_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) +endif(CPACK_RPM_PRE_UNINSTALL_READ_FILE) # CPACK_RPM_CHANGELOG_FILE # May be used to embed a changelog in the spec file. @@ -478,17 +527,6 @@ SET(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") #STRING(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") SET(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") - -# Are we packaging components ? -IF(CPACK_RPM_PACKAGE_COMPONENT) - SET(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") - SET(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "/${CPACK_RPM_PACKAGE_COMPONENT}") - SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${CPACK_RPM_PACKAGE_COMPONENT}") -ELSE(CPACK_RPM_PACKAGE_COMPONENT) - SET(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "") - SET(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "") - SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}") -ENDIF(CPACK_RPM_PACKAGE_COMPONENT) # Use files tree to construct files command (spec file) # We should not forget to include symlinks (thus -o -type l) # We should include directory as well (thus -type d) From 98c49a4a258214306db86eb5d7a2383d8b0561d1 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 20 Sep 2011 18:40:22 -0400 Subject: [PATCH 279/539] Revert "FindThreads: Try pthreads with no special option first (#11333)" This reverts commit fd61be71401ef9e0a241562fc31539273084deff. --- Modules/FindThreads.cmake | 47 ++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index 21614fb66d0..a6c2df89baa 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -23,7 +23,6 @@ INCLUDE (CheckIncludeFiles) INCLUDE (CheckLibraryExists) -INCLUDE (CheckSymbolExists) SET(Threads_FOUND FALSE) # Do we have sproc? @@ -45,41 +44,33 @@ ELSE() # SET(CMAKE_HAVE_THREADS_LIBRARY) IF(NOT THREADS_HAVE_PTHREAD_ARG) - # Check if pthread functions are in normal C library - CHECK_SYMBOL_EXISTS(pthread_create pthread.h CMAKE_HAVE_LIBC_CREATE) - IF(CMAKE_HAVE_LIBC_CREATE) - SET(CMAKE_THREAD_LIBS_INIT "") + + # Do we have -lpthreads + CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE) + IF(CMAKE_HAVE_PTHREADS_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lpthreads") SET(CMAKE_HAVE_THREADS_LIBRARY 1) SET(Threads_FOUND TRUE) ENDIF() - IF(NOT CMAKE_HAVE_THREADS_LIBRARY) - # Do we have -lpthreads - CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE) - IF(CMAKE_HAVE_PTHREADS_CREATE) - SET(CMAKE_THREAD_LIBS_INIT "-lpthreads") - SET(CMAKE_HAVE_THREADS_LIBRARY 1) - SET(Threads_FOUND TRUE) - ENDIF() + # Ok, how about -lpthread + CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) + IF(CMAKE_HAVE_PTHREAD_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lpthread") + SET(Threads_FOUND TRUE) + SET(CMAKE_HAVE_THREADS_LIBRARY 1) + ENDIF() - # Ok, how about -lpthread - CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) - IF(CMAKE_HAVE_PTHREAD_CREATE) - SET(CMAKE_THREAD_LIBS_INIT "-lpthread") + IF(CMAKE_SYSTEM MATCHES "SunOS.*") + # On sun also check for -lthread + CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE) + IF(CMAKE_HAVE_THR_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lthread") SET(CMAKE_HAVE_THREADS_LIBRARY 1) SET(Threads_FOUND TRUE) ENDIF() + ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*") - IF(CMAKE_SYSTEM MATCHES "SunOS.*") - # On sun also check for -lthread - CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE) - IF(CMAKE_HAVE_THR_CREATE) - SET(CMAKE_THREAD_LIBS_INIT "-lthread") - SET(CMAKE_HAVE_THREADS_LIBRARY 1) - SET(Threads_FOUND TRUE) - ENDIF() - ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*") - ENDIF(NOT CMAKE_HAVE_THREADS_LIBRARY) ENDIF(NOT THREADS_HAVE_PTHREAD_ARG) IF(NOT CMAKE_HAVE_THREADS_LIBRARY) @@ -120,7 +111,7 @@ ELSE() ENDIF(CMAKE_HAVE_PTHREAD_H) ENDIF() -IF(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE) +IF(CMAKE_THREAD_LIBS_INIT) SET(CMAKE_USE_PTHREADS_INIT 1) SET(Threads_FOUND TRUE) ENDIF() From 41c6b3dd4db6f75cfc1ca2be3c28890c0506b6b5 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 21 Sep 2011 00:01:04 -0400 Subject: [PATCH 280/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index df6076f4797..fa561b56bf0 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 20) +SET(KWSYS_DATE_STAMP_DAY 21) From 4a1aadbb0071467da3e217af1a1413cc3d9d9eca Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 22 Sep 2011 00:01:03 -0400 Subject: [PATCH 281/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index fa561b56bf0..d421f4cc7f5 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 21) +SET(KWSYS_DATE_STAMP_DAY 22) From ad11118ebf398e2374f1905ebfb4f3fe04cd27cd Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 22 Sep 2011 14:39:19 +0200 Subject: [PATCH 282/539] Remove trailing whitespace Alex --- Modules/UsePkgConfig.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Modules/UsePkgConfig.cmake b/Modules/UsePkgConfig.cmake index d101e61d00f..14bbf221e7f 100644 --- a/Modules/UsePkgConfig.cmake +++ b/Modules/UsePkgConfig.cmake @@ -42,20 +42,20 @@ MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) # and if the package of interest also exists for pkg-config, then get the information IF(NOT _return_VALUE) - EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=includedir + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=includedir OUTPUT_VARIABLE ${_include_DIR} ) STRING(REGEX REPLACE "[\r\n]" " " ${_include_DIR} "${${_include_DIR}}") - - EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=libdir + + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=libdir OUTPUT_VARIABLE ${_link_DIR} ) STRING(REGEX REPLACE "[\r\n]" " " ${_link_DIR} "${${_link_DIR}}") - EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --libs + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --libs OUTPUT_VARIABLE ${_link_FLAGS} ) STRING(REGEX REPLACE "[\r\n]" " " ${_link_FLAGS} "${${_link_FLAGS}}") - EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags OUTPUT_VARIABLE ${_cflags} ) STRING(REGEX REPLACE "[\r\n]" " " ${_cflags} "${${_cflags}}") @@ -64,10 +64,10 @@ MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) MESSAGE(STATUS "PKGCONFIG() indicates that ${_package} is not installed (install the package which contains ${_package}.pc if you want to support this feature)") ENDIF(NOT _return_VALUE) - + # if pkg-config has NOT been found, INFORM the user ELSE(PKGCONFIG_EXECUTABLE) - + MESSAGE(STATUS "WARNING: PKGCONFIG() indicates that the tool pkg-config has not been found on your system. You should install it.") ENDIF(PKGCONFIG_EXECUTABLE) From 59ccf385540709c5c3e9352120f55b8ca90aaf6e Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 22 Sep 2011 14:47:18 +0200 Subject: [PATCH 283/539] Minor improvements to the UsePkgConfig.cmake docs Alex --- Modules/UsePkgConfig.cmake | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Modules/UsePkgConfig.cmake b/Modules/UsePkgConfig.cmake index 14bbf221e7f..3db9e43dc4a 100644 --- a/Modules/UsePkgConfig.cmake +++ b/Modules/UsePkgConfig.cmake @@ -1,13 +1,14 @@ -# - obsolete pkg-config module for CMake +# - Osolete pkg-config module for CMake, use FindPkgConfig instead. # -# Defines the following macros: +# This module defines the following macro: # # PKGCONFIG(package includedir libdir linkflags cflags) # # Calling PKGCONFIG will fill the desired information into the 4 given arguments, # e.g. PKGCONFIG(libart-2.0 LIBART_INCLUDE_DIR LIBART_LINK_DIR LIBART_LINK_FLAGS LIBART_CFLAGS) # if pkg-config was NOT found or the specified software package doesn't exist, the -# variable will be empty when the function returns, otherwise they will contain the respective information +# variable will be empty when the function returns, otherwise they will contain +# the respective information # #============================================================================= @@ -27,7 +28,7 @@ FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config ) MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) MESSAGE(STATUS - "WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig") + "WARNING: you are using the obsolete 'PKGCONFIG' macro, use FindPkgConfig") # reset the variables at the beginning SET(${_include_DIR}) SET(${_link_DIR}) From c16e387412b015b0ee61f6a807cc1000b3267a94 Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 22 Sep 2011 14:08:22 -0400 Subject: [PATCH 284/539] CMake 2.8.6-rc4 --- CMakeLists.txt | 2 +- ChangeLog.manual | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df06c9a480a..8927637cd22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -420,7 +420,7 @@ SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) SET(CMake_VERSION_PATCH 6) SET(CMake_VERSION_TWEAK 0) -SET(CMake_VERSION_RC 3) +SET(CMake_VERSION_RC 4) # Releases define a tweak level. IF(DEFINED CMake_VERSION_TWEAK) diff --git a/ChangeLog.manual b/ChangeLog.manual index c8237b939b1..88583b45986 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,46 @@ +Changes in CMake 2.8.6-rc4 (since 2.8.6-rc3) +-------------------------------------------- +Alex Neundorf (3): + FindFLEX.cmake: also search the include dir + Fix typos in FeatureSummary.cmake (#12462) + Don't warn when setting a property multiple times to the same value #12464 + +Bill Hoffman (2): + For VS Intel Fortran IDE builds, add a check to find the Fortran library PATH. + Enable Fortran tests for IDE builds. + +Brad King (5): + FortranCInterface: Compile separate Fortran lib in VerifyC[XX] + Move IntelVSImplicitPath project to better location + Simplify IntelVSImplicitPath detection project + libarchive: Fix ssize_t detection with mingwrt 3.20 + Make file(DOWNLOAD) fail on http error + +David Cole (8): + Tests: Add a KWStyle test, equivalent to the make StyleCheck target + KWStyle Test: Activate by default if KWStyle is found + Xcode: Use EFFECTIVE_PLATFORM_NAME reference in ComputeOutputDir + Xcode: Add test to demonstrate iOS project in Xcode + CMake: Reference test targets only when BUILD_TESTING is ON + Tests: Add the more modern Mac64 nightly build + Release Scripts: Use Qt 4.7.4 on dashmacmini5 (#12460) + Revert "FindThreads: Try pthreads with no special option first (#11333)" + +Eric NOULARD (4): + CPack fix #12449 doc mispelled + CPack fix template too + CPackDeb fix #10325 automagically use fakeroot for DEB if fakeroot is found + CPackRPM authorize per-component pre/post-[un]install scripts (#0012063) + +Marcus D. Hanwell (4): + Just code style changes. + Don't warn when nothing to do in visibility function. + Made ADD_COMPILER_EXPORT_FLAGS into a macro. + Make add_compiler_export_flags a function again. + +Rolf Eike Beer (1): + remove stray brace in CPackDeb documentation + Changes in CMake 2.8.6-rc3 (since 2.8.6-rc2) -------------------------------------------- Alexey Ozeritsky (2): From 6f935d7f55af5c96d18d23b72991e87d1e029dda Mon Sep 17 00:00:00 2001 From: Philip Lowman Date: Thu, 22 Sep 2011 23:31:37 -0400 Subject: [PATCH 285/539] FindBullet: Also search for _Debug postfixed library names --- Modules/FindBullet.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/FindBullet.cmake b/Modules/FindBullet.cmake index cebb8282aa2..aea9158e864 100644 --- a/Modules/FindBullet.cmake +++ b/Modules/FindBullet.cmake @@ -59,13 +59,13 @@ find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h # Find the libraries _FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY BulletDynamics) -_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG BulletDynamics_d) +_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG BulletDynamics_Debug BulletDynamics_d) _FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY BulletCollision) -_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_d) -_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY LinearMath BulletMath) -_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG LinearMath_d BulletMath_d) +_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_Debug BulletCollision_d) +_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY BulletMath LinearMath) +_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG BulletMath_Debug BulletMath_d LinearMath_d) _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY BulletSoftBody) -_FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_d) +_FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_Debug BulletSoftBody_d) # handle the QUIETLY and REQUIRED arguments and set BULLET_FOUND to TRUE if From 8c280435dfd746a897f6ce6696ba27571f195424 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 23 Sep 2011 00:01:04 -0400 Subject: [PATCH 286/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index d421f4cc7f5..5fbe5584858 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 22) +SET(KWSYS_DATE_STAMP_DAY 23) From f8c77fa97b0dc7d6c55a15d980f123f2e41cef40 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Thu, 22 Sep 2011 23:04:14 -0300 Subject: [PATCH 287/539] Fix typo in set_target_properties' documentation. our -> or --- Source/cmSetTargetPropertiesCommand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index feead00a9e2..320378d054e 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -92,7 +92,7 @@ class cmSetTargetPropertiesCommand : public cmCommand "If not set here then it is set to target_EXPORTS by default " "(with some substitutions if the target is not a valid C " "identifier). This is useful for headers to know whether they are " - "being included from inside their library our outside to properly " + "being included from inside their library or outside to properly " "setup dllexport/dllimport decorations. " "The COMPILE_FLAGS property sets additional compiler flags used " "to build sources within the target. It may also be used to pass " From 3d5632ed59d3d46298304d20d3f11f9d1da02f93 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 23 Sep 2011 09:07:40 -0400 Subject: [PATCH 288/539] Add Visual Studio 11 generator for x86 and x64 tools --- Modules/CMakeVS11FindMake.cmake | 54 +++++++++++++++++++ Source/CMakeLists.txt | 4 ++ Source/cmGlobalVisualStudio10Generator.h | 1 - Source/cmGlobalVisualStudio11Generator.cxx | 45 ++++++++++++++++ Source/cmGlobalVisualStudio11Generator.h | 43 +++++++++++++++ .../cmGlobalVisualStudio11Win64Generator.cxx | 33 ++++++++++++ Source/cmGlobalVisualStudio11Win64Generator.h | 37 +++++++++++++ Source/cmake.cxx | 6 +++ 8 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 Modules/CMakeVS11FindMake.cmake create mode 100644 Source/cmGlobalVisualStudio11Generator.cxx create mode 100644 Source/cmGlobalVisualStudio11Generator.h create mode 100644 Source/cmGlobalVisualStudio11Win64Generator.cxx create mode 100644 Source/cmGlobalVisualStudio11Win64Generator.h diff --git a/Modules/CMakeVS11FindMake.cmake b/Modules/CMakeVS11FindMake.cmake new file mode 100644 index 00000000000..302efaa59a9 --- /dev/null +++ b/Modules/CMakeVS11FindMake.cmake @@ -0,0 +1,54 @@ + +#============================================================================= +# Copyright 2007-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Look for devenv as a build program. We need to use this to support +# Intel Fortran integration into VS. MSBuild can not be used for that case +# since Intel Fortran uses the older devenv file format. +FIND_PROGRAM(CMAKE_MAKE_PROGRAM + NAMES devenv + HINTS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;EnvironmentDirectory] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup;Dbghelp_path] + "$ENV{ProgramFiles}/Microsoft Visual Studio 11.0/Common7/IDE" + "$ENV{ProgramFiles}/Microsoft Visual Studio11.0/Common7/IDE" + "$ENV{ProgramFiles}/Microsoft Visual Studio 11/Common7/IDE" + "$ENV{ProgramFiles}/Microsoft Visual Studio11/Common7/IDE" + "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 11.0/Common7/IDE" + "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio11.0/Common7/IDE" + "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 11/Common7/IDE" + "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio11/Common7/IDE" + "/Program Files/Microsoft Visual Studio 11.0/Common7/IDE/" + "/Program Files/Microsoft Visual Studio 11/Common7/IDE/" + ) + +# if devenv is not found, then use MSBuild. +# it is expected that if devenv is not found, then we are +# dealing with Visual Studio Express. VCExpress has random +# failures when being run as a command line build tool which +# causes the compiler checks and try-compile stuff to fail. MSbuild +# is a better choice for this. However, VCExpress does not support +# cross compiling needed for Win CE. +IF(NOT CMAKE_CROSSCOMPILING) + FIND_PROGRAM(CMAKE_MAKE_PROGRAM + NAMES MSBuild + HINTS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;ProductDir] + "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;CLR Version]/" + "c:/WINDOWS/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;CLR Version]/" + "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0;CLR Version]/") +ENDIF() + +MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) +SET(MSVC11 1) +SET(MSVC_VERSION 1700) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 96b3ea06aa3..ba41d98c465 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -324,6 +324,10 @@ IF (WIN32) cmGlobalVisualStudio10Win64Generator.cxx cmGlobalVisualStudio10IA64Generator.h cmGlobalVisualStudio10IA64Generator.cxx + cmGlobalVisualStudio11Generator.h + cmGlobalVisualStudio11Generator.cxx + cmGlobalVisualStudio11Win64Generator.h + cmGlobalVisualStudio11Win64Generator.cxx cmGlobalVisualStudioGenerator.cxx cmGlobalVisualStudioGenerator.h cmGlobalWatcomWMakeGenerator.cxx diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 85736707cc4..18b483d095c 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -79,7 +79,6 @@ class cmGlobalVisualStudio10Generator : virtual const char* GetIDEVersion() { return "10.0"; } std::string PlatformToolset; -private: bool ExpressEdition; }; #endif diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx new file mode 100644 index 00000000000..a70427ada53 --- /dev/null +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -0,0 +1,45 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmGlobalVisualStudio11Generator.h" +#include "cmMakefile.h" + +//---------------------------------------------------------------------------- +cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator() +{ + this->FindMakeProgramFile = "CMakeVS11FindMake.cmake"; + this->ExpressEdition = false; // TODO: VS 11 Express support + this->PlatformToolset = "v110"; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio11Generator::AddPlatformDefinitions(cmMakefile* mf) +{ + mf->AddDefinition("MSVC11", "1"); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86"); +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) +{ + fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; + fout << "# Visual Studio 2011\n"; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio11Generator +::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates Visual Studio 11 project files."; + entry.Full = ""; +} diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h new file mode 100644 index 00000000000..14019a7d86a --- /dev/null +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -0,0 +1,43 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmGlobalVisualStudio11Generator_h +#define cmGlobalVisualStudio11Generator_h + +#include "cmGlobalVisualStudio10Generator.h" + + +/** \class cmGlobalVisualStudio11Generator */ +class cmGlobalVisualStudio11Generator: + public cmGlobalVisualStudio10Generator +{ +public: + cmGlobalVisualStudio11Generator(); + static cmGlobalGenerator* New() { + return new cmGlobalVisualStudio11Generator; } + + ///! Get the name for the generator. + virtual const char* GetName() const { + return cmGlobalVisualStudio11Generator::GetActualName();} + static const char* GetActualName() {return "Visual Studio 11";} + virtual void AddPlatformDefinitions(cmMakefile* mf); + + virtual void WriteSLNHeader(std::ostream& fout); + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + /** TODO: VS 11 user macro support. */ + virtual std::string GetUserMacrosDirectory() { return ""; } +protected: + virtual const char* GetIDEVersion() { return "11.0"; } +}; +#endif diff --git a/Source/cmGlobalVisualStudio11Win64Generator.cxx b/Source/cmGlobalVisualStudio11Win64Generator.cxx new file mode 100644 index 00000000000..10c902753e0 --- /dev/null +++ b/Source/cmGlobalVisualStudio11Win64Generator.cxx @@ -0,0 +1,33 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmGlobalVisualStudio11Win64Generator.h" +#include "cmMakefile.h" +#include "cmake.h" + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio11Win64Generator +::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates Visual Studio 11 Win64 project files."; + entry.Full = ""; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio11Win64Generator +::AddPlatformDefinitions(cmMakefile* mf) +{ + this->cmGlobalVisualStudio11Generator::AddPlatformDefinitions(mf); + mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64"); +} diff --git a/Source/cmGlobalVisualStudio11Win64Generator.h b/Source/cmGlobalVisualStudio11Win64Generator.h new file mode 100644 index 00000000000..53f19538c96 --- /dev/null +++ b/Source/cmGlobalVisualStudio11Win64Generator.h @@ -0,0 +1,37 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmGlobalVisualStudio11Win64Generator_h +#define cmGlobalVisualStudio11Win64Generator_h + +#include "cmGlobalVisualStudio11Generator.h" + +class cmGlobalVisualStudio11Win64Generator : + public cmGlobalVisualStudio11Generator +{ +public: + cmGlobalVisualStudio11Win64Generator() {} + static cmGlobalGenerator* New() { + return new cmGlobalVisualStudio11Win64Generator; } + + ///! Get the name for the generator. + virtual const char* GetName() const { + return cmGlobalVisualStudio11Win64Generator::GetActualName();} + static const char* GetActualName() {return "Visual Studio 11 Win64";} + + virtual const char* GetPlatformName() const {return "x64";} + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + virtual void AddPlatformDefinitions(cmMakefile* mf); +}; +#endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 41c67e2325b..05699da4dbf 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -68,6 +68,8 @@ # include "cmGlobalVisualStudio10Generator.h" # include "cmGlobalVisualStudio10IA64Generator.h" # include "cmGlobalVisualStudio10Win64Generator.h" +# include "cmGlobalVisualStudio11Generator.h" +# include "cmGlobalVisualStudio11Win64Generator.h" # include "cmGlobalVisualStudio8Win64Generator.h" # include "cmGlobalBorlandMakefileGenerator.h" # include "cmGlobalNMakeMakefileGenerator.h" @@ -2580,6 +2582,10 @@ void cmake::AddDefaultGenerators() &cmGlobalVisualStudio10IA64Generator::New; this->Generators[cmGlobalVisualStudio10Win64Generator::GetActualName()] = &cmGlobalVisualStudio10Win64Generator::New; + this->Generators[cmGlobalVisualStudio11Generator::GetActualName()] = + &cmGlobalVisualStudio11Generator::New; + this->Generators[cmGlobalVisualStudio11Win64Generator::GetActualName()] = + &cmGlobalVisualStudio11Win64Generator::New; this->Generators[cmGlobalVisualStudio71Generator::GetActualName()] = &cmGlobalVisualStudio71Generator::New; this->Generators[cmGlobalVisualStudio8Generator::GetActualName()] = From 3b5256e19e27794ba871b0149f4c8f0237d1e872 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 23 Sep 2011 11:04:15 -0400 Subject: [PATCH 289/539] Teach our tests about special cases for VS 11 Teach the CheckCompilerRelatedVariables test to verify MSVC11. Update the special cases already in the Preprocess and VSExternalInclude tests for VS 10 to work for VS 11 too. --- Tests/CheckCompilerRelatedVariables/CMakeLists.txt | 4 ++++ Tests/Preprocess/CMakeLists.txt | 5 ++++- Tests/VSExternalInclude/CMakeLists.txt | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Tests/CheckCompilerRelatedVariables/CMakeLists.txt b/Tests/CheckCompilerRelatedVariables/CMakeLists.txt index 8095a1cf19c..8b279a5c473 100644 --- a/Tests/CheckCompilerRelatedVariables/CMakeLists.txt +++ b/Tests/CheckCompilerRelatedVariables/CMakeLists.txt @@ -34,6 +34,9 @@ endif() if(DEFINED MSVC10) math(EXPR msvc_total "${msvc_total} + 1") endif() +if(DEFINED MSVC11) + math(EXPR msvc_total "${msvc_total} + 1") +endif() echo_var(MSVC) echo_var(MSVC60) @@ -42,6 +45,7 @@ echo_var(MSVC71) echo_var(MSVC80) echo_var(MSVC90) echo_var(MSVC10) +echo_var(MSVC11) if(MSVC) # diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt index b4ec17c6b78..1ed7b83acaa 100644 --- a/Tests/Preprocess/CMakeLists.txt +++ b/Tests/Preprocess/CMakeLists.txt @@ -37,6 +37,9 @@ endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio") if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 10") set(PP_VS100 1) endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio 10") +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 11") + set(PP_VS110 1) +endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio 11") # Some tests below check the PP_* variables set above. They are meant # to test the case that the build tool is at fault. Other tests below @@ -52,7 +55,7 @@ endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio 10") # must not have it escaped inside the configured header. set(STRING_EXTRA "") -if(NOT BORLAND AND NOT PP_VS70 AND NOT PP_VS100) +if(NOT BORLAND AND NOT PP_VS70 AND NOT PP_VS100 AND NOT PP_VS110) # Borland, VS70 IDE: ; # The Borland compiler will simply not accept a non-escaped semicolon # on the command line. If it is escaped \; then the escape character diff --git a/Tests/VSExternalInclude/CMakeLists.txt b/Tests/VSExternalInclude/CMakeLists.txt index 1e6896801a5..a2fd61973e0 100644 --- a/Tests/VSExternalInclude/CMakeLists.txt +++ b/Tests/VSExternalInclude/CMakeLists.txt @@ -6,7 +6,7 @@ IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") SET(PROJECT_EXT vcproj) ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") -IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 10") +IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[01]") SET(PROJECT_EXT vcxproj) ENDIF() @@ -46,7 +46,7 @@ ADD_DEPENDENCIES(VSExternalInclude lib2) # and the sln file can no longer be the only source # of that depend. So, for VS 10 make the executable # depend on lib1 and lib2 -IF(MSVC10) +IF(MSVC10 OR MSVC11) ADD_DEPENDENCIES(VSExternalInclude lib1) ENDIF() From b0cd630521658ddf8f8547597ac9c24a725f20e7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 23 Sep 2011 14:27:25 -0400 Subject: [PATCH 290/539] Refactor find_* command final path list computation All find_* commands re-root the list of paths and then add trailing slashes. Factor this pair of calls out into a dedicated method. The new method would be the only caller to AddTrailingSlashes, so subsume that method into it. --- Source/cmFindBase.cxx | 6 +----- Source/cmFindCommon.cxx | 7 ++++++- Source/cmFindCommon.h | 4 ++-- Source/cmFindPackageCommand.cxx | 14 +------------- Source/cmFindPackageCommand.h | 1 - 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index ce9deb1435c..183da4a7935 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -299,11 +299,7 @@ bool cmFindBase::ParseArguments(std::vector const& argsIn) this->GetIgnoredPaths(ignored); this->FilterPaths(this->SearchPaths, ignored); - // Handle search root stuff. - this->RerootPaths(this->SearchPaths); - - // Add a trailing slash to all prefixes to aid the search process. - this->AddTrailingSlashes(this->SearchPaths); + this->ComputeFinalPaths(); return true; } diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index a05e3379845..b44864e1349 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -471,8 +471,13 @@ void cmFindCommon::AddPathInternal(std::string const& in_path, } //---------------------------------------------------------------------------- -void cmFindCommon::AddTrailingSlashes(std::vector& paths) +void cmFindCommon::ComputeFinalPaths() { + std::vector& paths = this->SearchPaths; + + // Expand list of paths inside all search roots. + this->RerootPaths(paths); + // Add a trailing slash to all paths to aid the search process. for(std::vector::iterator i = paths.begin(); i != paths.end(); ++i) diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 875c223548e..542805fafb1 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -47,8 +47,8 @@ class cmFindCommon : public cmCommand void FilterPaths(std::vector& paths, const std::set& ignore); - /** Add trailing slashes to all search paths. */ - void AddTrailingSlashes(std::vector& paths); + /** Compute final search path list (reroot + trailing slash). */ + void ComputeFinalPaths(); /** Compute the current default root path mode. */ void SelectDefaultRootPathMode(); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 2e72b583f60..7d3f09bda5f 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1243,7 +1243,7 @@ void cmFindPackageCommand::ComputePrefixes() this->AddPrefixesCMakeSystemVariable(); this->AddPrefixesSystemRegistry(); this->AddPrefixesUserGuess(); - this->ComputeFinalPrefixes(); + this->ComputeFinalPaths(); } //---------------------------------------------------------------------------- @@ -1573,18 +1573,6 @@ void cmFindPackageCommand::AddPrefixesUserHints() this->AddPathsInternal(this->UserHints, CMakePath); } -//---------------------------------------------------------------------------- -void cmFindPackageCommand::ComputeFinalPrefixes() -{ - std::vector& prefixes = this->SearchPaths; - - // Construct the final set of prefixes. - this->RerootPaths(prefixes); - - // Add a trailing slash to all prefixes to aid the search process. - this->AddTrailingSlashes(prefixes); -} - //---------------------------------------------------------------------------- bool cmFindPackageCommand::SearchDirectory(std::string const& dir) { diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 2b2e1dace24..e73635284a0 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -93,7 +93,6 @@ class cmFindPackageCommand : public cmFindCommon void AddPrefixesCMakeSystemVariable(); void AddPrefixesUserGuess(); void AddPrefixesUserHints(); - void ComputeFinalPrefixes(); void LoadPackageRegistryDir(std::string const& dir); void LoadPackageRegistryWinUser(); void LoadPackageRegistryWinSystem(); From e4bd3b0cf31d88976dbe657c68f56eb779d38cf1 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 24 Sep 2011 00:01:23 -0400 Subject: [PATCH 291/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 5fbe5584858..c358531c888 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 23) +SET(KWSYS_DATE_STAMP_DAY 24) From 95841356744bc7b1d4290a7b8f717e689490c912 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 25 Sep 2011 00:01:05 -0400 Subject: [PATCH 292/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index c358531c888..3f6184dce9f 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 24) +SET(KWSYS_DATE_STAMP_DAY 25) From 0bf12af36c4f4998efe77e62ee14455aa7a1a4fd Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 26 Sep 2011 00:01:03 -0400 Subject: [PATCH 293/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 3f6184dce9f..19f42af35e5 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 25) +SET(KWSYS_DATE_STAMP_DAY 26) From 77593178cf49d427cc60fb9e026cb85b28a2856b Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 27 Sep 2011 00:01:04 -0400 Subject: [PATCH 294/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 19f42af35e5..b265443a23b 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 26) +SET(KWSYS_DATE_STAMP_DAY 27) From f15945edad8aba724b80914cf3b50f5cc9f5a021 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 27 Sep 2011 18:59:42 +0200 Subject: [PATCH 295/539] Use makefile->IssueMessage() for better error messages Alex --- Source/cmTryCompileCommand.cxx | 2 +- Source/cmTryRunCommand.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index 546e42fbd24..12ce015d2cb 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -23,7 +23,7 @@ ::InitialPass(std::vector const& argv, cmExecutionStatus &) if(this->Makefile->GetCMakeInstance()->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) { - cmSystemTools::Error( + this->Makefile->IssueMessage(cmake::FATAL_ERROR, "The TRY_COMPILE() command is not supported in --find-package mode."); return false; } diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 9044cf8ffe9..4fc0b13c0a5 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -25,7 +25,7 @@ ::InitialPass(std::vector const& argv, cmExecutionStatus &) if(this->Makefile->GetCMakeInstance()->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) { - cmSystemTools::Error( + this->Makefile->IssueMessage(cmake::FATAL_ERROR, "The TRY_RUN() command is not supported in --find-package mode."); return false; } From ef8cc9997cab748098bab52caf1ca038f90ec826 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 28 Sep 2011 00:01:04 -0400 Subject: [PATCH 296/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index b265443a23b..41709d68123 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 27) +SET(KWSYS_DATE_STAMP_DAY 28) From 8a3bca50fa55b82f134c8a763bc837f0d5a17afa Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 29 Sep 2011 00:01:06 -0400 Subject: [PATCH 297/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 41709d68123..7fbe5f3d078 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 28) +SET(KWSYS_DATE_STAMP_DAY 29) From 9cbbea31d30a6a1851c078d574f40c73154301fa Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Tue, 27 Sep 2011 09:54:38 +0200 Subject: [PATCH 298/539] Fix typo in UsePkgConfig.cmake --- Modules/UsePkgConfig.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/UsePkgConfig.cmake b/Modules/UsePkgConfig.cmake index 3db9e43dc4a..7f4318f0551 100644 --- a/Modules/UsePkgConfig.cmake +++ b/Modules/UsePkgConfig.cmake @@ -1,4 +1,4 @@ -# - Osolete pkg-config module for CMake, use FindPkgConfig instead. +# - Obsolete pkg-config module for CMake, use FindPkgConfig instead. # # This module defines the following macro: # From ad6fa0cbca85febca573e18bbbd7bafa2ea00f81 Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 29 Sep 2011 15:44:03 -0400 Subject: [PATCH 299/539] CTestCustom.cmake: Ignore clang's summary warning Assuming prior text has matched some other warning expression... --- CTestCustom.cmake.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 0e61da4416d..1a466889b7b 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -44,6 +44,10 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION "cc-3968 CC: WARNING File.*" # "implicit" truncation by static_cast "ld: warning: directory not found for option .-(F|L)" "warning.*This version of Mac OS X is unsupported" + + # Ignore clang's summary warning, assuming prior text has matched some + # other warning expression: + "[0-9,]+ warnings? generated." ) IF(NOT "@CMAKE_GENERATOR@" MATCHES "Xcode") From 72bac428cc9caaeb52b069c97845e3d031eded4a Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 30 Sep 2011 00:01:05 -0400 Subject: [PATCH 300/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 7fbe5f3d078..3a76525a580 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 29) +SET(KWSYS_DATE_STAMP_DAY 30) From 0cd3606afde42c3cf3ef706d11e6da2981e06a67 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 30 Sep 2011 15:52:37 -0400 Subject: [PATCH 301/539] Use version 11.0 for 12.x and 9.10 for 10.x intel versions to fix 12.1 vsIDE. The intel compiler for 12.0 and 12.1 are known to expect the file version to be 11.0 in the .vfproj file. For 10.x it should be 9.10. Prior to this fix 12.0 and 10.1 were the only values checked. If those did not match the actual version of intel was put in the vfproj file causing an error about future version load attempt in the IDE. --- Source/cmLocalVisualStudio7Generator.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 54175845ef5..be5b4c6b93f 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1836,14 +1836,14 @@ ::WriteProjectStartFortran(std::ostream& fout, vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion"; cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion, cmSystemTools::KeyWOW64_32); - if (intelVersion == "12.0") + if (intelVersion.find("12") == 0) { - // Version 12 actually uses 11.0 in project files! + // Version 12.x actually uses 11.0 in project files! intelVersion = "11.0" ; } - else if(intelVersion == "10.1") + else if(intelVersion.find("10") == 0) { - // Version 10.1 actually uses 9.10 in project files! + // Version 10.x actually uses 9.10 in project files! intelVersion = "9.10"; } From 8f1ee5181d9a4c8c17f516a01a1772a741e3cb14 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 30 Sep 2011 17:11:34 -0400 Subject: [PATCH 302/539] Also, check for 11.x as an intel fortran version. As Dave Cole pointed out the previous commit only checked for 10.x and 12.x. 11.0 was accounted for, but 11.1, 11.2 and 11.3 were not. This patch should make it work for those versions as well. I did a web check and there are 11.0, 11.1, 11.2 and 11.3 versions from Intel. I assume if 12.x uses 11.0 as the version in the .vfproj file, then all of the 11.x versions would as well. --- Source/cmLocalVisualStudio7Generator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index be5b4c6b93f..d9b27729897 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1836,9 +1836,9 @@ ::WriteProjectStartFortran(std::ostream& fout, vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion"; cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion, cmSystemTools::KeyWOW64_32); - if (intelVersion.find("12") == 0) + if (intelVersion.find("12") == 0 || (intelVersion.find("11") == 0)) { - // Version 12.x actually uses 11.0 in project files! + // Version 11.x and 12.x actually use 11.0 in project files! intelVersion = "11.0" ; } else if(intelVersion.find("10") == 0) From 867b226898fa1dab1001abf7dd18e21d273b259e Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 1 Oct 2011 00:01:05 -0400 Subject: [PATCH 303/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 3a76525a580..e166eb73ccd 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 09) +SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 30) +SET(KWSYS_DATE_STAMP_DAY 01) From 3df49dc7b1517109ef198177f541e24bc61fefea Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 1 Oct 2011 19:09:24 +0200 Subject: [PATCH 304/539] fix #12392: handle CMAKE_CXX_COMPILER_ARG1 for Eclipse projects CMAKE_CXX/C_COMPILER_ARG1 have to be used for finding the include dirs and builtin macros, so Eclipse can do code completion Alex --- ...ratorDetermineCompilerMacrosAndIncludeDirs.cmake | 4 +++- Source/cmExtraEclipseCDT4Generator.cxx | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake index 55c37c20945..1b4532debbf 100644 --- a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake +++ b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake @@ -25,10 +25,12 @@ MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines IF (${_lang} STREQUAL "c++") SET(_compilerExecutable "${CMAKE_CXX_COMPILER}") + SET(_arg1 "${CMAKE_CXX_COMPILER_ARG1}") ELSE () SET(_compilerExecutable "${CMAKE_C_COMPILER}") + SET(_arg1 "${CMAKE_C_COMPILER_ARG1}") ENDIF () - EXECUTE_PROCESS(COMMAND ${_compilerExecutable} -v -E -x ${_lang} -dD dummy + EXECUTE_PROCESS(COMMAND ${_compilerExecutable} ${_arg1} -v -E -x ${_lang} -dD dummy WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles ERROR_VARIABLE _gccOutput OUTPUT_VARIABLE _gccStdout ) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 1dd9bf33d4b..7beffdcf2e0 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -987,17 +987,26 @@ ::AppendStorageScanners(cmGeneratedFileStream& fout, // we need the "make" and the C (or C++) compiler which are used, Alex std::string make = makefile.GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); std::string compiler = makefile.GetSafeDefinition("CMAKE_C_COMPILER"); + std::string arg1 = makefile.GetSafeDefinition("CMAKE_C_COMPILER_ARG1"); if (compiler.empty()) { compiler = makefile.GetSafeDefinition("CMAKE_CXX_COMPILER"); + arg1 = makefile.GetSafeDefinition("CMAKE_CXX_COMPILER_ARG1"); } if (compiler.empty()) //Hmm, what to do now ? { compiler = "gcc"; } - // the following right now hardcodes gcc behaviour :-/ + std::string compilerArgs = + "-E -P -v -dD ${plugin_state_location}/${specs_file}"; + if (!arg1.empty()) + { + arg1 += " "; + compilerArgs = arg1 + compilerArgs; + } + fout << "\n" " Date: Sun, 2 Oct 2011 00:01:25 -0400 Subject: [PATCH 305/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index e166eb73ccd..7b823269188 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 01) +SET(KWSYS_DATE_STAMP_DAY 02) From 3db2973bd2ceb65a0d88ed6a3428e17cc9f0e182 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 20 Mar 2011 17:57:42 +0100 Subject: [PATCH 306/539] Refactor TargetTypeNames. Make it a static method instead of an array. It is safer for the type checking and if we add a new target type we will be warned to add a case to the switch. --- Source/cmComputeTargetDepends.cxx | 2 +- Source/cmLocalGenerator.cxx | 2 +- Source/cmMakefile.cxx | 2 +- Source/cmTarget.cxx | 72 +++++++++++++------------------ Source/cmTarget.h | 2 +- 5 files changed, 35 insertions(+), 45 deletions(-) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 3a0ed06406d..8e701c402e0 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -404,7 +404,7 @@ ::ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c, // Describe the depender. e << " \"" << depender->GetName() << "\" of type " - << cmTarget::TargetTypeNames[depender->GetType()] << "\n"; + << cmTarget::GetTargetTypeName(depender->GetType()) << "\n"; // List its dependencies that are inside the component. EdgeList const& nl = this->InitialGraph[i]; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 1d1e8da0190..6af7fd5e1d2 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -996,7 +996,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(variable == "TARGET_TYPE") { - return cmTarget::TargetTypeNames[replaceValues.CMTarget->GetType()]; + return cmTarget::GetTargetTypeName(replaceValues.CMTarget->GetType()); } } if(replaceValues.Output) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e5b54439a88..573c430be68 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1379,7 +1379,7 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target, { cmOStringStream e; e << "Target \"" << lib << "\" of type " - << cmTarget::TargetTypeNames[static_cast(tgt->GetType())] + << cmTarget::GetTargetTypeName(tgt->GetType()) << " may not be linked into another target. " << "One may link only to STATIC or SHARED libraries, or " << "to executables with the ENABLE_EXPORTS property set."; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fb920165806..e74e70c2cbc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -25,12 +25,35 @@ #include #include // required for atof #include -const char* cmTarget::TargetTypeNames[] = { - "EXECUTABLE", "STATIC_LIBRARY", - "SHARED_LIBRARY", "MODULE_LIBRARY", "UTILITY", "GLOBAL_TARGET", - "INSTALL_FILES", "INSTALL_PROGRAMS", "INSTALL_DIRECTORY", - "UNKNOWN_LIBRARY" -}; + +const char* cmTarget::GetTargetTypeName(TargetType targetType) +{ + switch( targetType ) + { + case cmTarget::STATIC_LIBRARY: + return "STATIC_LIBRARY"; + case cmTarget::MODULE_LIBRARY: + return "MODULE_LIBRARY"; + case cmTarget::SHARED_LIBRARY: + return "SHARED_LIBRARY"; + case cmTarget::EXECUTABLE: + return "EXECUTABLE"; + case cmTarget::UTILITY: + return "UTILITY"; + case cmTarget::GLOBAL_TARGET: + return "GLOBAL_TARGET"; + case cmTarget::INSTALL_FILES: + return "INSTALL_FILES"; + case cmTarget::INSTALL_PROGRAMS: + return "INSTALL_PROGRAMS"; + case cmTarget::INSTALL_DIRECTORY: + return "INSTALL_DIRECTORY"; + case cmTarget::UNKNOWN_LIBRARY: + return "UNKNOWN_LIBRARY"; + } + assert(0 && "Unexpected target type"); + return 0; +} //---------------------------------------------------------------------------- struct cmTarget::OutputInfo @@ -2346,7 +2369,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) std::string msg = "cmTarget::GetOutputInfo called for "; msg += this->GetName(); msg += " which has type "; - msg += cmTarget::TargetTypeNames[this->GetType()]; + msg += cmTarget::GetTargetTypeName(this->GetType()); this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); abort(); return 0; @@ -2645,40 +2668,7 @@ const char *cmTarget::GetProperty(const char* prop, // the type property returns what type the target is if (!strcmp(prop,"TYPE")) { - switch( this->GetType() ) - { - case cmTarget::STATIC_LIBRARY: - return "STATIC_LIBRARY"; - // break; /* unreachable */ - case cmTarget::MODULE_LIBRARY: - return "MODULE_LIBRARY"; - // break; /* unreachable */ - case cmTarget::SHARED_LIBRARY: - return "SHARED_LIBRARY"; - // break; /* unreachable */ - case cmTarget::EXECUTABLE: - return "EXECUTABLE"; - // break; /* unreachable */ - case cmTarget::UTILITY: - return "UTILITY"; - // break; /* unreachable */ - case cmTarget::GLOBAL_TARGET: - return "GLOBAL_TARGET"; - // break; /* unreachable */ - case cmTarget::INSTALL_FILES: - return "INSTALL_FILES"; - // break; /* unreachable */ - case cmTarget::INSTALL_PROGRAMS: - return "INSTALL_PROGRAMS"; - // break; /* unreachable */ - case cmTarget::INSTALL_DIRECTORY: - return "INSTALL_DIRECTORY"; - // break; /* unreachable */ - case cmTarget::UNKNOWN_LIBRARY: - return "UNKNOWN_LIBRARY"; - // break; /* unreachable */ - } - return 0; + return cmTarget::GetTargetTypeName(this->GetType()); } bool chain = false; const char *retVal = diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 26fcef289be..0abdddb0a8f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -62,7 +62,7 @@ class cmTarget SHARED_LIBRARY, MODULE_LIBRARY, UTILITY, GLOBAL_TARGET, INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY, UNKNOWN_LIBRARY}; - static const char* TargetTypeNames[]; + static const char* GetTargetTypeName(TargetType targetType); enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD }; /** From 4532d36cc948228ca5e1ed072b7907a84a78c0e7 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sat, 26 Mar 2011 14:31:59 +0100 Subject: [PATCH 307/539] Add const versions of some getters. --- Source/cmGlobalGenerator.h | 1 + Source/cmLocalGenerator.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 88eb8b61a62..97cacc53d6b 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -120,6 +120,7 @@ class cmGlobalGenerator ///! Get the CMake instance cmake *GetCMakeInstance() { return this->CMakeInstance; }; + const cmake *GetCMakeInstance() const { return this->CMakeInstance; }; void SetConfiguredFilesPath(cmGlobalGenerator* gen); const std::vector& GetLocalGenerators() const { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index cfc09dc3216..1f5a26eba2f 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -83,6 +83,8 @@ class cmLocalGenerator ///! Get the GlobalGenerator this is associated with cmGlobalGenerator *GetGlobalGenerator() { return this->GlobalGenerator; }; + const cmGlobalGenerator *GetGlobalGenerator() const { + return this->GlobalGenerator; }; ///! Set the Global Generator, done on creation by the GlobalGenerator void SetGlobalGenerator(cmGlobalGenerator *gg); From 8a0eb78f3b49b1f999f4b0c0d5d23f4589b465f7 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sat, 26 Mar 2011 14:52:19 +0100 Subject: [PATCH 308/539] Constify many getters of cmGlobalGenerator. --- Source/cmGlobalGenerator.h | 32 ++++++++++++------------- Source/cmGlobalUnixMakefileGenerator3.h | 22 ++++++++--------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 97cacc53d6b..adf7b7727e7 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -163,8 +163,8 @@ class cmGlobalGenerator int TryCompileTimeout; - bool GetForceUnixPaths() {return this->ForceUnixPaths;} - bool GetToolSupportsColor() { return this->ToolSupportsColor; } + bool GetForceUnixPaths() const { return this->ForceUnixPaths; } + bool GetToolSupportsColor() const { return this->ToolSupportsColor; } ///! return the language for the given extension const char* GetLanguageFromExtension(const char* ext); @@ -179,11 +179,11 @@ class cmGlobalGenerator virtual const char* GetCMakeCFGInitDirectory() { return "."; } /** Get whether the generator should use a script for link commands. */ - bool GetUseLinkScript() { return this->UseLinkScript; } + bool GetUseLinkScript() const { return this->UseLinkScript; } /** Get whether the generator should produce special marks on rules producing symbolic (non-file) outputs. */ - bool GetNeedSymbolicMark() { return this->NeedSymbolicMark; } + bool GetNeedSymbolicMark() const { return this->NeedSymbolicMark; } /* * Determine what program to use for building the project. @@ -213,7 +213,7 @@ class cmGlobalGenerator /** Get the manifest of all targets that will be built for each configuration. This is valid during generation only. */ - cmTargetManifest const& GetTargetManifest() { return this->TargetManifest; } + cmTargetManifest const& GetTargetManifest() const { return this->TargetManifest; } /** Get the content of a directory. Directory listings are loaded from disk at most once and cached. During the generation step @@ -224,17 +224,17 @@ class cmGlobalGenerator void AddTarget(cmTargets::value_type &v); - virtual const char* GetAllTargetName() { return "ALL_BUILD"; } - virtual const char* GetInstallTargetName() { return "INSTALL"; } - virtual const char* GetInstallLocalTargetName() { return 0; } - virtual const char* GetInstallStripTargetName() { return 0; } - virtual const char* GetPreinstallTargetName() { return 0; } - virtual const char* GetTestTargetName() { return "RUN_TESTS"; } - virtual const char* GetPackageTargetName() { return "PACKAGE"; } - virtual const char* GetPackageSourceTargetName(){ return 0; } - virtual const char* GetEditCacheTargetName() { return 0; } - virtual const char* GetRebuildCacheTargetName() { return 0; } - virtual const char* GetCleanTargetName() { return 0; } + virtual const char* GetAllTargetName() const { return "ALL_BUILD"; } + virtual const char* GetInstallTargetName() const { return "INSTALL"; } + virtual const char* GetInstallLocalTargetName() const { return 0; } + virtual const char* GetInstallStripTargetName() const { return 0; } + virtual const char* GetPreinstallTargetName() const { return 0; } + virtual const char* GetTestTargetName() const { return "RUN_TESTS"; } + virtual const char* GetPackageTargetName() const { return "PACKAGE"; } + virtual const char* GetPackageSourceTargetName() const { return 0; } + virtual const char* GetEditCacheTargetName() const { return 0; } + virtual const char* GetRebuildCacheTargetName() const { return 0; } + virtual const char* GetCleanTargetName() const { return 0; } // Class to track a set of dependencies. typedef cmTargetDependSet TargetDependSet; diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index d21d5b957e8..7c6bbc2dcd2 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -137,17 +137,17 @@ class cmGlobalUnixMakefileGenerator3 : public cmGlobalGenerator bool NeedRequiresStep(cmTarget const&); // Setup target names - virtual const char* GetAllTargetName() { return "all"; } - virtual const char* GetInstallTargetName() { return "install"; } - virtual const char* GetInstallLocalTargetName() { return "install/local"; } - virtual const char* GetInstallStripTargetName() { return "install/strip"; } - virtual const char* GetPreinstallTargetName() { return "preinstall"; } - virtual const char* GetTestTargetName() { return "test"; } - virtual const char* GetPackageTargetName() { return "package"; } - virtual const char* GetPackageSourceTargetName(){ return "package_source"; } - virtual const char* GetEditCacheTargetName() { return "edit_cache"; } - virtual const char* GetRebuildCacheTargetName() { return "rebuild_cache"; } - virtual const char* GetCleanTargetName() { return "clean"; } + virtual const char* GetAllTargetName() const { return "all"; } + virtual const char* GetInstallTargetName() const { return "install"; } + virtual const char* GetInstallLocalTargetName() const { return "install/local"; } + virtual const char* GetInstallStripTargetName() const { return "install/strip"; } + virtual const char* GetPreinstallTargetName() const { return "preinstall"; } + virtual const char* GetTestTargetName() const { return "test"; } + virtual const char* GetPackageTargetName() const { return "package"; } + virtual const char* GetPackageSourceTargetName() const { return "package_source"; } + virtual const char* GetEditCacheTargetName() const { return "edit_cache"; } + virtual const char* GetRebuildCacheTargetName() const { return "rebuild_cache"; } + virtual const char* GetCleanTargetName() const { return "clean"; } virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { return true; } From 903d914b28655f0643409c4c165654b1daf2e0fd Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 22 Aug 2011 14:02:20 +0100 Subject: [PATCH 309/539] Make cmLocalGenerator::ConvertToLinkReference virtual This provides a mechanism for the local generator to override how library search paths are generated. --- Source/cmLocalGenerator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 1f5a26eba2f..69e452be50a 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -369,7 +369,7 @@ class cmLocalGenerator std::string FindRelativePathTopBinary(); void SetupPathConversions(); - std::string ConvertToLinkReference(std::string const& lib); + virtual std::string ConvertToLinkReference(std::string const& lib); /** Check whether the native build system supports the given definition. Issues a warning. */ From 5b114c9bee735eebf3e6b4d6ef18e4c732ac55f0 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 7 Sep 2011 02:41:41 +0100 Subject: [PATCH 310/539] Introduce a cmLocalGenerator::ConvertToIncludeReference function This provides a mechanism for the local generator to override how header search paths are generated. --- Source/cmLocalGenerator.cxx | 9 ++++++++- Source/cmLocalGenerator.h | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6af7fd5e1d2..aeda164053c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1184,6 +1184,13 @@ cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote, return this->ConvertToOutputForExistingCommon(remotePath, result); } +//---------------------------------------------------------------------------- +std::string +cmLocalGenerator::ConvertToIncludeReference(std::string const& path) +{ + return this->ConvertToOutputForExisting(path.c_str()); +} + //---------------------------------------------------------------------------- const char* cmLocalGenerator::GetIncludeFlags(const char* lang, bool forResponseFile) @@ -1285,7 +1292,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang, } else { - includePath = this->ConvertToOutputForExisting(i->c_str()); + includePath = this->ConvertToIncludeReference(*i); } if(quotePaths && includePath.size() && includePath[0] != '\"') { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 69e452be50a..c0fe8860fcd 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -179,7 +179,9 @@ class cmLocalGenerator path and short path if spaces. */ std::string ConvertToOutputForExisting(RelativeRoot remote, const char* local = 0); - + + virtual std::string ConvertToIncludeReference(std::string const& path); + /** Called from command-line hook to clear dependencies. */ virtual void ClearDependencies(cmMakefile* /* mf */, bool /* verbose */) {} From 557956f3489dbc75c7b6d26ed531c7c577aac146 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sat, 10 Sep 2011 03:52:53 +0100 Subject: [PATCH 311/539] Introduce a cmGlobalGenerator::ResolveLanguageCompiler function It is factored out of cmGlobalUnixMakefileGenerator3::EnableLanguage, and may be used by other generators to resolve CMAKE_*_COMPILER settings. --- Source/cmGlobalGenerator.cxx | 73 +++++++++++++++++++++++ Source/cmGlobalGenerator.h | 7 +++ Source/cmGlobalUnixMakefileGenerator3.cxx | 70 +--------------------- 3 files changed, 81 insertions(+), 69 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d62fb445dc5..124519ada49 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -77,6 +77,79 @@ cmGlobalGenerator::~cmGlobalGenerator() this->ClearExportSets(); } +void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, + cmMakefile *mf, + bool optional) { + std::string langComp = "CMAKE_"; + langComp += lang; + langComp += "_COMPILER"; + + if(!mf->GetDefinition(langComp.c_str())) + { + if(!optional) + { + cmSystemTools::Error(langComp.c_str(), + " not set, after EnableLanguage"); + } + return; + } + const char* name = mf->GetRequiredDefinition(langComp.c_str()); + std::string path; + if(!cmSystemTools::FileIsFullPath(name)) + { + path = cmSystemTools::FindProgram(name); + } + else + { + path = name; + } + if((path.size() == 0 || !cmSystemTools::FileExists(path.c_str())) + && (optional==false)) + { + std::string message = "your "; + message += lang; + message += " compiler: \""; + message += name; + message += "\" was not found. Please set "; + message += langComp; + message += " to a valid compiler path or name."; + cmSystemTools::Error(message.c_str()); + path = name; + } + std::string doc = lang; + doc += " compiler."; + const char* cname = this->GetCMakeInstance()-> + GetCacheManager()->GetCacheValue(langComp.c_str()); + std::string changeVars; + if(cname && (path != cname) && (optional==false)) + { + std::string cnameString = cname; + std::string pathString = path; + // get rid of potentially multiple slashes: + cmSystemTools::ConvertToUnixSlashes(cnameString); + cmSystemTools::ConvertToUnixSlashes(pathString); + if (cnameString != pathString) + { + const char* cvars = + this->GetCMakeInstance()->GetProperty( + "__CMAKE_DELETE_CACHE_CHANGE_VARS_"); + if(cvars) + { + changeVars += cvars; + changeVars += ";"; + } + changeVars += langComp; + changeVars += ";"; + changeVars += cname; + this->GetCMakeInstance()->SetProperty( + "__CMAKE_DELETE_CACHE_CHANGE_VARS_", + changeVars.c_str()); + } + } + mf->AddCacheDefinition(langComp.c_str(), path.c_str(), + doc.c_str(), cmCacheManager::FILEPATH); +} + // Find the make program for the generator, required for try compiles void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index adf7b7727e7..96a326cf5de 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -76,6 +76,13 @@ class cmGlobalGenerator virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *, bool optional); + /** + * Resolve the CMAKE__COMPILER setting for the given language. + * Intended to be called from EnableLanguage. + */ + void ResolveLanguageCompiler(const std::string &lang, cmMakefile *mf, + bool optional); + /** * Try to determine system infomation, get it from another generator */ diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 169d77d9de9..a23c0d8d397 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -39,7 +39,6 @@ ::EnableLanguage(std::vectorconst& languages, bool optional) { this->cmGlobalGenerator::EnableLanguage(languages, mf, optional); - std::string path; for(std::vector::const_iterator l = languages.begin(); l != languages.end(); ++l) { @@ -47,74 +46,7 @@ ::EnableLanguage(std::vectorconst& languages, { continue; } - const char* lang = l->c_str(); - std::string langComp = "CMAKE_"; - langComp += lang; - langComp += "_COMPILER"; - - if(!mf->GetDefinition(langComp.c_str())) - { - if(!optional) - { - cmSystemTools::Error(langComp.c_str(), - " not set, after EnableLanguage"); - } - continue; - } - const char* name = mf->GetRequiredDefinition(langComp.c_str()); - if(!cmSystemTools::FileIsFullPath(name)) - { - path = cmSystemTools::FindProgram(name); - } - else - { - path = name; - } - if((path.size() == 0 || !cmSystemTools::FileExists(path.c_str())) - && (optional==false)) - { - std::string message = "your "; - message += lang; - message += " compiler: \""; - message += name; - message += "\" was not found. Please set "; - message += langComp; - message += " to a valid compiler path or name."; - cmSystemTools::Error(message.c_str()); - path = name; - } - std::string doc = lang; - doc += " compiler."; - const char* cname = this->GetCMakeInstance()-> - GetCacheManager()->GetCacheValue(langComp.c_str()); - std::string changeVars; - if(cname && (path != cname) && (optional==false)) - { - std::string cnameString = cname; - std::string pathString = path; - // get rid of potentially multiple slashes: - cmSystemTools::ConvertToUnixSlashes(cnameString); - cmSystemTools::ConvertToUnixSlashes(pathString); - if (cnameString != pathString) - { - const char* cvars = - this->GetCMakeInstance()->GetProperty( - "__CMAKE_DELETE_CACHE_CHANGE_VARS_"); - if(cvars) - { - changeVars += cvars; - changeVars += ";"; - } - changeVars += langComp; - changeVars += ";"; - changeVars += cname; - this->GetCMakeInstance()->SetProperty( - "__CMAKE_DELETE_CACHE_CHANGE_VARS_", - changeVars.c_str()); - } - } - mf->AddCacheDefinition(langComp.c_str(), path.c_str(), - doc.c_str(), cmCacheManager::FILEPATH); + this->ResolveLanguageCompiler(*l, mf, optional); } } From fec4b637148bf6dca4b1d532ad0c1332c3038ea8 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 03:59:55 +0100 Subject: [PATCH 312/539] Fix configuration-dependent flag lookup in cmLocalGenerator::GetTargetFlags Specifically, perform configuration-dependent lookup of STATIC_LIBRARY_FLAGS for static libraries, and use the correct prefix for configuration-dependent lookup of LINK_FLAGS (i.e. "LINK_FLAGS_", as opposed to the value of the LINK_FLAGS property). --- Source/cmLocalGenerator.cxx | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index aeda164053c..65d6fa6564f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1463,6 +1463,17 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += targetLinkFlags; linkFlags += " "; } + if(!buildType.empty()) + { + std::string build = "STATIC_LIBRARY_FLAGS_"; + build += buildType; + targetLinkFlags = target.GetProperty(build.c_str()); + if(targetLinkFlags) + { + linkFlags += targetLinkFlags; + linkFlags += " "; + } + } } break; case cmTarget::MODULE_LIBRARY: @@ -1471,7 +1482,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable); linkFlags += " "; - if(buildType.size()) + if(!buildType.empty()) { std::string build = libraryLinkVariable; build += "_"; @@ -1502,7 +1513,10 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { linkFlags += targetLinkFlags; linkFlags += " "; - std::string configLinkFlags = targetLinkFlags; + } + if(!buildType.empty()) + { + std::string configLinkFlags = "LINK_FLAGS_"; configLinkFlags += buildType; targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); if(targetLinkFlags) @@ -1521,7 +1535,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); linkFlags += " "; - if(buildType.size()) + if(!buildType.empty()) { std::string build = "CMAKE_EXE_LINKER_FLAGS_"; build += buildType; @@ -1573,8 +1587,11 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, if(targetLinkFlags) { linkFlags += targetLinkFlags; - linkFlags += " "; - std::string configLinkFlags = targetLinkFlags; + linkFlags += " "; + } + if(!buildType.empty()) + { + std::string configLinkFlags = "LINK_FLAGS_"; configLinkFlags += buildType; targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); if(targetLinkFlags) From a92b17e42187f0a16a3489f989de0a9c97c7e1e3 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 3 Oct 2011 00:01:03 -0400 Subject: [PATCH 313/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 7b823269188..c2ba28a6ff8 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 02) +SET(KWSYS_DATE_STAMP_DAY 03) From cf4b52980db90600fb9bf77f826ae72b38f71967 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 20 Jul 2011 22:28:32 -0400 Subject: [PATCH 314/539] Add QT_LIBRARIES_PLUGINS variable to UseQt4. --- Modules/FindQt4.cmake | 8 ++++++++ Modules/UseQt4.cmake | 2 ++ 2 files changed, 10 insertions(+) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 3b05c2b385f..c56827eaa68 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -1062,6 +1062,14 @@ IF (QT_QMAKE_EXECUTABLE AND QTVERSION) SET( QT_SCRIPT_PLUGINS qtscriptdbus ) SET( QT_SQLDRIVERS_PLUGINS qsqldb2 qsqlibase qsqlite qsqlite2 qsqlmysql qsqloci qsqlodbc qsqlpsql qsqltds ) + SET( QT_PHONON_PLUGINS ${QT_PHONON_BACKEND_PLUGINS} ) + SET( QT_QT3SUPPORT_PLUGINS qtaccessiblecompatwidgets ) + SET( QT_QTCORE_PLUGINS ${QT_BEARER_PLUGINS} ${QT_CODECS_PLUGINS} ) + SET( QT_QTGUI_PLUGINS qtaccessiblewidgets qgif qjpeg qmng qico qtiff ${QT_DECORATIONS_PLUGINS} ${QT_GRAPHICSDRIVERS_PLUGINS} ${QT_GRAPHICSSYSTEMS_PLUGINS} ${QT_INPUTMETHODS_PLUGINS} ${QT_MOUSEDRIVERS_PLUGINS} ) + SET( QT_QTSCRIPT_PLUGINS ${QT_SCRIPT_PLUGINS} ) + SET( QT_QTSQL_PLUGINS ${QT_SQLDRIVERS_PLUGINS} ) + SET( QT_QTSVG_PLUGINS qsvg qsvgicon ) + IF(QT_QMAKE_CHANGED) FOREACH(QT_PLUGIN_TYPE ${QT_PLUGIN_TYPES}) STRING(TOUPPER ${QT_PLUGIN_TYPE} _upper_qt_plugin_type) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index dbe28ac548a..b8243923653 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -28,6 +28,7 @@ ENDIF() INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}) SET(QT_LIBRARIES "") +SET(QT_LIBRARIES_PLUGINS "") IF (QT_USE_QTMAIN) IF (Q_WS_WIN) @@ -91,6 +92,7 @@ FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN INCLUDE_DIRECTORIES(${QT_${module}_INCLUDE_DIR}) ENDIF(QT_USE_${module}) SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY}) + SET(QT_LIBRARIES_PLUGINS ${QT_LIBRARIES_PLUGINS} ${QT_${module}_PLUGINS}) IF(QT_IS_STATIC) SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES}) ENDIF(QT_IS_STATIC) From 06180459cc61a107047957edbc945116e3ca6171 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 30 Sep 2011 13:40:49 +0100 Subject: [PATCH 315/539] Add DeployQt4 module. Add a module that gives better support to BundleUtilities to handle Qt plugins and deploy Qt applications. --- Modules/DeployQt4.cmake | 274 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 Modules/DeployQt4.cmake diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake new file mode 100644 index 00000000000..bdf83604a62 --- /dev/null +++ b/Modules/DeployQt4.cmake @@ -0,0 +1,274 @@ +# - Functions to help assemble a standalone Qt4 executable. +# A collection of CMake utility functions useful for deploying +# Qt4 executables. +# +# The following functions are provided by this module: +# write_qt4_conf +# resolve_qt4_paths +# fixup_qt4_executable +# install_qt4_plugin_path +# install_qt4_plugin +# install_qt4_executable +# Requires CMake 2.6 or greater because it uses function and +# PARENT_SCOPE. Also depends on BundleUtilities.cmake. +# +# WRITE_QT4_CONF( ) +# Writes a qt.conf file with the into . +# +# RESOLVE_QT4_PATHS( []) +# Loop through list and if any don't exist resolve them +# relative to the (if supplied) or the CMAKE_INSTALL_PREFIX. +# +# FIXUP_QT4_EXECUTABLE( [ ]) +# Copies Qt plugins, writes a Qt configuration file (if needed) and fixes up a +# Qt4 executable using BundleUtilities so it is standalone and can be +# drag-and-drop copied to another machine as long as all of the system +# libraries are compatible. +# +# should point to the executable to be fixed-up. +# +# should contain a list of the names or paths of any Qt plugins +# to be installed. +# +# will be passed to BundleUtilities and should be a list of any already +# installed plugins, libraries or executables to also be fixed-up. +# +# will be passed to BundleUtilities and should contain and directories +# to be searched to find library dependencies. +# +# allows an custom plugins directory to be used. +# +# will force a qt.conf file to be written even if not needed. +# +# INSTALL_QT4_PLUGIN_PATH(plugin executable copy installed_plugin_path_var ) +# Install (or copy) a resolved to the default plugins directory +# (or ) relative to and store the result in +# . +# +# If is set to TRUE then the plugins will be copied rather than +# installed. This is to allow this module to be used at CMake time rather than +# install time. +# +# If is set then anything installed will use this COMPONENT. +# +# INSTALL_QT4_PLUGIN(plugin executable copy installed_plugin_path_var ) +# Install (or copy) an unresolved to the default plugins directory +# (or ) relative to and store the result in +# . See documentation of INSTALL_QT4_PLUGIN_PATH. +# +# INSTALL_QT4_EXECUTABLE( [ ]) +# Installs Qt plugins, writes a Qt configuration file (if needed) and fixes up +# a Qt4 executable using BundleUtilities so it is standalone and can be +# drag-and-drop copied to another machine as long as all of the system +# libraries are compatible. The executable will be fixed-up at install time. +# See documentation of FIXUP_QT4_BUNDLE. + +#============================================================================= +# Copyright 2011 Mike McQuaid +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# The functions defined in this file depend on the fixup_bundle function +# (and others) found in BundleUtilities.cmake + +include(BundleUtilities) +set(DeployQt4_cmake_dir "${CMAKE_CURRENT_LIST_DIR}") + +function(write_qt4_conf qt_conf_dir qt_conf_contents) + set(qt_conf_path "${qt_conf_dir}/qt.conf") + message(STATUS "Writing ${qt_conf_path}") + file(WRITE "${qt_conf_path}" "${qt_conf_contents}") +endfunction() + +function(resolve_qt4_paths paths_var) + set(executable_path ${ARGV1}) + + set(paths_resolved) + foreach(path ${${paths_var}}) + if(EXISTS "${path}") + list(APPEND paths_resolved "${path}") + else() + if(${executable_path}) + list(APPEND paths_resolved "${executable_path}/${path}") + else() + list(APPEND paths_resolved "\${CMAKE_INSTALL_PREFIX}/${path}") + endif() + endif() + endforeach() + set(${paths_var} ${paths_resolved} PARENT_SCOPE) +endfunction() + +function(fixup_qt4_executable executable qtplugins) + set(libs ${ARGV2}) + set(dirs ${ARGV3}) + set(plugins_dir ${ARGV4}) + set(request_qt_conf ${ARGV5}) + + message(STATUS "fixup_qt4_executable") + message(STATUS " executable='${executable}'") + message(STATUS " qtplugins='${qtplugins}'") + message(STATUS " libs='${libs}'") + message(STATUS " dirs='${dirs}'") + message(STATUS " plugins_dir='${plugins_dir}'") + message(STATUS " request_qt_conf='${request_qt_conf}'") + + if(QT_LIBRARY_DIR) + list(APPEND dirs "${QT_LIBRARY_DIR}") + endif() + + if(APPLE) + set(qt_conf_dir "${executable}/Contents/Resources") + set(executable_path "${executable}") + set(write_qt_conf TRUE) + else() + get_filename_component(executable_path "${executable}" PATH) + if(NOT executable_path) + set(executable_path ".") + endif() + set(qt_conf_dir "${executable_path}") + set(write_qt_conf ${request_qt_conf}) + endif() + + foreach(plugin ${qtplugins}) + set(installed_plugin_path "") + install_qt4_plugin("${plugin}" "${plugins_dir}" "${executable}" 1 installed_plugin_path) + list(APPEND libs ${installed_plugin_path}) + endforeach() + + foreach(lib ${libs}) + if(NOT EXISTS "${lib}") + message(FATAL_ERROR "Library does not exist: ${lib}") + endif() + endforeach() + + resolve_qt4_paths(libs "${executable_path}") + resolve_qt4_paths(dirs "${executable_path}") + + if(write_qt_conf) + set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}") + write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}") + endif() + + fixup_bundle("${executable}" "${libs}" "${dirs}") +endfunction() + +function(install_qt4_plugin_path plugin executable copy installed_plugin_path_var) + set(plugins_dir ${ARGV4}) + set(component ${ARGV5}) + set(configurations ${ARGV6}) + if(EXISTS "${plugin}") + if(plugins_dir) + set(plugins_dir "${plugins_dir}") + else() + if(APPLE) + set(plugins_dir "PlugIns") + else() + set(plugins_dir "plugins") + endif() + endif() + if(APPLE) + set(plugins_path "${executable}/Contents/${plugins_dir}") + else() + get_filename_component(executable_path "${executable}" PATH) + if(NOT executable_path) + set(executable_path ".") + endif() + set(plugins_path "${executable_path}/${plugins_dir}") + endif() + + set(plugin_group "") + + get_filename_component(plugin_path "${plugin}" PATH) + get_filename_component(plugin_parent_path "${plugin_path}" PATH) + get_filename_component(plugin_parent_dir_name "${plugin_parent_path}" NAME) + get_filename_component(plugin_name "${plugin}" NAME) + string(TOLOWER "${plugin_parent_dir_name}" plugin_parent_dir_name) + + if("${plugin_parent_dir_name}" STREQUAL "plugins") + get_filename_component(plugin_group "${plugin_path}" NAME) + set(${plugin_group_var} "${plugin_group}") + endif() + set(plugins_path "${plugins_path}/${plugin_group}") + + if(${copy}) + file(MAKE_DIRECTORY "${plugins_path}") + file(COPY "${plugin}" DESTINATION "${plugins_path}") + else() + if(configurations AND (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)) + set(configurations CONFIGURATIONS ${configurations}) + endif() + if(component) + set(component COMPONENT ${component}) + endif() + install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component}) + endif() + set(${installed_plugin_path_var} ${${installed_path_var}} "${plugins_path}/${plugin_name}" PARENT_SCOPE) + endif() +endfunction() + +function(install_qt4_plugin plugin executable copy installed_plugin_path_var) + set(plugins_dir ${ARGV4}) + set(component ${ARGV5}) + if(EXISTS "${plugin}") + install_qt4_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}") + else() + if(QT_IS_STATIC) + string(TOUPPER "QT_${plugin}_LIBRARY" plugin_var) + else() + string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var) + endif() + set(plugin_release "${${plugin_var}_RELEASE}") + set(plugin_debug "${${plugin_var}_DEBUG}") + if(NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}") + message(WARNING "Qt plugin \"${plugin}\" not recognized or found.") + endif() + install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}" "Release|RelWithDebInfo|MinSizeRel") + install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}" "Debug") + endif() + set(installed_plugin_path_var "${installed_plugin_path_var}" PARENT_SCOPE) +endfunction() + +function(install_qt4_executable executable) + set(qtplugins ${ARGV1}) + set(libs ${ARGV2}) + set(dirs ${ARGV3}) + set(plugins_dir ${ARGV4}) + set(request_qt_conf ${ARGV5}) + set(plugin_component ${ARGV6}) + if(QT_LIBRARY_DIR) + list(APPEND dirs "${QT_LIBRARY_DIR}") + endif() + + get_filename_component(executable_absolute "${executable}" ABSOLUTE) + gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY}" qtcore_type) + if(qtcore_type STREQUAL "system") + set(qt_plugins_dir "") + endif() + + if(NOT qtplugins AND QT_LIBRARIES_PLUGINS) + set(qtplugins "${QT_LIBRARIES_PLUGINS}") + endif() + + foreach(plugin ${qtplugins}) + set(installed_plugin_paths "") + install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${plugin_component}") + list(APPEND libs ${installed_plugin_paths}) + endforeach() + + resolve_qt4_paths(libs) + resolve_qt4_paths(dirs) + + install(CODE + " INCLUDE( \"${DeployQt4_cmake_dir}/DeployQt4.cmake\" ) + SET( BU_CHMOD_BUNDLE_ITEMS TRUE ) + FIXUP_QT4_EXECUTABLE( \"\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\" ) " + ) +endfunction() From 80a0e2c3447442e210b85513ea79cdb2c6e43ab7 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 4 Oct 2011 00:01:04 -0400 Subject: [PATCH 316/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index c2ba28a6ff8..7fff66aa889 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 03) +SET(KWSYS_DATE_STAMP_DAY 04) From 5971063a5c41a1c899de3700ffce38c8655abe34 Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 4 Oct 2011 11:48:52 -0400 Subject: [PATCH 317/539] CMake 2.8.6 --- CMakeLists.txt | 2 +- ChangeLog.manual | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8927637cd22..126a006795e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -420,7 +420,7 @@ SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) SET(CMake_VERSION_PATCH 6) SET(CMake_VERSION_TWEAK 0) -SET(CMake_VERSION_RC 4) +#SET(CMake_VERSION_RC 4) # Releases define a tweak level. IF(DEFINED CMake_VERSION_TWEAK) diff --git a/ChangeLog.manual b/ChangeLog.manual index 88583b45986..31997678130 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,32 @@ +Changes in CMake 2.8.6 (since 2.8.6-rc4) +---------------------------------------- +Alex Neundorf (5): + Remove trailing whitespace + Minor improvements to the UsePkgConfig.cmake docs + Remove trailing whitespace + Improve behaviour of --find-package mode with try_run/try_compile + Use makefile->IssueMessage() for better error messages + +Bill Hoffman (2): + Use version 11.0 for 12.x and 9.10 for 10.x intel versions to fix 12.1 vsIDE. + Also, check for 11.x as an intel fortran version. + +Brad King (2): + Add Visual Studio 11 generator for x86 and x64 tools + Teach our tests about special cases for VS 11 + +David Cole (1): + CTestCustom.cmake: Ignore clang's summary warning + +Philip Lowman (1): + FindBullet: Also search for _Debug postfixed library names + +Raphael Kubo da Costa (1): + Fix typo in set_target_properties' documentation. + +Rolf Eike Beer (1): + Fix typo in UsePkgConfig.cmake + Changes in CMake 2.8.6-rc4 (since 2.8.6-rc3) -------------------------------------------- Alex Neundorf (3): From 3105dc3de60a7b1fa29c7720e0cebb71e747ee6f Mon Sep 17 00:00:00 2001 From: David Cole Date: Tue, 4 Oct 2011 14:41:15 -0400 Subject: [PATCH 318/539] Begin post-2.8.6 development --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 126a006795e..a586764ea4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -419,8 +419,8 @@ ENDIF() SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) SET(CMake_VERSION_PATCH 6) -SET(CMake_VERSION_TWEAK 0) -#SET(CMake_VERSION_RC 4) +#SET(CMake_VERSION_TWEAK 0) +#SET(CMake_VERSION_RC 1) # Releases define a tweak level. IF(DEFINED CMake_VERSION_TWEAK) From ab97790c33c74127b4698e1c858ab6a3ce966b40 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 5 Oct 2011 00:01:05 -0400 Subject: [PATCH 319/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 7fff66aa889..d1ffc3a85a4 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 04) +SET(KWSYS_DATE_STAMP_DAY 05) From 41719b7507a70b0c098f652c96693ba7755b397f Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Wed, 5 Oct 2011 10:24:26 +0200 Subject: [PATCH 320/539] libarchive: fix typo in CheckFileOffsetBits.cmake s/Cheking/Checking/ --- .../cmlibarchive/build/cmake/CheckFileOffsetBits.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Utilities/cmlibarchive/build/cmake/CheckFileOffsetBits.cmake b/Utilities/cmlibarchive/build/cmake/CheckFileOffsetBits.cmake index 5f4e053d020..472b80d0de2 100644 --- a/Utilities/cmlibarchive/build/cmake/CheckFileOffsetBits.cmake +++ b/Utilities/cmlibarchive/build/cmake/CheckFileOffsetBits.cmake @@ -18,7 +18,7 @@ MACRO (CHECK_FILE_OFFSET_BITS) IF(NOT DEFINED _FILE_OFFSET_BITS) - MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files") + MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files") TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64 ${CMAKE_BINARY_DIR} ${libarchive_SOURCE_DIR}/build/cmake/CheckFileOffsetBits.c @@ -32,10 +32,10 @@ MACRO (CHECK_FILE_OFFSET_BITS) IF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) SET(_FILE_OFFSET_BITS 64 CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files") - MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files - needed") + MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - needed") ELSE(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) SET(_FILE_OFFSET_BITS "" CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files") - MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files - not needed") + MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - not needed") ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) ENDIF(NOT DEFINED _FILE_OFFSET_BITS) From 240d39a6a4f72fe0e45fc1a1403e0b578d36a142 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Wed, 5 Oct 2011 10:02:32 -0600 Subject: [PATCH 321/539] Fix XML safety issue with adding preprocessor defines in CodeBlocks project. --- Source/cmExtraCodeBlocksGenerator.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 7db91c78ee8..9a0b1eaff73 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -19,6 +19,7 @@ #include "cmGeneratedFileStream.h" #include "cmTarget.h" #include "cmSystemTools.h" +#include "cmXMLSafe.h" #include @@ -585,7 +586,8 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, for(std::vector::const_iterator di = defs.begin(); di != defs.end(); ++di) { - fout <<" c_str() << "\" />\n"; + cmXMLSafe safedef(di->c_str()); + fout <<" \n"; } } From e36a1be46694796277b68e61d7312475babb4e0c Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 5 Oct 2011 21:51:35 +0200 Subject: [PATCH 322/539] fix #12262: use the C dependency scanner also for ASM files Files for the ASM language are those assembler files which are processed by the C/CXX compiler, and they may contain preprocessor directives, so run the C dependency scanner also on them. Alex --- Source/cmLocalUnixMakefileGenerator3.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 2eae9d056d4..da6a1c64368 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1559,7 +1559,7 @@ ::ScanDependencies(const char* targetDir, // Create the scanner for this language cmDepends *scanner = 0; - if(lang == "C" || lang == "CXX" || lang == "RC") + if(lang == "C" || lang == "CXX" || lang == "RC" || lang == "ASM") { // TODO: Handle RC (resource files) dependencies correctly. scanner = new cmDependsC(this, targetDir, lang.c_str(), &validDeps); From 61c69d3fbbdb0390eb8f27e39a30a21d43ab4169 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 6 Oct 2011 00:01:21 -0400 Subject: [PATCH 323/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index d1ffc3a85a4..86cdb39c5f4 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 05) +SET(KWSYS_DATE_STAMP_DAY 06) From cf93d63c0ac5d2a5da21dd78812938dace4067e0 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 6 Oct 2011 17:57:32 +0200 Subject: [PATCH 324/539] fix #12465: detect the masm compiler ID ("MSVC") Alex --- Modules/CMakeDetermineASMCompiler.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 171e31f9254..0a70d0a827e 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -107,6 +107,10 @@ IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_XL "-qversion") SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_XL "XL C") + LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS MSVC ) + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_MSVC "/?") + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_MSVC "Microsoft") + LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS TI_DSP ) SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_TI_DSP "-h") SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_TI_DSP "Texas Instruments") From 783da62f2ea539fa5baf96bb28f7f6690f748229 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 7 Oct 2011 00:01:04 -0400 Subject: [PATCH 325/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 86cdb39c5f4..79825b20d47 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 06) +SET(KWSYS_DATE_STAMP_DAY 07) From 029ab3102e9aa21b4d3bc0471884e8c877bf5c9e Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 7 Oct 2011 08:22:05 -0400 Subject: [PATCH 326/539] Constify XCode generator getters to match cmGlobalGenerator Commit 8a0eb78f (Constify many getters of cmGlobalGenerator, 2011-03-26) added const qualifiers to many cmGlobalGenerator methods. Fix the signature of the virtual function overrides in cmGlobalXCodeGenerator to match. --- Source/cmGlobalXCodeGenerator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index fa55ff08a7d..ed54be3b957 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -194,8 +194,8 @@ class cmGlobalXCodeGenerator : public cmGlobalGenerator void AppendFlag(std::string& flags, std::string const& flag); protected: - virtual const char* GetInstallTargetName() { return "install"; } - virtual const char* GetPackageTargetName() { return "package"; } + virtual const char* GetInstallTargetName() const { return "install"; } + virtual const char* GetPackageTargetName() const { return "package"; } unsigned int XcodeVersion; std::string VersionString; From 48171cefb5bc4a52953b08ade9459584fddc3d0d Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 8 Oct 2011 00:01:05 -0400 Subject: [PATCH 327/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 79825b20d47..f15993a825c 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 07) +SET(KWSYS_DATE_STAMP_DAY 08) From d17ab57c538cb283e8e0b3f3d2764a1b527a89d9 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 9 Oct 2011 00:01:03 -0400 Subject: [PATCH 328/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index f15993a825c..4476828e122 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 08) +SET(KWSYS_DATE_STAMP_DAY 09) From c83cfd7a01f2fb00ba7d545b0df667c0d43b296f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 9 Oct 2011 17:39:24 +0200 Subject: [PATCH 329/539] Remove unused define. --- Tests/Module/GenerateExportHeader/CMakeLists.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 3edb548e695..7a52c717719 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -90,10 +90,6 @@ macro(_do_build Include Library LibrarySource Source) " add_definitions(${ERROR_FLAG})\n" "endif()\n" - "if(MSVC)\n" - " add_definitions(-DCOMPILER_IS_MSVC)\n" - "endif()\n" - "add_subdirectory(\"${LibrarySource}\")\n" "include_directories(\"${LibrarySource}\" \"\${CMAKE_CURRENT_BINARY_DIR}/${LibrarySource}\")\n" @@ -125,10 +121,6 @@ include(GenerateExportHeader) add_compiler_export_flags() -if (MSVC) - add_definitions(-DCOMPILER_IS_MSVC) -endif() - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) message("#### COMPILER_HAS_DEPRECATED: " ${COMPILER_HAS_DEPRECATED}) From 08271ec7d3184c8a53ae80be9ec0ac6438032cfa Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 9 Oct 2011 17:41:47 +0200 Subject: [PATCH 330/539] Build each library only once instead of once for each test. --- .../GenerateExportHeader/CMakeLists.txt | 30 ++++++++++++++++--- .../lib_shared_and_static/CMakeLists.txt | 13 +++++++- .../libshared/CMakeLists.txt | 10 +++++++ .../libstatic/CMakeLists.txt | 10 +++++++ 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 7a52c717719..4a5b1cb5a3b 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -55,6 +55,29 @@ else() endif() endif() +set(DEPS + libshared + libstatic + lib_shared_and_static +) + +foreach(DEP ${DEPS}) + try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/${DEP}_build + ${CMAKE_CURRENT_SOURCE_DIR}/${DEP} + ${DEP} + OUTPUT_VARIABLE Out + ) + if (NOT Result) + message("OUTPUT: ${Out}") + endif() +endforeach() + +# The _do_build macro is called from a child scope, where +# the current source and binary dir are different. Save them here +# for use in the macro. +set(TEST_TOP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(TEST_TOP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + # We seem to get race conditions is writing this stuff to the same file at least on MinGW # So to write to separate source and build directories, we use a count to differentiate. @@ -67,8 +90,6 @@ macro(_do_build Include Library LibrarySource Source) "int main() { ${Source}; }\n" ) - file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/../${LibrarySource}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}") - if ("${Library}" STREQUAL "static_variant") set(CONDITIONAL_STATIC_DEFINE "add_definitions(-DLIBSHARED_AND_STATIC_STATIC_DEFINE)\n") endif() @@ -90,9 +111,10 @@ macro(_do_build Include Library LibrarySource Source) " add_definitions(${ERROR_FLAG})\n" "endif()\n" - "add_subdirectory(\"${LibrarySource}\")\n" + "include(\"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build/Targets.cmake\")\n" - "include_directories(\"${LibrarySource}\" \"\${CMAKE_CURRENT_BINARY_DIR}/${LibrarySource}\")\n" + "include_directories(\"${TEST_TOP_SOURCE_DIR}/${LibrarySource}\"\n" + " \"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build\")\n" "${CONDITIONAL_STATIC_DEFINE}" diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt index d19b6dc2fd0..be0387fd58c 100644 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt @@ -1,4 +1,13 @@ -project(shared_and_static) + +cmake_minimum_required(VERSION 2.8) + +project(lib_shared_and_static) + +include(GenerateExportHeader) + +add_compiler_export_flags() + +set(CMAKE_INCLUDE_CURRENT_DIR ON) set(lib_SRCS libshared_and_static.cpp @@ -10,3 +19,5 @@ add_library(static_variant ${lib_SRCS}) generate_export_header(shared_variant BASE_NAME libshared_and_static) set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) + +export(TARGETS shared_variant static_variant FILE Targets.cmake) diff --git a/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt index 8e4ee2b312d..e20adb1a7ca 100644 --- a/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt @@ -1,6 +1,16 @@ +cmake_minimum_required(VERSION 2.8) + project(libshared) +include(GenerateExportHeader) + +add_compiler_export_flags() + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + add_library(libshared SHARED libshared.cpp) generate_export_header(libshared) + +export(TARGETS libshared FILE Targets.cmake) diff --git a/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt index 8db18271004..b2db3ea74bb 100644 --- a/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt @@ -1,8 +1,18 @@ +cmake_minimum_required(VERSION 2.8) + project(libstatic) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include(GenerateExportHeader) + +add_compiler_export_flags() + # Show that the export header has no effect on a static library. add_library(libstatic STATIC libstatic.cpp) generate_export_header(libstatic) + +export(TARGETS libstatic FILE Targets.cmake) From d1f5a3bff9ebebf1e0df268e31f4853bfd46a8df Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 10 Oct 2011 00:01:03 -0400 Subject: [PATCH 331/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 4476828e122..b22febf96db 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 09) +SET(KWSYS_DATE_STAMP_DAY 10) From 32f8437bbfc7141ba4ff9c6dd4311e67c25c2ad2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 10 Oct 2011 09:44:33 -0400 Subject: [PATCH 332/539] Fix line-too-long style violations Commit 8a0eb78f (Constify many getters of cmGlobalGenerator, 2011-03-26) added const qualifiers to many cmGlobalGenerator methods but left the resulting lines beyond our style's limit of 79 characters. --- Source/cmGlobalGenerator.h | 7 ++++--- Source/cmGlobalUnixMakefileGenerator3.h | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 96a326cf5de..9f140a9c9fc 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -220,7 +220,8 @@ class cmGlobalGenerator /** Get the manifest of all targets that will be built for each configuration. This is valid during generation only. */ - cmTargetManifest const& GetTargetManifest() const { return this->TargetManifest; } + cmTargetManifest const& GetTargetManifest() const + { return this->TargetManifest; } /** Get the content of a directory. Directory listings are loaded from disk at most once and cached. During the generation step @@ -231,12 +232,12 @@ class cmGlobalGenerator void AddTarget(cmTargets::value_type &v); - virtual const char* GetAllTargetName() const { return "ALL_BUILD"; } + virtual const char* GetAllTargetName() const { return "ALL_BUILD"; } virtual const char* GetInstallTargetName() const { return "INSTALL"; } virtual const char* GetInstallLocalTargetName() const { return 0; } virtual const char* GetInstallStripTargetName() const { return 0; } virtual const char* GetPreinstallTargetName() const { return 0; } - virtual const char* GetTestTargetName() const { return "RUN_TESTS"; } + virtual const char* GetTestTargetName() const { return "RUN_TESTS"; } virtual const char* GetPackageTargetName() const { return "PACKAGE"; } virtual const char* GetPackageSourceTargetName() const { return 0; } virtual const char* GetEditCacheTargetName() const { return 0; } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 7c6bbc2dcd2..481640b7aed 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -136,18 +136,18 @@ class cmGlobalUnixMakefileGenerator3 : public cmGlobalGenerator // does this generator need a requires step for any of its targets bool NeedRequiresStep(cmTarget const&); - // Setup target names - virtual const char* GetAllTargetName() const { return "all"; } - virtual const char* GetInstallTargetName() const { return "install"; } - virtual const char* GetInstallLocalTargetName() const { return "install/local"; } - virtual const char* GetInstallStripTargetName() const { return "install/strip"; } - virtual const char* GetPreinstallTargetName() const { return "preinstall"; } - virtual const char* GetTestTargetName() const { return "test"; } - virtual const char* GetPackageTargetName() const { return "package"; } - virtual const char* GetPackageSourceTargetName() const { return "package_source"; } - virtual const char* GetEditCacheTargetName() const { return "edit_cache"; } - virtual const char* GetRebuildCacheTargetName() const { return "rebuild_cache"; } - virtual const char* GetCleanTargetName() const { return "clean"; } + // Target name hooks for superclass. + const char* GetAllTargetName() const { return "all"; } + const char* GetInstallTargetName() const { return "install"; } + const char* GetInstallLocalTargetName() const { return "install/local"; } + const char* GetInstallStripTargetName() const { return "install/strip"; } + const char* GetPreinstallTargetName() const { return "preinstall"; } + const char* GetTestTargetName() const { return "test"; } + const char* GetPackageTargetName() const { return "package"; } + const char* GetPackageSourceTargetName() const { return "package_source"; } + const char* GetEditCacheTargetName() const { return "edit_cache"; } + const char* GetRebuildCacheTargetName() const { return "rebuild_cache"; } + const char* GetCleanTargetName() const { return "clean"; } virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { return true; } From fac6e2ef4448a3dd42c149383468b9b681d3215f Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 11 Oct 2011 00:01:08 -0400 Subject: [PATCH 333/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index b22febf96db..434e6af049f 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 10) +SET(KWSYS_DATE_STAMP_DAY 11) From 25116a3cc21f252fe64ba074e3aeaa6335fc6624 Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Tue, 11 Oct 2011 22:48:41 +0200 Subject: [PATCH 334/539] Fix CMAKE_VERBOSE_MAKEFILE for VS10 vcxproj files (#12504) --- Source/cmVisualStudioGeneratorOptions.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index ae496ad12fc..4edeedc86dc 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -86,14 +86,14 @@ void cmVisualStudioGeneratorOptions::SetVerboseMakefile(bool verbose) // to the generated project to disable logo suppression. Otherwise // the GUI default is to enable suppression. // - // Avoid this on Visual Studio 10 (and later!) because it results in: + // On Visual Studio 10 (and later!), the value of this attribute should be + // an empty string, instead of "FALSE", in order to avoid a warning: // "cl ... warning D9035: option 'nologo-' has been deprecated" // if(verbose && - this->Version != 10 && this->FlagMap.find("SuppressStartupBanner") == this->FlagMap.end()) { - this->FlagMap["SuppressStartupBanner"] = "FALSE"; + this->FlagMap["SuppressStartupBanner"] = this->Version < 10 ? "FALSE" : ""; } } From 83e4a45609ef436d032b3c527bce9b0382cfe329 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 12 Oct 2011 00:01:04 -0400 Subject: [PATCH 335/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 434e6af049f..d542d7e035b 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 11) +SET(KWSYS_DATE_STAMP_DAY 12) From 0d44ce2bf4ced68e6d61b1733002988e0a8e6a40 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 12 Oct 2011 22:20:18 +0200 Subject: [PATCH 336/539] Silence make on OpenBSD in FindPackageModeTest(#12508) BSD make doesn't use -v for printing its name and version, and so complains on stderr that this is a bad command line option, used in Tests/FindPackageModeMakefileTest/CMakeLists.txt . Silence stderr to make that ugly output go away. Patch by David Coppy. Alex --- Tests/FindPackageModeMakefileTest/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index def8d63ec7a..3674f0efe3f 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -7,6 +7,7 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") # is AFAIK a GNU make extension. Alex execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} -v OUTPUT_VARIABLE makeVersionOutput + ERROR_QUIET TIMEOUT 10) string(TOUPPER "${makeVersionOutput}" MAKE_VERSION_OUTPUT) if("${MAKE_VERSION_OUTPUT}" MATCHES ".*GNU MAKE.*") From ba5a8bcf5d8c8350c195b4c197d57576bbd27e99 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 12 Oct 2011 23:05:30 +0200 Subject: [PATCH 337/539] Remove trailing whitespace Alex --- Modules/FindRuby.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index 80fb216e9f8..0c86b2d6d4f 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -137,7 +137,7 @@ IF(RUBY_EXECUTABLE AND NOT RUBY_MAJOR_VERSION) ) ENDIF(RUBY_EXECUTABLE AND NOT RUBY_MAJOR_VERSION) -# In case RUBY_EXECUTABLE could not be executed (e.g. cross compiling) +# In case RUBY_EXECUTABLE could not be executed (e.g. cross compiling) # try to detect which version we found. This is not too good. IF(NOT RUBY_VERSION_MAJOR) # by default assume 1.8.0 @@ -170,9 +170,9 @@ SET(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIR} ) IF( ${Ruby_FIND_VERSION_SHORT_NODOT} GREATER 18 OR ${_RUBY_VERSION_SHORT_NODOT} GREATER 18 OR RUBY_HDR_DIR) FIND_PATH(RUBY_CONFIG_INCLUDE_DIR NAMES ruby/config.h config.h - HINTS + HINTS ${RUBY_HDR_DIR}/${RUBY_ARCH} - ${RUBY_ARCH_DIR} + ${RUBY_ARCH_DIR} ) SET(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIRS} ${RUBY_CONFIG_INCLUDE_DIR} ) @@ -202,7 +202,7 @@ IF(WIN32) LIST(APPEND _RUBY_POSSIBLE_LIB_NAMES "msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}" - "msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}-static" + "msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}-static" "msvcrt-ruby${_RUBY_NODOT_VERSION}" "msvcrt-ruby${_RUBY_NODOT_VERSION}-static" ) ENDIF(WIN32) From d2b1ce6af0fbdaf75e07cdb102839e9eaf49c1b9 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 12 Oct 2011 23:05:52 +0200 Subject: [PATCH 338/539] Find Ruby on OpenBSD when installed from ports (#12507) The ruby library on OpenBSD is named rubyXY, not ruby X.y. Find that too. Alex --- Modules/FindRuby.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index 0c86b2d6d4f..ae2ea2e3308 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -180,7 +180,7 @@ ENDIF( ${Ruby_FIND_VERSION_SHORT_NODOT} GREATER 18 OR ${_RUBY_VERSION_SHORT_NO # Determine the list of possible names for the ruby library -SET(_RUBY_POSSIBLE_LIB_NAMES ruby ruby-static ruby${_RUBY_VERSION_SHORT}) +SET(_RUBY_POSSIBLE_LIB_NAMES ruby ruby-static ruby${_RUBY_VERSION_SHORT} ruby${_RUBY_VERSION_SHORT_NODOT}) IF(WIN32) SET( _RUBY_MSVC_RUNTIME "" ) From a481d84ff72f554bc2e98fe4d9d63f960cf0ebfc Mon Sep 17 00:00:00 2001 From: Philip Lowman Date: Wed, 12 Oct 2011 23:44:40 -0400 Subject: [PATCH 339/539] FindProtoBuf: Documented limitation of the public macro --- Modules/FindProtobuf.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 38f5a7572a8..53443040dd5 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -39,7 +39,11 @@ # target_link_libraries(bar ${PROTOBUF_LIBRARIES}) # # NOTE: You may need to link against pthreads, depending -# on the platform. +# on the platform. +# +# NOTE: The PROTOBUF_GENERATE_CPP macro & add_executable() or add_library() +# calls only work properly within the same directory. +# # ==================================================================== # # PROTOBUF_GENERATE_CPP (public function) From 731d61d8d9119417e5cc0b10ef167183d137cb00 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 13 Oct 2011 00:01:03 -0400 Subject: [PATCH 340/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index d542d7e035b..7bde0b018b7 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 12) +SET(KWSYS_DATE_STAMP_DAY 13) From 6eb2d79d721fdbf8e5a6a54e0b37270dfed76a04 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 14 Oct 2011 00:01:16 -0400 Subject: [PATCH 341/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 7bde0b018b7..7c4a805234e 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 13) +SET(KWSYS_DATE_STAMP_DAY 14) From 7041cd6a884d96941af0ac7aad442a83618aff71 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 14 Oct 2011 07:46:01 -0400 Subject: [PATCH 342/539] CTest: Fix crash when variables are not defined Avoiding dereference of NULL pointers is always good. --- Source/CTest/cmCTestConfigureCommand.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 9a668bce1ed..7a99ddfa0b0 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -41,7 +41,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() { this->CTest->SetCTestConfiguration("BuildDirectory", cmSystemTools::CollapseFullPath( - this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY")).c_str()); + this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY")).c_str()); } if ( this->Values[ct_SOURCE] ) @@ -54,7 +54,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() { this->CTest->SetCTestConfiguration("SourceDirectory", cmSystemTools::CollapseFullPath( - this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")).c_str()); + this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")).c_str()); } if ( this->CTest->GetCTestConfiguration("BuildDirectory").empty() ) From eb11e0b9ac0933a0c1c7bbba06d08e4f035bd59f Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 15 Oct 2011 00:01:09 -0400 Subject: [PATCH 343/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 7c4a805234e..5cdc7f8142d 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 14) +SET(KWSYS_DATE_STAMP_DAY 15) From 4974ec90a4f4d688b8beac603f7da9ed690d4827 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 15 Oct 2011 18:43:27 +0200 Subject: [PATCH 344/539] Eclipse generator: detect Eclipse version Try to detect the eclipse version and put it in the cache. Alex --- Modules/CMakeFindEclipseCDT4.cmake | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index 2f71cb936b9..02ce44a344f 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -17,6 +17,43 @@ FIND_PROGRAM(CMAKE_ECLIPSE_EXECUTABLE NAMES eclipse DOC "The Eclipse executable") +FUNCTION(_FIND_ECLIPSE_VERSION) + # This code is in a function so the variables used here have only local scope + IF(CMAKE_ECLIPSE_EXECUTABLE) + GET_FILENAME_COMPONENT(_ECLIPSE_DIR "${CMAKE_ECLIPSE_EXECUTABLE}" PATH) + FILE(GLOB _ECLIPSE_FEATURE_DIR "${_ECLIPSE_DIR}/features/org.eclipse.platform*") + IF("${_ECLIPSE_FEATURE_DIR}" MATCHES ".+org.eclipse.platform_([0-9]+\\.[0-9]+).+") + SET(_ECLIPSE_VERSION ${CMAKE_MATCH_1}) + ENDIF() + ENDIF() + + IF(_ECLIPSE_VERSION) + MESSAGE(STATUS "Found Eclipse version ${_ECLIPSE_VERSION}") + ELSE() + SET(_ECLIPSE_VERSION "3.6" ) + MESSAGE(STATUS "Could not determine Eclipse version, assuming ${_ECLIPSE_VERSION}") + ENDIF() + + # Set up a map with the names of the Eclipse releases: + SET(_ECLIPSE_VERSION_NAME_ "Unknown" ) + SET(_ECLIPSE_VERSION_NAME_3.2 "Callisto" ) + SET(_ECLIPSE_VERSION_NAME_3.3 "Europa" ) + SET(_ECLIPSE_VERSION_NAME_3.4 "Ganymede" ) + SET(_ECLIPSE_VERSION_NAME_3.5 "Galileo" ) + SET(_ECLIPSE_VERSION_NAME_3.6 "Helios" ) + SET(_ECLIPSE_VERSION_NAME_3.7 "Indigo" ) + + SET(CMAKE_ECLIPSE_VERSION "${_ECLIPSE_VERSION} (${_ECLIPSE_VERSION_NAME_${_ECLIPSE_VERSION}})" CACHE STRING "The version of Eclipse. If Eclipse has not been found, 3.6 (Helios) is assumed.") + SET_PROPERTY(CACHE CMAKE_ECLIPSE_VERSION PROPERTY STRINGS "3.2 (${_ECLIPSE_VERSION_NAME_3.2})" + "3.3 (${_ECLIPSE_VERSION_NAME_3.3})" + "3.4 (${_ECLIPSE_VERSION_NAME_3.4})" + "3.5 (${_ECLIPSE_VERSION_NAME_3.5})" + "3.6 (${_ECLIPSE_VERSION_NAME_3.6})" + "3.7 (${_ECLIPSE_VERSION_NAME_3.7})") +ENDFUNCTION() + +_FIND_ECLIPSE_VERSION() + # This variable is used by the Eclipse generator and appended to the make invocation commands. SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j to get parallel builds") From 5b200e3bed8e450027ddad42a155d670f247e58c Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 15 Oct 2011 19:40:21 +0200 Subject: [PATCH 345/539] Detect whether the current Eclipse version supports VirtualFolders VirtualFolders are supported since 3.6 (Helios). Next patch will be to actually make use of the new flag SupportsVirtualFolders. Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 20 ++++++++++++++++++++ Source/cmExtraEclipseCDT4Generator.h | 1 + 2 files changed, 21 insertions(+) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 7beffdcf2e0..21b1b619bdb 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -34,6 +34,8 @@ ::cmExtraEclipseCDT4Generator() : cmExternalMakefileProjectGenerator() // this->SupportedGlobalGenerators.push_back("MSYS Makefiles"); #endif this->SupportedGlobalGenerators.push_back("Unix Makefiles"); + + this->SupportsVirtualFolders = true; } //---------------------------------------------------------------------------- @@ -57,6 +59,24 @@ void cmExtraEclipseCDT4Generator::Generate() const cmMakefile* mf = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); + std::string eclipseVersion = mf->GetSafeDefinition("CMAKE_ECLIPSE_VERSION"); + cmsys::RegularExpression regex(".*([0-9]+\\.[0-9]+).*"); + if (regex.find(eclipseVersion.c_str())) + { + unsigned int majorVersion = 0; + unsigned int minorVersion = 0; + int res=sscanf(regex.match(1).c_str(), "%u.%u", &majorVersion, + &minorVersion); + if (res == 2) + { + int version = majorVersion * 1000 + minorVersion; + if (version < 3006) // 3.6 is Helios + { + this->SupportsVirtualFolders = false; + } + } + } + // TODO: Decide if these are local or member variables this->HomeDirectory = mf->GetHomeDirectory(); this->HomeOutputDirectory = mf->GetHomeOutputDirectory(); diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index a6837313b3a..b866619715c 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -107,6 +107,7 @@ class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator std::string HomeOutputDirectory; bool IsOutOfSourceBuild; bool GenerateSourceProject; + bool SupportsVirtualFolders; }; From b4b2fc33f936631b826456bfa098dcd2702e914d Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 15 Oct 2011 21:03:14 +0200 Subject: [PATCH 346/539] Eclipse: don't create VirtualFolders if not supported Eclipse versions before 3.6 (Helios) did not support VirtualFolders yet (#12479), so only create them if Eclipse is new enough. Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 45 ++++++++++++++------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 21b1b619bdb..f303f16fdd7 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -420,29 +420,32 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() } - // for each sub project create a linked resource to the source dir - // - only if it is an out-of-source build - this->AppendLinkedResource(fout, "[Subprojects]", - "virtual:/virtual", true); - - for (std::map >::const_iterator - it = this->GlobalGenerator->GetProjectMap().begin(); - it != this->GlobalGenerator->GetProjectMap().end(); - ++it) + if (this->SupportsVirtualFolders) { - std::string linkSourceDirectory = this->GetEclipsePath( - it->second[0]->GetMakefile()->GetStartDirectory()); - // a linked resource must not point to a parent directory of .project or - // .project itself - if ((this->HomeOutputDirectory != linkSourceDirectory) && - !cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(), - linkSourceDirectory.c_str())) + // for each sub project create a linked resource to the source dir + // - only if it is an out-of-source build + this->AppendLinkedResource(fout, "[Subprojects]", + "virtual:/virtual", true); + + for (std::map >::const_iterator + it = this->GlobalGenerator->GetProjectMap().begin(); + it != this->GlobalGenerator->GetProjectMap().end(); + ++it) { - std::string linkName = "[Subprojects]/"; - linkName += it->first; - this->AppendLinkedResource(fout, linkName, - this->GetEclipsePath(linkSourceDirectory)); - this->SrcLinkedResources.push_back(it->first); + std::string linkSourceDirectory = this->GetEclipsePath( + it->second[0]->GetMakefile()->GetStartDirectory()); + // a linked resource must not point to a parent directory of .project or + // .project itself + if ((this->HomeOutputDirectory != linkSourceDirectory) && + !cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(), + linkSourceDirectory.c_str())) + { + std::string linkName = "[Subprojects]/"; + linkName += it->first; + this->AppendLinkedResource(fout, linkName, + this->GetEclipsePath(linkSourceDirectory)); + this->SrcLinkedResources.push_back(it->first); + } } } From dcd245913c41249637010f6b804e4ee4207ccc8f Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 15 Oct 2011 21:04:23 +0200 Subject: [PATCH 347/539] Eclipse: better message when Eclipse version could not be determined Alex --- Modules/CMakeFindEclipseCDT4.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index 02ce44a344f..cf0984e1ad5 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -27,13 +27,6 @@ FUNCTION(_FIND_ECLIPSE_VERSION) ENDIF() ENDIF() - IF(_ECLIPSE_VERSION) - MESSAGE(STATUS "Found Eclipse version ${_ECLIPSE_VERSION}") - ELSE() - SET(_ECLIPSE_VERSION "3.6" ) - MESSAGE(STATUS "Could not determine Eclipse version, assuming ${_ECLIPSE_VERSION}") - ENDIF() - # Set up a map with the names of the Eclipse releases: SET(_ECLIPSE_VERSION_NAME_ "Unknown" ) SET(_ECLIPSE_VERSION_NAME_3.2 "Callisto" ) @@ -43,6 +36,13 @@ FUNCTION(_FIND_ECLIPSE_VERSION) SET(_ECLIPSE_VERSION_NAME_3.6 "Helios" ) SET(_ECLIPSE_VERSION_NAME_3.7 "Indigo" ) + IF(_ECLIPSE_VERSION) + MESSAGE(STATUS "Found Eclipse version ${_ECLIPSE_VERSION} (${_ECLIPSE_VERSION_NAME_${_ECLIPSE_VERSION}})") + ELSE() + SET(_ECLIPSE_VERSION "3.6" ) + MESSAGE(STATUS "Could not determine Eclipse version, assuming at least ${_ECLIPSE_VERSION} (${_ECLIPSE_VERSION_NAME_${_ECLIPSE_VERSION}}). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.") + ENDIF() + SET(CMAKE_ECLIPSE_VERSION "${_ECLIPSE_VERSION} (${_ECLIPSE_VERSION_NAME_${_ECLIPSE_VERSION}})" CACHE STRING "The version of Eclipse. If Eclipse has not been found, 3.6 (Helios) is assumed.") SET_PROPERTY(CACHE CMAKE_ECLIPSE_VERSION PROPERTY STRINGS "3.2 (${_ECLIPSE_VERSION_NAME_3.2})" "3.3 (${_ECLIPSE_VERSION_NAME_3.3})" From 80621968ea0cff551e7389533c907aca875e6c0e Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 16 Oct 2011 00:01:04 -0400 Subject: [PATCH 348/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 5cdc7f8142d..40b2422e9de 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 15) +SET(KWSYS_DATE_STAMP_DAY 16) From c6e748749900a5b9020f04ffaddf71d4f5572d99 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 17 Oct 2011 00:01:08 -0400 Subject: [PATCH 349/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 40b2422e9de..8723a3a9e89 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 16) +SET(KWSYS_DATE_STAMP_DAY 17) From fa7a747b33e0859a8ec4f1ca18c7b7e0aa57c77c Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 18 Oct 2011 00:01:04 -0400 Subject: [PATCH 350/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 8723a3a9e89..0e6922dbe85 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 17) +SET(KWSYS_DATE_STAMP_DAY 18) From 1b6c33f79874ce7c03c6895ea531472b7d89a4ed Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 19 Oct 2011 00:01:19 -0400 Subject: [PATCH 351/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 0e6922dbe85..80902d52bbe 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 18) +SET(KWSYS_DATE_STAMP_DAY 19) From b6d4de7911c5d54c087d5616660ee7e4050da834 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Wed, 19 Oct 2011 22:02:14 +0200 Subject: [PATCH 352/539] Eclipse: add virtual folder for each target For each target a virtual folder is created, which contains one virtual folder for each sourcegroup, which contain links to the actual source files (#12294, #12223) Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 103 +++++++++++++++++++++++-- Source/cmExtraEclipseCDT4Generator.h | 4 +- 2 files changed, 99 insertions(+), 8 deletions(-) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index f303f16fdd7..3f63646bb92 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -17,6 +17,7 @@ #include "cmMakefile.h" #include "cmGeneratedFileStream.h" #include "cmTarget.h" +#include "cmSourceFile.h" #include "cmSystemTools.h" #include @@ -414,7 +415,8 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() linkSourceDirectory.c_str())) { this->AppendLinkedResource(fout, sourceLinkedResourceName, - this->GetEclipsePath(linkSourceDirectory)); + this->GetEclipsePath(linkSourceDirectory), + LinkToFolder); this->SrcLinkedResources.push_back(sourceLinkedResourceName); } @@ -425,7 +427,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() // for each sub project create a linked resource to the source dir // - only if it is an out-of-source build this->AppendLinkedResource(fout, "[Subprojects]", - "virtual:/virtual", true); + "virtual:/virtual", VirtualFolder); for (std::map >::const_iterator it = this->GlobalGenerator->GetProjectMap().begin(); @@ -443,10 +445,92 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() std::string linkName = "[Subprojects]/"; linkName += it->first; this->AppendLinkedResource(fout, linkName, - this->GetEclipsePath(linkSourceDirectory)); + this->GetEclipsePath(linkSourceDirectory), + LinkToFolder + ); this->SrcLinkedResources.push_back(it->first); } } + + std::string linkName = "[Targets]"; + this->AppendLinkedResource(fout, linkName, "virtual:/virtual", + VirtualFolder); + + + for (std::vector::const_iterator + lgIt = this->GlobalGenerator->GetLocalGenerators().begin(); + lgIt != this->GlobalGenerator->GetLocalGenerators().end(); + ++lgIt) + { + cmMakefile* makefile = (*lgIt)->GetMakefile(); + const cmTargets& targets = makefile->GetTargets(); + + for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end();++ti) + { + std::string linkName2 = linkName; + linkName2 += "/"; + switch(ti->second.GetType()) + { + case cmTarget::EXECUTABLE: + case cmTarget::STATIC_LIBRARY: + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: + { + const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ? + "[exe] " : "[lib] "); + linkName2 += prefix; + linkName2 += ti->first; + this->AppendLinkedResource(fout, linkName2, "virtual:/virtual", + VirtualFolder); + std::vector sourceGroups = + makefile->GetSourceGroups(); + // get the files from the source lists then add them to the groups + cmTarget* tgt = const_cast(&ti->second); + std::vectorconst & files = tgt->GetSourceFiles(); + for(std::vector::const_iterator sfIt = files.begin(); + sfIt != files.end(); + sfIt++) + { + // Add the file to the list of sources. + std::string source = (*sfIt)->GetFullPath(); + cmSourceGroup& sourceGroup = + makefile->FindSourceGroup(source.c_str(), sourceGroups); + sourceGroup.AssignSource(*sfIt); + } + + + for(std::vector::iterator sgIt=sourceGroups.begin(); + sgIt != sourceGroups.end(); + ++sgIt) + { + std::string linkName3 = linkName2; + linkName3 += "/"; + linkName3 += sgIt->GetFullName(); + this->AppendLinkedResource(fout, linkName3, "virtual:/virtual", + VirtualFolder); + + std::vector sFiles = sgIt->GetSourceFiles(); + for(std::vector::const_iterator fileIt = + sFiles.begin(); + fileIt != sFiles.end(); + ++fileIt) + { + std::string linkName4 = linkName3; + linkName4 += "/"; + linkName4 += + cmSystemTools::GetFilenameName((*fileIt)->GetFullPath()); + this->AppendLinkedResource(fout, linkName4, + (*fileIt)->GetFullPath(), LinkToFile); + } + } + } + break; + // ignore all others: + default: + break; + } + } + } } // I'm not sure this makes too much sense. There can be different @@ -1115,20 +1199,25 @@ void cmExtraEclipseCDT4Generator ::AppendLinkedResource (cmGeneratedFileStream& fout, const std::string& name, const std::string& path, - bool isVirtualFolder) + LinkType linkType) { const char* locationTag = "location"; - if (isVirtualFolder) // ... and not a linked folder + const char* typeTag = "2"; + if (linkType == VirtualFolder) // ... and not a linked folder { locationTag = "locationURI"; } + if (linkType == LinkToFile) + { + typeTag = "1"; + } fout << "\t\t\n" "\t\t\t" << cmExtraEclipseCDT4Generator::EscapeForXML(name) << "\n" - "\t\t\t2\n" + "\t\t\t" << typeTag << "\n" "\t\t\t<" << locationTag << ">" << cmExtraEclipseCDT4Generator::EscapeForXML(path) << "\n" @@ -1177,7 +1266,7 @@ ::AppendOutLinkedResource(cmGeneratedFileStream& fout, else { this->AppendLinkedResource(fout, name, - this->GetEclipsePath(outputPath)); + this->GetEclipsePath(outputPath), LinkToFolder); this->OutLinkedResources.push_back(name); return true; } diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index b866619715c..2c7aa4398f8 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -25,6 +25,8 @@ class cmGeneratedFileStream; class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator { public: + enum LinkType {VirtualFolder, LinkToFolder, LinkToFile }; + cmExtraEclipseCDT4Generator(); static cmExternalMakefileProjectGenerator* New() { @@ -88,7 +90,7 @@ class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator static void AppendLinkedResource (cmGeneratedFileStream& fout, const std::string& name, const std::string& path, - bool isVirtualFolder = false); + LinkType linkType); bool AppendOutLinkedResource(cmGeneratedFileStream& fout, const std::string& defname, From 173fb485f076089bca2aa4a7c9e2631e8c94a0b0 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 20 Oct 2011 00:01:04 -0400 Subject: [PATCH 353/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 80902d52bbe..a4c90e9687f 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 19) +SET(KWSYS_DATE_STAMP_DAY 20) From f0d66ab40aee3af3d201201e7b1275783ffbab36 Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 20 Oct 2011 18:48:26 -0400 Subject: [PATCH 354/539] VS11: Fix comment generated at the top of *.sln files With "Visual Studio 2011" the launcher does not recognize the version of the *.sln files. With "Visual Studio 11" it does. --- Source/cmGlobalVisualStudio11Generator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index a70427ada53..97308bb3637 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -32,7 +32,7 @@ void cmGlobalVisualStudio11Generator::AddPlatformDefinitions(cmMakefile* mf) void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) { fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; - fout << "# Visual Studio 2011\n"; + fout << "# Visual Studio 11\n"; } //---------------------------------------------------------------------------- From 5a94d099ddbd8f3d4b850957faa8c11f619c6f18 Mon Sep 17 00:00:00 2001 From: Johan Bjork Date: Mon, 17 Oct 2011 13:47:19 +0200 Subject: [PATCH 355/539] Xcode: Avoid spewing the environment on every script run (#12522) This is the prefered way to get rid of the 'setenv XXX' output, instead of stripping it in the cmakexbuild wrapper. --- Source/cmGlobalXCodeGenerator.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 09265ae0e33..32eaef837e2 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1328,6 +1328,8 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ "); buildphase->AddAttribute("shellScript", this->CreateString(makecmd.c_str())); + buildphase->AddAttribute("showEnvVarsInLog", + this->CreateString("0")); } //---------------------------------------------------------------------------- @@ -2065,6 +2067,9 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) shellBuildPhase->AddAttribute("shellScript", this->CreateString( "# shell script goes here\nexit 0")); + shellBuildPhase->AddAttribute("showEnvVarsInLog", + this->CreateString("0")); + cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXAggregateTarget); target->SetComment(cmtarget.GetName()); From b9e9ad57fa9914d5b3c34a39a5d00d77051a1614 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 21 Oct 2011 00:01:04 -0400 Subject: [PATCH 356/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index a4c90e9687f..cfec8a67678 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 20) +SET(KWSYS_DATE_STAMP_DAY 21) From af772893b856b50697f18c9bb7b1a0fb326cf715 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 22 Oct 2011 00:01:21 -0400 Subject: [PATCH 357/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index cfec8a67678..216edc99008 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 21) +SET(KWSYS_DATE_STAMP_DAY 22) From 2f309cba455d0a946e935f66a53561ba64717faf Mon Sep 17 00:00:00 2001 From: David Cole Date: Sat, 22 Oct 2011 10:38:16 -0400 Subject: [PATCH 358/539] CTest: Add COVERAGE_EXTRA_FLAGS cache variable (#12490) COVERAGE_EXTRA_FLAGS is a space separated value of extra flags that will be passed to gcov when ctest's coverage handler invokes gcov to do coverage analysis. Map to CoverageExtraFlags in the CTest ini file. Use default value of "-l" to match the coverage handler's earlier behavior from ctest 2.8.4 and earlier. The fix for related issue #11717 had added a " -p" which was the cause of both #12415 and #12490. Here, we revert that change to the default value, so -p is no longer there by default. The people that care to add -p may do so in their own build trees by appending " -p" to the new cache variable COVERAGE_EXTRA_FLAGS. --- Modules/CTest.cmake | 3 +++ Modules/DartConfiguration.tcl.in | 5 ++++- Source/CTest/cmCTestCoverageHandler.cxx | 9 +++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index c261eb385e8..ec9dbeb7913 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -189,6 +189,8 @@ IF(BUILD_TESTING) FIND_PROGRAM(COVERAGE_COMMAND gcov DOC "Path to the coverage program that CTest uses for performing coverage inspection" ) + SET(COVERAGE_EXTRA_FLAGS "-l" CACHE STRING + "Extra command line flags to pass to the coverage tool") # set the site name SITE_NAME(SITE) @@ -257,6 +259,7 @@ IF(BUILD_TESTING) BZRCOMMAND BZR_UPDATE_OPTIONS COVERAGE_COMMAND + COVERAGE_EXTRA_FLAGS CTEST_SUBMIT_RETRY_DELAY CTEST_SUBMIT_RETRY_COUNT CVSCOMMAND diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index caf0afe23c9..ad7f80517f6 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -59,14 +59,17 @@ UpdateType: @UPDATE_TYPE@ # Compiler info Compiler: @CMAKE_CXX_COMPILER@ -# Dynamic analysis and coverage +# Dynamic analysis (MemCheck) PurifyCommand: @PURIFYCOMMAND@ ValgrindCommand: @VALGRIND_COMMAND@ ValgrindCommandOptions: @VALGRIND_COMMAND_OPTIONS@ MemoryCheckCommand: @MEMORYCHECK_COMMAND@ MemoryCheckCommandOptions: @MEMORYCHECK_COMMAND_OPTIONS@ MemoryCheckSuppressionFile: @MEMORYCHECK_SUPPRESSIONS_FILE@ + +# Coverage CoverageCommand: @COVERAGE_COMMAND@ +CoverageExtraFlags: @COVERAGE_EXTRA_FLAGS@ # Cluster commands SlurmBatchCommand: @SLURM_SBATCH_COMMAND@ diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 005651f847e..0b1c9fef8e0 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -751,12 +751,15 @@ int cmCTestCoverageHandler::HandlePHPCoverage( } return static_cast(cont->TotalCoverage.size()); } + //---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleGCovCoverage( cmCTestCoverageHandlerContainer* cont) { std::string gcovCommand = this->CTest->GetCTestConfiguration("CoverageCommand"); + std::string gcovExtraFlags + = this->CTest->GetCTestConfiguration("CoverageExtraFlags"); // Style 1 std::string st1gcovOutputRex1 @@ -825,8 +828,10 @@ int cmCTestCoverageHandler::HandleGCovCoverage( // Call gcov to get coverage data for this *.gcda file: // std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); - std::string command = "\"" + gcovCommand + "\" -l -p -o \"" + fileDir - + "\" \"" + *it + "\""; + std::string command = "\"" + gcovCommand + "\" " + + gcovExtraFlags + " " + + "-o \"" + fileDir + "\" " + + "\"" + *it + "\""; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() << std::endl); From 56aa6ffae75dd2567d2041147774bb1a9a3a1bdf Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 22 Oct 2011 19:38:39 +0200 Subject: [PATCH 359/539] automoc:run moc on the header if the source file contains include "foo.moc" This fixes #12533. Before automoc did not check the header if the source file contained a statement, now it does. Additionally, moc is now only run on explicitely listed headers which contain a Q_OBJECT macro. Alex --- Source/cmQtAutomoc.cxx | 150 ++++++++++++++++----------------- Source/cmQtAutomoc.h | 3 + Tests/QtAutomoc/CMakeLists.txt | 2 +- Tests/QtAutomoc/foo.cpp | 26 ++++++ Tests/QtAutomoc/foo.h | 15 ++++ Tests/QtAutomoc/main.cpp | 4 + 6 files changed, 124 insertions(+), 76 deletions(-) create mode 100644 Tests/QtAutomoc/foo.cpp create mode 100644 Tests/QtAutomoc/foo.h diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index abda47e5d77..7e7f04fa3a5 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -377,9 +377,8 @@ bool cmQtAutomoc::RunAutomocQt4() // key = moc source filepath, value = moc output filepath std::map includedMocs; - // key = moc source filepath, value = moc output filename - std::map notIncludedMocs; - + // collect all headers which may need to be mocced + std::set headerFiles; std::vector sourceFiles; cmSystemTools::ExpandListArgument(this->Sources, sourceFiles); @@ -393,34 +392,22 @@ bool cmQtAutomoc::RunAutomocQt4() { std::cout << "AUTOMOC: Checking " << absFilename << std::endl; } - this->ParseCppFile(absFilename, includedMocs, notIncludedMocs); + this->ParseCppFile(absFilename, includedMocs, headerFiles); } - std::vector headerFiles; - cmSystemTools::ExpandListArgument(this->Headers, headerFiles); - for (std::vector::const_iterator it = headerFiles.begin(); - it != headerFiles.end(); + std::vector headerFilesVec; + cmSystemTools::ExpandListArgument(this->Headers, headerFilesVec); + for (std::vector::const_iterator it = headerFilesVec.begin(); + it != headerFilesVec.end(); ++it) { - const std::string &absFilename = *it; - if (this->Verbose) - { - std::cout << "AUTOMOC: Checking " << absFilename << std::endl; - } - if (includedMocs.find(absFilename) == includedMocs.end() - && notIncludedMocs.find(absFilename) == notIncludedMocs.end()) - { - // if this header is not getting processed yet and is explicitly - // mentioned for the automoc the moc is run unconditionally on the - // header and the resulting file is included in the _automoc.cpp file - // (unless there's a .cpp file later on that includes the moc from - // this header) - const std::string currentMoc = "moc_" + cmsys::SystemTools:: - GetFilenameWithoutLastExtension(absFilename) + ".cpp"; - notIncludedMocs[absFilename] = currentMoc; - } + headerFiles.insert(*it); } + // key = moc source filepath, value = moc output filename + std::map notIncludedMocs; + this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs); + // run moc on all the moc's that are #included in source files for(std::map::const_iterator it = includedMocs.begin(); @@ -487,7 +474,7 @@ bool cmQtAutomoc::RunAutomocQt4() void cmQtAutomoc::ParseCppFile(const std::string& absFilename, std::map& includedMocs, - std::map& notIncludedMocs) + std::set& absHeaders) { cmsys::RegularExpression mocIncludeRegExp( "[\n][ \t]*#[ \t]*include[ \t]+" @@ -520,52 +507,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; std::string::size_type matchOffset = 0; - if (!mocIncludeRegExp.find(contentsString.c_str())) - { - // no moc #include, look whether we need to create a moc from - // the .h nevertheless - const std::string basename = - cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); - for(std::list::const_iterator ext = headerExtensions.begin(); - ext != headerExtensions.end(); - ++ext) - { - const std::string headername = absPath + basename + (*ext); - if (cmsys::SystemTools::FileExists(headername.c_str()) - && includedMocs.find(headername) == includedMocs.end() - && notIncludedMocs.find(headername) == notIncludedMocs.end()) - { - const std::string currentMoc = "moc_" + basename + ".cpp"; - const std::string contents = this->ReadAll(headername); - if (qObjectRegExp.find(contents)) - { - //std::cout << "header contains Q_OBJECT macro"; - notIncludedMocs[headername] = currentMoc; - } - break; - } - } - for(std::list::const_iterator ext = headerExtensions.begin(); - ext != headerExtensions.end(); - ++ext) - { - const std::string privateHeaderName = absPath+basename+"_p"+(*ext); - if (cmsys::SystemTools::FileExists(privateHeaderName.c_str()) - && includedMocs.find(privateHeaderName) == includedMocs.end() - && notIncludedMocs.find(privateHeaderName) == notIncludedMocs.end()) - { - const std::string currentMoc = "moc_" + basename + "_p.cpp"; - const std::string contents = this->ReadAll(privateHeaderName); - if (qObjectRegExp.find(contents)) - { - //std::cout << "header contains Q_OBJECT macro"; - notIncludedMocs[privateHeaderName] = currentMoc; - } - break; - } - } - } - else + if (mocIncludeRegExp.find(contentsString.c_str())) { // for every moc include in the file do @@ -604,7 +546,6 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, { headerFound = true; includedMocs[sourceFilePath] = currentMoc; - notIncludedMocs.erase(sourceFilePath); break; } } @@ -628,7 +569,6 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, { headerFound = true; includedMocs[sourceFilePath] = currentMoc; - notIncludedMocs.erase(sourceFilePath); break; } } @@ -658,11 +598,71 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, else { includedMocs[absFilename] = currentMoc; - notIncludedMocs.erase(absFilename); } matchOffset += mocIncludeRegExp.end(); } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); } + + // search for header files and private header files we may need to moc: + const std::string basename = + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); + for(std::list::const_iterator ext = headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string headerName = absPath + basename + (*ext); + if (cmsys::SystemTools::FileExists(headerName.c_str())) + { + absHeaders.insert(headerName); + break; + } + } + for(std::list::const_iterator ext = headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string privateHeaderName = absPath+basename+"_p"+(*ext); + if (cmsys::SystemTools::FileExists(privateHeaderName.c_str())) + { + absHeaders.insert(privateHeaderName); + break; + } + } + +} + + +void cmQtAutomoc::ParseHeaders(const std::set& absHeaders, + const std::map& includedMocs, + std::map& notIncludedMocs) +{ + cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); + for(std::set::const_iterator hIt=absHeaders.begin(); + hIt!=absHeaders.end(); + ++hIt) + { + const std::string& headerName = *hIt; + + if (includedMocs.find(headerName) == includedMocs.end()) + { + if (this->Verbose) + { + std::cout << "AUTOMOC: Checking " << headerName << std::endl; + } + + const std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(headerName); + + const std::string currentMoc = "moc_" + basename + ".cpp"; + const std::string contents = this->ReadAll(headerName); + if (qObjectRegExp.find(contents)) + { + //std::cout << "header contains Q_OBJECT macro"; + notIncludedMocs[headerName] = currentMoc; + } + } + } + } diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index 4fd90416130..8fb790a9779 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -27,6 +27,9 @@ class cmQtAutomoc const std::string& mocFileName); void ParseCppFile(const std::string& absFilename, std::map& includedMocs, + std::set& absHeaders); + void ParseHeaders(const std::set& absHeaders, + const std::map& includedMocs, std::map& notIncludedMocs); void Init(); diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt index 4a5ff1099ba..01f6bead512 100644 --- a/Tests/QtAutomoc/CMakeLists.txt +++ b/Tests/QtAutomoc/CMakeLists.txt @@ -13,7 +13,7 @@ add_definitions(-DFOO) # create an executable and a library target, both requiring automoc: add_library(codeeditorLib STATIC codeeditor.cpp) -add_executable(foo main.cpp calwidget.cpp ) +add_executable(foo main.cpp calwidget.cpp foo.cpp) set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE) diff --git a/Tests/QtAutomoc/foo.cpp b/Tests/QtAutomoc/foo.cpp new file mode 100644 index 00000000000..a7a47838d61 --- /dev/null +++ b/Tests/QtAutomoc/foo.cpp @@ -0,0 +1,26 @@ +#include "foo.h" + +#include + +class FooFoo : public QObject +{ + Q_OBJECT + public: + FooFoo():QObject() {} + public slots: + int getValue() const { return 12; } +}; + +Foo::Foo() +:QObject() +{ +} + + +void Foo::doFoo() +{ + FooFoo ff; + printf("Hello automoc: %d\n", ff.getValue()); +} + +#include "foo.moc" diff --git a/Tests/QtAutomoc/foo.h b/Tests/QtAutomoc/foo.h new file mode 100644 index 00000000000..7323ff39605 --- /dev/null +++ b/Tests/QtAutomoc/foo.h @@ -0,0 +1,15 @@ +#ifndef FOO_H +#define FOO_H + +#include + +class Foo : public QObject +{ + Q_OBJECT + public: + Foo(); + public slots: + void doFoo(); +}; + +#endif diff --git a/Tests/QtAutomoc/main.cpp b/Tests/QtAutomoc/main.cpp index 7bf4a5d2074..b7cfb410ef3 100644 --- a/Tests/QtAutomoc/main.cpp +++ b/Tests/QtAutomoc/main.cpp @@ -42,6 +42,7 @@ #include "codeeditor.h" #include "calwidget.h" +#include "foo.h" int main(int argv, char **args) { @@ -54,5 +55,8 @@ int main(int argv, char **args) Window w; w.show(); + Foo foo; + foo.doFoo(); + return app.exec(); } From ea8ac9f5dc2eab7b263a18eee5db75aedd31e26a Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 22 Oct 2011 19:43:34 +0200 Subject: [PATCH 360/539] Add copyright notices Alex --- Source/cmQtAutomoc.cxx | 13 +++++++++++++ Source/cmQtAutomoc.h | 13 +++++++++++++ Tests/QtAutomoc/foo.cpp | 13 +++++++++++++ Tests/QtAutomoc/foo.h | 13 +++++++++++++ 4 files changed, 52 insertions(+) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 7e7f04fa3a5..edf1d57d0f5 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -1,3 +1,16 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index 8fb790a9779..c3550a42d33 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -1,3 +1,16 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + #ifndef cmQtAutomoc_h #define cmQtAutomoc_h diff --git a/Tests/QtAutomoc/foo.cpp b/Tests/QtAutomoc/foo.cpp index a7a47838d61..699ba094b26 100644 --- a/Tests/QtAutomoc/foo.cpp +++ b/Tests/QtAutomoc/foo.cpp @@ -1,3 +1,16 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + #include "foo.h" #include diff --git a/Tests/QtAutomoc/foo.h b/Tests/QtAutomoc/foo.h index 7323ff39605..32d4c8d8f9e 100644 --- a/Tests/QtAutomoc/foo.h +++ b/Tests/QtAutomoc/foo.h @@ -1,3 +1,16 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + #ifndef FOO_H #define FOO_H From 5e8e9ad68ca9e617ef5442236247a49e3b246a5d Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 22 Oct 2011 21:16:39 +0200 Subject: [PATCH 361/539] automoc: always run moc on the cpp file if there is a foo.moc included This makes automoc behaves as the documentation says. If there is a #include "foo.moc" in the source file, moc will be executed on foo.cpp. Before it was also executed on foo.cpp, but only if foo.cpp contained a Q_OBJECT macro, otherwise moc was executed on foo.h. This was confusing, and this change also shouldn't break anything, since the headers are moc'ed anyway if they contain a Q_OBJECT macro. Alex --- Source/cmQtAutomoc.cxx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index edf1d57d0f5..a839489a982 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -492,7 +492,6 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, cmsys::RegularExpression mocIncludeRegExp( "[\n][ \t]*#[ \t]*include[ \t]+" "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); - cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); std::list headerExtensions; headerExtensions.push_back(".h"); headerExtensions.push_back(".hpp"); @@ -536,17 +535,13 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, // the Q_OBJECT class declaration in a header file. // If the moc include is of the foo.moc style we need to look for // a Q_OBJECT macro in the current source file, if it contains the - // macro we generate the moc file from the source file, else from the - // header. + // macro we generate the moc file from the source file. // Q_OBJECT - if (moc_style || !qObjectRegExp.find(contentsString)) + if (moc_style) { - if (moc_style) - { - // basename should be the part of the moc filename used for - // finding the correct header, so we need to remove the moc_ part - basename = basename.substr(4); - } + // basename should be the part of the moc filename used for + // finding the correct header, so we need to remove the moc_ part + basename = basename.substr(4); bool headerFound = false; for(std::list::const_iterator ext = From a390d6cc891cebec8df01c37da3433e3abfc8a8b Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 23 Oct 2011 00:01:07 -0400 Subject: [PATCH 362/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 216edc99008..0294f5bee64 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 22) +SET(KWSYS_DATE_STAMP_DAY 23) From cef6bd94d76a24c5948fea0224a78217f34c0b23 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 23 Oct 2011 11:00:45 +0200 Subject: [PATCH 363/539] Eclipse: move code for generating links to projects into separate function Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 63 +++++++++++++++----------- Source/cmExtraEclipseCDT4Generator.h | 3 ++ 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 3f63646bb92..c1a810bba51 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -424,33 +424,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() if (this->SupportsVirtualFolders) { - // for each sub project create a linked resource to the source dir - // - only if it is an out-of-source build - this->AppendLinkedResource(fout, "[Subprojects]", - "virtual:/virtual", VirtualFolder); - - for (std::map >::const_iterator - it = this->GlobalGenerator->GetProjectMap().begin(); - it != this->GlobalGenerator->GetProjectMap().end(); - ++it) - { - std::string linkSourceDirectory = this->GetEclipsePath( - it->second[0]->GetMakefile()->GetStartDirectory()); - // a linked resource must not point to a parent directory of .project or - // .project itself - if ((this->HomeOutputDirectory != linkSourceDirectory) && - !cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(), - linkSourceDirectory.c_str())) - { - std::string linkName = "[Subprojects]/"; - linkName += it->first; - this->AppendLinkedResource(fout, linkName, - this->GetEclipsePath(linkSourceDirectory), - LinkToFolder - ); - this->SrcLinkedResources.push_back(it->first); - } - } + this->CreateLinksToSubprojects(fout); std::string linkName = "[Targets]"; this->AppendLinkedResource(fout, linkName, "virtual:/virtual", @@ -550,6 +524,41 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() fout << "\n"; } + +//---------------------------------------------------------------------------- +void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( + cmGeneratedFileStream& fout) +{ + // for each sub project create a linked resource to the source dir + // - only if it is an out-of-source build + this->AppendLinkedResource(fout, "[Subprojects]", + "virtual:/virtual", VirtualFolder); + + for (std::map >::const_iterator + it = this->GlobalGenerator->GetProjectMap().begin(); + it != this->GlobalGenerator->GetProjectMap().end(); + ++it) + { + std::string linkSourceDirectory = this->GetEclipsePath( + it->second[0]->GetMakefile()->GetStartDirectory()); + // a linked resource must not point to a parent directory of .project or + // .project itself + if ((this->HomeOutputDirectory != linkSourceDirectory) && + !cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(), + linkSourceDirectory.c_str())) + { + std::string linkName = "[Subprojects]/"; + linkName += it->first; + this->AppendLinkedResource(fout, linkName, + this->GetEclipsePath(linkSourceDirectory), + LinkToFolder + ); + this->SrcLinkedResources.push_back(it->first); + } + } +} + + //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::AppendIncludeDirectories( cmGeneratedFileStream& fout, diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index 2c7aa4398f8..5a1a4534192 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -103,6 +103,9 @@ class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar, cmMakefile* mf); + void CreateLinksToSubprojects(cmGeneratedFileStream& fout); + + std::vector SrcLinkedResources; std::vector OutLinkedResources; std::string HomeDirectory; From c3f30bdd63682b4ba7166e23b3b3dc38548aab07 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 23 Oct 2011 12:22:20 +0200 Subject: [PATCH 364/539] Eclipse: move code for generating links to targets into separate function Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 162 +++++++++++++------------ Source/cmExtraEclipseCDT4Generator.h | 2 +- 2 files changed, 84 insertions(+), 80 deletions(-) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index c1a810bba51..9fc9e169afa 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -426,85 +426,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() { this->CreateLinksToSubprojects(fout); - std::string linkName = "[Targets]"; - this->AppendLinkedResource(fout, linkName, "virtual:/virtual", - VirtualFolder); - - - for (std::vector::const_iterator - lgIt = this->GlobalGenerator->GetLocalGenerators().begin(); - lgIt != this->GlobalGenerator->GetLocalGenerators().end(); - ++lgIt) - { - cmMakefile* makefile = (*lgIt)->GetMakefile(); - const cmTargets& targets = makefile->GetTargets(); - - for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end();++ti) - { - std::string linkName2 = linkName; - linkName2 += "/"; - switch(ti->second.GetType()) - { - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - { - const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ? - "[exe] " : "[lib] "); - linkName2 += prefix; - linkName2 += ti->first; - this->AppendLinkedResource(fout, linkName2, "virtual:/virtual", - VirtualFolder); - std::vector sourceGroups = - makefile->GetSourceGroups(); - // get the files from the source lists then add them to the groups - cmTarget* tgt = const_cast(&ti->second); - std::vectorconst & files = tgt->GetSourceFiles(); - for(std::vector::const_iterator sfIt = files.begin(); - sfIt != files.end(); - sfIt++) - { - // Add the file to the list of sources. - std::string source = (*sfIt)->GetFullPath(); - cmSourceGroup& sourceGroup = - makefile->FindSourceGroup(source.c_str(), sourceGroups); - sourceGroup.AssignSource(*sfIt); - } - - - for(std::vector::iterator sgIt=sourceGroups.begin(); - sgIt != sourceGroups.end(); - ++sgIt) - { - std::string linkName3 = linkName2; - linkName3 += "/"; - linkName3 += sgIt->GetFullName(); - this->AppendLinkedResource(fout, linkName3, "virtual:/virtual", - VirtualFolder); - - std::vector sFiles = sgIt->GetSourceFiles(); - for(std::vector::const_iterator fileIt = - sFiles.begin(); - fileIt != sFiles.end(); - ++fileIt) - { - std::string linkName4 = linkName3; - linkName4 += "/"; - linkName4 += - cmSystemTools::GetFilenameName((*fileIt)->GetFullPath()); - this->AppendLinkedResource(fout, linkName4, - (*fileIt)->GetFullPath(), LinkToFile); - } - } - } - break; - // ignore all others: - default: - break; - } - } - } + this->CreateLinksForTargets(fout); } // I'm not sure this makes too much sense. There can be different @@ -525,6 +447,88 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() } +//---------------------------------------------------------------------------- +void cmExtraEclipseCDT4Generator::CreateLinksForTargets( + cmGeneratedFileStream& fout) +{ + std::string linkName = "[Targets]"; + this->AppendLinkedResource(fout, linkName, "virtual:/virtual",VirtualFolder); + + for (std::vector::const_iterator + lgIt = this->GlobalGenerator->GetLocalGenerators().begin(); + lgIt != this->GlobalGenerator->GetLocalGenerators().end(); + ++lgIt) + { + cmMakefile* makefile = (*lgIt)->GetMakefile(); + const cmTargets& targets = makefile->GetTargets(); + + for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end();++ti) + { + std::string linkName2 = linkName; + linkName2 += "/"; + switch(ti->second.GetType()) + { + case cmTarget::EXECUTABLE: + case cmTarget::STATIC_LIBRARY: + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: + { + const char* prefix = (ti->second.GetType()==cmTarget::EXECUTABLE ? + "[exe] " : "[lib] "); + linkName2 += prefix; + linkName2 += ti->first; + this->AppendLinkedResource(fout, linkName2, "virtual:/virtual", + VirtualFolder); + std::vector sourceGroups=makefile->GetSourceGroups(); + // get the files from the source lists then add them to the groups + cmTarget* tgt = const_cast(&ti->second); + std::vectorconst & files = tgt->GetSourceFiles(); + for(std::vector::const_iterator sfIt = files.begin(); + sfIt != files.end(); + sfIt++) + { + // Add the file to the list of sources. + std::string source = (*sfIt)->GetFullPath(); + cmSourceGroup& sourceGroup = + makefile->FindSourceGroup(source.c_str(), sourceGroups); + sourceGroup.AssignSource(*sfIt); + } + + for(std::vector::iterator sgIt = sourceGroups.begin(); + sgIt != sourceGroups.end(); + ++sgIt) + { + std::string linkName3 = linkName2; + linkName3 += "/"; + linkName3 += sgIt->GetFullName(); + this->AppendLinkedResource(fout, linkName3, "virtual:/virtual", + VirtualFolder); + + std::vector sFiles = sgIt->GetSourceFiles(); + for(std::vector::const_iterator fileIt = + sFiles.begin(); + fileIt != sFiles.end(); + ++fileIt) + { + std::string linkName4 = linkName3; + linkName4 += "/"; + linkName4 += + cmSystemTools::GetFilenameName((*fileIt)->GetFullPath()); + this->AppendLinkedResource(fout, linkName4, + (*fileIt)->GetFullPath(), LinkToFile); + } + } + } + break; + // ignore all others: + default: + break; + } + } + } +} + + //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( cmGeneratedFileStream& fout) diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index 5a1a4534192..ac2de16b5b8 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -104,7 +104,7 @@ class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator cmMakefile* mf); void CreateLinksToSubprojects(cmGeneratedFileStream& fout); - + void CreateLinksForTargets(cmGeneratedFileStream& fout); std::vector SrcLinkedResources; std::vector OutLinkedResources; From 117f2b8257d92328b32cb90ced3d85d88815130b Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 23 Oct 2011 12:25:33 +0200 Subject: [PATCH 365/539] Eclipse: add Build and Clean targets to targets With this commit the virtual folder for the targets now have "Build" and "Clean" targets associated to them, so you can build and clean per-target now in the project explorer. Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 33 ++++++++++++++++++++++++-- Source/cmExtraEclipseCDT4Generator.h | 3 ++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 9fc9e169afa..a847666b745 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -888,6 +888,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); const std::string makeArgs = mf->GetSafeDefinition( "CMAKE_ECLIPSE_MAKE_ARGUMENTS"); + const std::string cmake = mf->GetRequiredDefinition("CMAKE_COMMAND"); + cmGlobalGenerator* generator = const_cast(this->GlobalGenerator); @@ -976,6 +978,25 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const std::string fastTarget = ti->first; fastTarget += "/fast"; this->AppendTarget(fout, fastTarget, make, makeArgs, subdir, prefix); + + // Add Build and Clean targets in the virtual folder of targets: + if (this->SupportsVirtualFolders) + { + std::string virtDir = "[Targets]/"; + virtDir += prefix; + virtDir += ti->first; + this->AppendTarget(fout, "Build", make, makeArgs, virtDir, "", + ti->first.c_str()); + + std::string cleanArgs = "-E chdir \""; + cleanArgs += makefile->GetCurrentOutputDirectory(); + cleanArgs += "\" \""; + cleanArgs += cmake; + cleanArgs += "\" -P \""; + cleanArgs += (*it)->GetTargetDirectory(ti->second); + cleanArgs += "/cmake_clean.cmake\""; + this->AppendTarget(fout, "Clean", cmake, cleanArgs, virtDir, "", ""); + } } break; // ignore these: @@ -1160,9 +1181,17 @@ void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout, const std::string& make, const std::string& makeArgs, const std::string& path, - const char* prefix) + const char* prefix, + const char* makeTarget + ) { std::string targetXml = cmExtraEclipseCDT4Generator::EscapeForXML(target); + std::string makeTargetXml = targetXml; + if (makeTarget != NULL) + { + makeTargetXml = cmExtraEclipseCDT4Generator::EscapeForXML(makeTarget); + } + cmExtraEclipseCDT4Generator::EscapeForXML(target); std::string pathXml = cmExtraEclipseCDT4Generator::EscapeForXML(path); fout << "\n" "" << makeArgs << "\n" - "" << targetXml << "\n" + "" << makeTargetXml << "\n" "true\n" "false\n" "\n" diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index ac2de16b5b8..61302e73449 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -75,7 +75,8 @@ class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator const std::string& make, const std::string& makeArguments, const std::string& path, - const char* prefix = ""); + const char* prefix = "", + const char* makeTarget = NULL); static void AppendScannerProfile (cmGeneratedFileStream& fout, const std::string& profileID, bool openActionEnabled, From 70de8bd5ae95936b8187e1af707e2d0111c74329 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 23 Oct 2011 14:33:25 +0200 Subject: [PATCH 366/539] Eclipse: detect number of CPUs, set CMAKE_ECLIPSE_MAKE_ARGUMENTS accordigly Using the new module ProcessorCount.cmake now the number of CPUs is detected, and if it is bigger than 1, make -jX is set accordingly. Alex --- Modules/CMakeFindEclipseCDT4.cmake | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index cf0984e1ad5..f7a6e29f0fb 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -54,8 +54,20 @@ ENDFUNCTION() _FIND_ECLIPSE_VERSION() +# Try to find out how many CPUs we have and set the -j argument for make accordingly +SET(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "") + +INCLUDE(ProcessorCount) +PROCESSORCOUNT(_CMAKE_ECLIPSE_PROCESSOR_COUNT) + +# Only set -j if we are under UNIX and if the make-tool used actually has "make" in the name +# (we may also get here in the future e.g. for ninja) +IF("${_CMAKE_ECLIPSE_PROCESSOR_COUNT}" GREATER 1 AND UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make) + SET(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "-j${_CMAKE_ECLIPSE_PROCESSOR_COUNT}") +ENDIF() + # This variable is used by the Eclipse generator and appended to the make invocation commands. -SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j to get parallel builds") +SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "${_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j to get parallel builds") # This variable is used by the Eclipse generator in out-of-source builds only. SET(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR") From 66bd543b9b0b09d38697f2c321dda7e4aeb6916d Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 23 Oct 2011 14:58:52 +0200 Subject: [PATCH 367/539] Eclipse: fix #12417, don't create wrong src pathentries Actually the Eclipse generator now does not create any CDT_SOURCE pathentries anymore, since I was not able to find out what they are good for, not even by asking on the cdt-dev mailing list. So, at least the warning from eclipse about bad pathentries are gone this way, and I didn't see anything which was not working anymore. Let's see whether we can find out what they are good for. Alex --- Source/cmExtraEclipseCDT4Generator.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index a847666b745..785e85a6105 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -695,6 +695,18 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const // - make it type 'src' // - and exclude it from type 'out' std::string excludeFromOut; +/* I don't know what the pathentry kind="src" are good for, e.g. autocompletion + * works also without them. Done wrong, the indexer complains, see #12417 + * and #12213. + * The CDT documentation is very terse on that: + * "CDT_SOURCE: Entry kind constant describing a path entry identifying a + * folder containing source code to be compiled." + * Also on the cdt-dev list didn't bring any information: + * http://web.archiveorange.com/archive/v/B4NlJDNIpYoOS1SbxFNy + * So I'm disabling them for now, hoping that somebody will report if something + * is not workging anymore. + * Alex */ +#ifdef DO_CREATE_SRC_PATH_ENTRIES for (std::vector::const_iterator it = this->SrcLinkedResources.begin(); it != this->SrcLinkedResources.end(); @@ -711,6 +723,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const excludeFromOut += this->EscapeForXML(*it) + "/|"; } } +#endif excludeFromOut += "**/CMakeFiles/"; fout << "\n"; From d3d7e45df205bd22d6fbeaba853354b097034719 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Thu, 13 Oct 2011 19:51:18 +0200 Subject: [PATCH 368/539] Remove trailing white-spaces. --- Source/CPack/cmCPackNSISGenerator.h | 12 +- Source/CPack/cpack.cxx | 10 +- Source/CTest/cmCTestSubmitHandler.h | 24 ++-- Source/CursesDialog/ccmake.cxx | 34 ++--- Source/CursesDialog/cmCursesMainForm.cxx | 132 ++++++++++---------- Source/cmCommandArgumentLexer.cxx | 100 +++++++-------- Source/cmDependsJavaLexer.cxx | 56 ++++----- Source/cmDocumentation.cxx | 152 +++++++++++------------ Source/cmDocumentationFormatter.h | 10 +- Source/cmExprLexer.cxx | 62 ++++----- Source/cmGlobalKdevelopGenerator.h | 20 +-- Source/cmGlobalVisualStudio7Generator.h | 30 ++--- Source/cmLocalGenerator.h | 48 +++---- Source/cmLocalUnixMakefileGenerator3.h | 46 +++---- Source/cmMakefile.h | 144 ++++++++++----------- Source/ctest.cxx | 6 +- 16 files changed, 443 insertions(+), 443 deletions(-) diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index 6ad103f11a9..dde1bbb89d2 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -46,10 +46,10 @@ class cmCPackNSISGenerator : public cmCPackGenerator virtual bool SupportsComponentInstallation() const; - /// Produce a string that contains the NSIS code to describe a - /// particular component. Any added macros will be emitted via + /// Produce a string that contains the NSIS code to describe a + /// particular component. Any added macros will be emitted via /// macrosOut. - std::string + std::string CreateComponentDescription(cmCPackComponent *component, cmOStringStream& macrosOut); @@ -65,14 +65,14 @@ class cmCPackNSISGenerator : public cmCPackGenerator (cmCPackComponent *component, std::set& visited); - /// Produce a string that contains the NSIS code to describe a + /// Produce a string that contains the NSIS code to describe a /// particular component group, including its components. Any /// added macros will be emitted via macrosOut. - std::string + std::string CreateComponentGroupDescription(cmCPackComponentGroup *group, cmOStringStream& macrosOut); - /// Translations any newlines found in the string into \r\n, so that the + /// Translations any newlines found in the string into \r\n, so that the /// resulting string can be used within NSIS. static std::string TranslateNewlines(std::string str); }; diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 9163af811f9..71ba1182a88 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -244,7 +244,7 @@ int main (int argc, char *argv[]) // find out which system cpack is running on, so it can setup the search // paths, so FIND_XXX() commands can be used in scripts cminst.AddCMakePaths(); - std::string systemFile = + std::string systemFile = globalMF->GetModulesFile("CMakeDetermineSystem.cmake"); if (!globalMF->ReadListFile(0, systemFile.c_str())) { @@ -253,7 +253,7 @@ int main (int argc, char *argv[]) return 1; } - systemFile = + systemFile = globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake"); if (!globalMF->ReadListFile(0, systemFile.c_str())) { @@ -264,7 +264,7 @@ int main (int argc, char *argv[]) if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) ) { - cpackConfigFile = + cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile.c_str()); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Read CPack configuration file: " << cpackConfigFile.c_str() @@ -410,7 +410,7 @@ int main (int argc, char *argv[]) cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: " << projName << std::endl); - const char* projVersion = + const char* projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION"); if ( !projVersion ) { @@ -423,7 +423,7 @@ int main (int argc, char *argv[]) cmOStringStream ostr; ostr << projVersionMajor << "." << projVersionMinor << "." << projVersionPatch; - mf->AddDefinition("CPACK_PACKAGE_VERSION", + mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str()); } diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index e7755b138bd..9cfd7df250b 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -18,7 +18,7 @@ * \brief Helper class for CTest * * Submit testing results - * + * */ class cmCTestSubmitHandler : public cmCTestGenericHandler { @@ -47,32 +47,32 @@ class cmCTestSubmitHandler : public cmCTestGenericHandler /** * Submit file using various ways */ - bool SubmitUsingFTP(const cmStdString& localprefix, + bool SubmitUsingFTP(const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url); - bool SubmitUsingHTTP(const cmStdString& localprefix, + bool SubmitUsingHTTP(const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url); bool SubmitUsingSCP(const cmStdString& scp_command, - const cmStdString& localprefix, + const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url); - bool SubmitUsingCP( const cmStdString& localprefix, + bool SubmitUsingCP( const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url); bool TriggerUsingHTTP(const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url); - bool SubmitUsingXMLRPC(const cmStdString& localprefix, + bool SubmitUsingXMLRPC(const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url); void ParseResponse(std::vector); diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 9ede7a6cc10..7cf107118ae 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -76,11 +76,11 @@ void onsig(int) if (cmCursesForm::CurrentForm) { endwin(); - initscr(); /* Initialization */ - noecho(); /* Echo off */ - cbreak(); /* nl- or cr not needed */ - keypad(stdscr,TRUE); /* Use key symbols as - KEY_DOWN*/ + initscr(); /* Initialization */ + noecho(); /* Echo off */ + cbreak(); /* nl- or cr not needed */ + keypad(stdscr,TRUE); /* Use key symbols as + KEY_DOWN*/ refresh(); int x,y; getmaxyx(stdscr, y, x); @@ -89,7 +89,7 @@ void onsig(int) } signal(SIGWINCH, onsig); } - + } void CMakeErrorHandler(const char* message, const char* title, bool&, void* clientData) @@ -121,8 +121,8 @@ int main(int argc, char** argv) doc.SetSection("Compatibility Commands",compatCommands); doc.SetSeeAlsoList(cmDocumentationSeeAlso); return doc.PrintRequestedDocumentation(std::cout)? 0:1; - } - + } + bool debug = false; unsigned int i; int j; @@ -156,22 +156,22 @@ int main(int argc, char** argv) cmCursesForm::DebugStart(); } - initscr(); /* Initialization */ - noecho(); /* Echo off */ - cbreak(); /* nl- or cr not needed */ - keypad(stdscr,TRUE); /* Use key symbols as - KEY_DOWN*/ + initscr(); /* Initialization */ + noecho(); /* Echo off */ + cbreak(); /* nl- or cr not needed */ + keypad(stdscr,TRUE); /* Use key symbols as + KEY_DOWN*/ signal(SIGWINCH, onsig); int x,y; getmaxyx(stdscr, y, x); - if ( x < cmCursesMainForm::MIN_WIDTH || + if ( x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT ) { endwin(); std::cerr << "Window is too small. A size of at least " - << cmCursesMainForm::MIN_WIDTH << " x " + << cmCursesMainForm::MIN_WIDTH << " x " << cmCursesMainForm::MIN_HEIGHT << " is required to run ccmake." << std::endl; return 1; @@ -201,7 +201,7 @@ int main(int argc, char** argv) myform->Render(1, 1, x, y); myform->HandleInput(); } - + // Need to clean-up better curses_clear(); touchwin(stdscr); @@ -210,7 +210,7 @@ int main(int argc, char** argv) cmCursesForm::CurrentForm = 0; std::cout << std::endl << std::endl; - + return 0; } diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index e1876b9024c..17fa0ffc16a 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -27,7 +27,7 @@ inline int ctrl(int z) { return (z&037); -} +} cmCursesMainForm::cmCursesMainForm(std::vector const& args, int initWidth) : @@ -80,7 +80,7 @@ cmCursesMainForm::~cmCursesMainForm() { delete this->CMakeInstance; this->CMakeInstance = 0; - } + } } // See if a cache entry is in the list of entries in the ui. @@ -99,7 +99,7 @@ bool cmCursesMainForm::LookForCacheEntry(const char* key) return true; } } - + return false; } @@ -114,7 +114,7 @@ void cmCursesMainForm::InitializeUI() // Count non-internal and non-static entries int count=0; - for(cmCacheManager::CacheIterator i = + for(cmCacheManager::CacheIterator i = this->CMakeInstance->GetCacheManager()->NewIterator(); !i.IsAtEnd(); i.Next()) { @@ -142,12 +142,12 @@ void cmCursesMainForm::InitializeUI() // Create the composites. // First add entries which are new - for(cmCacheManager::CacheIterator i = + for(cmCacheManager::CacheIterator i = this->CMakeInstance->GetCacheManager()->NewIterator(); !i.IsAtEnd(); i.Next()) { const char* key = i.GetName(); - if ( i.GetType() == cmCacheManager::INTERNAL || + if ( i.GetType() == cmCacheManager::INTERNAL || i.GetType() == cmCacheManager::STATIC || i.GetType() == cmCacheManager::UNINITIALIZED ) { @@ -164,12 +164,12 @@ void cmCursesMainForm::InitializeUI() } // then add entries which are old - for(cmCacheManager::CacheIterator i = + for(cmCacheManager::CacheIterator i = this->CMakeInstance->GetCacheManager()->NewIterator(); !i.IsAtEnd(); i.Next()) { const char* key = i.GetName(); - if ( i.GetType() == cmCacheManager::INTERNAL || + if ( i.GetType() == cmCacheManager::INTERNAL || i.GetType() == cmCacheManager::STATIC || i.GetType() == cmCacheManager::UNINITIALIZED ) { @@ -184,7 +184,7 @@ void cmCursesMainForm::InitializeUI() } } } - + // Clean old entries if (this->Entries) { @@ -197,7 +197,7 @@ void cmCursesMainForm::InitializeUI() } delete this->Entries; this->Entries = newEntries; - + // Compute fields from composites this->RePost(); } @@ -224,7 +224,7 @@ void cmCursesMainForm::RePost() std::vector::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - cmCacheManager::CacheIterator mit = + cmCacheManager::CacheIterator mit = this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); if (mit.IsAtEnd() || (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) @@ -253,7 +253,7 @@ void cmCursesMainForm::RePost() std::vector::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - cmCacheManager::CacheIterator mit = + cmCacheManager::CacheIterator mit = this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); if (mit.IsAtEnd() || (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) @@ -301,7 +301,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) } // Wrong window size - if ( width < cmCursesMainForm::MIN_WIDTH || + if ( width < cmCursesMainForm::MIN_WIDTH || width < this->InitialWidth || height < cmCursesMainForm::MIN_HEIGHT ) { @@ -322,7 +322,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) std::vector::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - cmCacheManager::CacheIterator mit = + cmCacheManager::CacheIterator mit = this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); if (mit.IsAtEnd() || (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) @@ -372,7 +372,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) this->UpdateStatusBar(); this->PrintKeys(); - touchwin(stdscr); + touchwin(stdscr); refresh(); } @@ -380,7 +380,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) { int x,y; getmaxyx(stdscr, y, x); - if ( x < cmCursesMainForm::MIN_WIDTH || + if ( x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth || y < cmCursesMainForm::MIN_HEIGHT ) { @@ -399,7 +399,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) { cw->PrintKeys(); } - + // { // } // else @@ -409,18 +409,18 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) char thirdLine[512]=""; if (process) { - sprintf(firstLine, - " "); - sprintf(secondLine, - " "); - sprintf(thirdLine, - " "); + sprintf(firstLine, + " "); + sprintf(secondLine, + " "); + sprintf(thirdLine, + " "); } else { if (this->OkToGenerate) { - sprintf(firstLine, + sprintf(firstLine, "Press [c] to configure Press [g] to generate and exit"); } else @@ -435,8 +435,8 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) { sprintf(thirdLine, "Press [t] to toggle advanced mode (Currently Off)"); } - - sprintf(secondLine, + + sprintf(secondLine, "Press [h] for help Press [q] to quit without generating"); } @@ -463,7 +463,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) // } pos_form_cursor(this->Form); - + } // Print the key of the current entry and the CMake version @@ -473,7 +473,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) int x,y; getmaxyx(stdscr, y, x); // If window size is too small, display error and return - if ( x < cmCursesMainForm::MIN_WIDTH || + if ( x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth || y < cmCursesMainForm::MIN_HEIGHT ) { @@ -482,10 +482,10 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) char fmt[] = "Window is too small. A size of at least %dx%d is required."; printw(fmt, (cmCursesMainForm::MIN_WIDTH < this->InitialWidth ? - this->InitialWidth : cmCursesMainForm::MIN_WIDTH), + this->InitialWidth : cmCursesMainForm::MIN_WIDTH), cmCursesMainForm::MIN_HEIGHT); - touchwin(stdscr); - wrefresh(stdscr); + touchwin(stdscr); + wrefresh(stdscr); return; } @@ -502,10 +502,10 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) if ( lbl ) { curField = lbl->GetValue(); - + // Get the help string of the current entry // and add it to the help string - cmCacheManager::CacheIterator it = + cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager()->GetCacheIterator(curField); if (!it.IsAtEnd()) { @@ -549,9 +549,9 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) if ( curFieldLen < width ) { strcpy(bar, curField); - for(i=curFieldLen; i < width; ++i) - { - bar[i] = ' '; + for(i=curFieldLen; i < width; ++i) + { + bar[i] = ' '; } } else @@ -578,14 +578,14 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) else { strcpy(bar+curFieldLen+2, help); - for(i=curFieldLen+helpLen+2; i < width; ++i) - { - bar[i] = ' '; + for(i=curFieldLen+helpLen+2; i < width; ++i) + { + bar[i] = ' '; } } } } - + bar[width] = '\0'; @@ -605,7 +605,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) attron(A_STANDOUT); char format[] = "%s"; printw(format, bar); - attroff(A_STANDOUT); + attroff(A_STANDOUT); curses_move(y-4,0); printw(version); pos_form_cursor(this->Form); @@ -631,7 +631,7 @@ void cmCursesMainForm::UpdateProgress(const char *msg, float prog, void* vp) cm->UpdateStatusBar(cmsg); cm->PrintKeys(1); curses_move(1,1); - touchwin(stdscr); + touchwin(stdscr); refresh(); } @@ -643,7 +643,7 @@ int cmCursesMainForm::Configure(int noconfigure) curses_move(1,1); this->UpdateStatusBar("Configuring, please wait..."); this->PrintKeys(1); - touchwin(stdscr); + touchwin(stdscr); refresh(); this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, this); @@ -652,7 +652,7 @@ int cmCursesMainForm::Configure(int noconfigure) this->CMakeInstance->GetCacheManager()->SaveCache( this->CMakeInstance->GetHomeOutputDirectory()); this->LoadCache(0); - + // Get rid of previous errors this->Errors = std::vector(); @@ -674,8 +674,8 @@ int cmCursesMainForm::Configure(int noconfigure) } this->CMakeInstance->SetProgressCallback(0, 0); - keypad(stdscr,TRUE); /* Use key symbols as - KEY_DOWN*/ + keypad(stdscr,TRUE); /* Use key symbols as + KEY_DOWN*/ if( retVal != 0 || !this->Errors.empty()) { @@ -705,10 +705,10 @@ int cmCursesMainForm::Configure(int noconfigure) CurrentForm = this; this->Render(1,1,xx,yy); } - + this->InitializeUI(); this->Render(1, 1, xi, yi); - + return 0; } @@ -731,8 +731,8 @@ int cmCursesMainForm::Generate() int retVal = this->CMakeInstance->Generate(); this->CMakeInstance->SetProgressCallback(0, 0); - keypad(stdscr,TRUE); /* Use key symbols as - KEY_DOWN*/ + keypad(stdscr,TRUE); /* Use key symbols as + KEY_DOWN*/ if( retVal != 0 || !this->Errors.empty()) { @@ -764,10 +764,10 @@ int cmCursesMainForm::Generate() CurrentForm = this; this->Render(1,1,xx,yy); } - + this->InitializeUI(); this->Render(1, 1, xi, yi); - + return 0; } @@ -798,11 +798,11 @@ void cmCursesMainForm::RemoveEntry(const char* value) // copy from the list box to the cache manager void cmCursesMainForm::FillCacheManagerFromUI() -{ +{ size_t size = this->Entries->size(); for(size_t i=0; i < size; i++) { - cmCacheManager::CacheIterator it = + cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager()->GetCacheIterator( (*this->Entries)[i]->Key.c_str()); if (!it.IsAtEnd()) @@ -872,14 +872,14 @@ void cmCursesMainForm::HandleInput() this->PrintKeys(1); curses_move(y-5,static_cast(searchstr.size())); //curses_move(1,1); - touchwin(stdscr); + touchwin(stdscr); refresh(); } int key = getch(); getmaxyx(stdscr, y, x); // If window too small, handle 'q' only - if ( x < cmCursesMainForm::MIN_WIDTH || + if ( x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT ) { // quit @@ -948,7 +948,7 @@ void cmCursesMainForm::HandleInput() } if ((!currentWidget || !widgetHandled) && !this->SearchMode) { - // If the current widget does not want to handle input, + // If the current widget does not want to handle input, // we handle it. sprintf(debugMessage, "Main form handling input, key: %d", key); cmCursesForm::LogMessage(debugMessage); @@ -1028,7 +1028,7 @@ void cmCursesMainForm::HandleInput() this->Fields[findex-2])); const char* curField = lbl->GetValue(); const char* helpString=0; - cmCacheManager::CacheIterator it = + cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager()->GetCacheIterator(curField); if (!it.IsAtEnd()) { @@ -1052,7 +1052,7 @@ void cmCursesMainForm::HandleInput() CurrentForm = msgs; msgs->Render(1,1,x,y); msgs->HandleInput(); - CurrentForm = this; + CurrentForm = this; this->Render(1,1,x,y); set_current_field(this->Form, cur); } @@ -1137,7 +1137,7 @@ void cmCursesMainForm::HandleInput() // each entry consists of fields: label, isnew, value // therefore, the label field for the is findex-2 // (findex always corresponds to the value field) - cmCursesWidget* lbl + cmCursesWidget* lbl = reinterpret_cast( field_userptr(this->Fields[findex-2])); if ( lbl ) @@ -1177,15 +1177,15 @@ void cmCursesMainForm::HandleInput() } } - touchwin(stdscr); - wrefresh(stdscr); + touchwin(stdscr); + wrefresh(stdscr); } } int cmCursesMainForm::LoadCache(const char *) { - int r = this->CMakeInstance->LoadCache(); + int r = this->CMakeInstance->LoadCache(); if(r < 0) { return r; @@ -1194,7 +1194,7 @@ int cmCursesMainForm::LoadCache(const char *) this->CMakeInstance->PreLoadCMakeFiles(); return r; } - + void cmCursesMainForm::JumpToCacheEntry(const char* astr) { std::string str; @@ -1247,7 +1247,7 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr) /* char buffer[1024]; sprintf(buffer, "Line: %d != %d / %d\n", findex, idx, this->NumberOfVisibleEntries); - touchwin(stdscr); + touchwin(stdscr); refresh(); this->UpdateStatusBar( buffer ); usleep(100000); @@ -1262,7 +1262,7 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr) } -const char* cmCursesMainForm::s_ConstHelpMessage = +const char* cmCursesMainForm::s_ConstHelpMessage = "CMake is used to configure and generate build files for software projects. " "The basic steps for configuring a project with ccmake are as follows:\n\n" "1. Run ccmake in the directory where you want the object and executable files to be placed (build directory). If the source directory is not the same as this build directory, you have to specify it as an argument on the command line.\n\n" diff --git a/Source/cmCommandArgumentLexer.cxx b/Source/cmCommandArgumentLexer.cxx index 13679453d44..89819cedd9c 100644 --- a/Source/cmCommandArgumentLexer.cxx +++ b/Source/cmCommandArgumentLexer.cxx @@ -47,7 +47,7 @@ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -64,7 +64,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; @@ -189,7 +189,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) - + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ @@ -251,7 +251,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -832,25 +832,25 @@ YY_RULE_SETUP case 2: YY_RULE_SETUP #line 72 "cmCommandArgumentLexer.in.l" -{ +{ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); - return cal_NCURLY; -} + yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); + return cal_NCURLY; +} case 3: YY_RULE_SETUP #line 78 "cmCommandArgumentLexer.in.l" -{ +{ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); - return cal_ATNAME; -} + yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); + return cal_ATNAME; +} case 4: YY_RULE_SETUP #line 84 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->DCURLYVariable; return cal_DCURLY; } @@ -859,7 +859,7 @@ YY_RULE_SETUP #line 91 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->RCURLYVariable; return cal_RCURLY; } @@ -868,17 +868,17 @@ YY_RULE_SETUP #line 98 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->ATVariable; return cal_AT; } case 7: YY_RULE_SETUP #line 105 "cmCommandArgumentLexer.in.l" -{ +{ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); - return cal_NAME; + yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + return cal_NAME; } case 8: YY_RULE_SETUP @@ -888,40 +888,40 @@ YY_RULE_SETUP { return cal_ERROR; } - return cal_SYMBOL; + return cal_SYMBOL; } case 9: /* rule 9 can match eol */ YY_RULE_SETUP #line 119 "cmCommandArgumentLexer.in.l" -{ +{ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); - return cal_SYMBOL; + yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + return cal_SYMBOL; } case 10: YY_RULE_SETUP #line 125 "cmCommandArgumentLexer.in.l" { - //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->DOLLARVariable; - return cal_DOLLAR; + return cal_DOLLAR; } case 11: YY_RULE_SETUP #line 131 "cmCommandArgumentLexer.in.l" { - //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->LCURLYVariable; - return cal_LCURLY; + return cal_LCURLY; } case 12: YY_RULE_SETUP #line 137 "cmCommandArgumentLexer.in.l" { - //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->BSLASHVariable; - return cal_BSLASH; + return cal_BSLASH; } case 13: YY_RULE_SETUP @@ -1419,7 +1419,7 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner) YY_BUFFER_STATE cmCommandArgument_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) cmCommandArgument_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yy_create_buffer()" ); @@ -1463,7 +1463,7 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner) #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ - + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a cmCommandArgument_yyrestart() or at EOF. @@ -1489,7 +1489,7 @@ extern int isatty (int ); } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + errno = oerrno; } @@ -1595,9 +1595,9 @@ static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner) , yyscanner); if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yyensure_buffer_stack()" ); - + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_top = 0; return; @@ -1626,12 +1626,12 @@ static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner) * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -1667,7 +1667,7 @@ YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char * base, yy_size_t size */ YY_BUFFER_STATE cmCommandArgument_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) { - + return cmCommandArgument_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); } @@ -1684,7 +1684,7 @@ YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char * yybytes, int _ char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) cmCommandArgument_yyalloc(n ,yyscanner ); @@ -1752,10 +1752,10 @@ YY_EXTRA_TYPE cmCommandArgument_yyget_extra (yyscan_t yyscanner) int cmCommandArgument_yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yylineno; } @@ -1765,10 +1765,10 @@ int cmCommandArgument_yyget_lineno (yyscan_t yyscanner) int cmCommandArgument_yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yycolumn; } @@ -1829,8 +1829,8 @@ void cmCommandArgument_yyset_lineno (int line_number , yyscan_t yyscanner) /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmCommandArgument_yyset_lineno called with no buffer" , yyscanner); - + yy_fatal_error( "cmCommandArgument_yyset_lineno called with no buffer" , yyscanner); + yylineno = line_number; } @@ -1844,8 +1844,8 @@ void cmCommandArgument_yyset_column (int column_no , yyscan_t yyscanner) /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmCommandArgument_yyset_column called with no buffer" , yyscanner); - + yy_fatal_error( "cmCommandArgument_yyset_column called with no buffer" , yyscanner); + yycolumn = column_no; } @@ -1928,20 +1928,20 @@ int cmCommandArgument_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* p errno = EINVAL; return 1; } - + *ptr_yy_globals = (yyscan_t) cmCommandArgument_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - + if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; } - + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - + cmCommandArgument_yyset_extra (yy_user_defined, *ptr_yy_globals); - + return yy_init_globals ( *ptr_yy_globals ); } diff --git a/Source/cmDependsJavaLexer.cxx b/Source/cmDependsJavaLexer.cxx index d7149c7edce..e4487f8beef 100644 --- a/Source/cmDependsJavaLexer.cxx +++ b/Source/cmDependsJavaLexer.cxx @@ -48,7 +48,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ @@ -169,7 +169,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) - + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ @@ -234,7 +234,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -1428,9 +1428,9 @@ YY_RULE_SETUP case 107: YY_RULE_SETUP #line 200 "cmDependsJavaLexer.in.l" -{ - yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); - return jp_NAME; +{ + yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + return jp_NAME; } case 108: /* rule 108 can match eol */ @@ -1447,11 +1447,11 @@ YY_RULE_SETUP case 110: YY_RULE_SETUP #line 207 "cmDependsJavaLexer.in.l" -{ - std::cerr << "Unknown character: " << yytext[0] - << " (" << (int)yytext[0] << ")" << std::endl; - yyextra->Error("Unknown character"); - return jp_ERROR; +{ + std::cerr << "Unknown character: " << yytext[0] + << " (" << (int)yytext[0] << ")" << std::endl; + yyextra->Error("Unknown character"); + return jp_ERROR; } case 111: YY_RULE_SETUP @@ -1933,7 +1933,7 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner) YY_BUFFER_STATE cmDependsJava_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) cmDependsJava_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yy_create_buffer()" ); @@ -1977,7 +1977,7 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner) #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ - + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a cmDependsJava_yyrestart() or at EOF. @@ -2003,7 +2003,7 @@ extern int isatty (int ); } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + errno = oerrno; } @@ -2107,9 +2107,9 @@ static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner) yyg->yy_buffer_stack = (struct yy_buffer_state**)cmDependsJava_yyalloc (nuto_alloc * sizeof(struct yy_buffer_state*) , yyscanner); - + memset(yyg->yy_buffer_stack, 0, nuto_alloc * sizeof(struct yy_buffer_state*)); - + yyg->yy_buffer_stack_max = nuto_alloc; yyg->yy_buffer_stack_top = 0; return; @@ -2136,12 +2136,12 @@ static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner) * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -2177,7 +2177,7 @@ YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char * base, yy_size_t size , yy */ YY_BUFFER_STATE cmDependsJava_yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner) { - + return cmDependsJava_yy_scan_bytes(yy_str,strlen(yy_str) ,yyscanner); } @@ -2194,7 +2194,7 @@ YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char * bytes, int len , y char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = len + 2; buf = (char *) cmDependsJava_yyalloc(n ,yyscanner ); @@ -2262,10 +2262,10 @@ YY_EXTRA_TYPE cmDependsJava_yyget_extra (yyscan_t yyscanner) int cmDependsJava_yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yylineno; } @@ -2275,10 +2275,10 @@ int cmDependsJava_yyget_lineno (yyscan_t yyscanner) int cmDependsJava_yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yycolumn; } @@ -2339,8 +2339,8 @@ void cmDependsJava_yyset_lineno (int line_number , yyscan_t yyscanner) /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmDependsJava_yyset_lineno called with no buffer" , yyscanner); - + yy_fatal_error( "cmDependsJava_yyset_lineno called with no buffer" , yyscanner); + yylineno = line_number; } @@ -2354,8 +2354,8 @@ void cmDependsJava_yyset_column (int column_no , yyscan_t yyscanner) /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmDependsJava_yyset_column called with no buffer" , yyscanner); - + yy_fatal_error( "cmDependsJava_yyset_column called with no buffer" , yyscanner); + yycolumn = column_no; } diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index bfe11c194fa..5e56b29e6af 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -235,24 +235,24 @@ cmDocumentation::cmDocumentation() sec = new cmDocumentationSection("See Also","SEE ALSO"); sec->Append(cmDocumentationStandardSeeAlso); - this->AllSections["Standard See Also"] = sec; + this->AllSections["Standard See Also"] = sec; sec = new cmDocumentationSection("Options","OPTIONS"); sec->Append(cmDocumentationStandardOptions); - this->AllSections["Options"] = sec; + this->AllSections["Options"] = sec; sec = new cmDocumentationSection("Properties","PROPERTIES"); sec->Append(cmPropertiesDocumentationDescription); - this->AllSections["Properties Description"] = sec; + this->AllSections["Properties Description"] = sec; sec = new cmDocumentationSection("Generators","GENERATORS"); sec->Append(cmDocumentationGeneratorsHeader); - this->AllSections["Generators"] = sec; + this->AllSections["Generators"] = sec; sec = new cmDocumentationSection("Compatibility Commands", "COMPATIBILITY COMMANDS"); sec->Append(cmCompatCommandsDocumentationDescription); - this->AllSections["Compatibility Commands"] = sec; + this->AllSections["Compatibility Commands"] = sec; this->PropertySections.push_back("Properties of Global Scope"); @@ -279,7 +279,7 @@ cmDocumentation::~cmDocumentation() { delete [] *i; } - for(std::map::iterator i = + for(std::map::iterator i = this->AllSections.begin(); i != this->AllSections.end(); ++i) { @@ -314,7 +314,7 @@ bool cmDocumentation::PrintCopyright(std::ostream& os) //---------------------------------------------------------------------------- bool cmDocumentation::PrintVersion(std::ostream& os) { - os << this->GetNameString() << " version " + os << this->GetNameString() << " version " << cmVersion::GetCMakeVersion() << "\n"; return true; } @@ -331,7 +331,7 @@ void cmDocumentation::AddSectionToPrint(const char *section) //---------------------------------------------------------------------------- void cmDocumentation::ClearSections() { - this->PrintSections.erase(this->PrintSections.begin(), + this->PrintSections.erase(this->PrintSections.begin(), this->PrintSections.end()); this->ModulesFound.clear(); } @@ -359,7 +359,7 @@ void cmDocumentation::AddDocumentIntroToPrint(const char* intro[2]) bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os, const char* docname) { - if ((this->CurrentFormatter->GetForm() != HTMLForm) + if ((this->CurrentFormatter->GetForm() != HTMLForm) && (this->CurrentFormatter->GetForm() != DocbookForm) && (this->CurrentFormatter->GetForm() != ManForm)) { @@ -394,8 +394,8 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os, this->PrintDocumentationList(os,"Commands"); this->PrintDocumentationList(os,"Compatibility Commands"); return true; - case cmDocumentation::ModuleList: - // find the modules first, print the custom module docs only if + case cmDocumentation::ModuleList: + // find the modules first, print the custom module docs only if // any custom modules have been found actually, Alex this->CreateCustomModulesSection(); this->CreateModulesSection(); @@ -406,43 +406,43 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os, } this->PrintDocumentationList(os,"Modules"); return true; - case cmDocumentation::PropertyList: + case cmDocumentation::PropertyList: this->PrintDocumentationList(os,"Properties Description"); - for (std::vector::iterator i = + for (std::vector::iterator i = this->PropertySections.begin(); i != this->PropertySections.end(); ++i) { this->PrintDocumentationList(os,i->c_str()); } return true; - case cmDocumentation::VariableList: - for (std::vector::iterator i = + case cmDocumentation::VariableList: + for (std::vector::iterator i = this->VariableSections.begin(); i != this->VariableSections.end(); ++i) { this->PrintDocumentationList(os,i->c_str()); } return true; - case cmDocumentation::Full: + case cmDocumentation::Full: return this->PrintDocumentationFull(os); - case cmDocumentation::Modules: + case cmDocumentation::Modules: return this->PrintDocumentationModules(os); - case cmDocumentation::CustomModules: + case cmDocumentation::CustomModules: return this->PrintDocumentationCustomModules(os); - case cmDocumentation::Policies: + case cmDocumentation::Policies: return this->PrintDocumentationPolicies(os); - case cmDocumentation::Properties: + case cmDocumentation::Properties: return this->PrintDocumentationProperties(os); - case cmDocumentation::Variables: + case cmDocumentation::Variables: return this->PrintDocumentationVariables(os); - case cmDocumentation::Commands: + case cmDocumentation::Commands: return this->PrintDocumentationCurrentCommands(os); - case cmDocumentation::CompatCommands: + case cmDocumentation::CompatCommands: return this->PrintDocumentationCompatCommands(os); - case cmDocumentation::Copyright: + case cmDocumentation::Copyright: return this->PrintCopyright(os); - case cmDocumentation::Version: + case cmDocumentation::Version: return true; default: return false; } @@ -451,7 +451,7 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os, //---------------------------------------------------------------------------- bool cmDocumentation::CreateModulesSection() { - cmDocumentationSection *sec = + cmDocumentationSection *sec = new cmDocumentationSection("Standard CMake Modules", "MODULES"); this->AllSections["Modules"] = sec; std::string cmakeModules = this->CMakeRoot; @@ -485,7 +485,7 @@ bool cmDocumentation::CreateCustomModulesSection() { if (!sectionHasHeader) { - cmDocumentationSection *sec = + cmDocumentationSection *sec = new cmDocumentationSection("Custom CMake Modules","CUSTOM MODULES"); this->AllSections["Custom CMake Modules"] = sec; sec->Append(cmDocumentationCustomModulesHeader[0]); @@ -502,10 +502,10 @@ bool cmDocumentation::CreateCustomModulesSection() //---------------------------------------------------------------------------- void cmDocumentation -::CreateModuleDocsForDir(cmsys::Directory& dir, +::CreateModuleDocsForDir(cmsys::Directory& dir, cmDocumentationSection &moduleSection) { - // sort the files alphabetically, so the docs for one module are easier + // sort the files alphabetically, so the docs for one module are easier // to find than if they are in random order std::vector sortedFiles; for(unsigned int i = 0; i < dir.GetNumberOfFiles(); ++i) @@ -530,7 +530,7 @@ ::CreateModuleDocsForDir(cmsys::Directory& dir, std::string path = dir.GetPath(); path += "/"; path += (*fname); - this->CreateSingleModule(path.c_str(), moduleName.c_str(), + this->CreateSingleModule(path.c_str(), moduleName.c_str(), moduleSection); } } @@ -539,7 +539,7 @@ ::CreateModuleDocsForDir(cmsys::Directory& dir, } //---------------------------------------------------------------------------- -bool cmDocumentation::CreateSingleModule(const char* fname, +bool cmDocumentation::CreateSingleModule(const char* fname, const char* moduleName, cmDocumentationSection &moduleSection) { @@ -548,7 +548,7 @@ bool cmDocumentation::CreateSingleModule(const char* fname, { std::cerr << "Internal error: can not open module." << fname << std::endl; return false; - } + } std::string line; std::string text; std::string brief; @@ -561,14 +561,14 @@ bool cmDocumentation::CreateSingleModule(const char* fname, // blank line if(line.size() <= 2) { - text += "\n"; + text += "\n"; newParagraph = true; } - else if(line[2] == '-') + else if(line[2] == '-') { brief = line.c_str()+4; } - else + else { // two spaces if(line[1] == ' ' && line[2] == ' ') @@ -630,11 +630,11 @@ bool cmDocumentation::CreateSingleModule(const char* fname, bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) { bool result = true; - + // Loop over requested documentation types. - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->RequestedHelpItems.begin(); - i != this->RequestedHelpItems.end(); + i != this->RequestedHelpItems.end(); ++i) { this->SetForm(i->HelpForm); @@ -660,13 +660,13 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) docname = cmSystemTools::GetFilenameWithoutLastExtension(i->Filename); } } - + // Print this documentation type to the stream. if(!this->PrintDocumentation(i->HelpType, *s, docname.c_str()) || !*s) { result = false; } - + // Close the file if we wrote one. if(fout) { @@ -876,8 +876,8 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, GET_OPT_ARGUMENT(help.Filename); help.HelpForm = cmDocumentation::UsageForm; } - else if((strcmp(argv[i], "--version") == 0) || - (strcmp(argv[i], "-version") == 0) || + else if((strcmp(argv[i], "--version") == 0) || + (strcmp(argv[i], "-version") == 0) || (strcmp(argv[i], "/V") == 0)) { help.HelpType = cmDocumentation::Version; @@ -904,14 +904,14 @@ void cmDocumentation::Print(Form f, std::ostream& os) //---------------------------------------------------------------------------- void cmDocumentation::Print(std::ostream& os) { - // if the formatter supports it, print a master index for + // if the formatter supports it, print a master index for // all sections this->CurrentFormatter->PrintIndex(os, this->PrintSections); for(unsigned int i=0; i < this->PrintSections.size(); ++i) { std::string name = this->PrintSections[i]-> GetName((this->CurrentFormatter->GetForm())); - this->CurrentFormatter->PrintSection(os,*this->PrintSections[i], + this->CurrentFormatter->PrintSection(os,*this->PrintSections[i], name.c_str()); } } @@ -929,7 +929,7 @@ void cmDocumentation::SetDocName(const char *docname) } //---------------------------------------------------------------------------- -void cmDocumentation::SetSection(const char *name, +void cmDocumentation::SetSection(const char *name, cmDocumentationSection *section) { if (this->AllSections.find(name) != this->AllSections.end()) @@ -940,22 +940,22 @@ void cmDocumentation::SetSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::SetSection(const char *name, +void cmDocumentation::SetSection(const char *name, std::vector &docs) { - cmDocumentationSection *sec = - new cmDocumentationSection(name, + cmDocumentationSection *sec = + new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str()); sec->Append(docs); this->SetSection(name,sec); } //---------------------------------------------------------------------------- -void cmDocumentation::SetSection(const char *name, +void cmDocumentation::SetSection(const char *name, const char *docs[][3]) { - cmDocumentationSection *sec = - new cmDocumentationSection(name, + cmDocumentationSection *sec = + new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str()); sec->Append(docs); this->SetSection(name,sec); @@ -965,15 +965,15 @@ void cmDocumentation::SetSection(const char *name, void cmDocumentation ::SetSections(std::map §ions) { - for (std::map::const_iterator + for (std::map::const_iterator it = sections.begin(); it != sections.end(); ++it) { this->SetSection(it->first.c_str(),it->second); - } + } } //---------------------------------------------------------------------------- -void cmDocumentation::PrependSection(const char *name, +void cmDocumentation::PrependSection(const char *name, const char *docs[][3]) { cmDocumentationSection *sec = 0; @@ -991,7 +991,7 @@ void cmDocumentation::PrependSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::PrependSection(const char *name, +void cmDocumentation::PrependSection(const char *name, std::vector &docs) { cmDocumentationSection *sec = 0; @@ -1009,7 +1009,7 @@ void cmDocumentation::PrependSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::AppendSection(const char *name, +void cmDocumentation::AppendSection(const char *name, const char *docs[][3]) { cmDocumentationSection *sec = 0; @@ -1027,7 +1027,7 @@ void cmDocumentation::AppendSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::AppendSection(const char *name, +void cmDocumentation::AppendSection(const char *name, std::vector &docs) { cmDocumentationSection *sec = 0; @@ -1045,7 +1045,7 @@ void cmDocumentation::AppendSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::AppendSection(const char *name, +void cmDocumentation::AppendSection(const char *name, cmDocumentationEntry &docs) { @@ -1055,7 +1055,7 @@ void cmDocumentation::AppendSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::PrependSection(const char *name, +void cmDocumentation::PrependSection(const char *name, cmDocumentationEntry &docs) { @@ -1067,7 +1067,7 @@ void cmDocumentation::PrependSection(const char *name, //---------------------------------------------------------------------------- void cmDocumentation::SetSeeAlsoList(const char *data[][3]) { - cmDocumentationSection *sec = + cmDocumentationSection *sec = new cmDocumentationSection("See Also", "SEE ALSO"); this->AllSections["See Also"] = sec; this->SeeAlsoString = ".B "; @@ -1075,7 +1075,7 @@ void cmDocumentation::SetSeeAlsoList(const char *data[][3]) while(data[i][1]) { this->SeeAlsoString += data[i][1]; - this->SeeAlsoString += data[i+1][1]? "(1), ":"(1)"; + this->SeeAlsoString += data[i+1][1]? "(1), ":"(1)"; ++i; } sec->Append(0,this->SeeAlsoString.c_str(),0); @@ -1096,9 +1096,9 @@ bool cmDocumentation::PrintDocumentationGeneric(std::ostream& os, os << "Required argument missing.\n"; return false; } - const std::vector &entries = + const std::vector &entries = this->AllSections[section]->GetEntries(); - for(std::vector::const_iterator ei = + for(std::vector::const_iterator ei = entries.begin(); ei != entries.end(); ++ei) { @@ -1138,7 +1138,7 @@ bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os) os << "Argument --help-module needs a module name.\n"; return false; } - + std::string moduleName; // find the module std::vector dirs; @@ -1172,10 +1172,10 @@ bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os) if(!moduleName.empty()) { - cmDocumentationSection *sec = + cmDocumentationSection *sec = new cmDocumentationSection("Standard CMake Modules", "MODULES"); this->AllSections["Modules"] = sec; - if (this->CreateSingleModule(moduleName.c_str(), + if (this->CreateSingleModule(moduleName.c_str(), this->CurrentArgument.c_str(), *this->AllSections["Modules"])) { @@ -1204,7 +1204,7 @@ bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os) bool cmDocumentation::PrintDocumentationSingleProperty(std::ostream& os) { bool done = false; - for (std::vector::iterator i = + for (std::vector::iterator i = this->PropertySections.begin(); !done && i != this->PropertySections.end(); ++i) { @@ -1241,7 +1241,7 @@ bool cmDocumentation::PrintDocumentationSinglePolicy(std::ostream& os) bool cmDocumentation::PrintDocumentationSingleVariable(std::ostream& os) { bool done = false; - for (std::vector::iterator i = + for (std::vector::iterator i = this->VariableSections.begin(); !done && i != this->VariableSections.end(); ++i) { @@ -1270,9 +1270,9 @@ bool cmDocumentation::PrintDocumentationList(std::ostream& os, return false; } - const std::vector &entries = + const std::vector &entries = this->AllSections[section]->GetEntries(); - for(std::vector::const_iterator ei = + for(std::vector::const_iterator ei = entries.begin(); ei != entries.end(); ++ei) { @@ -1364,7 +1364,7 @@ bool cmDocumentation::PrintDocumentationProperties(std::ostream& os) this->ClearSections(); this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Properties)); this->AddSectionToPrint("Properties Description"); - for (std::vector::iterator i = + for (std::vector::iterator i = this->PropertySections.begin(); i != this->PropertySections.end(); ++i) { @@ -1383,7 +1383,7 @@ bool cmDocumentation::PrintDocumentationVariables(std::ostream& os) { this->ClearSections(); this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Variables)); - for (std::vector::iterator i = + for (std::vector::iterator i = this->VariableSections.begin(); i != this->VariableSections.end(); ++i) { @@ -1464,10 +1464,10 @@ void cmDocumentation::CreateFullDocumentation() this->AddSectionToPrint("Commands"); emitted.insert("Commands"); - + this->AddSectionToPrint("Properties Description"); emitted.insert("Properties Description"); - for (std::vector::iterator i = + for (std::vector::iterator i = this->PropertySections.begin(); i != this->PropertySections.end(); ++i) { @@ -1481,7 +1481,7 @@ void cmDocumentation::CreateFullDocumentation() emitted.insert("Author"); // add any sections not yet written out, or to be written out - for (std::map::iterator i = + for (std::map::iterator i = this->AllSections.begin(); i != this->AllSections.end(); ++i) { @@ -1579,6 +1579,6 @@ const char* cmDocumentation::GetDefaultDocName(Type ht) const //---------------------------------------------------------------------------- bool cmDocumentation::IsOption(const char* arg) const { - return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) || + return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) || (strcmp(arg, "/?") == 0)); } diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h index f8cdc96c43a..1dcff1a23d0 100644 --- a/Source/cmDocumentationFormatter.h +++ b/Source/cmDocumentationFormatter.h @@ -16,7 +16,7 @@ /** This is just a helper class to make it build with MSVC 6.0. Actually the enums and internal classes could directly go into -cmDocumentation, but then MSVC6 complains in RequestedHelpItem that +cmDocumentation, but then MSVC6 complains in RequestedHelpItem that cmDocumentation is an undefined type and so it doesn't know the enums. Moving the enums to a class which is then already completely parsed helps against this. */ @@ -24,10 +24,10 @@ class cmDocumentationEnums { public: /** Types of help provided. */ - enum Type + enum Type { None, Usage, Single, SingleModule, SingleProperty, SingleVariable, List, ModuleList, PropertyList, VariableList, - Full, Properties, Variables, Modules, CustomModules, Commands, + Full, Properties, Variables, Modules, CustomModules, Commands, CompatCommands, Copyright, Version, Policies, SinglePolicy }; /** Forms of documentation output. */ @@ -36,7 +36,7 @@ class cmDocumentationEnums class cmDocumentationSection; -/** Base class for printing the documentation in the various supported +/** Base class for printing the documentation in the various supported formats. */ class cmDocumentationFormatter { @@ -46,7 +46,7 @@ class cmDocumentationFormatter void PrintFormatted(std::ostream& os, const char* text); virtual cmDocumentationEnums::Form GetForm() const = 0; - + virtual void PrintHeader(const char* /*docname*/, const char* /*appname*/, std::ostream& /*os*/) {} diff --git a/Source/cmExprLexer.cxx b/Source/cmExprLexer.cxx index a642f553582..cd0530db75d 100644 --- a/Source/cmExprLexer.cxx +++ b/Source/cmExprLexer.cxx @@ -44,7 +44,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ @@ -165,7 +165,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) - + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ @@ -231,7 +231,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -787,7 +787,7 @@ YY_DECL case 1: YY_RULE_SETUP #line 88 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ yylvalp->Number = atoi(yytext); return exp_NUMBER; } +{ yylvalp->Number = atoi(yytext); return exp_NUMBER; } case 2: YY_RULE_SETUP #line 90 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" @@ -795,43 +795,43 @@ YY_RULE_SETUP case 3: YY_RULE_SETUP #line 91 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_MINUS; } +{ return exp_MINUS; } case 4: YY_RULE_SETUP #line 92 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_TIMES; } +{ return exp_TIMES; } case 5: YY_RULE_SETUP #line 93 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_DIVIDE; } +{ return exp_DIVIDE; } case 6: YY_RULE_SETUP #line 94 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_MOD; } +{ return exp_MOD; } case 7: YY_RULE_SETUP #line 95 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_OR; } +{ return exp_OR; } case 8: YY_RULE_SETUP #line 96 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_AND; } +{ return exp_AND; } case 9: YY_RULE_SETUP #line 97 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_XOR; } +{ return exp_XOR; } case 10: YY_RULE_SETUP #line 98 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_NOT; } +{ return exp_NOT; } case 11: YY_RULE_SETUP #line 99 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_SHIFTLEFT; } +{ return exp_SHIFTLEFT; } case 12: YY_RULE_SETUP #line 100 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_SHIFTRIGHT; } +{ return exp_SHIFTRIGHT; } case 13: YY_RULE_SETUP #line 101 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" @@ -1319,7 +1319,7 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner) YY_BUFFER_STATE cmExpr_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) cmExpr_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_create_buffer()" ); @@ -1363,7 +1363,7 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner) #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ - + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a cmExpr_yyrestart() or at EOF. @@ -1389,7 +1389,7 @@ extern int isatty (int ); } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + errno = oerrno; } @@ -1493,9 +1493,9 @@ static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner) yyg->yy_buffer_stack = (struct yy_buffer_state**)cmExpr_yyalloc (nuto_alloc * sizeof(struct yy_buffer_state*) , yyscanner); - + memset(yyg->yy_buffer_stack, 0, nuto_alloc * sizeof(struct yy_buffer_state*)); - + yyg->yy_buffer_stack_max = nuto_alloc; yyg->yy_buffer_stack_top = 0; return; @@ -1522,12 +1522,12 @@ static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner) * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -1564,7 +1564,7 @@ YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t */ YY_BUFFER_STATE cmExpr_yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner) { - + return cmExpr_yy_scan_bytes(yy_str,strlen(yy_str) ,yyscanner); } @@ -1581,7 +1581,7 @@ YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char * bytes, int len , yyscan_t char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = len + 2; buf = (char *) cmExpr_yyalloc(n ,yyscanner ); @@ -1649,10 +1649,10 @@ YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner) int cmExpr_yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yylineno; } @@ -1662,10 +1662,10 @@ int cmExpr_yyget_lineno (yyscan_t yyscanner) int cmExpr_yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yycolumn; } @@ -1726,8 +1726,8 @@ void cmExpr_yyset_lineno (int line_number , yyscan_t yyscanner) /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmExpr_yyset_lineno called with no buffer" , yyscanner); - + yy_fatal_error( "cmExpr_yyset_lineno called with no buffer" , yyscanner); + yylineno = line_number; } @@ -1741,8 +1741,8 @@ void cmExpr_yyset_column (int column_no , yyscan_t yyscanner) /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmExpr_yyset_column called with no buffer" , yyscanner); - + yy_fatal_error( "cmExpr_yyset_column called with no buffer" , yyscanner); + yycolumn = column_no; } diff --git a/Source/cmGlobalKdevelopGenerator.h b/Source/cmGlobalKdevelopGenerator.h index 63f7c1f9400..f2769435d13 100644 --- a/Source/cmGlobalKdevelopGenerator.h +++ b/Source/cmGlobalKdevelopGenerator.h @@ -36,19 +36,19 @@ class cmGlobalKdevelopGenerator : public cmExternalMakefileProjectGenerator virtual const char* GetName() const { return cmGlobalKdevelopGenerator::GetActualName();} static const char* GetActualName() { return "KDevelop3";} - static cmExternalMakefileProjectGenerator* New() + static cmExternalMakefileProjectGenerator* New() { return new cmGlobalKdevelopGenerator; } /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry, + virtual void GetDocumentation(cmDocumentationEntry& entry, const char* fullName) const; virtual void Generate(); private: /*** Create the foo.kdevelop.filelist file, return false if it doesn't - succeed. If the file already exists the contents will be merged. + succeed. If the file already exists the contents will be merged. */ bool CreateFilelistFile(const std::vector& lgs, - const std::string& outputDir, + const std::string& outputDir, const std::string& projectDirIn, const std::string& projectname, std::string& cmakeFilePattern, @@ -62,13 +62,13 @@ class cmGlobalKdevelopGenerator : public cmExternalMakefileProjectGenerator listfiles used by this CMakeLists.txt */ void CreateProjectFile(const std::string& outputDir, const std::string& projectDir, - const std::string& projectname, - const std::string& executable, + const std::string& projectname, + const std::string& executable, const std::string& cmakeFilePattern, const std::string& fileToOpen); /*** Reads the old foo.kdevelop line by line and only replaces the - "important" lines + "important" lines */ void MergeProjectFiles(const std::string& outputDir, const std::string& projectDir, @@ -78,10 +78,10 @@ class cmGlobalKdevelopGenerator : public cmExternalMakefileProjectGenerator const std::string& fileToOpen, const std::string& sessionFilename); ///! Creates a new foo.kdevelop and a new foo.kdevses file - void CreateNewProjectFile(const std::string& outputDir, - const std::string& projectDir, + void CreateNewProjectFile(const std::string& outputDir, + const std::string& projectDir, const std::string& filename, - const std::string& executable, + const std::string& executable, const std::string& cmakeFilePattern, const std::string& fileToOpen, const std::string& sessionFilename); diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 7f19d8301ca..ebb6fe41790 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -26,9 +26,9 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator { public: cmGlobalVisualStudio7Generator(); - static cmGlobalGenerator* New() { + static cmGlobalGenerator* New() { return new cmGlobalVisualStudio7Generator; } - + ///! Get the name for the generator. virtual const char* GetName() const { return cmGlobalVisualStudio7Generator::GetActualName();} @@ -39,12 +39,12 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry) const; - + /** * Try to determine system infomation such as shared library - * extension, pthreads, byte order etc. + * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vectorconst& languages, + virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *, bool optional); /** @@ -52,8 +52,8 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator * loaded commands, not as part of the usual build process. */ virtual std::string GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char* additionalOptions, + const char *projectName, + const char* additionalOptions, const char *targetName, const char* config, bool ignoreErrors, @@ -62,7 +62,7 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator /** * Generate the all required files for building this project/tree. This * basically creates a series of LocalGenerators for each directory and - * requests that they Generate. + * requests that they Generate. */ virtual void Generate(); @@ -75,7 +75,7 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator * Get the list of configurations */ std::vector *GetConfigurations(); - + ///! Create a GUID or get an existing one. void CreateGUID(const char* name); std::string GetGUID(const char* name); @@ -97,13 +97,13 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator virtual const char* GetIDEVersion() { return "7.0"; } static cmIDEFlagTable const* GetExtraFlagTableVS7(); - virtual void OutputSLNFile(cmLocalGenerator* root, + virtual void OutputSLNFile(cmLocalGenerator* root, std::vector& generators); virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector& generators); - virtual void WriteProject(std::ostream& fout, + virtual void WriteProject(std::ostream& fout, const char* name, const char* path, cmTarget &t); - virtual void WriteProjectDepends(std::ostream& fout, + virtual void WriteProjectDepends(std::ostream& fout, const char* name, const char* path, cmTarget &t); virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, @@ -124,11 +124,11 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator std::ostream& fout, cmLocalGenerator* root, OrderedTargetDependSet const& projectTargets); - + void GenerateConfigurations(cmMakefile* mf); - virtual void WriteExternalProject(std::ostream& fout, - const char* name, + virtual void WriteExternalProject(std::ostream& fout, + const char* name, const char* path, const std::set& dependencies); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index c0fe8860fcd..3d96f01baff 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -33,19 +33,19 @@ class cmLocalGenerator public: cmLocalGenerator(); virtual ~cmLocalGenerator(); - + /** - * Generate the makefile for this directory. + * Generate the makefile for this directory. */ virtual void Generate() {} /** * Process the CMakeLists files for this directory to fill in the - * Makefile ivar + * Makefile ivar */ virtual void Configure(); - /** + /** * Calls TraceVSDependencies() on all targets of this generator. */ virtual void TraceDependencies(); @@ -75,11 +75,11 @@ class cmLocalGenerator ///! Get the makefile for this generator cmMakefile *GetMakefile() { return this->Makefile; }; - + ///! Get the makefile for this generator, const version const cmMakefile *GetMakefile() const { return this->Makefile; }; - + ///! Get the GlobalGenerator this is associated with cmGlobalGenerator *GetGlobalGenerator() { return this->GlobalGenerator; }; @@ -89,10 +89,10 @@ class cmLocalGenerator ///! Set the Global Generator, done on creation by the GlobalGenerator void SetGlobalGenerator(cmGlobalGenerator *gg); - /** + /** * Convert something to something else. This is a centralized coversion * routine used by the generators to handle relative paths and the like. - * The flags determine what is actually done. + * The flags determine what is actually done. * * relative: treat the argument as a directory and convert it to make it * relative or full or unchanged. If relative (HOME, START etc) then that @@ -117,7 +117,7 @@ class cmLocalGenerator * Get path for the specified relative root. */ const char* GetRelativeRootPath(RelativeRoot relroot); - + /** * Convert the given path to an output path that is optionally * relative based on the cache option CMAKE_USE_RELATIVE_PATHS. The @@ -126,14 +126,14 @@ class cmLocalGenerator */ std::string ConvertToOptionallyRelativeOutputPath(const char* remote); - ///! set/get the parent generator + ///! set/get the parent generator cmLocalGenerator* GetParent(){return this->Parent;} void SetParent(cmLocalGenerator* g) { this->Parent = g; g->AddChild(this); } ///! set/get the children void AddChild(cmLocalGenerator* g) { this->Children.push_back(g); } std::vector& GetChildren() { return this->Children; }; - + void AddArchitectureFlags(std::string& flags, cmTarget* target, const char *lang, const char* config); @@ -183,9 +183,9 @@ class cmLocalGenerator virtual std::string ConvertToIncludeReference(std::string const& path); /** Called from command-line hook to clear dependencies. */ - virtual void ClearDependencies(cmMakefile* /* mf */, + virtual void ClearDependencies(cmMakefile* /* mf */, bool /* verbose */) {} - + /** Called from command-line hook to update dependencies. */ virtual bool UpdateDependencies(const char* /* tgtInfo */, bool /*verbose*/, @@ -259,11 +259,11 @@ class cmLocalGenerator /** Return the directories into which object files will be put. * There maybe more than one for fat binary systems like OSX. */ - virtual void + virtual void GetTargetObjectFileDirectories(cmTarget* target, - std::vector& + std::vector& dirs); - + /** * Convert the given remote path to a relative path with respect to * the given local path. The local path must be given in component @@ -321,15 +321,15 @@ class cmLocalGenerator /** Fill out these strings for the given target. Libraries to link, * flags, and linkflags. */ - void GetTargetFlags(std::string& linkLibs, + void GetTargetFlags(std::string& linkLibs, std::string& flags, std::string& linkFlags, cmTarget&target); - + protected: ///! put all the libraries for a target on into the given stream virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink); - + // Expand rule variables in CMake of the type found in language rules void ExpandRuleVariables(std::string& string, const RuleVariables& replaceValues); @@ -341,13 +341,13 @@ class cmLocalGenerator void InsertRuleLauncher(std::string& s, cmTarget* target, const char* prop); - - /** Convert a target to a utility target for unsupported + + /** Convert a target to a utility target for unsupported * languages of a generator */ void AddBuildTargetRule(const char* llang, cmTarget& target); - ///! add a custom command to build a .o file that is part of a target - void AddCustomCommandToCreateObject(const char* ofname, - const char* lang, + ///! add a custom command to build a .o file that is part of a target + void AddCustomCommandToCreateObject(const char* ofname, + const char* lang, cmSourceFile& source, cmTarget& target); // Create Custom Targets and commands for unsupported languages diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 0994222642a..1fd1aa7ffda 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -38,21 +38,21 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator /** * Process the CMakeLists files for this directory to fill in the - * Makefile ivar + * Makefile ivar */ virtual void Configure(); /** - * Generate the makefile for this directory. + * Generate the makefile for this directory. */ virtual void Generate(); - + // this returns the relative path between the HomeOutputDirectory and this // local generators StartOutputDirectory const std::string &GetHomeRelativeOutputPath(); - // Write out a make rule + // Write out a make rule void WriteMakeRule(std::ostream& os, const char* comment, const char* target, @@ -60,7 +60,7 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator const std::vector& commands, bool symbolic, bool in_help = false); - + // write the main variables used by the makefiles void WriteMakeVariables(std::ostream& makefileStream); @@ -71,7 +71,7 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator */ void SetPassMakeflags(bool s){this->PassMakeflags = s;} bool GetPassMakeflags() { return this->PassMakeflags; } - + /** * Set the flag used to keep the make program silent. */ @@ -115,7 +115,7 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator void SetDefineWindowsNULL(bool v) {this->DefineWindowsNULL = v;} /** - * If set to true, cd dir && command is used to + * If set to true, cd dir && command is used to * run commands in a different directory. */ void SetUnixCD(bool v) {this->UnixCD = v;} @@ -168,8 +168,8 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator void WriteDivider(std::ostream& os); /** used to create a recursive make call */ - std::string GetRecursiveMakeCall(const char *makefile, const char* tgt); - + std::string GetRecursiveMakeCall(const char *makefile, const char* tgt); + // append flags to a string virtual void AppendFlags(std::string& flags, const char* newFlags); @@ -185,7 +185,7 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator virtual std::string GetTargetDirectory(cmTarget const& target) const; // create a command that cds to the start dir then runs the commands - void CreateCDCommand(std::vector& commands, + void CreateCDCommand(std::vector& commands, const char *targetDir, cmLocalGenerator::RelativeRoot returnDir); @@ -200,7 +200,7 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator /** Called from command-line hook to clear dependencies. */ virtual void ClearDependencies(cmMakefile* mf, bool verbose); - + /** write some extra rules such as make test etc */ void WriteSpecialTargetsTop(std::ostream& makefileStream); void WriteSpecialTargetsBottom(std::ostream& makefileStream); @@ -224,7 +224,7 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator // write the target rules for the local Makefile into the stream void WriteLocalAllRules(std::ostream& ruleFileStream); - + struct LocalObjectEntry { cmTarget* Target; @@ -238,7 +238,7 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator bool HasSourceExtension; bool HasPreprocessRule; bool HasAssembleRule; - LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false), + LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false), HasAssembleRule(false) {} }; std::map const& GetLocalObjectFiles() @@ -261,15 +261,15 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator void GetTargetObjectFileDirectories(cmTarget* target, std::vector& dirs); - // Fill the vector with the target names for the object files, - // preprocessed files and assembly files. Currently only used by the + // Fill the vector with the target names for the object files, + // preprocessed files and assembly files. Currently only used by the // Eclipse generator. void GetIndividualFileTargets(std::vector& targets); - + protected: void WriteLocalMakefile(); - - + + // write the target rules for the local Makefile into the stream void WriteLocalMakefileTargets(std::ostream& ruleFileStream, std::set &emitted); @@ -278,17 +278,17 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator void WriteDirectoryInformationFile(); - // write the depend info + // write the depend info void WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &tgt); - + // write the local help rule void WriteHelpRule(std::ostream& ruleFileStream); - + // this converts a file name that is relative to the StartOuputDirectory // into a full path std::string ConvertToFullPath(const std::string& localPath); - + void WriteConvenienceRule(std::ostream& ruleFileStream, const char* realTarget, const char* helpTarget); @@ -304,7 +304,7 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator void WriteObjectConvenienceRule(std::ostream& ruleFileStream, const char* comment, const char* output, LocalObjectInfo const& info); - + std::string GetObjectFileName(cmTarget& target, const cmSourceFile& source, std::string* nameWithoutTargetDir = 0, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 618f4f39122..c80d4cca61f 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -72,7 +72,7 @@ class cmMakefile /** Return whether compatibility features needed for a version of the cache or lower should be enabled. */ bool NeedCacheCompatibility(int major, int minor); - + /** * Construct an empty makefile. */ @@ -87,8 +87,8 @@ class cmMakefile /** * Read and parse a CMakeLists.txt file. */ - bool ReadListFile(const char* listfile, - const char* external= 0, + bool ReadListFile(const char* listfile, + const char* external= 0, std::string* fullPath= 0, bool noPolicyScope = true); @@ -121,21 +121,21 @@ class cmMakefile * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. */ - int TryCompile(const char *srcdir, const char *bindir, + int TryCompile(const char *srcdir, const char *bindir, const char *projectName, const char *targetName, bool fast, const std::vector *cmakeArgs, std::string *output); - + /** * Specify the makefile generator. This is platform/compiler * dependent, although the interface is through a generic * superclass. */ void SetLocalGenerator(cmLocalGenerator*); - + ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() + cmLocalGenerator* GetLocalGenerator() { return this->LocalGenerator;} /** @@ -153,15 +153,15 @@ class cmMakefile /** * Perform FinalPass, Library dependency analysis etc before output of the - * makefile. + * makefile. */ void ConfigureFinalPass(); - + /** * run the final pass on all commands. */ void FinalPass(); - + /** * Print the object state to std::cout. */ @@ -205,11 +205,11 @@ class cmMakefile cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type); cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name); - + /** * Add an executable to the build. */ - cmTarget* AddExecutable(const char *exename, + cmTarget* AddExecutable(const char *exename, const std::vector &srcs, bool excludeFromAll = false); @@ -237,7 +237,7 @@ class cmMakefile */ void AddLinkLibrary(const char*); void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type); - void AddLinkLibraryForTarget(const char *tgt, const char*, + void AddLinkLibraryForTarget(const char *tgt, const char*, cmTarget::LinkLibraryType type); void AddLinkDirectoryForTarget(const char *tgt, const char* d); @@ -265,9 +265,9 @@ class cmMakefile /** * Add a subdirectory to the build. */ - void AddSubDirectory(const char*, bool excludeFromAll=false, + void AddSubDirectory(const char*, bool excludeFromAll=false, bool preorder = false); - void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir, + void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir, bool excludeFromAll, bool preorder, bool immediate); @@ -275,7 +275,7 @@ class cmMakefile * Configure a subdirectory */ void ConfigureSubDirectory(cmLocalGenerator *); - + /** * Add an include directory to the build. */ @@ -287,13 +287,13 @@ class cmMakefile */ void AddDefinition(const char* name, const char* value); ///! Add a definition to this makefile and the global cmake cache. - void AddCacheDefinition(const char* name, const char* value, + void AddCacheDefinition(const char* name, const char* value, const char* doc, cmCacheManager::CacheEntryType type, bool force = false); /** - * Add bool variable definition to the build. + * Add bool variable definition to the build. */ void AddDefinition(const char* name, bool); @@ -304,7 +304,7 @@ class cmMakefile void RemoveDefinition(const char* name); ///! Remove a definition from the cache. void RemoveCacheDefinition(const char* name); - + /** * Specify the name of the project for this build. */ @@ -339,14 +339,14 @@ class cmMakefile * Add a source group for consideration when adding a new source. * name is tokenized. */ - void AddSourceGroup(const std::vector& name, + void AddSourceGroup(const std::vector& name, const char* regex=0); #endif //@{ /** - * Set, Push, Pop policy values for CMake. + * Set, Push, Pop policy values for CMake. */ bool SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); bool SetPolicy(const char *id, cmPolicies::PolicyStatus status); @@ -374,31 +374,31 @@ class cmMakefile * Get the Policies Instance */ cmPolicies *GetPolicies(); - + /** * Add an auxiliary directory to the build. */ void AddExtraDirectory(const char* dir); - + /** * Add an auxiliary directory to the build. */ void MakeStartDirectoriesCurrent() { - this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", + this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", this->cmStartDirectory.c_str()); - this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", + this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", this->StartOutputDirectory.c_str()); } - + //@{ /** * Set/Get the home directory (or output directory) in the project. The * home directory is the top directory of the project. It is where * CMakeSetup or configure was run. Remember that CMake processes * CMakeLists files by recursing up the tree starting at the StartDirectory - * and going up until it reaches the HomeDirectory. + * and going up until it reaches the HomeDirectory. */ void SetHomeDirectory(const char* dir); const char* GetHomeDirectory() const @@ -428,15 +428,15 @@ class cmMakefile * is the directory of the CMakeLists.txt file that started the current * round of processing. Remember that CMake processes CMakeLists files by * recursing up the tree starting at the StartDirectory and going up until - * it reaches the HomeDirectory. + * it reaches the HomeDirectory. */ - void SetStartDirectory(const char* dir) + void SetStartDirectory(const char* dir) { this->cmStartDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory); - this->cmStartDirectory = + this->cmStartDirectory = cmSystemTools::CollapseFullPath(this->cmStartDirectory.c_str()); - this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", + this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", this->cmStartDirectory.c_str()); } const char* GetStartDirectory() const @@ -447,10 +447,10 @@ class cmMakefile { this->StartOutputDirectory = lib; cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory); - this->StartOutputDirectory = + this->StartOutputDirectory = cmSystemTools::CollapseFullPath(this->StartOutputDirectory.c_str()); cmSystemTools::MakeDirectory(this->StartOutputDirectory.c_str()); - this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", + this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", this->StartOutputDirectory.c_str()); } const char* GetStartOutputDirectory() const @@ -459,7 +459,7 @@ class cmMakefile } //@} - const char* GetCurrentDirectory() const + const char* GetCurrentDirectory() const { return this->cmStartDirectory.c_str(); } @@ -478,7 +478,7 @@ class cmMakefile //@} - /** + /** * Set a regular expression that include files must match * in order to be considered as part of the depend information. */ @@ -487,11 +487,11 @@ class cmMakefile this->IncludeFileRegularExpression = regex; } const char* GetIncludeRegularExpression() - { + { return this->IncludeFileRegularExpression.c_str(); } - /** + /** * Set a regular expression that include files that are not found * must match in order to be considered a problem. */ @@ -523,11 +523,11 @@ class cmMakefile * Get a list of include directories in the build. */ std::vector& GetIncludeDirectories() - { + { return this->IncludeDirectories; } const std::vector& GetIncludeDirectories() const - { + { return this->IncludeDirectories; } void SetIncludeDirectories(const std::vector& vec) @@ -542,7 +542,7 @@ class cmMakefile bool IsSystemIncludeDirectory(const char* dir); /** Expand out any arguements in the vector that have ; separated - * strings into multiple arguements. A new vector is created + * strings into multiple arguements. A new vector is created * containing the expanded versions of all arguments in argsIn. * This method differes from the one in cmSystemTools in that if * the CmakeLists file is version 1.2 or earlier it will check for @@ -558,7 +558,7 @@ class cmMakefile cmSourceFile* GetSource(const char* sourceName); /** Get a cmSourceFile pointer for a given source name, if the name is - * not found, then create the source file and return it. generated + * not found, then create the source file and return it. generated * indicates if it is a generated file, this is used in determining * how to create the source file instance e.g. name */ @@ -597,8 +597,8 @@ class cmMakefile * variables will be listed. */ std::vector GetDefinitions(int cacheonly=0) const; - - /** Test a boolean cache entry to see if it is true or false, + + /** Test a boolean cache entry to see if it is true or false, * returns false if no entry defined. */ bool IsOn(const char* name) const; @@ -617,13 +617,13 @@ class cmMakefile * Make sure CMake can write this file */ bool CanIWriteThisFile(const char* fileName); - + /** * Get the vector of used command instances. */ const std::vector& GetUsedCommands() const {return this->UsedCommands;} - + #if defined(CMAKE_BUILD_WITH_CMAKE) /** * Get the vector source groups. @@ -663,9 +663,9 @@ class cmMakefile { return this->OutputFiles; } void AddCMakeOutputFile(const char* file) { this->OutputFiles.push_back(file);} - + /** - * Expand all defined variables in the string. + * Expand all defined variables in the string. * Defined variables come from the this->Definitions map. * They are expanded with ${var} where var is the * entry in the this->Definitions map. Also @var@ is @@ -682,15 +682,15 @@ class cmMakefile /** * Remove any remaining variables in the string. Anything with ${var} or - * @var@ will be removed. + * @var@ will be removed. */ - void RemoveVariablesInString(std::string& source, + void RemoveVariablesInString(std::string& source, bool atOnly = false) const; /** * Expand variables in the makefiles ivars such as link directories etc */ - void ExpandVariables(); + void ExpandVariables(); /** * Replace variables and #cmakedefine lines in the given string. @@ -702,7 +702,7 @@ class cmMakefile /** * Copy file but change lines acording to ConfigureString */ - int ConfigureFile(const char* infile, const char* outfile, + int ConfigureFile(const char* infile, const char* outfile, bool copyonly, bool atOnly, bool escapeQuotes); #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -717,12 +717,12 @@ class cmMakefile * Execute a single CMake command. Returns true if the command * succeeded or false if it failed. */ - bool ExecuteCommand(const cmListFileFunction& lff, + bool ExecuteCommand(const cmListFileFunction& lff, cmExecutionStatus &status); /** Check if a command exists. */ bool CommandExists(const char* name) const; - + /** * Add a command to this cmake instance */ @@ -748,7 +748,7 @@ class cmMakefile ///! Display progress or status message. void DisplayStatus(const char*, float); - + /** * Expand the given list file arguments into the full set after * variable replacement and list expansion. @@ -757,13 +757,13 @@ class cmMakefile std::vector& outArgs); /** * Get the instance - */ + */ cmake *GetCMakeInstance() const; /** * Get all the source files this makefile knows about */ - const std::vector &GetSourceFiles() const + const std::vector &GetSourceFiles() const {return this->SourceFiles;} std::vector &GetSourceFiles() {return this->SourceFiles;} @@ -775,7 +775,7 @@ class cmMakefile /** * Add a macro to the list of macros. The arguments should be name of the - * macro and a documentation signature of it + * macro and a documentation signature of it */ void AddMacro(const char* name, const char* signature); @@ -797,7 +797,7 @@ class cmMakefile */ std::string GetModulesFile(const char* name); - ///! Set/Get a property of this directory + ///! Set/Get a property of this directory void SetProperty(const char *prop, const char *value); void AppendProperty(const char *prop, const char *value,bool asString=false); const char *GetProperty(const char *prop); @@ -812,7 +812,7 @@ class cmMakefile ///! Initialize a makefile from its parent void InitializeFromParent(); - + ///! Set/Get the preorder flag void SetPreOrder(bool p) { this->PreOrder = p; } bool GetPreOrder() const { return this->PreOrder; } @@ -859,11 +859,11 @@ class cmMakefile void CheckForUnused(const char* reason, const char* name) const; std::string Prefix; - std::vector AuxSourceDirectories; // + std::vector AuxSourceDirectories; // - std::string cmStartDirectory; - std::string StartOutputDirectory; - std::string cmHomeDirectory; + std::string cmStartDirectory; + std::string StartOutputDirectory; + std::string cmHomeDirectory; std::string HomeOutputDirectory; std::string cmCurrentListFile; @@ -875,7 +875,7 @@ class cmMakefile // Tests std::map Tests; - + // The include and link-library paths. These may have order // dependency, so they must be vectors (not set). std::vector IncludeDirectories; @@ -887,8 +887,8 @@ class cmMakefile std::vector ListFiles; // list of command files loaded std::vector OutputFiles; // list of command files loaded - - + + cmTarget::LinkLibraryVectorType LinkLibraries; std::vector InstallGenerators; @@ -911,9 +911,9 @@ class cmMakefile std::vector UsedCommands; cmLocalGenerator* LocalGenerator; - bool IsFunctionBlocked(const cmListFileFunction& lff, + bool IsFunctionBlocked(const cmListFileFunction& lff, cmExecutionStatus &status); - + private: void Initialize(); @@ -923,10 +923,10 @@ class cmMakefile void ReadSources(std::ifstream& fin, bool t); friend class cmMakeDepend; // make depend needs direct access - // to the Sources array - void PrintStringVector(const char* s, const + // to the Sources array + void PrintStringVector(const char* s, const std::vector >& v) const; - void PrintStringVector(const char* s, + void PrintStringVector(const char* s, const std::vector& v) const; void AddDefaultDefinitions(); @@ -954,7 +954,7 @@ class cmMakefile bool WarnUnused; bool CheckSystemVars; - // stack of list files being read + // stack of list files being read std::deque ListFileStack; // stack of commands being invoked. diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 3937d8d17b3..cc11686bd39 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -180,8 +180,8 @@ static const char * cmDocumentationOptions[][3] = {"--build-project", "Specify the name of the project to build.", "" }, {"--build-makeprogram", "Specify the make program to use.", "" }, {"--build-noclean", "Skip the make clean step.", "" }, - {"--build-config-sample", - "A sample executable to use to determine the configuration", + {"--build-config-sample", + "A sample executable to use to determine the configuration", "A sample executable to use to determine the configuration that " "should be used. e.g. Debug/Release/etc" }, {"--build-options", "Add extra options to the build step.", @@ -276,7 +276,7 @@ int main (int argc, char *argv[]) // If there is a testing input file, check for documentation options // only if there are actually arguments. We want running without // arguments to run tests. - if(argc > 1 || !(cmSystemTools::FileExists("CTestTestfile.cmake") || + if(argc > 1 || !(cmSystemTools::FileExists("CTestTestfile.cmake") || cmSystemTools::FileExists("DartTestfile.txt"))) { if(argc == 1) From d0b3a7fa48e000996775516f9ed0d78386c262de Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sat, 19 Mar 2011 11:41:00 +0100 Subject: [PATCH 369/539] Fix typo. --- Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.h | 2 +- Source/cmGlobalVisualStudio7Generator.h | 2 +- Source/cmLocalGenerator.h | 4 ++-- Source/cmLocalUnixMakefileGenerator3.h | 2 +- Source/cmake.cxx | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9f140a9c9fc..ded3345db81 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -90,7 +90,7 @@ class cmGlobalGenerator cmMakefile* mf); /** - * Try running cmake and building a file. This is used for dynalically + * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ virtual int TryCompile(const char *srcdir, const char *bindir, diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 481640b7aed..7566afaf818 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -90,7 +90,7 @@ class cmGlobalUnixMakefileGenerator3 : public cmGlobalGenerator void WriteHelpRule(std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3 *); - // write the top lvel target rules + // write the top level target rules void WriteConvenienceRules(std::ostream& ruleFileStream, std::set &emitted); diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index ebb6fe41790..adfb757f145 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -48,7 +48,7 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator cmMakefile *, bool optional); /** - * Try running cmake and building a file. This is used for dynalically + * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ virtual std::string GenerateBuildCommand(const char* makeProgram, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 3d96f01baff..7fe5d939076 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -25,7 +25,7 @@ class cmCustomCommand; * \brief Create required build files for a directory. * * Subclasses of this abstract class generate makefiles, DSP, etc for various - * platforms. This class should never be constructued directly. A + * platforms. This class should never be constructed directly. A * GlobalGenerator will create it and invoke the appropriate commands on it. */ class cmLocalGenerator @@ -90,7 +90,7 @@ class cmLocalGenerator void SetGlobalGenerator(cmGlobalGenerator *gg); /** - * Convert something to something else. This is a centralized coversion + * Convert something to something else. This is a centralized conversion * routine used by the generators to handle relative paths and the like. * The flags determine what is actually done. * diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 1fd1aa7ffda..fab98da0e5a 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -161,7 +161,7 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator // used in writing out Cmake files such as WriteDirectoryInformation static void WriteCMakeArgument(std::ostream& os, const char* s); - /** creates the common disclainer text at the top of each makefile */ + /** creates the common disclaimer text at the top of each makefile */ void WriteDisclaimer(std::ostream& os); // write a comment line #====... in the stream diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 05699da4dbf..d691f46dc25 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2881,7 +2881,7 @@ int cmake::CheckBuildSystem() return 1; } - // Find find the newest dependency. + // Find the newest dependency. std::vector::iterator dep = depends.begin(); std::string dep_newest = *dep++; for(;dep != depends.end(); ++dep) @@ -2907,7 +2907,7 @@ int cmake::CheckBuildSystem() } } - // Find find the oldest output. + // Find the oldest output. std::vector::iterator out = outputs.begin(); std::string out_oldest = *out++; for(;out != outputs.end(); ++out) From dd13ecd00528b8d8041145e278cb7590d943f9de Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 20 Mar 2011 12:16:43 +0100 Subject: [PATCH 370/539] Doxygen: Improve code documentation. --- Source/cmLocalGenerator.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 7fe5d939076..0c5b9d07418 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -143,6 +143,7 @@ class cmLocalGenerator void AddSharedFlags(std::string& flags, const char* lang, bool shared); void AddConfigVariableFlags(std::string& flags, const char* var, const char* config); + ///! Append flags to a string. virtual void AppendFlags(std::string& flags, const char* newFlags); ///! Get the include flags for the current makefile and language const char* GetIncludeFlags(const char* lang, From faede37b79ef0c4dee9cce67ab57499ddf46b47f Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 20 Mar 2011 13:41:06 +0100 Subject: [PATCH 371/539] Doxygen: Generate call graph and relationships. It helps code browsing and understanding for new developers. --- Utilities/Doxygen/doxyfile.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Utilities/Doxygen/doxyfile.in b/Utilities/Doxygen/doxyfile.in index c3d3a386930..9743af72188 100644 --- a/Utilities/Doxygen/doxyfile.in +++ b/Utilities/Doxygen/doxyfile.in @@ -28,6 +28,8 @@ INCLUDED_BY_GRAPH = YES CLASS_DIAGRAMS = YES GENERATE_LEGEND = YES GRAPHICAL_HIERARCHY = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES ALLEXTERNALS = NO @@ -61,7 +63,7 @@ SORT_MEMBER_DOCS = NO DISTRIBUTE_GROUP_DOC = YES TAB_SIZE = 3 -FILE_PATTERNS = *.h *.hxx +FILE_PATTERNS = *.h *.hxx *.cxx RECURSIVE = NO EXCLUDE_PATTERNS = From a92f14f3386e8dee055fe0c3eb624bfb833ee350 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 20 Mar 2011 14:22:39 +0100 Subject: [PATCH 372/539] Doxygen: Fix warnings. --- Source/CPack/cmCPackNSISGenerator.h | 2 +- Source/CTest/cmCTestLaunch.h | 2 +- Source/CTest/cmCTestSubmitHandler.h | 4 +++- Source/cmCommandArgumentLexer.cxx | 8 ++++---- Source/cmDependsFortranLexer.cxx | 8 ++++---- Source/cmDependsJavaLexer.cxx | 6 +++--- Source/cmDocumentationFormatter.h | 2 +- Source/cmExprLexer.cxx | 5 ++--- Source/cmGlobalKdevelopGenerator.h | 4 ++-- Source/cmGlobalUnixMakefileGenerator3.h | 2 +- Source/cmMakefile.h | 4 ++-- 11 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index dde1bbb89d2..7bccb89fb5b 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -72,7 +72,7 @@ class cmCPackNSISGenerator : public cmCPackGenerator CreateComponentGroupDescription(cmCPackComponentGroup *group, cmOStringStream& macrosOut); - /// Translations any newlines found in the string into \r\n, so that the + /// Translations any newlines found in the string into \\r\\n, so that the /// resulting string can be used within NSIS. static std::string TranslateNewlines(std::string str); }; diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h index cd876d085c3..7457e8357fb 100644 --- a/Source/CTest/cmCTestLaunch.h +++ b/Source/CTest/cmCTestLaunch.h @@ -24,7 +24,7 @@ class cmCTestLaunch { public: /** Entry point from ctest executable main(). */ - static int Main(int argc, const char* const* argv); + static int Main(int argc, const char* const argv[]); private: // Initialize the launcher from its command line. cmCTestLaunch(int argc, const char* const* argv); diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index 9cfd7df250b..14eac80b522 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -75,7 +75,9 @@ class cmCTestSubmitHandler : public cmCTestGenericHandler const cmStdString& remoteprefix, const cmStdString& url); - void ParseResponse(std::vector); + typedef std::vector cmCTestSubmitHandlerVectorOfChar; + + void ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk); std::string GetSubmitResultsPrefix(); diff --git a/Source/cmCommandArgumentLexer.cxx b/Source/cmCommandArgumentLexer.cxx index 89819cedd9c..1d7140bb261 100644 --- a/Source/cmCommandArgumentLexer.cxx +++ b/Source/cmCommandArgumentLexer.cxx @@ -1672,9 +1672,9 @@ YY_BUFFER_STATE cmCommandArgument_yy_scan_string (yyconst char * yystr , yyscan_ } /** Setup the input buffer state to scan the given bytes. The next call to cmCommandArgument_yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * scan from a @e copy of @a yybytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -1835,7 +1835,7 @@ void cmCommandArgument_yyset_lineno (int line_number , yyscan_t yyscanner) } /** Set the current column. - * @param line_number + * @param column_no * @param yyscanner The scanner object. */ void cmCommandArgument_yyset_column (int column_no , yyscan_t yyscanner) diff --git a/Source/cmDependsFortranLexer.cxx b/Source/cmDependsFortranLexer.cxx index a488884de7d..438af2df55a 100644 --- a/Source/cmDependsFortranLexer.cxx +++ b/Source/cmDependsFortranLexer.cxx @@ -1991,9 +1991,9 @@ YY_BUFFER_STATE cmDependsFortran_yy_scan_string (yyconst char * yystr , yyscan_t } /** Setup the input buffer state to scan the given bytes. The next call to cmDependsFortran_yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * scan from a @e copy of @a yybytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -2154,7 +2154,7 @@ void cmDependsFortran_yyset_lineno (int line_number , yyscan_t yyscanner) } /** Set the current column. - * @param line_number + * @param column_no * @param yyscanner The scanner object. */ void cmDependsFortran_yyset_column (int column_no , yyscan_t yyscanner) diff --git a/Source/cmDependsJavaLexer.cxx b/Source/cmDependsJavaLexer.cxx index e4487f8beef..63cfebcd796 100644 --- a/Source/cmDependsJavaLexer.cxx +++ b/Source/cmDependsJavaLexer.cxx @@ -2168,8 +2168,8 @@ YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char * base, yy_size_t size , yy } /** Setup the input buffer state to scan a string. The next call to cmDependsJava_yylex() will - * scan from a @e copy of @a str. - * @param str a NUL-terminated string to scan + * scan from a @e copy of @a yy_str. + * @param yy_str a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use @@ -2345,7 +2345,7 @@ void cmDependsJava_yyset_lineno (int line_number , yyscan_t yyscanner) } /** Set the current column. - * @param line_number + * @param column_no * @param yyscanner The scanner object. */ void cmDependsJava_yyset_column (int column_no , yyscan_t yyscanner) diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h index 1dcff1a23d0..665b9b61a5d 100644 --- a/Source/cmDocumentationFormatter.h +++ b/Source/cmDocumentationFormatter.h @@ -60,7 +60,7 @@ class cmDocumentationFormatter std::vector&) {} - /** Compute a prefix for links into a section (#_SOMETHING). */ + /** Compute a prefix for links into a section (#\_SOMETHING). */ std::string ComputeSectionLinkPrefix(std::string const& name); }; diff --git a/Source/cmExprLexer.cxx b/Source/cmExprLexer.cxx index cd0530db75d..53dfca7c011 100644 --- a/Source/cmExprLexer.cxx +++ b/Source/cmExprLexer.cxx @@ -1554,8 +1554,7 @@ YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t } /** Setup the input buffer state to scan a string. The next call to cmExpr_yylex() will - * scan from a @e copy of @a str. - * @param str a NUL-terminated string to scan + * scan from a @e copy of @a yy_str. * @param yy_str a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. @@ -1732,7 +1731,7 @@ void cmExpr_yyset_lineno (int line_number , yyscan_t yyscanner) } /** Set the current column. - * @param line_number + * @param column_no * @param yyscanner The scanner object. */ void cmExpr_yyset_column (int column_no , yyscan_t yyscanner) diff --git a/Source/cmGlobalKdevelopGenerator.h b/Source/cmGlobalKdevelopGenerator.h index f2769435d13..a1ad39d44bb 100644 --- a/Source/cmGlobalKdevelopGenerator.h +++ b/Source/cmGlobalKdevelopGenerator.h @@ -23,8 +23,8 @@ class cmLocalGenerator; * cmGlobalKdevelopGenerator produces a project file for KDevelop 3 (KDevelop * > 3.1.1). The project is based on the "Custom Makefile based C/C++" * project of KDevelop. Such a project consists of Unix Makefiles in the - * build directory together with a .kdevelop project file, - * which contains the project settings and a .kdevelop.filelist + * build directory together with a \.kdevelop project file, + * which contains the project settings and a \.kdevelop.filelist * file, which lists the source files relative to the kdevelop project * directory. The kdevelop project directory is the base source directory. */ diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 7566afaf818..9663b559235 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -36,7 +36,7 @@ class cmLocalUnixMakefileGenerator3; targets that are required to make the process work. Makefile2 in turn will recursively make targets in the correct order. Each - target has its own directory .dir and its own makefile build.make in + target has its own directory \.dir and its own makefile build.make in that directory. Also in that directory is a couple makefiles per source file used by the target. Typically these are named source.obj.build.make and source.obj.build.depend.make. The source.obj.build.make contains the rules diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index c80d4cca61f..7c3e4ee4bb6 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -668,7 +668,7 @@ class cmMakefile * Expand all defined variables in the string. * Defined variables come from the this->Definitions map. * They are expanded with ${var} where var is the - * entry in the this->Definitions map. Also @var@ is + * entry in the this->Definitions map. Also \@var\@ is * expanded to match autoconf style expansions. */ const char *ExpandVariablesInString(std::string& source); @@ -682,7 +682,7 @@ class cmMakefile /** * Remove any remaining variables in the string. Anything with ${var} or - * @var@ will be removed. + * \@var\@ will be removed. */ void RemoveVariablesInString(std::string& source, bool atOnly = false) const; From 6be15ed58b463b61c0ae99ccc960932c202d8605 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Fri, 25 Mar 2011 14:06:43 +0100 Subject: [PATCH 373/539] Doxygen: Remove dependency on VTK when building doxygen. --- Utilities/Doxygen/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/Utilities/Doxygen/CMakeLists.txt b/Utilities/Doxygen/CMakeLists.txt index 5d076e04141..2430391fd24 100644 --- a/Utilities/Doxygen/CMakeLists.txt +++ b/Utilities/Doxygen/CMakeLists.txt @@ -17,8 +17,6 @@ INCLUDE (${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL) IF (BUILD_DOCUMENTATION) - INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake) - # # Configure the script and the doxyfile, then add target # From 1b612caafe6ffb8804fb8deac6cf877a9e7c5565 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Wed, 12 Oct 2011 15:39:46 +0200 Subject: [PATCH 374/539] Usage: Document -j|--parallel option in help message. --- Source/ctest.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/ctest.cxx b/Source/ctest.cxx index cc11686bd39..e168fb80104 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -68,6 +68,10 @@ static const char * cmDocumentationOptions[][3] = {"-F", "Enable failover.", "This option allows ctest to resume a test " "set execution that was previously interrupted. If no interruption " "occurred, the -F option will have no effect."}, + {"-j , --parallel ", "Run the tests in parallel using the" + "given number of jobs.", + "This option tells ctest to run the tests in parallel using given " + "number of jobs."}, {"-Q,--quiet", "Make ctest quiet.", "This option will suppress all the output. The output log file will " "still be generated if the --output-log is specified. Options such " From 3353d84c14c5421bf4a6a1b013652b1f6c6917df Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Wed, 12 Oct 2011 15:52:20 +0200 Subject: [PATCH 375/539] Usage: Document all options printing usage information. --- Source/cmDocumentation.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 5e56b29e6af..ef53d4a9221 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -21,7 +21,7 @@ static const char *cmDocumentationStandardOptions[][3] = { {"--copyright [file]", "Print the CMake copyright and exit.", "If a file is specified, the copyright is written into it."}, - {"--help", "Print usage information and exit.", + {"--help,-help,-usage,-h,-H,/?", "Print usage information and exit.", "Usage describes the basic command line interface and its options."}, {"--help-full [file]", "Print full help and exit.", "Full help displays most of the documentation provided by the UNIX " From 9ae0604a623edba6f7e9598c66ae77b30adfccd5 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Wed, 12 Oct 2011 15:57:22 +0200 Subject: [PATCH 376/539] Usage: Document all options printing the version number. --- Source/cmDocumentation.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index ef53d4a9221..07683d08442 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -34,7 +34,8 @@ static const char *cmDocumentationStandardOptions[][3] = {"--help-man [file]", "Print full help as a UNIX man page and exit.", "This option is used by the cmake build to generate the UNIX man page. " "If a file is specified, the help is written into it."}, - {"--version [file]", "Show program name/version banner and exit.", + {"--version,-version,/V [file]", + "Show program name/version banner and exit.", "If a file is specified, the version is written into it."}, {0,0,0} }; From de512644d8b6c79b348e13e4affa25627040c597 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Wed, 12 Oct 2011 16:24:04 +0200 Subject: [PATCH 377/539] Usage: Print help, version and copyright options in usage information. There were missing for ctest, cpack and ccmake. --- Source/CPack/cpack.cxx | 2 +- Source/CursesDialog/ccmake.cxx | 2 +- Source/ctest.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 71ba1182a88..b1706e3ebb9 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -448,7 +448,7 @@ int main (int argc, char *argv[]) doc.SetSection("Name",cmDocumentationName); doc.SetSection("Usage",cmDocumentationUsage); doc.SetSection("Description",cmDocumentationDescription); - doc.SetSection("Options",cmDocumentationOptions); + doc.PrependSection("Options",cmDocumentationOptions); std::vector v; cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt; diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 7cf107118ae..b1a72afa43e 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -116,7 +116,7 @@ int main(int argc, char** argv) doc.SetSection("Usage",cmDocumentationUsage); doc.SetSection("Description",cmDocumentationDescription); doc.SetSection("Generators",generators); - doc.SetSection("Options",cmDocumentationOptions); + doc.PrependSection("Options",cmDocumentationOptions); doc.SetSection("Command",commands); doc.SetSection("Compatibility Commands",compatCommands); doc.SetSeeAlsoList(cmDocumentationSeeAlso); diff --git a/Source/ctest.cxx b/Source/ctest.cxx index e168fb80104..85cecea890e 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -305,7 +305,7 @@ int main (int argc, char *argv[]) doc.SetSection("Name",cmDocumentationName); doc.SetSection("Usage",cmDocumentationUsage); doc.SetSection("Description",cmDocumentationDescription); - doc.SetSection("Options",cmDocumentationOptions); + doc.PrependSection("Options",cmDocumentationOptions); doc.SetSection("Commands",commands); doc.SetSeeAlsoList(cmDocumentationSeeAlso); #ifdef cout From bfb0ed4293c3a25c47d2fef7b9f19c25b8f5a477 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Wed, 12 Oct 2011 16:28:03 +0200 Subject: [PATCH 378/539] Usage: Add missing exepath argument in get_prerequisites documentation. --- Modules/GetPrerequisites.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 023b8b5605f..2efa079993f 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -24,7 +24,7 @@ # PARENT_SCOPE. # # GET_PREREQUISITES( -# ) +# ) # Get the list of shared library files required by . The list in # the variable named should be empty on first entry to # this function. On exit, will contain the list of From fd63219557c4acc6e474263302ab9c78985f6d91 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Fri, 7 Jan 2011 14:48:35 +0100 Subject: [PATCH 379/539] ccmake: Align 'g' and 'q' key instructions. They were miss-aligned with the 'enter' key instruction. Before: ---- Press [enter] to edit option CMake Version 2.8.3.20110107-g4b05a-dirty Press [c] to configure Press [h] for help Press [q] to quit without generating ---- After: ---- Press [enter] to edit option CMake Version 2.8.3.20110107-g4b05a-dirty Press [c] to configure Press [h] for help Press [q] to quit without generating ---- --- Source/CursesDialog/cmCursesMainForm.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 17fa0ffc16a..faaac8b5c6e 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -421,7 +421,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) if (this->OkToGenerate) { sprintf(firstLine, - "Press [c] to configure Press [g] to generate and exit"); + "Press [c] to configure Press [g] to generate and exit"); } else { @@ -437,7 +437,8 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) } sprintf(secondLine, - "Press [h] for help Press [q] to quit without generating"); + "Press [h] for help " + "Press [q] to quit without generating"); } curses_move(y-4,0); From 19da10629d96333b2cdae8c0fa926a354fc9d79e Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Fri, 7 Jan 2011 16:34:27 +0100 Subject: [PATCH 380/539] ccmake: Document '/' key. --- Source/CursesDialog/cmCursesMainForm.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index faaac8b5c6e..735854df7f3 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -1302,6 +1302,5 @@ const char* cmCursesMainForm::s_ConstHelpMessage = " g : generate build files and exit, only available when there are no " "new options and no errors have been detected during last configuration.\n" " l : shows last errors\n" -" t : toggles advanced mode. In normal mode, only the most important options are shown. In advanced mode, all options are shown. We recommend using normal mode unless you are an expert.\n"; - - +" t : toggles advanced mode. In normal mode, only the most important options are shown. In advanced mode, all options are shown. We recommend using normal mode unless you are an expert.\n" +" / : search for a variable name.\n"; From ceff6ec5254bbee898ac6a193624dba5ccf18e56 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Fri, 7 Jan 2011 14:57:46 +0100 Subject: [PATCH 381/539] ccmake: Factor toggle key help instructions. --- Source/CursesDialog/cmCursesMainForm.cxx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 735854df7f3..6c7627f924b 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -427,15 +427,13 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) { sprintf(firstLine, "Press [c] to configure "); } - if (this->AdvancedMode) - { - sprintf(thirdLine, "Press [t] to toggle advanced mode (Currently On)"); - } - else - { - sprintf(thirdLine, "Press [t] to toggle advanced mode (Currently Off)"); - } - + { + const char* toggleKeyInstruction = + "Press [t] to toggle advanced mode (Currently %s)"; + sprintf(thirdLine, + toggleKeyInstruction, + this->AdvancedMode ? "On" : "Off"); + } sprintf(secondLine, "Press [h] for help " "Press [q] to quit without generating"); From 27e405ddb1bb9f4ab181ff38e4169d4806c43428 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 24 Oct 2011 00:01:03 -0400 Subject: [PATCH 382/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 0294f5bee64..60a30d59192 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 23) +SET(KWSYS_DATE_STAMP_DAY 24) From 89742d73cc684a78586fad2497048d9329c1160e Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Oct 2011 09:55:06 -0400 Subject: [PATCH 383/539] KWSys: Fix Doxygen warnings Author: Nicolas Despres --- Source/kwsys/SystemTools.hxx.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index fd2ed19712e..04f19784269 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -612,7 +612,7 @@ public: * Up to 'length' bytes are read from the file, if more than 'percent_bin' % * of the bytes are non-textual elements, the file is considered binary, * otherwise textual. Textual elements are bytes in the ASCII [0x20, 0x7E] - * range, but also \n, \r, \t. + * range, but also \\n, \\r, \\t. * The algorithm is simplistic, and should probably check for usual file * extensions, 'magic' signature, unicode, etc. */ @@ -812,7 +812,7 @@ public: * Convert windows-style arguments given as a command-line string * into more traditional argc/argv arguments. * Note that argv[0] will be assigned the executable name using - * the ::GetModuleFileName function. + * the GetModuleFileName() function. */ static void ConvertWindowsCommandLineToUnixArguments( const char *cmd_line, int *argc, char ***argv); From 3d5869ca3c065c872d6365164b301d2f8d7e2b64 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Oct 2011 10:18:36 -0400 Subject: [PATCH 384/539] Add pre-commit|commit-msg|prepare-commit-msg hook placeholders Add CMake-specific hook placeholders that chain from the main hooks branch after it is installed into the local .git/hooks directory. --- .gitattributes | 1 + .hooks-config.bash | 18 ++++++++++++++++++ Utilities/Git/commit-msg | 23 +++++++++++++++++++++++ Utilities/Git/pre-commit | 23 +++++++++++++++++++++++ Utilities/Git/prepare-commit-msg | 15 +++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 .hooks-config.bash create mode 100755 Utilities/Git/commit-msg create mode 100755 Utilities/Git/pre-commit create mode 100755 Utilities/Git/prepare-commit-msg diff --git a/.gitattributes b/.gitattributes index 43676a97f13..d9d64d639d0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ .gitattributes export-ignore +.hooks* export-ignore bootstrap crlf=input configure crlf=input diff --git a/.hooks-config.bash b/.hooks-config.bash new file mode 100644 index 00000000000..97152f6519d --- /dev/null +++ b/.hooks-config.bash @@ -0,0 +1,18 @@ +#============================================================================= +# CMake - Cross Platform Makefile Generator +# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +# Loaded by .git/hooks/(pre-commit|commit-msg|prepare-commit-msg) +# during git commit after local hooks have been installed. + +hooks_chain_pre_commit="Utilities/Git/pre-commit" +hooks_chain_commit_msg="Utilities/Git/commit-msg" +hooks_chain_prepare_commit_msg="Utilities/Git/prepare-commit-msg" diff --git a/Utilities/Git/commit-msg b/Utilities/Git/commit-msg new file mode 100755 index 00000000000..9a5d1c1b390 --- /dev/null +++ b/Utilities/Git/commit-msg @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +#============================================================================= +# CMake - Cross Platform Makefile Generator +# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +die() { + echo 'commit-msg hook failure' 1>&2 + echo '-----------------------' 1>&2 + echo '' 1>&2 + echo "$@" 1>&2 + exit 1 +} + +# This is a placeholder for future commit-msg checks. +exit 0 diff --git a/Utilities/Git/pre-commit b/Utilities/Git/pre-commit new file mode 100755 index 00000000000..e4f9fd0a70b --- /dev/null +++ b/Utilities/Git/pre-commit @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +#============================================================================= +# CMake - Cross Platform Makefile Generator +# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +die() { + echo 'pre-commit hook failure' 1>&2 + echo '-----------------------' 1>&2 + echo '' 1>&2 + echo "$@" 1>&2 + exit 1 +} + +# This is a placeholder for future pre-commit checks. +exit 0 diff --git a/Utilities/Git/prepare-commit-msg b/Utilities/Git/prepare-commit-msg new file mode 100755 index 00000000000..1517bb2db6f --- /dev/null +++ b/Utilities/Git/prepare-commit-msg @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +#============================================================================= +# CMake - Cross Platform Makefile Generator +# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +# This is a placeholder for future prepare-commit-msg hooks. +exit 0 From b2d6adf1266554de222fd438e9501c1eb67b429a Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Oct 2011 10:36:15 -0400 Subject: [PATCH 385/539] pre-commit: Reject changes to KWSys through Git Explain in the rejection message why KWSys cannot be changed in Git. --- Utilities/Git/pre-commit | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Utilities/Git/pre-commit b/Utilities/Git/pre-commit index e4f9fd0a70b..110e9ee350c 100755 --- a/Utilities/Git/pre-commit +++ b/Utilities/Git/pre-commit @@ -19,5 +19,29 @@ die() { exit 1 } -# This is a placeholder for future pre-commit checks. -exit 0 +if test -z "$HOOKS_ALLOW_KWSYS"; then + # Disallow changes to KWSys + files=$(git diff-index --name-only --cached HEAD -- Source/kwsys) && + if test -n "$files"; then + die 'Changes to KWSys files + +'"$(echo "$files" | sed 's/^/ /')"' + +cannot be committed through Git. KWSys is kept in a CVS repository +shared by several projects. A robot replays changes committed there +into the Source/kwsys directory in CMake. Please send changes to +this directory separately. Run + + git reset HEAD -- Source/kwsys + +to unstage these changes and then + + git diff -- Source/kwsys > kwsys.patch + +to construct the patch. Alternatively, set environment variable + + HOOKS_ALLOW_KWSYS=1 + +to disable this check and commit the changes locally.' + fi +fi From d9cbba7c2cd364a19b42cd856f5d048deb92b415 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 1 Oct 2011 12:23:56 +0200 Subject: [PATCH 386/539] Initialize LINK_INTERFACE_LIBRARIES target property with a variable Define variable CMAKE_LINK_INTERFACE_LIBRARIES to initialize the value of this property when a target is created. This allows authors to write set(CMAKE_LINK_INTERFACE_LIBRARIES "") to disable transitive linking to implementation dependencies of shared libraries on platforms where it is possible. --- Source/cmDocumentVariables.cxx | 9 ++++++++- Source/cmTarget.cxx | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index f2b01f13827..f4d4e7c5cb8 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1219,7 +1219,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Therefore a specific build configuration must be chosen even " "if the generated build system supports multiple configurations.",false, "Variables that Control the Build"); - + cm->DefineProperty + ("CMAKE_LINK_INTERFACE_LIBRARIES", cmProperty::VARIABLE, + "Default value for LINK_INTERFACE_LIBRARIES of targets.", + "This variable is used to initialize the " + "LINK_INTERFACE_LIBRARIES property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); // Variables defined when the a language is enabled These variables will // also be defined whenever CMake has loaded its support for compiling (LANG) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fb920165806..14b73d1f93a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -619,6 +619,9 @@ void cmTarget::DefineProperties(cmake *cm) "If the list is empty then no transitive link dependencies will be " "incorporated when this target is linked into another target even if " "the default set is non-empty. " + "This property is initialized by the value of the variable " + "CMAKE_LINK_INTERFACE_LIBRARIES if it is set when a target is " + "created. " "This property is ignored for STATIC libraries."); cm->DefineProperty @@ -1153,6 +1156,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); this->SetPropertyDefault("OSX_ARCHITECTURES", 0); this->SetPropertyDefault("AUTOMOC", 0); + this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0); // Collect the set of configuration types. std::vector configNames; From 74eb86c4a33140f71d9d248bb26ba0ff92fa0989 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Oct 2011 17:02:22 -0400 Subject: [PATCH 387/539] Fix CTest.UpdateSVN with Subversion 1.7 (#12535) The test adds a subdirectory with svn add subdir svn add ... subdir/foo.txt subdir/bar.txt Subversion 1.7 fails on the second command with svn: warning: W150002: '.../subdir/foo.txt' is already under version control svn: warning: W150002: '.../subdir/bar.txt' is already under version control svn: E200009: Could not add all targets because some targets don't exist because it considers adding an already-versioned file to be an error. Avoid the problem by using svn add --depth=empty subdir to add the subdirectory without the files it contains. --- Tests/CTestUpdateSVN.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/CTestUpdateSVN.cmake.in b/Tests/CTestUpdateSVN.cmake.in index 97b2a07fef8..e18dfc95d30 100644 --- a/Tests/CTestUpdateSVN.cmake.in +++ b/Tests/CTestUpdateSVN.cmake.in @@ -63,7 +63,7 @@ update_content(user-source files_added files_removed dirs_added) if(dirs_added) run_child( WORKING_DIRECTORY ${TOP}/user-source - COMMAND ${SVNCMD} add ${dirs_added} + COMMAND ${SVNCMD} add --depth=empty ${dirs_added} ) endif(dirs_added) run_child( From 6d79b50518d82a9bb116e527935d12498549fce9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Oct 2011 17:33:29 -0400 Subject: [PATCH 388/539] Teach CTest.UpdateSVN to detect svn add --depth before using it Older svn versions do not have the --depth option for "svn add". Fortunately we do not need it for versions that old. Look for the option and use it only when available. --- Tests/CTestUpdateSVN.cmake.in | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Tests/CTestUpdateSVN.cmake.in b/Tests/CTestUpdateSVN.cmake.in index e18dfc95d30..edafb4ef270 100644 --- a/Tests/CTestUpdateSVN.cmake.in +++ b/Tests/CTestUpdateSVN.cmake.in @@ -23,6 +23,16 @@ file(MAKE_DIRECTORY ${TOP}/config) set(SVNCMD ${SVN} --config-dir ${TOP}/config) set(SVNUSER --username "test author" --non-interactive) +# Configure for this svn version. +execute_process( + COMMAND ${SVN} help add OUTPUT_VARIABLE help_add ERROR_VARIABLE help_add + ) +if("${help_add}" MATCHES "--depth") + set(depth_empty "--depth=empty") +else() + set(depth_empty "") +endif() + #----------------------------------------------------------------------------- # Initialize the testing directory. message("Creating test directory...") @@ -63,7 +73,7 @@ update_content(user-source files_added files_removed dirs_added) if(dirs_added) run_child( WORKING_DIRECTORY ${TOP}/user-source - COMMAND ${SVNCMD} add --depth=empty ${dirs_added} + COMMAND ${SVNCMD} add ${depth_empty} ${dirs_added} ) endif(dirs_added) run_child( From 676fb3b2acea40f5eae7d4badc9dbea2366ce2da Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 25 Oct 2011 00:01:04 -0400 Subject: [PATCH 389/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 60a30d59192..b452f6df3bc 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 24) +SET(KWSYS_DATE_STAMP_DAY 25) From 26b6794fd5e570a4262a2adcf0c3c48d2c19e6e5 Mon Sep 17 00:00:00 2001 From: Bernhard Walle Date: Tue, 25 Oct 2011 11:15:21 +0200 Subject: [PATCH 390/539] Source/cmCTest.cxx: Add missing newline (#12538) In the log entry, the newline is missing. The output without the newline character is a bit strange, like SetCTestConfigurationFromCMakeVariable:MemoryCheckCommand:CTEST_MEMORYCHECK_COMMANDSetCTestConfiguration:MemoryCheckCommand:/usr/bin/valgrind Instead of SetCTestConfigurationFromCMakeVariable:MemoryCheckCommand:CTEST_MEMORYCHECK_COMMAND SetCTestConfiguration:MemoryCheckCommand:/usr/bin/valgrind This patch changes this to add a newline. Signed-off-by: Bernhard Walle --- Source/cmCTest.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 702ba10addb..e2e171a14f5 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2801,7 +2801,7 @@ bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf, } cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "SetCTestConfigurationFromCMakeVariable:" - << dconfig << ":" << cmake_var); + << dconfig << ":" << cmake_var << std::endl); this->SetCTestConfiguration(dconfig, ctvar); return true; } From fe6d9c1a448c511559967a6f8467c84d75d89e64 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Tue, 25 Oct 2011 23:03:17 +0200 Subject: [PATCH 391/539] FindLibXslt: also search libexslt and xsltproc merging some changes FindLibXslt.cmake from KDE Alex --- Modules/FindLibXslt.cmake | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Modules/FindLibXslt.cmake b/Modules/FindLibXslt.cmake index 462835a51e8..1f49c3bda31 100644 --- a/Modules/FindLibXslt.cmake +++ b/Modules/FindLibXslt.cmake @@ -5,6 +5,9 @@ # LIBXSLT_INCLUDE_DIR - the LibXslt include directory # LIBXSLT_LIBRARIES - Link these to LibXslt # LIBXSLT_DEFINITIONS - Compiler switches required for using LibXslt +# Additionally, the following two variables are set (but not required for using xslt): +# LIBXSLT_EXSLT_LIBRARIES - Link to these if you need to link against the exslt library +# LIBXSLT_XSLTPROC_EXECUTABLE - Contains the full path to the xsltproc executable if found #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -23,7 +26,7 @@ # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls FIND_PACKAGE(PkgConfig) -PKG_CHECK_MODULES(PC_LIBXSLT libxslt) +PKG_CHECK_MODULES(PC_LIBXSLT QUIET libxslt) SET(LIBXSLT_DEFINITIONS ${PC_LIBXSLT_CFLAGS_OTHER}) FIND_PATH(LIBXSLT_INCLUDE_DIR NAMES libxslt/xslt.h @@ -38,10 +41,22 @@ FIND_LIBRARY(LIBXSLT_LIBRARIES NAMES xslt libxslt ${PC_LIBXSLT_LIBRARY_DIRS} ) -# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if +FIND_LIBRARY(LIBXSLT_EXSLT_LIBRARY NAMES exslt libexslt + HINTS + ${PC_LIBXSLT_LIBDIR} + ${PC_LIBXSLT_LIBRARY_DIRS} + ) + +SET(LIBXSLT_EXSLT_LIBRARIES ${LIBXSLT_EXSLT_LIBRARY} ) + +FIND_PROGRAM(LIBXSLT_XSLTPROC_EXECUTABLE xsltproc) + +# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXslt DEFAULT_MSG LIBXSLT_LIBRARIES LIBXSLT_INCLUDE_DIR) -MARK_AS_ADVANCED(LIBXSLT_INCLUDE_DIR LIBXSLT_LIBRARIES) - +MARK_AS_ADVANCED(LIBXSLT_INCLUDE_DIR + LIBXSLT_LIBRARIES + LIBXSLT_EXSLT_LIBRARY + LIBXSLT_XSLTPROC_EXECUTABLE) From 2b0f8c7de0c922c98753a3a13d251306aabc9bdb Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 26 Oct 2011 00:01:05 -0400 Subject: [PATCH 392/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index b452f6df3bc..591df242099 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 25) +SET(KWSYS_DATE_STAMP_DAY 26) From 499c10457282f44d954c8a7385cbf9f8c82d1b08 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 26 Oct 2011 00:19:46 -0400 Subject: [PATCH 393/539] CTest: Clear custom vectors before populating (#12383) Important when calling ctest commands in a loop from a script. Each time Populate gets called, it uses the current definition of the variable. Without the clear, it was accumulating additional identical values each time through the loop. --- Source/cmCTest.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 702ba10addb..2a2cac9a1e9 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2526,6 +2526,8 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def, cmSystemTools::ExpandListArgument(dval, slist); std::vector::iterator it; + vec.clear(); + for ( it = slist.begin(); it != slist.end(); ++it ) { cmCTestLog(this, DEBUG, " -- " << it->c_str() << std::endl); From 76ecdd8d169fd2565466669875b5ed7e7c5c1963 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Wed, 26 Oct 2011 22:48:36 -0400 Subject: [PATCH 394/539] CTest: Look for CTestConfig.cmake in build dir first, then source dir Provide the ability to configure CTest with settings different from the ones available in the source tree by checking first if CTestConfig.cmake exists in the build tree. The motivation is to allow build system checking out external project to test and/or package them and submit the associated results to a different dashboard than the one specified (or not) in the source of the external project. For example, the build system of Slicer can checkout, build, test and package what I will call "extensions". These extensions can be developed by third parties who can test and submit to their own dashboard / project. When checked out by Slicer build system, the default dashboard can now be overwritten by adding a custom CTestConfig.cmake to the build directory. And if not overwritten, it would avoid to create CTestConfig.cmake within the source checkout of the extension. --- Source/cmCTest.cxx | 32 +++++++++++++++---- Tests/CMakeLists.txt | 29 +++++++++++++++++ .../CMakeLists.txt | 3 ++ .../CTestConfig.cmake | 7 ++++ .../test1.cmake.in | 17 ++++++++++ .../test2.cmake.in | 17 ++++++++++ 6 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 Tests/CTestTestConfigFileInBuildDir/CMakeLists.txt create mode 100644 Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake create mode 100644 Tests/CTestTestConfigFileInBuildDir/test1.cmake.in create mode 100644 Tests/CTestTestConfigFileInBuildDir/test2.cmake.in diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 702ba10addb..aa75453b669 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -655,10 +655,26 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) } cmMakefile* mf = command->GetMakefile(); - std::string fname = src_dir; - fname += "/CTestConfig.cmake"; - cmSystemTools::ConvertToUnixSlashes(fname); - if ( cmSystemTools::FileExists(fname.c_str()) ) + std::string fname; + + std::string src_dir_fname = src_dir; + src_dir_fname += "/CTestConfig.cmake"; + cmSystemTools::ConvertToUnixSlashes(src_dir_fname); + + std::string bld_dir_fname = bld_dir; + bld_dir_fname += "/CTestConfig.cmake"; + cmSystemTools::ConvertToUnixSlashes(bld_dir_fname); + + if ( cmSystemTools::FileExists(bld_dir_fname.c_str()) ) + { + fname = bld_dir_fname; + } + else if ( cmSystemTools::FileExists(src_dir_fname.c_str()) ) + { + fname = src_dir_fname; + } + + if ( !fname.empty() ) { cmCTestLog(this, OUTPUT, " Reading ctest configuration file: " << fname.c_str() << std::endl); @@ -674,8 +690,12 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) } else { - cmCTestLog(this, WARNING, "Cannot locate CTest configuration: " - << fname.c_str() << std::endl); + cmCTestLog(this, WARNING, + "Cannot locate CTest configuration: in BuildDirectory: " + << bld_dir_fname.c_str() << std::endl); + cmCTestLog(this, WARNING, + "Cannot locate CTest configuration: in SourceDirectory: " + << src_dir_fname.c_str() << std::endl); } this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime", diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 78db39d6fd6..21d1196c022 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1531,6 +1531,35 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ SET_TESTS_PROPERTIES(CTestTestUpload PROPERTIES PASS_REGULAR_EXPRESSION "Upload\\.xml") + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestConfigFileInBuildDir1 ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/testOut1.log" + ) + SET_TESTS_PROPERTIES(CTestTestConfigFileInBuildDir1 PROPERTIES DEPENDS CTestTestNoBuild + PASS_REGULAR_EXPRESSION + "Reading ctest configuration file: ${CMake_SOURCE_DIR}.Tests.CTestTestConfigFileInBuildDir.CTestConfig.cmake") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake" + @ONLY ESCAPE_QUOTES) + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake" + "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake" + @ONLY ESCAPE_QUOTES COPYONLY) + ADD_TEST(CTestTestConfigFileInBuildDir2 ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/testOut2.log" + ) + SET_TESTS_PROPERTIES(CTestTestConfigFileInBuildDir2 PROPERTIES DEPENDS CTestTestNoBuild + REQUIRED_FILES ${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake + PASS_REGULAR_EXPRESSION + "Reading ctest configuration file: ${CMake_BINARY_DIR}.Tests.CTestTestConfigFileInBuildDir2.CTestConfig.cmake") + # Use macro, not function so that build can still be driven by CMake 2.4. # After 2.6 is required, this could be a function without the extra 'set' # calls. diff --git a/Tests/CTestTestConfigFileInBuildDir/CMakeLists.txt b/Tests/CTestTestConfigFileInBuildDir/CMakeLists.txt new file mode 100644 index 00000000000..3c53e66237a --- /dev/null +++ b/Tests/CTestTestConfigFileInBuildDir/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(CTestTestConfigFileInBuildDir) +include(CTest) diff --git a/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake b/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake new file mode 100644 index 00000000000..d2c28f98cc4 --- /dev/null +++ b/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CTestTestConfigFileInBuildDir") +set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in new file mode 100644 index 00000000000..498cab280e2 --- /dev/null +++ b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in @@ -0,0 +1,17 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ConfigFileInBuildDir1") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir1") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in new file mode 100644 index 00000000000..d359f2d36ec --- /dev/null +++ b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in @@ -0,0 +1,17 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ConfigFileInBuildDir2") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir2") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) From 9a6257a40b8c915cf61d2d4e7f1f5a2e4b7b310a Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 27 Oct 2011 00:01:09 -0400 Subject: [PATCH 395/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 591df242099..1e7a177c18e 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 26) +SET(KWSYS_DATE_STAMP_DAY 27) From 30e4a5204fb067f28ae3bc31955f9b8fbc8a2643 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Wed, 26 Oct 2011 20:43:21 +0200 Subject: [PATCH 396/539] Tell people that link_directories() is not what they are searching for Judging from the questions I see on the #cmake IRC channel this is one of the most common pitfalls for people coming from other build systems, especially plain Makefiles. Finally put this into the documentation to stop people getting fooled into using this. Text by Brad King. --- Source/cmLinkDirectoriesCommand.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h index e5ff4f0f321..aa13589a397 100644 --- a/Source/cmLinkDirectoriesCommand.h +++ b/Source/cmLinkDirectoriesCommand.h @@ -65,7 +65,12 @@ class cmLinkDirectoriesCommand : public cmCommand "For historical reasons, relative paths given to this command are " "passed to the linker unchanged " "(unlike many CMake commands which interpret them relative to the " - "current source directory)." + "current source directory).\n" + "Note that this command is rarely necessary. Library locations " + "returned by find_package() and find_library() are absolute paths. " + "Pass these absolute library file paths directly to the " + "target_link_libraries() command. CMake will ensure the linker finds " + "them." ; } From 6a6f21412db4b34fdcc4ad4021ec12fa273b7aad Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 28 Oct 2011 00:01:03 -0400 Subject: [PATCH 397/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 1e7a177c18e..ed9dfce270e 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 27) +SET(KWSYS_DATE_STAMP_DAY 28) From ba5c6493d9a2ae1a24df725136395c36850de6f2 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 29 Oct 2011 00:01:10 -0400 Subject: [PATCH 398/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index ed9dfce270e..4b7e3f207b3 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 28) +SET(KWSYS_DATE_STAMP_DAY 29) From b1e9e55c6c56a07a7d8f4380bc5c16a1722e52ca Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 30 Oct 2011 00:01:13 -0400 Subject: [PATCH 399/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 4b7e3f207b3..4ee0f0b643d 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 29) +SET(KWSYS_DATE_STAMP_DAY 30) From e20c59ae5013affa5f80f5f9b76020bdcbd42f4d Mon Sep 17 00:00:00 2001 From: Eric NOULARD Date: Sun, 30 Oct 2011 20:13:20 +0100 Subject: [PATCH 400/539] CPackRPM support component specific variables for spec files This is a modified version of a user patch Inspired-By: informant --- Modules/CPackRPM.cmake | 39 ++++++++++++++++--- .../MyLibCPackConfig-IgnoreGroup.cmake.in | 1 + .../MyLibCPackConfig-OnePackPerGroup.cmake.in | 1 + 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 51c8eace247..36b86cfacac 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -4,7 +4,10 @@ # used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration # # However CPackRPM has specific features which are controlled by -# the specifics CPACK_RPM_XXX variables. +# the specifics CPACK_RPM_XXX variables. CPackRPM is a component aware +# generator so when CPACK_RPM_COMPONENT_INSTALL is ON some more +# CPACK_RPM__XXXX variables may be used in order +# to have component specific values. # Usually those vars correspond to RPM spec file entities, one may find # information about spec files here http://www.rpm.org/wiki/Docs. # You'll find a detailed usage of CPackRPM on the wiki: @@ -388,9 +391,33 @@ if(CPACK_RPM_PACKAGE_RELOCATABLE) endif(CPACK_SET_DESTDIR AND (NOT CPACK_SET_DESTDIR STREQUAL "I_ON")) endif(CPACK_RPM_PACKAGE_RELOCATABLE) -# check if additional fields for RPM spec header are given +# Check if additional fields for RPM spec header are given +# There may be some COMPONENT specific variables as well FOREACH(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV) - IF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) + IF(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}) + IF(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: using CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}}) + else() + IF(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER} not defined") + message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) + endif() + else() + IF(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) + endif() + + IF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) STRING(LENGTH ${_RPM_SPEC_HEADER} _PACKAGE_HEADER_STRLENGTH) MATH(EXPR _PACKAGE_HEADER_STRLENGTH "${_PACKAGE_HEADER_STRLENGTH} - 1") STRING(SUBSTRING ${_RPM_SPEC_HEADER} 1 ${_PACKAGE_HEADER_STRLENGTH} _PACKAGE_HEADER_TAIL) @@ -398,10 +425,10 @@ FOREACH(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLIC STRING(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) SET(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}") IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}") + MESSAGE("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") ENDIF(CPACK_RPM_PACKAGE_DEBUG) - SET(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}") - ENDIF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) + SET(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") +ENDIF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) ENDFOREACH(_RPM_SPEC_HEADER) # CPACK_RPM_SPEC_INSTALL_POST diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in index d82943f83c0..9444a14734b 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in @@ -7,6 +7,7 @@ endif(CPACK_GENERATOR MATCHES "ZIP") if(CPACK_GENERATOR MATCHES "RPM") set(CPACK_RPM_COMPONENT_INSTALL "ON") + set(CPACK_RPM_applications_PACKAGE_REQUIRES "mylib-libraries") endif(CPACK_GENERATOR MATCHES "RPM") if(CPACK_GENERATOR MATCHES "DEB") diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in index 1e1a410ab2e..2d251b36377 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in @@ -7,6 +7,7 @@ endif(CPACK_GENERATOR MATCHES "ZIP") if(CPACK_GENERATOR MATCHES "RPM") set(CPACK_RPM_COMPONENT_INSTALL "ON") + set(CPACK_RPM_Development_PACKAGE_REQUIRES "mylib-Runtime") endif(CPACK_GENERATOR MATCHES "RPM") if(CPACK_GENERATOR MATCHES "DEB") From 83b13a250c33bea555556eadc7a9cf9f3c55546b Mon Sep 17 00:00:00 2001 From: Eric NOULARD Date: Sun, 30 Oct 2011 22:34:18 +0100 Subject: [PATCH 401/539] Fix old reference to CMAKE_MAKE_PROGRAM inside CMAKE_BUILD_TOOL doc. --- Source/cmDocumentVariables.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index f4d4e7c5cb8..f46e1ce1f49 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -126,7 +126,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "This variable is set to the program that will be" " needed to build the output of CMake. If the " "generator selected was Visual Studio 6, the " - "CMAKE_MAKE_PROGRAM will be set to msdev, for " + "CMAKE_BUILD_TOOL will be set to msdev, for " "Unix makefiles it will be set to make or gmake, " "and for Visual Studio 7 it set to devenv. For " "Nmake Makefiles the value is nmake. This can be " From 07e88ae4499b632222367eb5b4308cac2a89718f Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 31 Oct 2011 00:01:12 -0400 Subject: [PATCH 402/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 4ee0f0b643d..6c5746429c7 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 30) +SET(KWSYS_DATE_STAMP_DAY 31) From 5e1c2f81a76943cce994f133fca71966aa35c1b4 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 1 Nov 2011 00:01:04 -0400 Subject: [PATCH 403/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 6c5746429c7..7ed070090b6 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 10) +SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 31) +SET(KWSYS_DATE_STAMP_DAY 01) From 13d19468d03bfea1b886c5473e8fcafa09cf2e3a Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 1 Nov 2011 10:48:12 -0400 Subject: [PATCH 404/539] KWSys: Address Intel compiler remarks CommandLineArguments.cxx: remark #181: argument is incompatible with corresponding format string conversion SystemInformation.cxx: remark #193: zero used for undefined preprocessing identifier "_WIN32" warning #177: variable "Regebx" was declared but never referenced SystemTools.cxx(375): remark #444: destructor for base class "std::vector" is not virtual class kwsysDeletingCharVector : private kwsys_stl::vector Author: Hans Johnson Change-Id: Ibc899c3ba14990158ef7bbabace4b435b22495c3 --- Source/kwsys/CommandLineArguments.cxx | 2 +- Source/kwsys/SystemInformation.cxx | 45 ++++++++++++--------------- Source/kwsys/SystemTools.cxx | 8 +++++ 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx index 9f43a47c8f5..ece88ae8924 100644 --- a/Source/kwsys/CommandLineArguments.cxx +++ b/Source/kwsys/CommandLineArguments.cxx @@ -592,7 +592,7 @@ void CommandLineArguments::GenerateHelp() // Create format for that string char format[80]; - sprintf(format, " %%-%ds ", static_cast(maxlen)); + sprintf(format, " %%-%us ", static_cast(maxlen)); maxlen += 4; // For the space before and after the option diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 9bc659e22a6..d49c0d73c1f 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -72,7 +72,7 @@ # include // int isdigit(int c); # include // extern int errno; # include -#elif __hpux +#elif defined( __hpux ) # include # include #endif @@ -1454,7 +1454,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed() { bool retrieved = false; -#if _WIN32 +#if defined(_WIN32) // First of all we check to see if the RDTSC (0x0F, 0x31) instruction is // supported. If not, we fallback to trying to read this value from the // registry: @@ -2389,7 +2389,7 @@ int SystemInformationImplementation::QueryMemory() this->AvailablePhysicalMemory = 0; #ifdef __CYGWIN__ return 0; -#elif _WIN32 +#elif defined(_WIN32) #if _MSC_VER < 1300 MEMORYSTATUS ms; unsigned long tv, tp, av, ap; @@ -2415,7 +2415,7 @@ int SystemInformationImplementation::QueryMemory() this->AvailableVirtualMemory = av>>10>>10; this->AvailablePhysicalMemory = ap>>10>>10; return 1; -#elif __linux +#elif defined(__linux) unsigned long tv=0; unsigned long tp=0; unsigned long av=0; @@ -2532,7 +2532,7 @@ int SystemInformationImplementation::QueryMemory() } fclose( fd ); return 1; -#elif __hpux +#elif defined(__hpux) unsigned long tv=0; unsigned long tp=0; unsigned long av=0; @@ -2639,7 +2639,7 @@ LongLong SystemInformationImplementation::GetCyclesDifference (DELAY_FUNC DelayF /** Compute the delay overhead */ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS) { -#if _WIN32 +#if defined(_WIN32) LARGE_INTEGER Frequency, StartCounter, EndCounter; __int64 x; @@ -2664,10 +2664,19 @@ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS) /** Return the number of logical CPU per physical CPUs Works only for windows */ unsigned char SystemInformationImplementation::LogicalCPUPerPhysicalCPU(void) { +#ifdef __APPLE__ + size_t len = 4; + int cores_per_package = 0; + int err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, &len, NULL, 0); + if (err != 0) + { + return 1; // That name was not found, default to 1 + } + return static_cast(cores_per_package); +#else unsigned int Regebx = 0; - #if USE_ASM_INSTRUCTIONS - if (!this->IsHyperThreadingSupported()) + if (!this->IsHyperThreadingSupported()) { return static_cast(1); // HT not supported } @@ -2678,22 +2687,8 @@ unsigned char SystemInformationImplementation::LogicalCPUPerPhysicalCPU(void) mov Regebx, ebx } #endif - -#ifdef __APPLE__ - size_t len = 4; - int cores_per_package = 0; - int err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, &len, NULL, 0); - if (err != 0) - { - return 1; // That name was not found, default to 1 - } - else - { - return static_cast(cores_per_package); - } -#endif - return static_cast ((Regebx & NUM_LOGICAL_BITS) >> 16); +#endif } @@ -2769,7 +2764,7 @@ unsigned char SystemInformationImplementation::GetAPICId() /** Count the number of CPUs. Works only on windows. */ int SystemInformationImplementation::CPUCount() { -#if _WIN32 +#if defined(_WIN32) unsigned char StatusFlag = 0; SYSTEM_INFO info; @@ -3359,7 +3354,7 @@ bool SystemInformationImplementation::QueryQNXProcessor() /** Query the operating system information */ bool SystemInformationImplementation::QueryOSInformation() { -#if _WIN32 +#if defined(_WIN32) this->OSName = "Windows"; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 695949a34bc..1bf19c057a1 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -371,6 +371,10 @@ bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result) } } +#ifdef INTEL_COMPILER +#pragma warning disable 444 +#endif + class kwsysDeletingCharVector : public kwsys_stl::vector { public: @@ -399,6 +403,10 @@ bool SystemTools::PutEnv(const char* value) return ret == 0; } +#ifdef INTEL_COMPILER +#pragma warning restore 444 +#endif + const char* SystemTools::GetExecutableExtension() { From 9cfc920973b6e479e3ba30e6b89e26ddea4d892f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 28 Oct 2011 17:31:30 +0100 Subject: [PATCH 405/539] Match fixup_qt4_executable with documentation. --- Modules/DeployQt4.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake index bdf83604a62..3e20d345756 100644 --- a/Modules/DeployQt4.cmake +++ b/Modules/DeployQt4.cmake @@ -56,7 +56,7 @@ # (or ) relative to and store the result in # . See documentation of INSTALL_QT4_PLUGIN_PATH. # -# INSTALL_QT4_EXECUTABLE( [ ]) +# INSTALL_QT4_EXECUTABLE( [ ]) # Installs Qt plugins, writes a Qt configuration file (if needed) and fixes up # a Qt4 executable using BundleUtilities so it is standalone and can be # drag-and-drop copied to another machine as long as all of the system @@ -106,7 +106,8 @@ function(resolve_qt4_paths paths_var) set(${paths_var} ${paths_resolved} PARENT_SCOPE) endfunction() -function(fixup_qt4_executable executable qtplugins) +function(fixup_qt4_executable executable) + set(qtplugins ${ARGV1}) set(libs ${ARGV2}) set(dirs ${ARGV3}) set(plugins_dir ${ARGV4}) From 4571ea6e4d0ecbf25ac7cfa63715cc931f0f17d0 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 28 Oct 2011 17:32:28 +0100 Subject: [PATCH 406/539] Don't resolve directories; are never relative. --- Modules/DeployQt4.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake index 3e20d345756..ef8dd1f1ab4 100644 --- a/Modules/DeployQt4.cmake +++ b/Modules/DeployQt4.cmake @@ -151,7 +151,6 @@ function(fixup_qt4_executable executable) endforeach() resolve_qt4_paths(libs "${executable_path}") - resolve_qt4_paths(dirs "${executable_path}") if(write_qt_conf) set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}") @@ -265,7 +264,6 @@ function(install_qt4_executable executable) endforeach() resolve_qt4_paths(libs) - resolve_qt4_paths(dirs) install(CODE " INCLUDE( \"${DeployQt4_cmake_dir}/DeployQt4.cmake\" ) From 467ee368402b73756ac1b662b86cd0eee95bbe07 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 28 Oct 2011 17:33:21 +0100 Subject: [PATCH 407/539] Check plugin variables are defined before warning. --- Modules/DeployQt4.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake index ef8dd1f1ab4..4bf1b6c4ba6 100644 --- a/Modules/DeployQt4.cmake +++ b/Modules/DeployQt4.cmake @@ -225,9 +225,11 @@ function(install_qt4_plugin plugin executable copy installed_plugin_path_var) else() string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var) endif() - set(plugin_release "${${plugin_var}_RELEASE}") - set(plugin_debug "${${plugin_var}_DEBUG}") - if(NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}") + set(plugin_release_var "${plugin_var}_RELEASE") + set(plugin_debug_var "${plugin_var}_DEBUG") + set(plugin_release "${${plugin_release_var}}") + set(plugin_debug "${${plugin_debug_var}}") + if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}") message(WARNING "Qt plugin \"${plugin}\" not recognized or found.") endif() install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}" "Release|RelWithDebInfo|MinSizeRel") From d4afce1ddd0a5f8c5bdc5b59d24344d61016aa99 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Wed, 2 Nov 2011 00:01:05 -0400 Subject: [PATCH 408/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 7ed070090b6..2598efd5ad0 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 01) +SET(KWSYS_DATE_STAMP_DAY 02) From 22bf096474dbd819e4a10cc3b45fa54ba50213d0 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 3 Nov 2011 00:01:05 -0400 Subject: [PATCH 409/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 2598efd5ad0..dba5d4a5eb6 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 02) +SET(KWSYS_DATE_STAMP_DAY 03) From ae09bab3d6c6c00710df9e2539a3129896ee9513 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Fri, 4 Nov 2011 00:01:05 -0400 Subject: [PATCH 410/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index dba5d4a5eb6..36d380c5e7c 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 03) +SET(KWSYS_DATE_STAMP_DAY 04) From 0727f38f71aa1583fd4724955ebe6001dfabd399 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sat, 5 Nov 2011 00:01:10 -0400 Subject: [PATCH 411/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 36d380c5e7c..1095e5c098a 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 04) +SET(KWSYS_DATE_STAMP_DAY 05) From fce8e81895454c31273921baec2cc6acd9e962a9 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Sun, 6 Nov 2011 00:01:04 -0400 Subject: [PATCH 412/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 1095e5c098a..b4e55d468db 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 05) +SET(KWSYS_DATE_STAMP_DAY 06) From 3de9669e1bda83e9960d224aa466d476e58b2ba7 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 7 Nov 2011 00:01:06 -0500 Subject: [PATCH 413/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index b4e55d468db..7d3eeb45d3d 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 06) +SET(KWSYS_DATE_STAMP_DAY 07) From 7fe3484f20652169b57b131d6c51a0a0e7eb0a8c Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Tue, 8 Nov 2011 00:01:13 -0500 Subject: [PATCH 414/539] KWSys Nightly Date Stamp --- Source/kwsys/kwsysDateStamp.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 7d3eeb45d3d..38b97192268 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 07) +SET(KWSYS_DATE_STAMP_DAY 08) From a0134a671396d30639681ceedc97a8a28b3dc5c4 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 10 Apr 2011 11:48:10 +0200 Subject: [PATCH 415/539] Add SystemTools::Trimmed(). --- Source/kwsys/SystemTools.cxx | 25 +++++++++++++++++++++++++ Source/kwsys/SystemTools.hxx.in | 5 +++++ 2 files changed, 30 insertions(+) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 1bf19c057a1..da07541e93a 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1195,6 +1195,31 @@ kwsys_stl::string SystemTools::UpperCase(const kwsys_stl::string& s) return n; } +// Returns a string that has whitespace removed from the start and the end. +kwsys_stl::string SystemTools::Trimmed(const kwsys_stl::string& s) +{ + kwsys_stl::string::const_iterator i = s.begin(); + while(i != s.end() && *i == ' ') + ++i; + kwsys_stl::string::const_iterator start = i; + + kwsys_stl::string::const_iterator stop = i; + while(i != s.end()) + { + if(*i != ' ') + stop = i; + ++i; + } + + if(start != stop) + ++stop; + + kwsys_stl::string n; + n.resize(stop - start); + copy(start, stop, n.begin()); + return n; +} + // Count char in string size_t SystemTools::CountChar(const char* str, char c) { diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 04f19784269..9ba4ecd82dc 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -128,6 +128,11 @@ public: */ static kwsys_stl::string UpperCase(const kwsys_stl::string&); + /** + * Returns a string that has whitespace removed from the start and the end. + */ + static kwsys_stl::string Trimmed(const kwsys_stl::string& s); + /** * Count char in string */ From 9ed2c2024957ddd21b805614a353dd3c7a8387db Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 20 Mar 2011 17:50:07 +0100 Subject: [PATCH 416/539] Ninja: Add beginning of the Ninja generator. Only virtual methods are implemented by calling their respective super method and printing some debug information on stdout. The documentation function are implemented and the generator is registered so that it appears in --help and --help-full. A module is added to find ninja on the system. --- Modules/CMakeNinjaFindMake.cmake | 17 ++ Source/CMakeLists.txt | 3 + Source/cmGlobalNinjaGenerator.cxx | 258 ++++++++++++++++++++++++++++++ Source/cmGlobalNinjaGenerator.h | 126 +++++++++++++++ Source/cmLocalNinjaGenerator.cxx | 224 ++++++++++++++++++++++++++ Source/cmLocalNinjaGenerator.h | 89 +++++++++++ Source/cmake.cxx | 16 ++ 7 files changed, 733 insertions(+) create mode 100644 Modules/CMakeNinjaFindMake.cmake create mode 100644 Source/cmGlobalNinjaGenerator.cxx create mode 100644 Source/cmGlobalNinjaGenerator.h create mode 100644 Source/cmLocalNinjaGenerator.cxx create mode 100644 Source/cmLocalNinjaGenerator.h diff --git a/Modules/CMakeNinjaFindMake.cmake b/Modules/CMakeNinjaFindMake.cmake new file mode 100644 index 00000000000..f15c3e0d44b --- /dev/null +++ b/Modules/CMakeNinjaFindMake.cmake @@ -0,0 +1,17 @@ + +#============================================================================= +# Copyright 2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +FIND_PROGRAM(CMAKE_MAKE_PROGRAM ninja + DOC "Program used to build from build.ninja files.") +MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ba41d98c465..a31ab4bb664 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -186,6 +186,8 @@ SET(SRCS cmGlobalGenerator.h cmGlobalUnixMakefileGenerator3.cxx cmGlobalUnixMakefileGenerator3.h + cmGlobalNinjaGenerator.cxx + cmGlobalNinjaGenerator.h cmGraphAdjacencyList.h cmGraphVizWriter.cxx cmGraphVizWriter.h @@ -206,6 +208,7 @@ SET(SRCS cmLocalGenerator.cxx cmLocalGenerator.h cmLocalUnixMakefileGenerator3.cxx + cmLocalNinjaGenerator.cxx cmMakeDepend.cxx cmMakeDepend.h cmMakefile.cxx diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx new file mode 100644 index 00000000000..e3eed6ee263 --- /dev/null +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -0,0 +1,258 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmGlobalNinjaGenerator.h" +#include "cmLocalNinjaGenerator.h" +#include "cmMakefile.h" + +cmGlobalNinjaGenerator::cmGlobalNinjaGenerator() + : cmGlobalGenerator() +{ + // // Ninja is not ported to non-Unix OS yet. + // this->ForceUnixPaths = true; + this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake"; +} + +//---------------------------------------------------------------------------- +// Virtual public methods. + +cmLocalGenerator* cmGlobalNinjaGenerator::CreateLocalGenerator() +{ + cmLocalGenerator* lg = new cmLocalNinjaGenerator; + lg->SetGlobalGenerator(this); + return lg; +} + +void cmGlobalNinjaGenerator +::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates build.ninja files."; + entry.Full = + "A hierarchy of build.ninja files is generated into the build tree. Any" + "version of the ninja program can build the project through the " + "\"all\" target. An \"install\" target is also provided."; +} + +// Implemented by: +// cmGlobalVisualStudio7Generator +// cmGlobalVisualStudio8Generator +// Used in: +// Source/cmake.cxx +void cmGlobalNinjaGenerator::Configure() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + cmGlobalGenerator::Configure(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Implemented in all cmGlobaleGenerator sub-classes. +// Used in: +// Source/cmLocalGenerator.cxx +// Source/cmake.cxx +void cmGlobalNinjaGenerator::Generate() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + cmGlobalGenerator::Generate(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Implemented in all cmGlobaleGenerator sub-classes. +// Used in: +// Source/cmMakefile.cxx: +void cmGlobalNinjaGenerator +::EnableLanguage(std::vectorconst& languages, + cmMakefile *mf, + bool optional) +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: languages: "; + for (std::vector::const_iterator l = languages.begin(); + l != languages.end(); + ++l) + std::cout << "'" << *l << "', "; + std::cout << std::endl; + std::cout << "DEBUG NINJA: ARG: cmMakefile: " << mf + << " project: '" << mf->GetProjectName() << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: optional: " << optional << std::endl; + + cmGlobalGenerator::EnableLanguage(languages, mf, optional); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Not implemented in none of cmLocalGenerator sub-classes. +// Used nowhere. +void cmGlobalNinjaGenerator +::EnableLanguagesFromGenerator(cmGlobalGenerator* gen, + cmMakefile* mf) +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: cmGlobaleGenerator: " << gen + << " name: '" << gen->GetName() << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: mf: " << mf + << " project: '" << mf->GetProjectName() << "'" << std::endl; + + cmGlobalGenerator::EnableLanguagesFromGenerator(gen, mf); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Not implemented in none of cmLocalGenerator sub-classes. +// Used in: +// Source/cmMakefile.cxx +int cmGlobalNinjaGenerator::TryCompile(const char* srcdir, + const char* bindir, + const char* projectName, + const char* targetName, + bool fast, + std::string* output, + cmMakefile* mf) +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: srcdir: '" << srcdir << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: bindir: '" << bindir << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: projectName: '" << projectName << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: fast: '" << fast << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: output: '" << *output << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: mf: " << mf + << " project: '" << mf->GetProjectName() << "'" << std::endl; + + int ret = cmGlobalGenerator::TryCompile(srcdir, + bindir, + projectName, + targetName, + fast, + output, + mf); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + return ret; +} + +// Implemented by: +// cmGlobalUnixMakefileGenerator3 +// cmGlobalVisualStudio10Generator +// cmGlobalVisualStudio6Generator +// cmGlobalVisualStudio7Generator +// cmGlobalXCodeGenerator +// Called by: +// cmGlobalGenerator::Build() +std::string cmGlobalNinjaGenerator +::GenerateBuildCommand(const char* makeProgram, + const char* projectName, + const char* additionalOptions, + const char* targetName, + const char* config, + bool ignoreErrors, + bool fast) +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: makeProgram: '" << makeProgram << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: projectName: '" << projectName << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: additionalOptions: '" << (additionalOptions ? additionalOptions : "NULL") << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: targetName: '" << targetName << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: ignoreErrors: '" << ignoreErrors << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: fast: '" << fast << "'" << std::endl; + + std::string ret = cmGlobalGenerator::GenerateBuildCommand(makeProgram, + projectName, + additionalOptions, + targetName, + config, + ignoreErrors, + fast); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + return ret; +} + +// Not implemented in UnixMakefile generator. +void cmGlobalNinjaGenerator +::AppendDirectoryForConfig(const char* prefix, + const char* config, + const char* suffix, + std::string& dir) +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: prefix: '" << prefix << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: config: '" << config << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: suffix: '" << suffix << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: dir: '" << dir << "'" << std::endl; + + cmGlobalGenerator::AppendDirectoryForConfig(prefix, + config, + suffix, + dir); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +//---------------------------------------------------------------------------- +// Virtual protected methods. + +// Not implemented in UnixMakefile generator. +void cmGlobalNinjaGenerator::GetTargetSets(TargetDependSet& projectTargets, + TargetDependSet& originalTargets, + cmLocalGenerator* root, + GeneratorVector const& generators) +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + + cmGlobalGenerator::GetTargetSets(projectTargets, + originalTargets, + root, + generators); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Not implemented in UnixMakefile generator. +bool cmGlobalNinjaGenerator::IsRootOnlyTarget(cmTarget* target) +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: target: " << target + << " name: '" << target->GetName() << "'" + << " type: '" << cmTarget::TargetTypeNames(target->GetType()) << "'" + << std::endl; + + bool ret = cmGlobalGenerator::IsRootOnlyTarget(target); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + return ret; +} + +// Not implemented in UnixMakefile generator. +bool cmGlobalNinjaGenerator::ComputeTargetDepends() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + bool ret = cmGlobalGenerator::ComputeTargetDepends(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + return ret; +} + +// Not implemented in UnixMakefile generator. +const char* cmGlobalNinjaGenerator::GetPredefinedTargetsFolder() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + const char* ret = cmGlobalGenerator::GetPredefinedTargetsFolder(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + return ret; +} + +// Not implemented in UnixMakefile generator. +bool cmGlobalNinjaGenerator::UseFolderProperty() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + bool ret = cmGlobalGenerator::UseFolderProperty(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + return ret; +} diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h new file mode 100644 index 00000000000..ede9a8bcc76 --- /dev/null +++ b/Source/cmGlobalNinjaGenerator.h @@ -0,0 +1,126 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmGlobalNinjaGenerator_h +# define cmGlobalNinjaGenerator_h + +# include "cmGlobalGenerator.h" + +class cmLocalGenerator; + +/** + * \class cmGlobalNinjaGenerator + * \brief Write a build.ninja file. + * + */ +class cmGlobalNinjaGenerator : public cmGlobalGenerator +{ +public: + /// Default constructor. + cmGlobalNinjaGenerator(); + + /// Convenience method for creating an instance of this class. + static cmGlobalGenerator* New() { + return new cmGlobalNinjaGenerator; } + + /// Destructor. + virtual ~cmGlobalNinjaGenerator() { } + + /// Overloaded methods. @see cmGlobalGenerator::CreateLocalGenerator() + virtual cmLocalGenerator* CreateLocalGenerator(); + + /// Overloaded methods. @see cmGlobalGenerator::GetName(). + virtual const char* GetName() const { + return cmGlobalNinjaGenerator::GetActualName(); } + + /// @return the name of this generator. + static const char* GetActualName() { return "Ninja (Experimental)"; } + + /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + /// Overloaded methods. @see cmGlobalGenerator::Configure() + virtual void Configure(); + + /// Overloaded methods. @see cmGlobalGenerator::Gonfigure() + virtual void Generate(); + + /// Overloaded methods. @see cmGlobalGenerator::EnableLanguage() + virtual void EnableLanguage(std::vectorconst& languages, + cmMakefile* mf, + bool optional); + + /// Overloaded methods. @see cmGlobalGenerator::EnableLanguagesFromGenerator() + virtual void EnableLanguagesFromGenerator(cmGlobalGenerator* gen, + cmMakefile* mf); + + /// Overloaded methods. @see cmGlobalGenerator::TryCompile() + virtual int TryCompile(const char* srcdir, + const char* bindir, + const char* projectName, + const char* targetName, + bool fast, std::string* output, + cmMakefile* mf); + + /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand() + virtual std::string GenerateBuildCommand(const char* makeProgram, + const char* projectName, + const char* additionalOptions, + const char* targetName, + const char* config, + bool ignoreErrors, + bool fast); + + /// Overloaded methods. + /// @see cmGlobalGenerator::AppendDirectoryForConfig() + virtual void AppendDirectoryForConfig(const char* prefix, + const char* config, + const char* suffix, + std::string& dir); + + // Setup target names + virtual const char* GetAllTargetName() const { return "all"; } + virtual const char* GetInstallTargetName() const { return "install"; } + virtual const char* GetInstallLocalTargetName() const { return "install/local"; } + virtual const char* GetInstallStripTargetName() const { return "install/strip"; } + virtual const char* GetPreinstallTargetName() const { return "preinstall"; } + virtual const char* GetTestTargetName() const { return "test"; } + virtual const char* GetPackageTargetName() const { return "package"; } + virtual const char* GetPackageSourceTargetName() const { return "package_source"; } + virtual const char* GetEditCacheTargetName() const { return "edit_cache"; } + virtual const char* GetRebuildCacheTargetName() const { return "rebuild_cache"; } + virtual const char* GetCleanTargetName() const { return "clean"; } + +protected: + + /// Overloaded methods. @see cmGlobalGenerator::GetTargetSets() + virtual void GetTargetSets(TargetDependSet& projectTargets, + TargetDependSet& originalTargets, + cmLocalGenerator* root, + GeneratorVector const& generators); + /// Overloaded methods. @see cmGlobalGenerator::IsRootOnlyTarget() + virtual bool IsRootOnlyTarget(cmTarget* target); + + /// Overloaded methods. @see cmGlobalGenerator::ComputeTargetDepends() + virtual bool ComputeTargetDepends(); + + /// Overloaded methods. + /// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() + virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { return true; } + + /// Overloaded methods. @see cmGlobalGenerator::GetPredefinedTargetsFolder() + virtual const char* GetPredefinedTargetsFolder(); + + /// Overloaded methods. @see cmGlobalGenerator::UseFolderProperty() + virtual bool UseFolderProperty(); +}; + +#endif // ! cmGlobalNinjaGenerator_h diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx new file mode 100644 index 00000000000..9867fc0c699 --- /dev/null +++ b/Source/cmLocalNinjaGenerator.cxx @@ -0,0 +1,224 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmLocalNinjaGenerator.h" +#include "cmMakefile.h" + +cmLocalNinjaGenerator::cmLocalNinjaGenerator() + : cmLocalGenerator() +{ + // TODO(Nicolas Despres): Maybe I should set this one to true?? + this->IsMakefileGenerator = false; +} + +//---------------------------------------------------------------------------- +// Virtual public methods. + +cmLocalNinjaGenerator::~cmLocalNinjaGenerator() +{ +} + +void cmLocalNinjaGenerator::Generate() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + cmLocalGenerator::Generate(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Implemented in: +// cmLocalUnixMakefileGenerator3. +// Used in: +// Source/cmMakefile.cxx +// Source/cmGlobalGenerator.cxx +void cmLocalNinjaGenerator::Configure() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + cmLocalGenerator::Configure(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Not implemented in none of cmLocalGenerator sub-classes. +void cmLocalNinjaGenerator::TraceDependencies() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + cmLocalGenerator::TraceDependencies(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Implemented only in some VisualStudio local generator. +void cmLocalNinjaGenerator::AddHelperCommands() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + cmLocalGenerator::AddHelperCommands(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Implemented only in some VisualStudio local generator. +void cmLocalNinjaGenerator::ConfigureFinalPass() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + cmLocalGenerator::ConfigureFinalPass(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Not implemented in none of cmLocalGenerator sub-classes. +void cmLocalNinjaGenerator::GenerateInstallRules() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + cmLocalGenerator::GenerateInstallRules(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Not implemented in none of cmLocalGenerator sub-classes. +void cmLocalNinjaGenerator::GenerateTestFiles() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + cmLocalGenerator::GenerateTestFiles(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Not implemented in none of cmLocalGenerator sub-classes. +void cmLocalNinjaGenerator::GenerateTargetManifest() +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + cmLocalGenerator::GenerateTargetManifest(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Implemented only in UnixMakefile local generator. +// Used in: +// Source/cmMakefileExecutableTargetGenerator.cxx +// Source/cmMakefileLibraryTargetGenerator.cxx +// Source/cmMakefileTargetGenerator.cxx +void cmLocalNinjaGenerator::AppendFlags(std::string& flags, + const char* newFlags) +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: flags: '" << flags << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: newFlags: '" << newFlags << "'" << std::endl; + + cmLocalGenerator::AppendFlags(flags, newFlags); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Implemented only in UnixMakefile local generator. +// Used in: +// Source/cmake.cxx +void cmLocalNinjaGenerator::ClearDependencies(cmMakefile* mf, + bool verbose) +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: cmMakefile: " << mf + << " project: '" << mf->GetProjectName() << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: verbose: " << verbose << std::endl; + + cmLocalGenerator::ClearDependencies(mf, verbose); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Implemented only in UnixMakefile local generator. +// Used in: +// Source/cmake.cxx +bool cmLocalNinjaGenerator::UpdateDependencies(const char* tgtInfo, + bool verbose, + bool color) +{ + std::cout << "DEBUG NINJA: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: tgtInfo: '" << tgtInfo << "'" << std::endl; + std::cout << "DEBUG NINJA: ARG: verbose: " << verbose << std::endl; + std::cout << "DEBUG NINJA: ARG: color: " << color << std::endl; + + bool ret = cmLocalGenerator::UpdateDependencies(tgtInfo, verbose, color); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + return ret; +} + +// Implemented in almost all cmLocalGenerator sub-classes. +// Used in: +// Source/cmTarget.cxx: +void cmLocalNinjaGenerator +::GetTargetObjectFileDirectories(cmTarget* target, + std::vector& dirs) +{ + std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: target: " << target + << " name: '" << target->GetName() << "'" + << " type: '" << cmTarget::TargetTypeNames(target->GetType()) << "'" + << std::endl; + std::cout << "DEBUG NINJA: ARG: dirs: "; + for (std::vector::const_iterator d = dirs.begin(); + d != dirs.end(); + ++d) + std::cout << "'" << *d << "', "; + std::cout << std::endl; + + cmLocalGenerator::GetTargetObjectFileDirectories(target, dirs); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Implemented and used in almost all cmLocalGenerator sub-classes. +std::string cmLocalNinjaGenerator +::GetTargetDirectory(cmTarget const& target) const +{ + std::cout << "DEBUG NINJA: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: target: " + << " name: '" << target.GetName() << "'" + << " type: '" << cmTarget::TargetTypeNames(target.GetType()) << "'" + << std::endl; + + std::string ret = cmLocalGenerator::GetTargetDirectory(target); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + return ret; +} + +//---------------------------------------------------------------------------- +// Virtual protected methods. + +// Not implemented in none of cmLocalGenerator sub-classes. +// Used in: +// Source/cmLocalGenerator.cxx +// Source/cmMakefileExecutableTargetGenerator.cxx +// Source/cmMakefileLibraryTargetGenerator.cxx +void cmLocalNinjaGenerator::OutputLinkLibraries(std::ostream& fout, + cmTarget& tgt, + bool relink) +{ + std::cout << "DEBUG NINJA: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: tgt: " + << " name: '" << tgt.GetName() << "'" + << " type: '" << cmTarget::TargetTypeNames(tgt.GetType()) << "'" + << std::endl; + std::cout << "DEBUG NINJA: ARG: relink: '" << relink << "'" << std::endl; + + cmLocalGenerator::OutputLinkLibraries(fout, tgt, relink); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; +} + +// Implemented only in cmLocalVisualStudio6Generator. +// Used in: +// Source/cmLocalGenerator.cxx +// Source/cmLocalVisualStudio6Generator.cxx +bool cmLocalNinjaGenerator::CheckDefinition(std::string const& define) const +{ + std::cout << "DEBUG NINJA: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: ARG: define: '" << define << "'" << std::endl; + + bool ret = cmLocalGenerator::CheckDefinition(define); + + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + return ret; +} diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h new file mode 100644 index 00000000000..7e8ca4fa58d --- /dev/null +++ b/Source/cmLocalNinjaGenerator.h @@ -0,0 +1,89 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmLocalNinjaGenerator_h +# define cmLocalNinjaGenerator_h + +# include "cmLocalGenerator.h" + +/** + * \class cmLocalNinjaGenerator + * \brief Write a local build.ninja file. + * + * cmLocalNinjaGenerator produces a local build.ninja file from its + * member Makefile. + */ +class cmLocalNinjaGenerator : public cmLocalGenerator +{ +public: + /// Default constructor. + cmLocalNinjaGenerator(); + + /// Destructor. + virtual ~cmLocalNinjaGenerator(); + + /// Overloaded methods. @see cmLocalGenerator::Generate() + virtual void Generate(); + + /// Overloaded methods. @see cmLocalGenerator::Configure() + virtual void Configure(); + + /// Overloaded methods. @see cmLocalGenerator::TraceDependencies() + virtual void TraceDependencies(); + + /// Overloaded methods. @see cmLocalGenerator::AddHelperCommands() + virtual void AddHelperCommands(); + + /// Overloaded methods. @see cmLocalGenerator::ConfigureFinalPass() + virtual void ConfigureFinalPass(); + + /// Overloaded methods. @see cmLocalGenerator::GenerateInstallRules() + virtual void GenerateInstallRules(); + + /// Overloaded methods. @see cmLocalGenerator::GenerateTestFiles() + virtual void GenerateTestFiles(); + + /// Overloaded methods. @see cmLocalGenerator::GenerateTargetManifest() + virtual void GenerateTargetManifest(); + + /// Overloaded methods. @see cmLocalGenerator::AppendFlags() + virtual void AppendFlags(std::string& flags, const char* newFlags); + + /// Overloaded methods. @see cmLocalGenerator::ClearDependencies() + virtual void ClearDependencies(cmMakefile* mf, bool verbose); + + /// Overloaded methods. @see cmLocalGenerator::UpdateDependencies() + virtual bool UpdateDependencies(const char* tgtInfo, + bool verbose, + bool color); + + /// Overloaded methods. + /// @see cmLocalGenerator::GetTargetObjectFileDirectories() + /// Get the directories into which the .o files will go for this target. + virtual void + GetTargetObjectFileDirectories(cmTarget* target, + std::vector& dirs); + + /// Overloaded methods. @see cmLocalGenerator::GetTargetDirectory() + virtual std::string GetTargetDirectory(cmTarget const& target) const; + +protected: + + /// Overloaded methods. @see cmLocalGenerator::OutputLinkLibraries() + virtual void OutputLinkLibraries(std::ostream& fout, + cmTarget& tgt, + bool relink); + + /// Overloaded methods. @see cmLocalGenerator::CheckDefinition() + virtual bool CheckDefinition(std::string const& define) const; +}; + +#endif // ! cmLocalNinjaGenerator_h diff --git a/Source/cmake.cxx b/Source/cmake.cxx index d691f46dc25..2643891178d 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -51,6 +51,14 @@ # define CMAKE_USE_ECLIPSE #endif +// Only build Ninja generator on non-windows platforms (until Ninja is ported +// to Windows) and when not bootstrapping cmake. +#if !defined(_WIN32) +# if defined(CMAKE_BUILD_WITH_CMAKE) +# define CMAKE_USE_NINJA +# endif +#endif + #if defined(__MINGW32__) && !defined(CMAKE_BUILD_WITH_CMAKE) # define CMAKE_BOOT_MINGW #endif @@ -84,6 +92,10 @@ #endif #include "cmGlobalUnixMakefileGenerator3.h" +#ifdef CMAKE_USE_NINJA +# include "cmGlobalNinjaGenerator.h" +#endif + #if defined(CMAKE_HAVE_VS_GENERATORS) #include "cmCallVisualStudioMacro.h" #endif @@ -2614,6 +2626,10 @@ void cmake::AddDefaultGenerators() #endif this->Generators[cmGlobalUnixMakefileGenerator3::GetActualName()] = &cmGlobalUnixMakefileGenerator3::New; +#ifdef CMAKE_USE_NINJA + this->Generators[cmGlobalNinjaGenerator::GetActualName()] = + &cmGlobalNinjaGenerator::New; +#endif #ifdef CMAKE_USE_XCODE this->Generators[cmGlobalXCodeGenerator::GetActualName()] = &cmGlobalXCodeGenerator::New; From 371d05b1385949e606fcbffed4b6c5a9790293d2 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Wed, 23 Mar 2011 12:20:39 +0100 Subject: [PATCH 417/539] Ninja: Configure and build an helloworld program. With this patch cmake with the Ninja generator is able to configure and build a simple helloworld program. Many targets are missing: all, install, clean, ... Basically there is only the executable target. The -rdynamic option is missing too. Most of the flags are not handled yet. All dependencies are not covered yet. Specially dependencies that triggers re-configuration. --- Source/CMakeLists.txt | 6 + Source/cmGlobalNinjaGenerator.cxx | 362 +++++++++++++++++++- Source/cmGlobalNinjaGenerator.h | 115 +++++++ Source/cmLocalNinjaGenerator.cxx | 143 +++++++- Source/cmLocalNinjaGenerator.h | 30 ++ Source/cmNinjaExecutableTargetGenerator.cxx | 290 ++++++++++++++++ Source/cmNinjaExecutableTargetGenerator.h | 48 +++ Source/cmNinjaTargetGenerator.cxx | 81 +++++ Source/cmNinjaTargetGenerator.h | 67 ++++ Source/cmNinjaTypes.h | 18 + 10 files changed, 1144 insertions(+), 16 deletions(-) create mode 100644 Source/cmNinjaExecutableTargetGenerator.cxx create mode 100644 Source/cmNinjaExecutableTargetGenerator.h create mode 100644 Source/cmNinjaTargetGenerator.cxx create mode 100644 Source/cmNinjaTargetGenerator.h create mode 100644 Source/cmNinjaTypes.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index a31ab4bb664..4f23118d681 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -188,6 +188,7 @@ SET(SRCS cmGlobalUnixMakefileGenerator3.h cmGlobalNinjaGenerator.cxx cmGlobalNinjaGenerator.h + cmNinjaTypes.h cmGraphAdjacencyList.h cmGraphVizWriter.cxx cmGraphVizWriter.h @@ -209,6 +210,11 @@ SET(SRCS cmLocalGenerator.h cmLocalUnixMakefileGenerator3.cxx cmLocalNinjaGenerator.cxx + cmLocalNinjaGenerator.h + cmNinjaTargetGenerator.cxx + cmNinjaTargetGenerator.h + cmNinjaExecutableTargetGenerator.cxx + cmNinjaExecutableTargetGenerator.h cmMakeDepend.cxx cmMakeDepend.h cmMakefile.cxx diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index e3eed6ee263..f11dc494a4b 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -12,9 +12,254 @@ #include "cmGlobalNinjaGenerator.h" #include "cmLocalNinjaGenerator.h" #include "cmMakefile.h" +#include "cmGeneratedFileStream.h" +#include "cmVersion.h" + +const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja"; +const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja"; +const char* cmGlobalNinjaGenerator::INDENT = " "; + +void cmGlobalNinjaGenerator::Indent(std::ostream& os, int count) +{ + for(int i = 0; i < count; ++i) + os << cmGlobalNinjaGenerator::INDENT; +} + +void cmGlobalNinjaGenerator::WriteDivider(std::ostream& os) +{ + os + << "# ======================================" + << "=======================================\n"; +} + +void cmGlobalNinjaGenerator::WriteComment(std::ostream& os, + const std::string& comment) +{ + if (comment.empty()) + return; + + std::string replace = comment; + std::string::size_type lpos = 0; + std::string::size_type rpos; + while((rpos = replace.find('\n', lpos)) != std::string::npos) + { + os << "# " << replace.substr(lpos, rpos - lpos) << "\n"; + lpos = rpos + 1; + } + os << "# " << replace.substr(lpos) << "\n"; +} + +void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, + const std::string& comment, + const std::string& rule, + const cmNinjaDeps& outputs, + const cmNinjaDeps& explicitDeps, + const cmNinjaDeps& implicitDeps, + const cmNinjaDeps& orderOnlyDeps, + const cmNinjaVars& variables) +{ + // Make sure there is a rule. + if(rule.empty()) + { + cmSystemTools::Error("No rule for WriteBuildStatement! called " + "with comment: ", + comment.c_str()); + return; + } + + // Make sure there is at least one output file. + if(outputs.empty()) + { + cmSystemTools::Error("No output files for WriteBuildStatement! called " + "with comment: ", + comment.c_str()); + return; + } + + // Make sure there is at least one input file. + if(explicitDeps.empty() && implicitDeps.empty() && orderOnlyDeps.empty()) + { + cmSystemTools::Error("No input files for WriteBuildStatement! called " + "with comment: ", + comment.c_str()); + return; + } + + cmGlobalNinjaGenerator::WriteComment(os, comment); + + // TODO(Nicolas Despres): Write one file per line when there is multiple + // input/output files. + + // Write outputs files. + os << "build"; + for(cmNinjaDeps::const_iterator i = outputs.begin(); + i != outputs.end(); + ++i) + os << " " << *i; + os << ":"; + + // Write the rule. + os << " " << rule; + + // Write explicit dependencies. + for(cmNinjaDeps::const_iterator i = explicitDeps.begin(); + i != explicitDeps.end(); + ++i) + os << " " << *i; + + // Write implicit dependencies. + if(!implicitDeps.empty()) + { + os << " |"; + for(cmNinjaDeps::const_iterator i = implicitDeps.begin(); + i != implicitDeps.end(); + ++i) + os << " " << *i; + } + + // Write order-only dependencies. + if(!orderOnlyDeps.empty()) + { + os << " ||"; + for(cmNinjaDeps::const_iterator i = orderOnlyDeps.begin(); + i != orderOnlyDeps.end(); + ++i) + os << " " << *i; + } + + os << "\n"; + + // Write the variables bound to this build statement. + if(!variables.empty()) + { + for(cmNinjaVars::const_iterator i = variables.begin(); + i != variables.end(); + ++i) + cmGlobalNinjaGenerator::WriteVariable(os, i->first, i->second, "", 1); + } +} + +void cmGlobalNinjaGenerator::WritePhonyBuild(std::ostream& os, + const std::string& comment, + const cmNinjaDeps& outputs, + const cmNinjaDeps& explicitDeps, + const cmNinjaDeps& implicitDeps, + const cmNinjaDeps& orderOnlyDeps, + const cmNinjaVars& variables) +{ + cmGlobalNinjaGenerator::WriteBuild(os, + comment, + "phony", + outputs, + explicitDeps, + implicitDeps, + orderOnlyDeps, + variables); +} + +void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, + const std::string& name, + const std::string& command, + const std::string& comment, + const std::string& description, + const std::string& depfile, + const cmNinjaVars& variables) +{ + // Make sure the rule has a name. + if(name.empty()) + { + cmSystemTools::Error("No name given for WriteRuleStatement! called " + "with comment: ", + comment.c_str()); + return; + } + + // Make sure a command is given. + if(command.empty()) + { + cmSystemTools::Error("No command given for WriteRuleStatement! called " + "with comment: ", + comment.c_str()); + return; + } + + cmGlobalNinjaGenerator::WriteComment(os, comment); + + // Write the rule. + os << "rule " << name << "\n"; + + // Write the depfile if any. + if(!depfile.empty()) + { + cmGlobalNinjaGenerator::Indent(os, 1); + os << "depfile = " << depfile << "\n"; + } + + // Write the command. + cmGlobalNinjaGenerator::Indent(os, 1); + os << "command = " << command << "\n"; + + // Write the description if any. + if(!description.empty()) + { + cmGlobalNinjaGenerator::Indent(os, 1); + os << "description = " << description << "\n"; + } + + // Write the variables bound to this build statement. + if(!variables.empty()) + { + for(cmNinjaVars::const_iterator i = variables.begin(); + i != variables.end(); + ++i) + cmGlobalNinjaGenerator::WriteVariable(os, i->first, i->second, "", 1); + } +} + +void cmGlobalNinjaGenerator::WriteVariable(std::ostream& os, + const std::string& name, + const std::string& value, + const std::string& comment, + int indent) +{ + // Make sure we have a name. + if(name.empty()) + { + cmSystemTools::Error("No name given for WriteVariable! called " + "with comment: ", + comment.c_str()); + return; + } + + // Make sure we have a value. + if(value.empty()) + { + cmSystemTools::Error("No name given for WriteVariable! called " + "with name: ", + name.c_str(), + " and comment: ", + comment.c_str()); + return; + } + + cmGlobalNinjaGenerator::WriteComment(os, comment); + cmGlobalNinjaGenerator::Indent(os, indent); + os << name << " = " << value << "\n"; +} + +void cmGlobalNinjaGenerator::WriteInclude(std::ostream& os, + const std::string& filename, + const std::string& comment) +{ + cmGlobalNinjaGenerator::WriteComment(os, comment); + os << "include " << filename << "\n"; +} + cmGlobalNinjaGenerator::cmGlobalNinjaGenerator() : cmGlobalGenerator() + , BuildFileStream(0) + , RulesFileStream(0) { // // Ninja is not ported to non-Unix OS yet. // this->ForceUnixPaths = true; @@ -61,7 +306,15 @@ void cmGlobalNinjaGenerator::Configure() void cmGlobalNinjaGenerator::Generate() { std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - cmGlobalGenerator::Generate(); + + this->OpenBuildFileStream(); + this->OpenRulesFileStream(); + + this->cmGlobalGenerator::Generate(); + + this->CloseRulesFileStream(); + this->CloseBuildFileStream(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } @@ -84,7 +337,10 @@ ::EnableLanguage(std::vectorconst& languages, << " project: '" << mf->GetProjectName() << "'" << std::endl; std::cout << "DEBUG NINJA: ARG: optional: " << optional << std::endl; - cmGlobalGenerator::EnableLanguage(languages, mf, optional); + this->cmGlobalGenerator::EnableLanguage(languages, mf, optional); + // NOTE: cmGlobalUnixMakefileGenerator3::EnableLanguage seems to + // do some checking and cleaning about the CMAKE__COMPILER + // variables. Maybe we should add it too?? std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } @@ -256,3 +512,105 @@ bool cmGlobalNinjaGenerator::UseFolderProperty() std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; return ret; } + +//---------------------------------------------------------------------------- +// Private methods + +void cmGlobalNinjaGenerator::OpenBuildFileStream() +{ + // Compute Ninja's build file path. + std::string buildFilePath = + this->GetCMakeInstance()->GetHomeOutputDirectory(); + buildFilePath += "/"; + buildFilePath += cmGlobalNinjaGenerator::NINJA_BUILD_FILE; + + // Get a stream where to generate things. + if (!this->BuildFileStream) + { + this->BuildFileStream = new cmGeneratedFileStream(buildFilePath.c_str()); + if (!this->BuildFileStream) + { + // An error message is generated by the constructor if it cannot + // open the file. + return; + } + } + + // Write the do not edit header. + this->WriteDisclaimer(*this->BuildFileStream); + + // Write a comment about this file. + *this->BuildFileStream + << "# This file contains all the build statements describing the\n" + << "# compilation DAG.\n\n" + ; +} + +void cmGlobalNinjaGenerator::CloseBuildFileStream() +{ + if (this->BuildFileStream) + { + delete this->BuildFileStream; + this->BuildFileStream = 0; + } + else + { + // TODO(Nicolas Despres): Add the the name of the build filestream. + cmSystemTools::Error("Build file stream was not open."); + } +} + +void cmGlobalNinjaGenerator::OpenRulesFileStream() +{ + // Compute Ninja's build file path. + std::string rulesFilePath = + this->GetCMakeInstance()->GetHomeOutputDirectory(); + rulesFilePath += "/"; + rulesFilePath += cmGlobalNinjaGenerator::NINJA_RULES_FILE; + + // Get a stream where to generate things. + if (!this->RulesFileStream) + { + this->RulesFileStream = new cmGeneratedFileStream(rulesFilePath.c_str()); + if (!this->RulesFileStream) + { + // An error message is generated by the constructor if it cannot + // open the file. + return; + } + } + + // Write the do not edit header. + this->WriteDisclaimer(*this->RulesFileStream); + + // Write comment about this file. + *this->RulesFileStream + << "# This file contains all the rules used to get the outputs files\n" + << "# built from the input files.\n" + << "# It is included in the main '" << NINJA_BUILD_FILE << "'.\n\n" + ; +} + +void cmGlobalNinjaGenerator::CloseRulesFileStream() +{ + if (this->RulesFileStream) + { + delete this->RulesFileStream; + this->RulesFileStream = 0; + } + else + { + // TODO(Nicolas Despres): Add the the name of the filestream. + cmSystemTools::Error("Rules file stream was not open."); + } +} + +void cmGlobalNinjaGenerator::WriteDisclaimer(std::ostream& os) +{ + os + << "# CMAKE generated file: DO NOT EDIT!\n" + << "# Generated by \"" << this->GetName() << "\"" + << " Generator, CMake Version " + << cmVersion::GetMajorVersion() << "." + << cmVersion::GetMinorVersion() << "\n\n"; +} diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index ede9a8bcc76..53548307c2d 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -13,16 +13,106 @@ # define cmGlobalNinjaGenerator_h # include "cmGlobalGenerator.h" +# include "cmNinjaTypes.h" class cmLocalGenerator; +class cmGeneratedFileStream; /** * \class cmGlobalNinjaGenerator * \brief Write a build.ninja file. * + * The main differences between this generator and the UnixMakefile + * generator family are: + * - We don't care about VERBOSE variable or RULE_MESSAGES property since + * it is handle by Ninja's -v option. + * - We don't care about computing any progress status since ninja manages + * it itself. */ class cmGlobalNinjaGenerator : public cmGlobalGenerator { +public: + /// The default name of Ninja's build file. Typically: build.ninja. + static const char* NINJA_BUILD_FILE; + + /// The default name of Ninja's rules file. Typically: rules.ninja. + /// It is included in the main build.ninja file. + static const char* NINJA_RULES_FILE; + + /// The indentation string used when generating Ninja's build file. + static const char* INDENT; + + /// Write @a count times INDENT level to output stream @a os. + static void Indent(std::ostream& os, int count); + + /// Write a divider in the given output stream @a os. + static void WriteDivider(std::ostream& os); + + /** + * Write the given @a comment to the output stream @a os. It + * handles new line character properly. + */ + static void WriteComment(std::ostream& os, const std::string& comment); + + /** + * Write a build statement to @a os with the @a comment using + * the @a rule the list of @a outputs files and inputs. + * It also writes the variables bound to this build statement. + * @warning no escaping of any kind is done here. + */ + static void WriteBuild(std::ostream& os, + const std::string& comment, + const std::string& rule, + const cmNinjaDeps& outputs, + const cmNinjaDeps& explicitDeps, + const cmNinjaDeps& implicitDeps, + const cmNinjaDeps& orderOnlyDeps, + const cmNinjaVars& variables); + + /** + * Helper to write a build statement with the special 'phony' rule. + */ + static void WritePhonyBuild(std::ostream& os, + const std::string& comment, + const cmNinjaDeps& outputs, + const cmNinjaDeps& explicitDeps, + const cmNinjaDeps& implicitDeps, + const cmNinjaDeps& orderOnlyDeps, + const cmNinjaVars& variables); + + /** + * Write a rule statement named @a name to @a os with the @a comment, + * the mandatory @a command, the @a depfile and the @a description. + * It also writes the variables bound to this rule statement. + * @warning no escaping of any kind is done here. + */ + static void WriteRule(std::ostream& os, + const std::string& name, + const std::string& command, + const std::string& comment, + const std::string& description, + const std::string& depfile, + const cmNinjaVars& variables); + + /** + * Write a variable named @a name to @a os with value @a value and an + * optional @a comment. An @a indent level can be specified. + * @warning no escaping of any kind is done here. + */ + static void WriteVariable(std::ostream& os, + const std::string& name, + const std::string& value, + const std::string& comment = "", + int indent = 0); + + /** + * Write an include statement including @a filename with an optional + * @a comment to the @a os stream. + */ + static void WriteInclude(std::ostream& os, + const std::string& filename, + const std::string& comment = ""); + public: /// Default constructor. cmGlobalNinjaGenerator(); @@ -99,6 +189,13 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator virtual const char* GetRebuildCacheTargetName() const { return "rebuild_cache"; } virtual const char* GetCleanTargetName() const { return "clean"; } +public: + cmGeneratedFileStream* GetBuildFileStream() const + { return this->BuildFileStream; } + + cmGeneratedFileStream* GetRulesFileStream() const + { return this->RulesFileStream; } + protected: /// Overloaded methods. @see cmGlobalGenerator::GetTargetSets() @@ -121,6 +218,24 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator /// Overloaded methods. @see cmGlobalGenerator::UseFolderProperty() virtual bool UseFolderProperty(); + +private: + void OpenBuildFileStream(); + void CloseBuildFileStream(); + + void OpenRulesFileStream(); + void CloseRulesFileStream(); + + /// Write the common disclaimer text at the top of each build file. + void WriteDisclaimer(std::ostream& os); + +private: + /// The file containing the build statement. (the relation ship of the + /// compilation DAG). + cmGeneratedFileStream* BuildFileStream; + /// The file containing the rule statements. (The action attached to each + /// edge of the compilation DAG). + cmGeneratedFileStream* RulesFileStream; }; #endif // ! cmGlobalNinjaGenerator_h diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9867fc0c699..e1978e39c4a 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -11,9 +11,14 @@ ============================================================================*/ #include "cmLocalNinjaGenerator.h" #include "cmMakefile.h" +#include "cmGlobalNinjaGenerator.h" +#include "cmNinjaTargetGenerator.h" +#include "cmGeneratedFileStream.h" +#include "cmSourceFile.h" cmLocalNinjaGenerator::cmLocalNinjaGenerator() : cmLocalGenerator() + , ConfigName("") { // TODO(Nicolas Despres): Maybe I should set this one to true?? this->IsMakefileGenerator = false; @@ -29,7 +34,22 @@ cmLocalNinjaGenerator::~cmLocalNinjaGenerator() void cmLocalNinjaGenerator::Generate() { std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - cmLocalGenerator::Generate(); + + this->SetConfigName(); + this->WriteProjectHeader(this->GetBuildFileStream()); + this->WriteNinjaFilesInclusion(this->GetBuildFileStream()); + + cmTargets& targets = this->GetMakefile()->GetTargets(); + for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + { + cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(&t->second); + if(tg) + { + tg->Generate(); + delete tg; + } + } + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } @@ -41,7 +61,12 @@ void cmLocalNinjaGenerator::Generate() void cmLocalNinjaGenerator::Configure() { std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - cmLocalGenerator::Configure(); + + // NOTE: cmLocalUnixMakefileGenerator3::Configure() compute + // a path used to write rules in Makefiles later. We will see if + // we need such a thing later. + this->cmLocalGenerator::Configure(); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } @@ -157,9 +182,9 @@ ::GetTargetObjectFileDirectories(cmTarget* target, << " type: '" << cmTarget::TargetTypeNames(target->GetType()) << "'" << std::endl; std::cout << "DEBUG NINJA: ARG: dirs: "; - for (std::vector::const_iterator d = dirs.begin(); - d != dirs.end(); - ++d) + for(std::vector::const_iterator d = dirs.begin(); + d != dirs.end(); + ++d) std::cout << "'" << *d << "', "; std::cout << std::endl; @@ -168,20 +193,59 @@ ::GetTargetObjectFileDirectories(cmTarget* target, std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } -// Implemented and used in almost all cmLocalGenerator sub-classes. +// TODO(Nicolas Despres): Picked up from cmLocalUnixMakefileGenerator3. +// Refactor it. std::string cmLocalNinjaGenerator ::GetTargetDirectory(cmTarget const& target) const { - std::cout << "DEBUG NINJA: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: target: " - << " name: '" << target.GetName() << "'" - << " type: '" << cmTarget::TargetTypeNames(target.GetType()) << "'" - << std::endl; + std::string dir = cmake::GetCMakeFilesDirectoryPostSlash(); + dir += target.GetName(); +#if defined(__VMS) + dir += "_dir"; +#else + dir += ".dir"; +#endif + return dir; +} + +//---------------------------------------------------------------------------- +// Non-virtual public methods. - std::string ret = cmLocalGenerator::GetTargetDirectory(target); +cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator() const +{ + return static_cast(this->GetGlobalGenerator()); +} - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; - return ret; +// TODO(Nicolas Despres): Picked up from cmLocalUnixMakefileGenerator3. +// Refactor it. +std::string +cmLocalNinjaGenerator +::GetObjectFileName(const cmTarget& target, + const cmSourceFile& source) +{ + // Make sure we never hit this old case. + if(source.GetProperty("MACOSX_PACKAGE_LOCATION")) + { + std::string msg = "MACOSX_PACKAGE_LOCATION set on source file: "; + msg += source.GetFullPath(); + this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, + msg.c_str()); + } + + // Start with the target directory. + std::string obj = this->GetTargetDirectory(target); + obj += "/"; + + // Get the object file name without the target directory. + std::string dir_max; + dir_max += this->Makefile->GetCurrentOutputDirectory(); + dir_max += "/"; + dir_max += obj; + std::string objectName = + this->GetObjectFileNameWithoutTarget(source, dir_max, 0); + // Append the object name to the target directory. + obj += objectName; + return obj; } //---------------------------------------------------------------------------- @@ -222,3 +286,54 @@ bool cmLocalNinjaGenerator::CheckDefinition(std::string const& define) const std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; return ret; } + +//---------------------------------------------------------------------------- +// Private methods. + +cmGeneratedFileStream& cmLocalNinjaGenerator::GetBuildFileStream() const +{ + return *this->GetGlobalNinjaGenerator()->GetBuildFileStream(); +} + +cmGeneratedFileStream& cmLocalNinjaGenerator::GetRulesFileStream() const +{ + return *this->GetGlobalNinjaGenerator()->GetRulesFileStream(); +} + +void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os) +{ + cmGlobalNinjaGenerator::WriteDivider(os); + os + << "# Project: " << this->GetMakefile()->GetProjectName() << "\n" + << "# Configuration: " << this->ConfigName << "\n" + << "\n" + ; +} + +void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os) +{ + cmGlobalNinjaGenerator::WriteDivider(os); + os + << "# Include auxiliary files.\n" + << "\n" + ; + cmGlobalNinjaGenerator::WriteInclude(os, + cmGlobalNinjaGenerator::NINJA_RULES_FILE, + "Include rules file."); + os << "\n"; +} + +void cmLocalNinjaGenerator::SetConfigName() +{ + // Store the configuration name that will be generated. + if(const char* config = this->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE")) + { + // Use the build type given by the user. + this->ConfigName = config; + } + else + { + // No configuration type given. + this->ConfigName = ""; + } +} diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 7e8ca4fa58d..4e441b0897f 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -14,6 +14,9 @@ # include "cmLocalGenerator.h" +class cmGlobalNinjaGenerator; +class cmGeneratedFileStream; + /** * \class cmLocalNinjaGenerator * \brief Write a local build.ninja file. @@ -75,6 +78,15 @@ class cmLocalNinjaGenerator : public cmLocalGenerator /// Overloaded methods. @see cmLocalGenerator::GetTargetDirectory() virtual std::string GetTargetDirectory(cmTarget const& target) const; +public: + cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const; + + const char* GetConfigName() const + { return this->ConfigName.c_str(); } + + std::string GetObjectFileName(const cmTarget& target, + const cmSourceFile& source); + protected: /// Overloaded methods. @see cmLocalGenerator::OutputLinkLibraries() @@ -84,6 +96,24 @@ class cmLocalNinjaGenerator : public cmLocalGenerator /// Overloaded methods. @see cmLocalGenerator::CheckDefinition() virtual bool CheckDefinition(std::string const& define) const; + +private: + // In order to access to protected member of the local generator. + friend class cmNinjaTargetGenerator; + friend class cmNinjaExecutableTargetGenerator; + + +private: + cmGeneratedFileStream& GetBuildFileStream() const; + cmGeneratedFileStream& GetRulesFileStream() const; + + void WriteProjectHeader(std::ostream& os); + void WriteNinjaFilesInclusion(std::ostream& os); + + void SetConfigName(); + +private: + std::string ConfigName; }; #endif // ! cmLocalNinjaGenerator_h diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx new file mode 100644 index 00000000000..8aa4e141f96 --- /dev/null +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -0,0 +1,290 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmNinjaExecutableTargetGenerator.h" +#include "cmLocalNinjaGenerator.h" +#include "cmGlobalNinjaGenerator.h" +#include "cmSourceFile.h" +#include "cmGeneratedFileStream.h" +#include "cmMakefile.h" + +cmNinjaExecutableTargetGenerator:: +cmNinjaExecutableTargetGenerator(cmTarget* target) + : cmNinjaTargetGenerator(target) + , TargetNameOut() + , TargetNameReal() + , TargetNameImport() + , TargetNamePDB() + , Objects() +{ + this->GetTarget()->GetExecutableNames(this->TargetNameOut, + this->TargetNameReal, + this->TargetNameImport, + this->TargetNamePDB, + GetLocalGenerator()->GetConfigName()); +} + +cmNinjaExecutableTargetGenerator::~cmNinjaExecutableTargetGenerator() +{ +} + +void cmNinjaExecutableTargetGenerator::Generate() +{ + // Write the rules for each language. + this->WriteLanguagesRules(); + + // Write the build statements + this->WriteObjectBuildStatements(); + + // Write the link statement. + this->WriteLinkStatement(); + + this->GetBuildFileStream() << "\n"; +} + +void cmNinjaExecutableTargetGenerator::WriteLanguagesRules() +{ + cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream()); + this->GetRulesFileStream() + << "# Rules for each languages for " + << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << " target " + << this->GetTarget()->GetName() + << "\n\n"; + + std::set languages; + this->GetTarget()->GetLanguages(languages); + for(std::set::const_iterator l = languages.begin(); + l != languages.end(); + ++l) + this->WriteLanguageRules(*l); +} + +void +cmNinjaExecutableTargetGenerator +::WriteLanguageRules(const std::string& language) +{ + this->GetRulesFileStream() + << "# Rules for language " << language << "\n\n"; + this->WriteCompileRule(language); + this->GetRulesFileStream() << "\n"; + this->WriteLinkRule(language); +} + +void +cmNinjaExecutableTargetGenerator +::WriteCompileRule(const std::string& language) +{ + cmLocalGenerator::RuleVariables vars; + vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; + vars.CMTarget = this->GetTarget(); + std::string lang = language; + vars.Language = lang.c_str(); + vars.Source = "$in"; + vars.Object = "$out"; + + // FIXME(Nicolas Despres): Factor flags construction with the + // cmMakefileTargetGenerator::WriteObjectBuildFile + // This is mandatory to use a local variables because the string must be + // in memory until ExpandRuleVariables() is called. + std::string flags = this->LanguageFlagsVarName(language); + vars.Flags = flags.c_str(); + // FIXME(Nicolas Despres): Factor defines construction with the + // cmMakefileTargetGenerator::WriteObjectBuildFile + vars.Defines = "$DEFINES"; + + // Rule for compiling object file. + std::string compileCmdVar = "CMAKE_"; + compileCmdVar += language; + compileCmdVar += "_COMPILE_OBJECT"; + std::string compileCmd = + this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str()); + std::cout << "DEBUG NINJA: COMPILE CMD: " << compileCmd << std::endl; + + this->GetLocalGenerator()->ExpandRuleVariables(compileCmd, vars); + + // Write the rule for compiling file of the given language. + std::ostringstream comment; + comment << "Rule for compiling " << language << " files."; + std::ostringstream description; + description << "Building " << language << " object $out"; + std::string depfile = ""; + cmNinjaVars emptyVars; + cmGlobalNinjaGenerator::WriteRule(this->GetRulesFileStream(), + this->LanguageCompilerRule(language), + compileCmd, + comment.str(), + description.str(), + depfile, + emptyVars); +} + +void +cmNinjaExecutableTargetGenerator +::WriteLinkRule(const std::string& language) +{ + cmLocalGenerator::RuleVariables vars; + vars.RuleLauncher = "RULE_LAUNCH_LINK"; + vars.CMTarget = this->GetTarget(); + std::string lang = language; + vars.Language = lang.c_str(); + vars.Objects = "$in"; + std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); + objdir += this->GetTarget()->GetName(); + objdir += ".dir"; + objdir = this->GetLocalGenerator()->Convert(objdir.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + vars.ObjectDir = objdir.c_str(); + vars.Target = "$out"; + + // Setup the target version. + std::string targetVersionMajor; + std::string targetVersionMinor; + { + cmOStringStream majorStream; + cmOStringStream minorStream; + int major; + int minor; + this->GetTarget()->GetTargetVersion(major, minor); + majorStream << major; + minorStream << minor; + targetVersionMajor = majorStream.str(); + targetVersionMinor = minorStream.str(); + } + vars.TargetVersionMajor = targetVersionMajor.c_str(); + vars.TargetVersionMinor = targetVersionMinor.c_str(); + + // FIXME(Nicolas Despres): List libraries to link with. + vars.LinkLibraries = ""; + // This is mandatory to use a local variables because the string must be + // in memory until ExpandRuleVariables() is called. + std::string flags = this->LanguageFlagsVarName(language); + vars.Flags = flags.c_str(); + vars.LinkFlags = "$LDFLAGS"; + + // Rule for linking executable. + std::string linkCmdVar = "CMAKE_"; + linkCmdVar += language; + linkCmdVar += "_LINK_EXECUTABLE"; + std::string linkCmd = + this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + + this->GetLocalGenerator()->ExpandRuleVariables(linkCmd, vars); + + // Write the rule for linking an executable. + std::ostringstream comment; + comment << "Rule for linking " << language << " executable."; + std::ostringstream description; + description << "Linking " << language << " executable $out"; + std::string depfile = ""; + cmNinjaVars emptyVars; + cmGlobalNinjaGenerator::WriteRule(this->GetRulesFileStream(), + this->LanguageLinkerRule(language), + linkCmd, + comment.str(), + description.str(), + depfile, + emptyVars); +} + +void +cmNinjaExecutableTargetGenerator +::WriteObjectBuildStatements() +{ + // Write comments. + cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); + this->GetBuildFileStream() + << "# Object build statements for " + << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << " target " + << this->GetTarget()->GetName() + << "\n\n"; + + // For each source files of this target. + for(std::vector::const_iterator i = + this->GetTarget()->GetSourceFiles().begin(); + i != this->GetTarget()->GetSourceFiles().end(); + ++i) + this->WriteObjectBuildStatement(*i); + + this->GetBuildFileStream() << "\n"; +} + +void +cmNinjaExecutableTargetGenerator +::WriteObjectBuildStatement(cmSourceFile* source) +{ + cmNinjaDeps emptyDeps; + cmNinjaVars emptyVars; + + std::string comment; + std::string rule = this->LanguageCompilerRule(source->GetLanguage()); + + cmNinjaDeps outputs; + std::string objectFileName = + this->GetLocalGenerator()->GetObjectFileName(*this->GetTarget(), *source); + outputs.insert(objectFileName); + // Add this object to the list of object files. + this->Objects.insert(objectFileName); + + cmNinjaDeps explicitDeps; + std::string sourceFileName = + this->GetLocalGenerator()->Convert(source->GetFullPath().c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); + explicitDeps.insert(sourceFileName); + + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + comment, + rule, + outputs, + explicitDeps, + emptyDeps, + emptyDeps, + emptyVars); +} + +void cmNinjaExecutableTargetGenerator::WriteLinkStatement() +{ + // Write comments. + cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); + this->GetBuildFileStream() + << "# Link build statements for " + << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << " target " + << this->GetTarget()->GetName() + << "\n\n"; + + cmNinjaDeps emptyDeps; + cmNinjaVars emptyVars; + + // Compute the comment. + std::ostringstream comment; + comment << "Link the executable " << this->TargetNameOut; + + // Compute outputs. + cmNinjaDeps outputs; + outputs.insert(this->TargetNameOut); + + const char* linkLanguage = + this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); + + // Write the build statement for this target. + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + comment.str(), + this->LanguageLinkerRule(linkLanguage), + outputs, + this->Objects, + emptyDeps, + emptyDeps, + emptyVars); +} diff --git a/Source/cmNinjaExecutableTargetGenerator.h b/Source/cmNinjaExecutableTargetGenerator.h new file mode 100644 index 00000000000..4c21ebe952b --- /dev/null +++ b/Source/cmNinjaExecutableTargetGenerator.h @@ -0,0 +1,48 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmNinjaExecutableTargetGenerator_h +# define cmNinjaExecutableTargetGenerator_h + +# include "cmNinjaTargetGenerator.h" +# include "cmNinjaTypes.h" + +class cmSourceFile; + +class cmNinjaExecutableTargetGenerator : public cmNinjaTargetGenerator +{ +public: + /// Build a NinjaTargetGenerator. + cmNinjaExecutableTargetGenerator(cmTarget* target); + ~cmNinjaExecutableTargetGenerator(); + + virtual void Generate(); + +private: + void WriteLanguagesRules(); + void WriteLanguageRules(const std::string& language); + void WriteCompileRule(const std::string& language); + void WriteLinkRule(const std::string& language); + void WriteObjectBuildStatements(); + void WriteObjectBuildStatement(cmSourceFile* source); + void WriteLinkStatement(); + +private: + // Target name info. + std::string TargetNameOut; + std::string TargetNameReal; + std::string TargetNameImport; + std::string TargetNamePDB; + /// List of object files for this target. + cmNinjaDeps Objects; +}; + +#endif // ! cmNinjaExecutableTargetGenerator_h diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx new file mode 100644 index 00000000000..9cb5533e61b --- /dev/null +++ b/Source/cmNinjaTargetGenerator.cxx @@ -0,0 +1,81 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmNinjaTargetGenerator.h" +#include "cmGlobalNinjaGenerator.h" +#include "cmLocalNinjaGenerator.h" +#include "cmGeneratedFileStream.h" +#include "cmNinjaExecutableTargetGenerator.h" +#include "cmSystemTools.h" +#include "cmMakefile.h" + +cmNinjaTargetGenerator * +cmNinjaTargetGenerator::New(cmTarget* target) +{ + switch (target->GetType()) + { + case cmTarget::EXECUTABLE: + return new cmNinjaExecutableTargetGenerator(target); + + default: + return 0; + } +} + +cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmTarget* target) + : Target(target) + , Makefile(target->GetMakefile()) + , LocalGenerator(static_cast(Makefile->GetLocalGenerator())) +{ +} + +cmNinjaTargetGenerator::~cmNinjaTargetGenerator() +{ +} + +cmGeneratedFileStream& cmNinjaTargetGenerator::GetBuildFileStream() const +{ + return *this->GetGlobalGenerator()->GetBuildFileStream(); +} + +cmGeneratedFileStream& cmNinjaTargetGenerator::GetRulesFileStream() const +{ + return *this->GetGlobalGenerator()->GetRulesFileStream(); +} + +cmGlobalNinjaGenerator* cmNinjaTargetGenerator::GetGlobalGenerator() const +{ + return this->LocalGenerator->GetGlobalNinjaGenerator(); +} + +const char* cmNinjaTargetGenerator::GetConfigName() const +{ + return this->LocalGenerator->ConfigName.c_str(); +} + +std::string +cmNinjaTargetGenerator +::LanguageLinkerRule(const std::string& lang) const +{ + return lang + + "_" + + cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + + "_LINKER"; +} + +std::string +cmNinjaTargetGenerator +::LanguageFlagsVarName(const std::string& language) const +{ + std::ostringstream varname; + varname << "$" << language << "FLAGS"; + return varname.str(); +} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h new file mode 100644 index 00000000000..ce8222bd445 --- /dev/null +++ b/Source/cmNinjaTargetGenerator.h @@ -0,0 +1,67 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmNinjaTargetGenerator_h +# define cmNinjaTargetGenerator_h + +# include "cmStandardIncludes.h" + +class cmTarget; +class cmLocalNinjaGenerator; +class cmGlobalNinjaGenerator; +class cmGeneratedFileStream; +class cmMakefile; + +class cmNinjaTargetGenerator +{ +public: + /// Create a cmNinjaTargetGenerator according to the @a target's type. + static cmNinjaTargetGenerator* New(cmTarget* target); + + /// Build a NinjaTargetGenerator. + cmNinjaTargetGenerator(cmTarget* target); + + /// Destructor. + ~cmNinjaTargetGenerator(); + + virtual void Generate() = 0; + +protected: + cmGeneratedFileStream& GetBuildFileStream() const; + cmGeneratedFileStream& GetRulesFileStream() const; + + cmTarget* GetTarget() const + { return this->Target; } + + cmLocalNinjaGenerator* GetLocalGenerator() const + { return this->LocalGenerator; } + + cmGlobalNinjaGenerator* GetGlobalGenerator() const; + + cmMakefile* GetMakefile() const + { return this->Makefile; } + + const char* GetConfigName() const; + + std::string LanguageCompilerRule(const std::string& lang) const + { return lang + "_COMPILER"; } + + std::string LanguageLinkerRule(const std::string& lang) const; + + std::string LanguageFlagsVarName(const std::string& language) const; + +private: + cmTarget* Target; + cmMakefile* Makefile; + cmLocalNinjaGenerator* LocalGenerator; +}; + +#endif // ! cmNinjaTargetGenerator_h diff --git a/Source/cmNinjaTypes.h b/Source/cmNinjaTypes.h new file mode 100644 index 00000000000..1c5c226dd4c --- /dev/null +++ b/Source/cmNinjaTypes.h @@ -0,0 +1,18 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmNinjaTypes_h +# define cmNinjaTypes_h + +typedef std::set cmNinjaDeps; +typedef std::map cmNinjaVars; + +#endif // ! cmGlobalNinjaGenerator_h From 337432e8ccb06e5bde0742b617ec3783efd14901 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sat, 9 Apr 2011 19:17:18 +0200 Subject: [PATCH 418/539] Ninja: Implement GenerateBuildCommand(). --- Source/cmGlobalNinjaGenerator.cxx | 33 ++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index f11dc494a4b..12de1d0ef64 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -419,16 +419,31 @@ ::GenerateBuildCommand(const char* makeProgram, std::cout << "DEBUG NINJA: ARG: ignoreErrors: '" << ignoreErrors << "'" << std::endl; std::cout << "DEBUG NINJA: ARG: fast: '" << fast << "'" << std::endl; - std::string ret = cmGlobalGenerator::GenerateBuildCommand(makeProgram, - projectName, - additionalOptions, - targetName, - config, - ignoreErrors, - fast); + // Project name and config are not used yet. + (void)projectName; + (void)config; + // Ninja does not have -i equivalent option yet. + (void)ignoreErrors; + // We do not handle fast build yet. + (void)fast; + + std::string makeCommand = + cmSystemTools::ConvertToUnixOutputPath(makeProgram); + + if(additionalOptions) + { + makeCommand += " "; + makeCommand += additionalOptions; + } + if(targetName) + { + makeCommand += " "; + makeCommand += targetName; + } - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; - return ret; + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ + << " RESULT='" << makeCommand << "'" << std::endl; + return makeCommand; } // Not implemented in UnixMakefile generator. From 5396d5f02779b185f3e34de9d34c6c3ffc2c74a1 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sat, 9 Apr 2011 21:37:20 +0200 Subject: [PATCH 419/539] Ninja: Add the 'all' target. --- Source/cmLocalNinjaGenerator.cxx | 35 +++++++++++++++++++++ Source/cmLocalNinjaGenerator.h | 5 +++ Source/cmNinjaExecutableTargetGenerator.cxx | 2 ++ 3 files changed, 42 insertions(+) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index e1978e39c4a..85a143411e7 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -19,6 +19,7 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator() : cmLocalGenerator() , ConfigName("") + , AllDependencies() { // TODO(Nicolas Despres): Maybe I should set this one to true?? this->IsMakefileGenerator = false; @@ -50,6 +51,8 @@ void cmLocalNinjaGenerator::Generate() } } + this->WriteBuiltinTargets(this->GetBuildFileStream()); + std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } @@ -337,3 +340,35 @@ void cmLocalNinjaGenerator::SetConfigName() this->ConfigName = ""; } } + +void cmLocalNinjaGenerator::WriteBuiltinTargets(std::ostream& os) +{ + // Write headers. + cmGlobalNinjaGenerator::WriteDivider(os); + os << "# Built-in targets\n\n"; + + this->WriteTargetAll(os); +} + + +void cmLocalNinjaGenerator::AddDependencyToAll(const std::string& dependency) +{ + this->AllDependencies.insert(dependency); +} + +void cmLocalNinjaGenerator::WriteTargetAll(std::ostream& os) +{ + cmNinjaDeps emptyDeps; + cmNinjaVars emptyVars; + + cmNinjaDeps outputs; + outputs.insert("all"); + + cmGlobalNinjaGenerator::WritePhonyBuild(os, + "The main all target.", + outputs, + emptyDeps, + emptyDeps, + this->AllDependencies, + emptyVars); +} diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 4e441b0897f..666fbfc8fc0 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -13,6 +13,7 @@ # define cmLocalNinjaGenerator_h # include "cmLocalGenerator.h" +# include "cmNinjaTypes.h" class cmGlobalNinjaGenerator; class cmGeneratedFileStream; @@ -109,11 +110,15 @@ class cmLocalNinjaGenerator : public cmLocalGenerator void WriteProjectHeader(std::ostream& os); void WriteNinjaFilesInclusion(std::ostream& os); + void WriteBuiltinTargets(std::ostream& os); + void WriteTargetAll(std::ostream& os); + void AddDependencyToAll(const std::string& dependency); void SetConfigName(); private: std::string ConfigName; + cmNinjaDeps AllDependencies; }; #endif // ! cmLocalNinjaGenerator_h diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index 8aa4e141f96..2bf1df34d31 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -274,6 +274,8 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() // Compute outputs. cmNinjaDeps outputs; outputs.insert(this->TargetNameOut); + // Add this executable to the all target. + this->GetLocalGenerator()->AddDependencyToAll(this->TargetNameOut); const char* linkLanguage = this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); From 99200e16bf193ab0147ccab5267f2adf787a41b3 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 10 Apr 2011 09:58:51 +0200 Subject: [PATCH 420/539] Ninja: Handle link libraries. Now we have the -rdynamic options at link time. --- Source/cmNinjaExecutableTargetGenerator.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index 2bf1df34d31..dae583f7adb 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -163,8 +163,7 @@ ::WriteLinkRule(const std::string& language) vars.TargetVersionMajor = targetVersionMajor.c_str(); vars.TargetVersionMinor = targetVersionMinor.c_str(); - // FIXME(Nicolas Despres): List libraries to link with. - vars.LinkLibraries = ""; + vars.LinkLibraries = "$LDLIBS"; // This is mandatory to use a local variables because the string must be // in memory until ExpandRuleVariables() is called. std::string flags = this->LanguageFlagsVarName(language); @@ -265,7 +264,7 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() << "\n\n"; cmNinjaDeps emptyDeps; - cmNinjaVars emptyVars; + cmNinjaVars vars; // Compute the comment. std::ostringstream comment; @@ -280,6 +279,15 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() const char* linkLanguage = this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); + // Compute specific libraries to link with. + { + std::ostringstream linkLibraries; + this->GetLocalGenerator()->OutputLinkLibraries(linkLibraries, + *this->GetTarget(), + false); + vars["LDLIBS"] = linkLibraries.str(); + } + // Write the build statement for this target. cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), comment.str(), @@ -288,5 +296,5 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() this->Objects, emptyDeps, emptyDeps, - emptyVars); + vars); } From a78994f809661b6fdc52eab0f7f66bca44b1440f Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 10 Apr 2011 11:07:17 +0200 Subject: [PATCH 421/539] Ninja: Compute link flags. With this patch we get the -v option at link time for cmTryCompileExec target. Remove debug messages in cmLocalNinjaGenerator::AppendFlags() since we don't need to overload this method. --- Source/cmLocalNinjaGenerator.cxx | 17 ------- Source/cmLocalNinjaGenerator.h | 3 -- Source/cmNinjaExecutableTargetGenerator.cxx | 55 +++++++++++++++++++++ Source/cmNinjaExecutableTargetGenerator.h | 1 + 4 files changed, 56 insertions(+), 20 deletions(-) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 85a143411e7..fa0fa4351ca 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -121,23 +121,6 @@ void cmLocalNinjaGenerator::GenerateTargetManifest() std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } -// Implemented only in UnixMakefile local generator. -// Used in: -// Source/cmMakefileExecutableTargetGenerator.cxx -// Source/cmMakefileLibraryTargetGenerator.cxx -// Source/cmMakefileTargetGenerator.cxx -void cmLocalNinjaGenerator::AppendFlags(std::string& flags, - const char* newFlags) -{ - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: flags: '" << flags << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: newFlags: '" << newFlags << "'" << std::endl; - - cmLocalGenerator::AppendFlags(flags, newFlags); - - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - // Implemented only in UnixMakefile local generator. // Used in: // Source/cmake.cxx diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 666fbfc8fc0..8b131065d32 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -58,9 +58,6 @@ class cmLocalNinjaGenerator : public cmLocalGenerator /// Overloaded methods. @see cmLocalGenerator::GenerateTargetManifest() virtual void GenerateTargetManifest(); - /// Overloaded methods. @see cmLocalGenerator::AppendFlags() - virtual void AppendFlags(std::string& flags, const char* newFlags); - /// Overloaded methods. @see cmLocalGenerator::ClearDependencies() virtual void ClearDependencies(cmMakefile* mf, bool verbose); diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index dae583f7adb..6ca6507899c 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -288,6 +288,9 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() vars["LDLIBS"] = linkLibraries.str(); } + // Compute specific link flags. + vars["LDFLAGS"] = this->ComputeLinkFlags(linkLanguage); + // Write the build statement for this target. cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), comment.str(), @@ -298,3 +301,55 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() emptyDeps, vars); } + +// TODO(Nicolas Despres): Most of the code is picked up from +// void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink). +// Refactor it. +std::string +cmNinjaExecutableTargetGenerator +::ComputeLinkFlags(const std::string& linkLanguage) +{ + // The returned variables. + std::string linkFlags; + // Convenience variables. + cmLocalNinjaGenerator* lg = this->GetLocalGenerator(); + cmTarget* target = this->GetTarget(); + cmMakefile* makefile = this->GetMakefile(); + + // Add flags to create an executable. + lg->AddConfigVariableFlags(linkFlags, + "CMAKE_EXE_LINKER_FLAGS", + this->GetConfigName()); + + if(target->GetPropertyAsBool("WIN32_EXECUTABLE")) + lg->AppendFlags(linkFlags, + makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE")); + else + lg->AppendFlags(linkFlags, + makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE")); + + // Add symbol export flags if necessary. + if(target->IsExecutableWithExports()) + { + std::string export_flag_var = "CMAKE_EXE_EXPORTS_"; + export_flag_var += linkLanguage; + export_flag_var += "_FLAG"; + lg->AppendFlags(linkFlags, + makefile->GetDefinition(export_flag_var.c_str())); + } + + // Target specific link flags. + lg->AppendFlags(linkFlags, target->GetProperty("LINK_FLAGS")); + + // Configuration specific link flags. + std::string linkFlagsConfig = "LINK_FLAGS_"; + linkFlagsConfig += cmSystemTools::UpperCase(this->GetConfigName()); + lg->AppendFlags(linkFlags, target->GetProperty(linkFlagsConfig.c_str())); + + // TODO(Nicolas Despres): Let's see later for the definition files. + // It looks like something specific to Windows and Ninja is not available + // on Windows yet. + // this->AddModuleDefinitionFlag(linkFlags); + + return linkFlags; +} diff --git a/Source/cmNinjaExecutableTargetGenerator.h b/Source/cmNinjaExecutableTargetGenerator.h index 4c21ebe952b..7199ac86ca0 100644 --- a/Source/cmNinjaExecutableTargetGenerator.h +++ b/Source/cmNinjaExecutableTargetGenerator.h @@ -34,6 +34,7 @@ class cmNinjaExecutableTargetGenerator : public cmNinjaTargetGenerator void WriteObjectBuildStatements(); void WriteObjectBuildStatement(cmSourceFile* source); void WriteLinkStatement(); + std::string ComputeLinkFlags(const std::string& linkLanguage); private: // Target name info. From 340183d986723e845c2b6474c6586fd4f2890e62 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 10 Apr 2011 11:48:50 +0200 Subject: [PATCH 422/539] Ninja: Variables' values are trimmed. --- Source/cmGlobalNinjaGenerator.cxx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 12de1d0ef64..e4ee2f51572 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -231,20 +231,16 @@ void cmGlobalNinjaGenerator::WriteVariable(std::ostream& os, return; } - // Make sure we have a value. - if(value.empty()) + // Do not add a variable if the value is empty. + std::string val = cmSystemTools::Trimmed(value); + if(val.empty()) { - cmSystemTools::Error("No name given for WriteVariable! called " - "with name: ", - name.c_str(), - " and comment: ", - comment.c_str()); return; } cmGlobalNinjaGenerator::WriteComment(os, comment); cmGlobalNinjaGenerator::Indent(os, indent); - os << name << " = " << value << "\n"; + os << name << " = " << val << "\n"; } void cmGlobalNinjaGenerator::WriteInclude(std::ostream& os, From 7750fb6024b9d41e03b12de6f81f607796e3bc10 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 17 Apr 2011 14:44:45 +0200 Subject: [PATCH 423/539] Ninja: Do not generate twice the same rule. --- Source/cmGlobalNinjaGenerator.cxx | 27 +++++++++++++++++++++++++++ Source/cmGlobalNinjaGenerator.h | 19 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index e4ee2f51572..a1ef35e70ce 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -256,6 +256,7 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator() : cmGlobalGenerator() , BuildFileStream(0) , RulesFileStream(0) + , Rules() { // // Ninja is not ported to non-Unix OS yet. // this->ForceUnixPaths = true; @@ -463,6 +464,32 @@ ::AppendDirectoryForConfig(const char* prefix, std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } +//---------------------------------------------------------------------------- +// Non-virtual public methods. + +void cmGlobalNinjaGenerator::AddRule(const std::string& name, + const std::string& command, + const std::string& comment, + const std::string& description, + const std::string& depfile, + const cmNinjaVars& variables) +{ + // Do not add twice the same rule. + RulesSetType::const_iterator rule = this->Rules.find(name); + if (rule != this->Rules.end()) + return; + + this->Rules.insert(name); + cmGlobalNinjaGenerator::WriteRule(*this->RulesFileStream, + name, + command, + comment, + description, + depfile, + variables); +} + + //---------------------------------------------------------------------------- // Virtual protected methods. diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 53548307c2d..d01a255c2dc 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -196,6 +196,18 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator cmGeneratedFileStream* GetRulesFileStream() const { return this->RulesFileStream; } + /** + * Add a rule to the generated build system. + * Call WriteRule() behind the scene but perform some check before like: + * - Do not add twice the same rule. + */ + void AddRule(const std::string& name, + const std::string& command, + const std::string& comment, + const std::string& description, + const std::string& depfile, + const cmNinjaVars& variables); + protected: /// Overloaded methods. @see cmGlobalGenerator::GetTargetSets() @@ -236,6 +248,13 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator /// The file containing the rule statements. (The action attached to each /// edge of the compilation DAG). cmGeneratedFileStream* RulesFileStream; + + /// The type used to store the set of rules added to the generated build + /// system. + typedef std::set RulesSetType; + + /// The set of rules added to the generated build system. + RulesSetType Rules; }; #endif // ! cmGlobalNinjaGenerator_h From 8e6f98d74c5c3fab1a2eb46fd1bca7eb40479f82 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 17 Apr 2011 17:45:08 +0200 Subject: [PATCH 424/539] Ninja: Handle shared libraries. --- Source/CMakeLists.txt | 2 + Source/cmLocalNinjaGenerator.cxx | 126 ++++++- Source/cmLocalNinjaGenerator.h | 2 +- Source/cmNinjaExecutableTargetGenerator.cxx | 64 ++-- Source/cmNinjaLibraryTargetGenerator.cxx | 385 ++++++++++++++++++++ Source/cmNinjaLibraryTargetGenerator.h | 50 +++ Source/cmNinjaTargetGenerator.cxx | 191 +++++++++- Source/cmNinjaTargetGenerator.h | 30 +- 8 files changed, 812 insertions(+), 38 deletions(-) create mode 100644 Source/cmNinjaLibraryTargetGenerator.cxx create mode 100644 Source/cmNinjaLibraryTargetGenerator.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 4f23118d681..afc28e6f584 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -215,6 +215,8 @@ SET(SRCS cmNinjaTargetGenerator.h cmNinjaExecutableTargetGenerator.cxx cmNinjaExecutableTargetGenerator.h + cmNinjaLibraryTargetGenerator.cxx + cmNinjaLibraryTargetGenerator.h cmMakeDepend.cxx cmMakeDepend.h cmMakefile.cxx diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index fa0fa4351ca..95e2177ff58 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -15,6 +15,7 @@ #include "cmNinjaTargetGenerator.h" #include "cmGeneratedFileStream.h" #include "cmSourceFile.h" +#include "cmComputeLinkInformation.h" cmLocalNinjaGenerator::cmLocalNinjaGenerator() : cmLocalGenerator() @@ -237,25 +238,124 @@ ::GetObjectFileName(const cmTarget& target, //---------------------------------------------------------------------------- // Virtual protected methods. -// Not implemented in none of cmLocalGenerator sub-classes. -// Used in: -// Source/cmLocalGenerator.cxx -// Source/cmMakefileExecutableTargetGenerator.cxx -// Source/cmMakefileLibraryTargetGenerator.cxx +// TODO(Nicolas Despres): Refactor with +// void cmLocalNinjaGenerator::OutputLinkLibraries(std::ostream& fout, +// cmTarget& tgt, +// bool relink); +// +// Actually do not want the list of .so files to show up here since I want +// to use them as explicit dependencies of the link and thus to be bind to +// the $in variable. So I keep here only the the flags. +// +// The list of dependent targets is compute by +// cmNinjaTargetGenerator::ComputeLinkDeps(). void cmLocalNinjaGenerator::OutputLinkLibraries(std::ostream& fout, cmTarget& tgt, bool relink) { - std::cout << "DEBUG NINJA: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: tgt: " - << " name: '" << tgt.GetName() << "'" - << " type: '" << cmTarget::TargetTypeNames(tgt.GetType()) << "'" - << std::endl; - std::cout << "DEBUG NINJA: ARG: relink: '" << relink << "'" << std::endl; + const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); + if(!pcli) + { + return; + } + cmComputeLinkInformation& cli = *pcli; - cmLocalGenerator::OutputLinkLibraries(fout, tgt, relink); + // Collect library linking flags command line options. + std::string linkLibs; - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + const char* linkLanguage = cli.GetLinkLanguage(); + + std::string libPathFlag = + this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); + std::string libPathTerminator = + this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); + + // Flags to link an executable to shared libraries. + std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_"; + linkFlagsVar += linkLanguage; + linkFlagsVar += "_FLAGS"; + if( tgt.GetType() == cmTarget::EXECUTABLE ) + { + linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar.c_str()); + linkLibs += " "; + } + + // Append the framework search path flags. + std::vector const& fwDirs = cli.GetFrameworkPaths(); + for(std::vector::const_iterator fdi = fwDirs.begin(); + fdi != fwDirs.end(); ++fdi) + { + linkLibs += "-F"; + linkLibs += this->Convert(fdi->c_str(), NONE, SHELL, false); + linkLibs += " "; + } + + // Append the library search path flags. + std::vector const& libDirs = cli.GetDirectories(); + for(std::vector::const_iterator libDir = libDirs.begin(); + libDir != libDirs.end(); ++libDir) + { + std::string libpath = this->ConvertToOutputForExisting(libDir->c_str()); + linkLibs += libPathFlag; + linkLibs += libpath; + linkLibs += libPathTerminator; + linkLibs += " "; + } + + // Write the library flags to the build rule. + fout << linkLibs; + + // Get the RPATH entries. + std::vector runtimeDirs; + cli.GetRPath(runtimeDirs, relink); + + // Check what kind of rpath flags to use. + if(cli.GetRuntimeSep().empty()) + { + // Each rpath entry gets its own option ("-R a -R b -R c") + std::string rpath; + for(std::vector::iterator ri = runtimeDirs.begin(); + ri != runtimeDirs.end(); ++ri) + { + rpath += cli.GetRuntimeFlag(); + rpath += this->Convert(ri->c_str(), NONE, SHELL, false); + rpath += " "; + } + fout << rpath; + } + else + { + // All rpath entries are combined ("-Wl,-rpath,a:b:c"). + std::string rpath = cli.GetRPathString(relink); + + // Store the rpath option in the stream. + if(!rpath.empty()) + { + fout << cli.GetRuntimeFlag(); + fout << this->EscapeForShell(rpath.c_str(), true); + fout << " "; + } + } + + // Add the linker runtime search path if any. + std::string rpath_link = cli.GetRPathLinkString(); + if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) + { + fout << cli.GetRPathLinkFlag(); + fout << this->EscapeForShell(rpath_link.c_str(), true); + fout << " "; + } + + // Add standard libraries for this language. + std::string standardLibsVar = "CMAKE_"; + standardLibsVar += cli.GetLinkLanguage(); + standardLibsVar += "_STANDARD_LIBRARIES"; + if(const char* stdLibs = + this->Makefile->GetDefinition(standardLibsVar.c_str())) + { + fout << stdLibs << " "; + } } // Implemented only in cmLocalVisualStudio6Generator. diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 8b131065d32..51453586702 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -99,7 +99,7 @@ class cmLocalNinjaGenerator : public cmLocalGenerator // In order to access to protected member of the local generator. friend class cmNinjaTargetGenerator; friend class cmNinjaExecutableTargetGenerator; - + friend class cmNinjaLibraryTargetGenerator; private: cmGeneratedFileStream& GetBuildFileStream() const; diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index 6ca6507899c..6a4d9966a5f 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -48,6 +48,7 @@ void cmNinjaExecutableTargetGenerator::Generate() this->WriteLinkStatement(); this->GetBuildFileStream() << "\n"; + this->GetRulesFileStream() << "\n"; } void cmNinjaExecutableTargetGenerator::WriteLanguagesRules() @@ -95,11 +96,12 @@ ::WriteCompileRule(const std::string& language) // cmMakefileTargetGenerator::WriteObjectBuildFile // This is mandatory to use a local variables because the string must be // in memory until ExpandRuleVariables() is called. - std::string flags = this->LanguageFlagsVarName(language); + std::string flags = this->LanguageFlagsVarName(language, true); vars.Flags = flags.c_str(); // FIXME(Nicolas Despres): Factor defines construction with the // cmMakefileTargetGenerator::WriteObjectBuildFile - vars.Defines = "$DEFINES"; + std::string defines = this->LanguageDefinesVarName(language, true); + vars.Defines = defines.c_str(); // Rule for compiling object file. std::string compileCmdVar = "CMAKE_"; @@ -118,13 +120,12 @@ ::WriteCompileRule(const std::string& language) description << "Building " << language << " object $out"; std::string depfile = ""; cmNinjaVars emptyVars; - cmGlobalNinjaGenerator::WriteRule(this->GetRulesFileStream(), - this->LanguageCompilerRule(language), - compileCmd, - comment.str(), - description.str(), - depfile, - emptyVars); + this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), + compileCmd, + comment.str(), + description.str(), + depfile, + emptyVars); } void @@ -166,7 +167,7 @@ ::WriteLinkRule(const std::string& language) vars.LinkLibraries = "$LDLIBS"; // This is mandatory to use a local variables because the string must be // in memory until ExpandRuleVariables() is called. - std::string flags = this->LanguageFlagsVarName(language); + std::string flags = this->LanguageFlagsVarName(language, true); vars.Flags = flags.c_str(); vars.LinkFlags = "$LDFLAGS"; @@ -176,6 +177,7 @@ ::WriteLinkRule(const std::string& language) linkCmdVar += "_LINK_EXECUTABLE"; std::string linkCmd = this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + std::cout << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; this->GetLocalGenerator()->ExpandRuleVariables(linkCmd, vars); @@ -186,13 +188,12 @@ ::WriteLinkRule(const std::string& language) description << "Linking " << language << " executable $out"; std::string depfile = ""; cmNinjaVars emptyVars; - cmGlobalNinjaGenerator::WriteRule(this->GetRulesFileStream(), - this->LanguageLinkerRule(language), - linkCmd, - comment.str(), - description.str(), - depfile, - emptyVars); + this->GetGlobalGenerator()->AddRule(this->LanguageLinkerRule(language), + linkCmd, + comment.str(), + description.str(), + depfile, + emptyVars); } void @@ -223,10 +224,14 @@ cmNinjaExecutableTargetGenerator ::WriteObjectBuildStatement(cmSourceFile* source) { cmNinjaDeps emptyDeps; - cmNinjaVars emptyVars; std::string comment; - std::string rule = this->LanguageCompilerRule(source->GetLanguage()); + const char* language = source->GetLanguage(); + // If we cannot get the language this is probably a non-source file provided in the list + // (typically an header file). + if (!language) + return; + std::string rule = this->LanguageCompilerRule(language); cmNinjaDeps outputs; std::string objectFileName = @@ -242,6 +247,15 @@ ::WriteObjectBuildStatement(cmSourceFile* source) cmLocalGenerator::MAKEFILE); explicitDeps.insert(sourceFileName); + const char* linkLanguage = + this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); + + cmNinjaVars vars; + vars[this->LanguageFlagsVarName(linkLanguage)] = + this->ComputeFlagsForObject(linkLanguage); + vars[this->LanguageDefinesVarName(linkLanguage)] = + this->ComputeDefines(linkLanguage); + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), comment, rule, @@ -249,7 +263,7 @@ ::WriteObjectBuildStatement(cmSourceFile* source) explicitDeps, emptyDeps, emptyDeps, - emptyVars); + vars); } void cmNinjaExecutableTargetGenerator::WriteLinkStatement() @@ -280,7 +294,13 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); // Compute specific libraries to link with. + cmNinjaDeps explicitDeps = this->Objects; { + cmNinjaDeps linkDeps = this->ComputeLinkDeps(); + for(cmNinjaDeps::const_iterator i = linkDeps.begin(); + i != linkDeps.end(); + ++i) + explicitDeps.insert(*i); std::ostringstream linkLibraries; this->GetLocalGenerator()->OutputLinkLibraries(linkLibraries, *this->GetTarget(), @@ -289,6 +309,8 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() } // Compute specific link flags. + vars[this->LanguageFlagsVarName(linkLanguage)] = + this->ComputeFlagsForLink(linkLanguage); vars["LDFLAGS"] = this->ComputeLinkFlags(linkLanguage); // Write the build statement for this target. @@ -296,7 +318,7 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() comment.str(), this->LanguageLinkerRule(linkLanguage), outputs, - this->Objects, + explicitDeps, emptyDeps, emptyDeps, vars); diff --git a/Source/cmNinjaLibraryTargetGenerator.cxx b/Source/cmNinjaLibraryTargetGenerator.cxx new file mode 100644 index 00000000000..7f82d956174 --- /dev/null +++ b/Source/cmNinjaLibraryTargetGenerator.cxx @@ -0,0 +1,385 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmNinjaLibraryTargetGenerator.h" +#include "cmLocalNinjaGenerator.h" +#include "cmGlobalNinjaGenerator.h" +#include "cmSourceFile.h" +#include "cmGeneratedFileStream.h" +#include "cmMakefile.h" + +cmNinjaLibraryTargetGenerator:: +cmNinjaLibraryTargetGenerator(cmTarget* target) + : cmNinjaTargetGenerator(target) + , TargetNameOut() + , TargetNameSO() + , TargetNameReal() + , TargetNameImport() + , TargetNamePDB() + , Objects() +{ + this->GetTarget()->GetLibraryNames(this->TargetNameOut, + this->TargetNameSO, + this->TargetNameReal, + this->TargetNameImport, + this->TargetNamePDB, + GetLocalGenerator()->GetConfigName()); +} + +cmNinjaLibraryTargetGenerator::~cmNinjaLibraryTargetGenerator() +{ +} + +void cmNinjaLibraryTargetGenerator::Generate() +{ + // Write the rules for each language. + this->WriteLanguagesRules(); + + // Write the build statements + this->WriteObjectBuildStatements(); + + // // Write the link statement. + this->WriteLinkStatement(); + + this->GetBuildFileStream() << "\n"; + this->GetRulesFileStream() << "\n"; +} + +void cmNinjaLibraryTargetGenerator::WriteLanguagesRules() +{ + cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream()); + this->GetRulesFileStream() + << "# Rules for each languages for " + << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << " target " + << this->GetTarget()->GetName() + << "\n\n"; + + std::set languages; + this->GetTarget()->GetLanguages(languages); + for(std::set::const_iterator l = languages.begin(); + l != languages.end(); + ++l) + this->WriteLanguageRules(*l); +} + +void +cmNinjaLibraryTargetGenerator +::WriteLanguageRules(const std::string& language) +{ + this->GetRulesFileStream() + << "# Rules for language " << language << "\n\n"; + this->WriteCompileRule(language); + this->GetRulesFileStream() << "\n"; + this->WriteLinkRule(language); +} + +// TODO(Nicolas Despres): Refactor with +// void cmNinjaExecutableTargetGenerator::WriteCompileRule(const std::string& language); +void +cmNinjaLibraryTargetGenerator +::WriteCompileRule(const std::string& language) +{ + cmLocalGenerator::RuleVariables vars; + vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; + vars.CMTarget = this->GetTarget(); + std::string lang = language; + vars.Language = lang.c_str(); + vars.Source = "$in"; + vars.Object = "$out"; + + // FIXME(Nicolas Despres): Factor flags construction with the + // cmMakefileTargetGenerator::WriteObjectBuildFile + // This is mandatory to use a local variables because the string must be + // in memory until ExpandRuleVariables() is called. + std::string flags = this->LanguageFlagsVarName(language, true); + vars.Flags = flags.c_str(); + // FIXME(Nicolas Despres): Factor defines construction with the + // cmMakefileTargetGenerator::WriteObjectBuildFile + std::string defines = this->LanguageDefinesVarName(language, true); + vars.Defines = defines.c_str(); + + // Rule for compiling object file. + std::string compileCmdVar = "CMAKE_"; + compileCmdVar += language; + compileCmdVar += "_COMPILE_OBJECT"; + std::string compileCmd = + this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str()); + std::cout << "DEBUG NINJA: COMPILE CMD: " << compileCmd << std::endl; + + this->GetLocalGenerator()->ExpandRuleVariables(compileCmd, vars); + + // Write the rule for compiling file of the given language. + std::ostringstream comment; + comment << "Rule for compiling " << language << " files."; + std::ostringstream description; + description << "Building " << language << " object $out"; + std::string depfile = ""; + cmNinjaVars emptyVars; + this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), + compileCmd, + comment.str(), + description.str(), + depfile, + emptyVars); +} + +void +cmNinjaLibraryTargetGenerator +::WriteLinkRule(const std::string& language) +{ + cmLocalGenerator::RuleVariables vars; + vars.RuleLauncher = "RULE_LAUNCH_LINK"; + vars.CMTarget = this->GetTarget(); + std::string lang = language; + vars.Language = lang.c_str(); + vars.Objects = "$in"; + std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); + objdir += this->GetTarget()->GetName(); + objdir += ".dir"; + objdir = this->GetLocalGenerator()->Convert(objdir.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + vars.ObjectDir = objdir.c_str(); + vars.Target = "$out"; + vars.TargetSOName = "$SONAME"; + + // Setup the target version. + std::string targetVersionMajor; + std::string targetVersionMinor; + { + cmOStringStream majorStream; + cmOStringStream minorStream; + int major; + int minor; + this->GetTarget()->GetTargetVersion(major, minor); + majorStream << major; + minorStream << minor; + targetVersionMajor = majorStream.str(); + targetVersionMinor = minorStream.str(); + } + vars.TargetVersionMajor = targetVersionMajor.c_str(); + vars.TargetVersionMinor = targetVersionMinor.c_str(); + + vars.LinkLibraries = "$LDLIBS"; + + // Add language feature flags. + // This is mandatory to use a local variables because the string must be + // in memory until ExpandRuleVariables() is called. + std::string langFlags = this->LanguageFlagsVarName(language, true); + vars.LanguageCompileFlags = langFlags.c_str(); + vars.LinkFlags = "$LDFLAGS"; + + // Rule for linking library. + std::string linkCmdVar = "CMAKE_"; + linkCmdVar += language; + linkCmdVar += "_CREATE_SHARED_LIBRARY"; + std::string linkCmd = + this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + std::cout << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; + + this->GetLocalGenerator()->ExpandRuleVariables(linkCmd, vars); + + // Write the rule for linking an library. + std::ostringstream comment; + comment << "Rule for linking " << language << " shared library."; + std::ostringstream description; + description << "Linking " << language << " shared library $out"; + std::string depfile = ""; + cmNinjaVars emptyVars; + this->GetGlobalGenerator()->AddRule(this->LanguageLinkerRule(language), + linkCmd, + comment.str(), + description.str(), + depfile, + emptyVars); +} + +void +cmNinjaLibraryTargetGenerator +::WriteObjectBuildStatements() +{ + // Write comments. + cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); + this->GetBuildFileStream() + << "# Object build statements for " + << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << " target " + << this->GetTarget()->GetName() + << "\n\n"; + + // For each source files of this target. + for(std::vector::const_iterator i = + this->GetTarget()->GetSourceFiles().begin(); + i != this->GetTarget()->GetSourceFiles().end(); + ++i) + this->WriteObjectBuildStatement(*i); + + this->GetBuildFileStream() << "\n"; +} + +void +cmNinjaLibraryTargetGenerator +::WriteObjectBuildStatement(cmSourceFile* source) +{ + cmNinjaDeps emptyDeps; + + std::string comment; + const char* language = source->GetLanguage(); + // If we cannot get the language this is probably a non-source file provided in the list + // (typically an header file). + if (!language) + return; + std::string rule = this->LanguageCompilerRule(language); + + cmNinjaDeps outputs; + std::string objectFileName = + this->GetLocalGenerator()->GetObjectFileName(*this->GetTarget(), *source); + outputs.insert(objectFileName); + // Add this object to the list of object files. + this->Objects.insert(objectFileName); + + cmNinjaDeps explicitDeps; + std::string sourceFileName = + this->GetLocalGenerator()->Convert(source->GetFullPath().c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); + explicitDeps.insert(sourceFileName); + + const char* linkLanguage = + this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); + + cmNinjaVars vars; + vars[this->LanguageFlagsVarName(linkLanguage)] = + this->ComputeFlagsForObject(linkLanguage); + vars[this->LanguageDefinesVarName(linkLanguage)] = + this->ComputeDefines(linkLanguage); + + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + comment, + rule, + outputs, + explicitDeps, + emptyDeps, + emptyDeps, + vars); +} + +void cmNinjaLibraryTargetGenerator::WriteLinkStatement() +{ + // Write comments. + cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); + this->GetBuildFileStream() + << "# Link build statements for " + << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << " target " + << this->GetTarget()->GetName() + << "\n\n"; + + cmNinjaDeps emptyDeps; + cmNinjaVars vars; + + // Compute the comment. + std::ostringstream comment; + comment << "Link the shared library " << this->TargetNameOut; + + // Compute outputs. + cmNinjaDeps outputs; + outputs.insert(this->TargetNameOut); + // Add this executable to the all target. + this->GetLocalGenerator()->AddDependencyToAll(this->TargetNameOut); + + const char* linkLanguage = + this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); + + // Compute specific libraries to link with. + cmNinjaDeps explicitDeps = this->Objects; + { + cmNinjaDeps linkDeps = this->ComputeLinkDeps(); + for(cmNinjaDeps::const_iterator i = linkDeps.begin(); + i != linkDeps.end(); + ++i) + explicitDeps.insert(*i); + std::ostringstream linkLibraries; + this->GetLocalGenerator()->OutputLinkLibraries(linkLibraries, + *this->GetTarget(), + false); + vars["LDLIBS"] = linkLibraries.str(); + } + + // Compute specific link flags. + vars[this->LanguageFlagsVarName(linkLanguage)] = + this->ComputeFlagsForLink(linkLanguage); + vars["LDFLAGS"] = this->ComputeLinkFlags(linkLanguage); + vars["SONAME"] = this->TargetNameSO; + + // Write the build statement for this target. + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + comment.str(), + this->LanguageLinkerRule(linkLanguage), + outputs, + explicitDeps, + emptyDeps, + emptyDeps, + vars); +} + +// TODO(Nicolas Despres): Most of the code is picked up from +// void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink). +// Refactor it. +std::string +cmNinjaLibraryTargetGenerator +::ComputeLinkFlags(const std::string& linkLanguage) +{ + // The returned variables. + std::string linkFlags; + // Convenience variables. + cmLocalNinjaGenerator* lg = this->GetLocalGenerator(); + cmTarget* target = this->GetTarget(); + cmMakefile* makefile = this->GetMakefile(); + + // Add flags to create an executable. + lg->AddConfigVariableFlags(linkFlags, + "CMAKE_EXE_LINKER_FLAGS", + this->GetConfigName()); + + if(target->GetPropertyAsBool("WIN32_EXECUTABLE")) + lg->AppendFlags(linkFlags, + makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE")); + else + lg->AppendFlags(linkFlags, + makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE")); + + // Add symbol export flags if necessary. + if(target->IsExecutableWithExports()) + { + std::string export_flag_var = "CMAKE_EXE_EXPORTS_"; + export_flag_var += linkLanguage; + export_flag_var += "_FLAG"; + lg->AppendFlags(linkFlags, + makefile->GetDefinition(export_flag_var.c_str())); + } + + // Target specific link flags. + lg->AppendFlags(linkFlags, target->GetProperty("LINK_FLAGS")); + + // Configuration specific link flags. + std::string linkFlagsConfig = "LINK_FLAGS_"; + linkFlagsConfig += cmSystemTools::UpperCase(this->GetConfigName()); + lg->AppendFlags(linkFlags, target->GetProperty(linkFlagsConfig.c_str())); + + // TODO(Nicolas Despres): Let's see later for the definition files. + // It looks like something specific to Windows and Ninja is not available + // on Windows yet. + // this->AddModuleDefinitionFlag(linkFlags); + + return linkFlags; +} diff --git a/Source/cmNinjaLibraryTargetGenerator.h b/Source/cmNinjaLibraryTargetGenerator.h new file mode 100644 index 00000000000..35d67214d60 --- /dev/null +++ b/Source/cmNinjaLibraryTargetGenerator.h @@ -0,0 +1,50 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmNinjaLibraryTargetGenerator_h +# define cmNinjaLibraryTargetGenerator_h + +# include "cmNinjaTargetGenerator.h" +# include "cmNinjaTypes.h" + +class cmSourceFile; + +class cmNinjaLibraryTargetGenerator : public cmNinjaTargetGenerator +{ +public: + /// Build a NinjaTargetGenerator. + cmNinjaLibraryTargetGenerator(cmTarget* target); + ~cmNinjaLibraryTargetGenerator(); + + virtual void Generate(); + +private: + void WriteLanguagesRules(); + void WriteLanguageRules(const std::string& language); + void WriteCompileRule(const std::string& language); + void WriteLinkRule(const std::string& language); + void WriteObjectBuildStatements(); + void WriteObjectBuildStatement(cmSourceFile* source); + void WriteLinkStatement(); + std::string ComputeLinkFlags(const std::string& linkLanguage); + +private: + // Target name info. + std::string TargetNameOut; + std::string TargetNameSO; + std::string TargetNameReal; + std::string TargetNameImport; + std::string TargetNamePDB; + /// List of object files for this target. + cmNinjaDeps Objects; +}; + +#endif // ! cmNinjaLibraryTargetGenerator_h diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 9cb5533e61b..58feb7f0206 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -14,8 +14,10 @@ #include "cmLocalNinjaGenerator.h" #include "cmGeneratedFileStream.h" #include "cmNinjaExecutableTargetGenerator.h" +#include "cmNinjaLibraryTargetGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" +#include "cmComputeLinkInformation.h" cmNinjaTargetGenerator * cmNinjaTargetGenerator::New(cmTarget* target) @@ -25,6 +27,9 @@ cmNinjaTargetGenerator::New(cmTarget* target) case cmTarget::EXECUTABLE: return new cmNinjaExecutableTargetGenerator(target); + case cmTarget::SHARED_LIBRARY: + return new cmNinjaLibraryTargetGenerator(target); + default: return 0; } @@ -73,9 +78,191 @@ ::LanguageLinkerRule(const std::string& lang) const std::string cmNinjaTargetGenerator -::LanguageFlagsVarName(const std::string& language) const +::LanguageFlagsVarName(const std::string& language, bool ref) const +{ + std::ostringstream varname; + if(ref) + varname << "$"; + varname << language << "_FLAGS"; + return varname.str(); +} + +std::string +cmNinjaTargetGenerator +::LanguageDefinesVarName(const std::string& language, bool ref) const { std::ostringstream varname; - varname << "$" << language << "FLAGS"; + if(ref) + varname << "$"; + varname << language << "_DEFINES"; return varname.str(); } + +// TODO(Nicolas Despres): Picked up from cmMakefileTargetGenerator. +// Refactor it. +const char* cmNinjaTargetGenerator::GetFeature(const char* feature) +{ + return this->Target->GetFeature(feature, this->GetConfigName()); +} + +// TODO(Nicolas Despres): Picked up from cmMakefileTargetGenerator. +// Refactor it. +bool cmNinjaTargetGenerator::GetFeatureAsBool(const char* feature) +{ + return cmSystemTools::IsOn(this->GetFeature(feature)); +} + +// TODO(Nicolas Despres): Picked up from cmMakefileTargetGenerator. +// Refactor it. +void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, + const char* lang) +{ + // Add language-specific flags. + this->LocalGenerator->AddLanguageFlags(flags, lang, this->GetConfigName()); + + if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION")) + { + this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO"); + } +} + +// TODO(Nicolas Despres): Most of the code is picked up from +// void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink), +// void cmMakefileTargetGenerator::WriteTargetLanguageFlags() +// Refactor it. +std::string +cmNinjaTargetGenerator::ComputeFlagsForObject(const std::string& language) +{ + std::string flags; + + this->AddFeatureFlags(flags, language.c_str()); + + this->GetLocalGenerator()->AddArchitectureFlags(flags, + this->GetTarget(), + language.c_str(), + this->GetConfigName()); + + // TODO(Nicolas Despres): Will see later for the Fortran support. + // // Fortran-specific flags computed for this target. + // if(*l == "Fortran") + // { + // this->AddFortranFlags(flags); + // } + + // Add shared-library flags if needed. + { + bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) || + (this->Target->GetType() == cmTarget::MODULE_LIBRARY)); + this->GetLocalGenerator()->AddSharedFlags(flags, language.c_str(), shared); + } + + // TODO(Nicolas Despres): Handle response file. + // Add include directory flags. + { + std::string includeFlags = + this->LocalGenerator->GetIncludeFlags(language.c_str(), false); + this->LocalGenerator->AppendFlags(flags, includeFlags.c_str()); + } + + // Append old-style preprocessor definition flags. + this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags()); + + // TODO(Nicolas Despres): Handle Apple frameworks. + // Add include directory flags. + // this->LocalGenerator->AppendFlags(flags, this->GetFrameworkFlags().c_str()); + + return flags; +} + +// TODO(Nicolas Despres): Most of the code is picked up from +// void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink), +// void cmMakefileTargetGenerator::WriteTargetLanguageFlags() +// Refactor it. +std::string +cmNinjaTargetGenerator::ComputeFlagsForLink(const std::string& language) +{ + std::string flags; + + this->AddFeatureFlags(flags, language.c_str()); + + this->GetLocalGenerator()->AddArchitectureFlags(flags, + this->GetTarget(), + language.c_str(), + this->GetConfigName()); + + // TODO(Nicolas Despres): Will see later for the Fortran support. + // // Fortran-specific flags computed for this target. + // if(*l == "Fortran") + // { + // this->AddFortranFlags(flags); + // } + + return flags; +} + +// TODO(Nicolas Despres): Refact with +// void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). +std::string +cmNinjaTargetGenerator:: +ComputeDefines(const std::string& language) +{ + std::string defines; + + // Add the export symbol definition for shared library objects. + if(const char* exportMacro = this->Target->GetExportMacro()) + { + this->LocalGenerator->AppendDefines(defines, exportMacro, language.c_str()); + } + + // Add preprocessor definitions for this target and configuration. + this->LocalGenerator->AppendDefines + (defines, + this->Makefile->GetProperty("COMPILE_DEFINITIONS"), + language.c_str()); + this->LocalGenerator->AppendDefines + (defines, + this->Target->GetProperty("COMPILE_DEFINITIONS"), + language.c_str()); + { + std::string defPropName = "COMPILE_DEFINITIONS_"; + defPropName += cmSystemTools::UpperCase(this->GetConfigName()); + this->LocalGenerator->AppendDefines + (defines, + this->Makefile->GetProperty(defPropName.c_str()), + language.c_str()); + this->LocalGenerator->AppendDefines + (defines, + this->Target->GetProperty(defPropName.c_str()), + language.c_str()); + } + + return defines; +} + +cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const +{ + cmNinjaDeps linkDeps; + + cmComputeLinkInformation* cli = + this->Target->GetLinkInformation(this->GetConfigName()); + if(!cli) + return linkDeps; + + + // Append the link items. + typedef cmComputeLinkInformation::ItemVector ItemVector; + ItemVector const& items = cli->GetItems(); + for(ItemVector::const_iterator li = items.begin(); li != items.end(); ++li) + { + if(li->IsPath) + { + linkDeps.insert(this->LocalGenerator->ConvertToLinkReference(li->Value)); + } + else + { + linkDeps.insert(li->Value); + } + } + + return linkDeps; +} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index ce8222bd445..5f0780195a5 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -13,6 +13,7 @@ # define cmNinjaTargetGenerator_h # include "cmStandardIncludes.h" +# include "cmNinjaTypes.h" class cmTarget; class cmLocalNinjaGenerator; @@ -56,7 +57,34 @@ class cmNinjaTargetGenerator std::string LanguageLinkerRule(const std::string& lang) const; - std::string LanguageFlagsVarName(const std::string& language) const; + std::string LanguageFlagsVarName(const std::string& language, + bool ref = false) const; + std::string LanguageDefinesVarName(const std::string& language, + bool ref = false) const; + + const char* GetFeature(const char* feature); + bool GetFeatureAsBool(const char* feature); + void AddFeatureFlags(std::string& flags, const char* lang); + + /** + * Compute the flags for compilation of object files for a given @a language. + * @note Generally it is the value of the variable whose name is computed + * by LanguageFlagsVarName(). + */ + std::string ComputeFlagsForObject(const std::string& language); + + /** + * Compute the flags for the linking of a target for a given @a language. + * @note Generally it is the value of the variable whose name is computed + * by LanguageFlagsVarName(). + */ + std::string ComputeFlagsForLink(const std::string& language); + + std::string ComputeDefines(const std::string& language); + + /// @return the list of link dependency for the given target @a target. + cmNinjaDeps ComputeLinkDeps() const; + private: cmTarget* Target; From 8953554ad77f3a60c1ed157c8dcff221a550322d Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 17 Apr 2011 18:08:37 +0200 Subject: [PATCH 425/539] Ninja: No longer use a set but a vector. Order matter. If we want to remove duplicated items it would be done by hand. --- Source/cmLocalNinjaGenerator.cxx | 4 ++-- Source/cmNinjaExecutableTargetGenerator.cxx | 10 +++++----- Source/cmNinjaLibraryTargetGenerator.cxx | 10 +++++----- Source/cmNinjaTargetGenerator.cxx | 4 ++-- Source/cmNinjaTypes.h | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 95e2177ff58..1b2f096dcea 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -436,7 +436,7 @@ void cmLocalNinjaGenerator::WriteBuiltinTargets(std::ostream& os) void cmLocalNinjaGenerator::AddDependencyToAll(const std::string& dependency) { - this->AllDependencies.insert(dependency); + this->AllDependencies.push_back(dependency); } void cmLocalNinjaGenerator::WriteTargetAll(std::ostream& os) @@ -445,7 +445,7 @@ void cmLocalNinjaGenerator::WriteTargetAll(std::ostream& os) cmNinjaVars emptyVars; cmNinjaDeps outputs; - outputs.insert("all"); + outputs.push_back("all"); cmGlobalNinjaGenerator::WritePhonyBuild(os, "The main all target.", diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index 6a4d9966a5f..f4114e16caa 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -236,16 +236,16 @@ ::WriteObjectBuildStatement(cmSourceFile* source) cmNinjaDeps outputs; std::string objectFileName = this->GetLocalGenerator()->GetObjectFileName(*this->GetTarget(), *source); - outputs.insert(objectFileName); + outputs.push_back(objectFileName); // Add this object to the list of object files. - this->Objects.insert(objectFileName); + this->Objects.push_back(objectFileName); cmNinjaDeps explicitDeps; std::string sourceFileName = this->GetLocalGenerator()->Convert(source->GetFullPath().c_str(), cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); - explicitDeps.insert(sourceFileName); + explicitDeps.push_back(sourceFileName); const char* linkLanguage = this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); @@ -286,7 +286,7 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() // Compute outputs. cmNinjaDeps outputs; - outputs.insert(this->TargetNameOut); + outputs.push_back(this->TargetNameOut); // Add this executable to the all target. this->GetLocalGenerator()->AddDependencyToAll(this->TargetNameOut); @@ -300,7 +300,7 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() for(cmNinjaDeps::const_iterator i = linkDeps.begin(); i != linkDeps.end(); ++i) - explicitDeps.insert(*i); + explicitDeps.push_back(*i); std::ostringstream linkLibraries; this->GetLocalGenerator()->OutputLinkLibraries(linkLibraries, *this->GetTarget(), diff --git a/Source/cmNinjaLibraryTargetGenerator.cxx b/Source/cmNinjaLibraryTargetGenerator.cxx index 7f82d956174..80574dbc839 100644 --- a/Source/cmNinjaLibraryTargetGenerator.cxx +++ b/Source/cmNinjaLibraryTargetGenerator.cxx @@ -243,16 +243,16 @@ ::WriteObjectBuildStatement(cmSourceFile* source) cmNinjaDeps outputs; std::string objectFileName = this->GetLocalGenerator()->GetObjectFileName(*this->GetTarget(), *source); - outputs.insert(objectFileName); + outputs.push_back(objectFileName); // Add this object to the list of object files. - this->Objects.insert(objectFileName); + this->Objects.push_back(objectFileName); cmNinjaDeps explicitDeps; std::string sourceFileName = this->GetLocalGenerator()->Convert(source->GetFullPath().c_str(), cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE); - explicitDeps.insert(sourceFileName); + explicitDeps.push_back(sourceFileName); const char* linkLanguage = this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); @@ -293,7 +293,7 @@ void cmNinjaLibraryTargetGenerator::WriteLinkStatement() // Compute outputs. cmNinjaDeps outputs; - outputs.insert(this->TargetNameOut); + outputs.push_back(this->TargetNameOut); // Add this executable to the all target. this->GetLocalGenerator()->AddDependencyToAll(this->TargetNameOut); @@ -307,7 +307,7 @@ void cmNinjaLibraryTargetGenerator::WriteLinkStatement() for(cmNinjaDeps::const_iterator i = linkDeps.begin(); i != linkDeps.end(); ++i) - explicitDeps.insert(*i); + explicitDeps.push_back(*i); std::ostringstream linkLibraries; this->GetLocalGenerator()->OutputLinkLibraries(linkLibraries, *this->GetTarget(), diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 58feb7f0206..7550da398cd 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -256,11 +256,11 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const { if(li->IsPath) { - linkDeps.insert(this->LocalGenerator->ConvertToLinkReference(li->Value)); + linkDeps.push_back(this->LocalGenerator->ConvertToLinkReference(li->Value)); } else { - linkDeps.insert(li->Value); + linkDeps.push_back(li->Value); } } diff --git a/Source/cmNinjaTypes.h b/Source/cmNinjaTypes.h index 1c5c226dd4c..99b2afd11f2 100644 --- a/Source/cmNinjaTypes.h +++ b/Source/cmNinjaTypes.h @@ -12,7 +12,7 @@ #ifndef cmNinjaTypes_h # define cmNinjaTypes_h -typedef std::set cmNinjaDeps; +typedef std::vector cmNinjaDeps; typedef std::map cmNinjaVars; #endif // ! cmGlobalNinjaGenerator_h From a4b35561780920bbf9104c577b47883ab2578e7d Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 17 Apr 2011 21:04:47 +0200 Subject: [PATCH 426/539] Ninja: We will never support multiple configurations. Remove overloading of AppendDirectoryForConfig(). --- Source/cmGlobalNinjaGenerator.cxx | 21 --------------------- Source/cmGlobalNinjaGenerator.h | 7 ------- 2 files changed, 28 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index a1ef35e70ce..2bc9f965a6c 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -443,27 +443,6 @@ ::GenerateBuildCommand(const char* makeProgram, return makeCommand; } -// Not implemented in UnixMakefile generator. -void cmGlobalNinjaGenerator -::AppendDirectoryForConfig(const char* prefix, - const char* config, - const char* suffix, - std::string& dir) -{ - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: prefix: '" << prefix << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: config: '" << config << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: suffix: '" << suffix << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: dir: '" << dir << "'" << std::endl; - - cmGlobalGenerator::AppendDirectoryForConfig(prefix, - config, - suffix, - dir); - - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - //---------------------------------------------------------------------------- // Non-virtual public methods. diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index d01a255c2dc..477b4d30a15 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -169,13 +169,6 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator bool ignoreErrors, bool fast); - /// Overloaded methods. - /// @see cmGlobalGenerator::AppendDirectoryForConfig() - virtual void AppendDirectoryForConfig(const char* prefix, - const char* config, - const char* suffix, - std::string& dir); - // Setup target names virtual const char* GetAllTargetName() const { return "all"; } virtual const char* GetInstallTargetName() const { return "install"; } From db3f34bc84237760e8820f7d59adee16eb934036 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 17 Apr 2011 21:06:59 +0200 Subject: [PATCH 427/539] Ninja: No longer overload UseFolderProperty(). None of the other generators overload it, so we probably don't need it either. --- Source/cmGlobalNinjaGenerator.cxx | 9 --------- Source/cmGlobalNinjaGenerator.h | 3 --- 2 files changed, 12 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 2bc9f965a6c..4dc4959d6ae 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -521,15 +521,6 @@ const char* cmGlobalNinjaGenerator::GetPredefinedTargetsFolder() return ret; } -// Not implemented in UnixMakefile generator. -bool cmGlobalNinjaGenerator::UseFolderProperty() -{ - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - bool ret = cmGlobalGenerator::UseFolderProperty(); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; - return ret; -} - //---------------------------------------------------------------------------- // Private methods diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 477b4d30a15..1832d58c3d1 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -221,9 +221,6 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator /// Overloaded methods. @see cmGlobalGenerator::GetPredefinedTargetsFolder() virtual const char* GetPredefinedTargetsFolder(); - /// Overloaded methods. @see cmGlobalGenerator::UseFolderProperty() - virtual bool UseFolderProperty(); - private: void OpenBuildFileStream(); void CloseBuildFileStream(); From 3c7be2abc6a64f9c760ca084d7ddb4c9445a457b Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 17 Apr 2011 21:17:18 +0200 Subject: [PATCH 428/539] Ninja: Add more debug messages. It helps me to understand how local and global generators are created, destroyed and invoked. I will remove this debugging code later. --- Source/cmGlobalNinjaGenerator.cxx | 8 ++++++-- Source/cmLocalNinjaGenerator.cxx | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 4dc4959d6ae..33bfc24da1e 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -302,7 +302,9 @@ void cmGlobalNinjaGenerator::Configure() // Source/cmake.cxx void cmGlobalNinjaGenerator::Generate() { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: BEGIN: " + << __PRETTY_FUNCTION__ + << " (" << this << ")" << std::endl; this->OpenBuildFileStream(); this->OpenRulesFileStream(); @@ -312,7 +314,9 @@ void cmGlobalNinjaGenerator::Generate() this->CloseRulesFileStream(); this->CloseBuildFileStream(); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: END: " + << __PRETTY_FUNCTION__ + << " (" << this << ")" << std::endl; } // Implemented in all cmGlobaleGenerator sub-classes. diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 1b2f096dcea..31e26457e38 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -31,11 +31,21 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator() cmLocalNinjaGenerator::~cmLocalNinjaGenerator() { + std::cout << "DEBUG NINJA: LOCAL GENERATOR DESTRUCTOR: " + << this << std::endl; } void cmLocalNinjaGenerator::Generate() { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: BEGIN: " + << __PRETTY_FUNCTION__ + << " (" << this << ")" << std::endl; + std::cout << "DEBUG NINJA: CURRENT DIRECTORY: " + << this->Makefile->GetCurrentDirectory() << std::endl; + std::cout << "DEBUG NINJA: CURRENT OUTPUT DIRECTORY: " + << this->Makefile->GetCurrentOutputDirectory() << std::endl; + std::cout << "DEBUG NINJA: CURRENT LIST FILE: " + << this->Makefile->GetCurrentListFile() << std::endl; this->SetConfigName(); this->WriteProjectHeader(this->GetBuildFileStream()); @@ -54,7 +64,9 @@ void cmLocalNinjaGenerator::Generate() this->WriteBuiltinTargets(this->GetBuildFileStream()); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cout << "DEBUG NINJA: END: " + << __PRETTY_FUNCTION__ + << " (" << this << ")" << std::endl; } // Implemented in: From cb4e823393c2657ec99ec262793b9a9d7587973a Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Sun, 17 Apr 2011 23:16:00 +0200 Subject: [PATCH 429/539] Ninja: Write bottom and top of the build file once. When there is recursive CMakeLists.txt we shall write once the top and the bottom of the build.ninja file. --- Source/cmGlobalNinjaGenerator.cxx | 34 +++++++++++++++++++ Source/cmGlobalNinjaGenerator.h | 12 +++++++ Source/cmLocalNinjaGenerator.cxx | 56 +++++++++++++------------------ Source/cmLocalNinjaGenerator.h | 14 ++++++-- 4 files changed, 81 insertions(+), 35 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 33bfc24da1e..b734d8db391 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -257,6 +257,7 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator() , BuildFileStream(0) , RulesFileStream(0) , Rules() + , AllDependencies() { // // Ninja is not ported to non-Unix OS yet. // this->ForceUnixPaths = true; @@ -311,6 +312,8 @@ void cmGlobalNinjaGenerator::Generate() this->cmGlobalGenerator::Generate(); + this->WriteBuiltinTargets(*this->BuildFileStream); + this->CloseRulesFileStream(); this->CloseBuildFileStream(); @@ -626,3 +629,34 @@ void cmGlobalNinjaGenerator::WriteDisclaimer(std::ostream& os) << cmVersion::GetMajorVersion() << "." << cmVersion::GetMinorVersion() << "\n\n"; } + +void cmGlobalNinjaGenerator::AddDependencyToAll(const std::string& dependency) +{ + this->AllDependencies.push_back(dependency); +} + +void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os) +{ + // Write headers. + cmGlobalNinjaGenerator::WriteDivider(os); + os << "# Built-in targets\n\n"; + + this->WriteTargetAll(os); +} + +void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os) +{ + cmNinjaDeps emptyDeps; + cmNinjaVars emptyVars; + + cmNinjaDeps outputs; + outputs.push_back("all"); + + cmGlobalNinjaGenerator::WritePhonyBuild(os, + "The main all target.", + outputs, + emptyDeps, + emptyDeps, + this->AllDependencies, + emptyVars); +} diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 1832d58c3d1..60dfb4d7dbb 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -221,6 +221,10 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator /// Overloaded methods. @see cmGlobalGenerator::GetPredefinedTargetsFolder() virtual const char* GetPredefinedTargetsFolder(); +private: + // In order to access the AddDependencyToAll() functions and co. + friend class cmLocalNinjaGenerator; + private: void OpenBuildFileStream(); void CloseBuildFileStream(); @@ -231,6 +235,11 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator /// Write the common disclaimer text at the top of each build file. void WriteDisclaimer(std::ostream& os); + void AddDependencyToAll(const std::string& dependency); + + void WriteBuiltinTargets(std::ostream& os); + void WriteTargetAll(std::ostream& os); + private: /// The file containing the build statement. (the relation ship of the /// compilation DAG). @@ -245,6 +254,9 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator /// The set of rules added to the generated build system. RulesSetType Rules; + + /// The set of dependencies to add to the "all" target. + cmNinjaDeps AllDependencies; }; #endif // ! cmGlobalNinjaGenerator_h diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 31e26457e38..03e78fb5ca3 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -16,11 +16,11 @@ #include "cmGeneratedFileStream.h" #include "cmSourceFile.h" #include "cmComputeLinkInformation.h" +#include "cmake.h" cmLocalNinjaGenerator::cmLocalNinjaGenerator() : cmLocalGenerator() , ConfigName("") - , AllDependencies() { // TODO(Nicolas Despres): Maybe I should set this one to true?? this->IsMakefileGenerator = false; @@ -48,8 +48,7 @@ void cmLocalNinjaGenerator::Generate() << this->Makefile->GetCurrentListFile() << std::endl; this->SetConfigName(); - this->WriteProjectHeader(this->GetBuildFileStream()); - this->WriteNinjaFilesInclusion(this->GetBuildFileStream()); + this->WriteBuildFileTop(); cmTargets& targets = this->GetMakefile()->GetTargets(); for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) @@ -62,8 +61,6 @@ void cmLocalNinjaGenerator::Generate() } } - this->WriteBuiltinTargets(this->GetBuildFileStream()); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << " (" << this << ")" << std::endl; @@ -398,6 +395,27 @@ cmGeneratedFileStream& cmLocalNinjaGenerator::GetRulesFileStream() const return *this->GetGlobalNinjaGenerator()->GetRulesFileStream(); } +cmake* cmLocalNinjaGenerator::GetCMakeInstance() const +{ + return this->GetGlobalGenerator()->GetCMakeInstance(); +} + +bool cmLocalNinjaGenerator::isRootMakefile() const +{ + return (strcmp(this->Makefile->GetCurrentDirectory(), + this->GetCMakeInstance()->GetHomeDirectory()) == 0); +} + +void cmLocalNinjaGenerator::WriteBuildFileTop() +{ + // We do that only once for the top CMakeLists.txt file. + if (!this->isRootMakefile()) + return; + + this->WriteProjectHeader(this->GetBuildFileStream()); + this->WriteNinjaFilesInclusion(this->GetBuildFileStream()); +} + void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os) { cmGlobalNinjaGenerator::WriteDivider(os); @@ -436,34 +454,8 @@ void cmLocalNinjaGenerator::SetConfigName() } } -void cmLocalNinjaGenerator::WriteBuiltinTargets(std::ostream& os) -{ - // Write headers. - cmGlobalNinjaGenerator::WriteDivider(os); - os << "# Built-in targets\n\n"; - - this->WriteTargetAll(os); -} - void cmLocalNinjaGenerator::AddDependencyToAll(const std::string& dependency) { - this->AllDependencies.push_back(dependency); -} - -void cmLocalNinjaGenerator::WriteTargetAll(std::ostream& os) -{ - cmNinjaDeps emptyDeps; - cmNinjaVars emptyVars; - - cmNinjaDeps outputs; - outputs.push_back("all"); - - cmGlobalNinjaGenerator::WritePhonyBuild(os, - "The main all target.", - outputs, - emptyDeps, - emptyDeps, - this->AllDependencies, - emptyVars); + this->GetGlobalNinjaGenerator()->AddDependencyToAll(dependency); } diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 51453586702..a3f517674f1 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -17,6 +17,7 @@ class cmGlobalNinjaGenerator; class cmGeneratedFileStream; +class cmake; /** * \class cmLocalNinjaGenerator @@ -79,12 +80,21 @@ class cmLocalNinjaGenerator : public cmLocalGenerator public: cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const; + /** + * Shortcut to get the cmake instance throw the global generator. + * @return an instance of the cmake object. + */ + cmake* GetCMakeInstance() const; + const char* GetConfigName() const { return this->ConfigName.c_str(); } std::string GetObjectFileName(const cmTarget& target, const cmSourceFile& source); + /// @return whether we are processing the top CMakeLists.txt file. + bool isRootMakefile() const; + protected: /// Overloaded methods. @see cmLocalGenerator::OutputLinkLibraries() @@ -105,17 +115,15 @@ class cmLocalNinjaGenerator : public cmLocalGenerator cmGeneratedFileStream& GetBuildFileStream() const; cmGeneratedFileStream& GetRulesFileStream() const; + void WriteBuildFileTop(); void WriteProjectHeader(std::ostream& os); void WriteNinjaFilesInclusion(std::ostream& os); - void WriteBuiltinTargets(std::ostream& os); - void WriteTargetAll(std::ostream& os); void AddDependencyToAll(const std::string& dependency); void SetConfigName(); private: std::string ConfigName; - cmNinjaDeps AllDependencies; }; #endif // ! cmLocalNinjaGenerator_h From 3aaca7457b4da83d8297f23d891230474277f694 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Tue, 19 Apr 2011 16:44:27 +0200 Subject: [PATCH 430/539] Ninja: Support recursive CMakeLists.txt. --- Source/cmLocalNinjaGenerator.cxx | 43 +++++++++++++++---- Source/cmLocalNinjaGenerator.h | 7 +++ Source/cmNinjaExecutableTargetGenerator.cxx | 14 +++--- Source/cmNinjaLibraryTargetGenerator.cxx | 14 +++--- Source/cmNinjaTargetGenerator.cxx | 47 ++++++++++++++++++++- Source/cmNinjaTargetGenerator.h | 12 ++++++ 6 files changed, 109 insertions(+), 28 deletions(-) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 03e78fb5ca3..1c5a2374e7b 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -21,6 +21,7 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator() : cmLocalGenerator() , ConfigName("") + , HomeRelativeOutputPath("") { // TODO(Nicolas Despres): Maybe I should set this one to true?? this->IsMakefileGenerator = false; @@ -47,7 +48,12 @@ void cmLocalNinjaGenerator::Generate() std::cout << "DEBUG NINJA: CURRENT LIST FILE: " << this->Makefile->GetCurrentListFile() << std::endl; + this->SetConfigName(); + + this->WriteProcessedMakefile(this->GetBuildFileStream()); + this->WriteProcessedMakefile(this->GetRulesFileStream()); + this->WriteBuildFileTop(); cmTargets& targets = this->GetMakefile()->GetTargets(); @@ -75,9 +81,14 @@ void cmLocalNinjaGenerator::Configure() { std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - // NOTE: cmLocalUnixMakefileGenerator3::Configure() compute - // a path used to write rules in Makefiles later. We will see if - // we need such a thing later. + // Compute the path to use when referencing the current output + // directory from the top output directory. + this->HomeRelativeOutputPath = + this->Convert(this->Makefile->GetStartOutputDirectory(), HOME_OUTPUT); + if(this->HomeRelativeOutputPath == ".") + { + this->HomeRelativeOutputPath = ""; + } this->cmLocalGenerator::Configure(); std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; @@ -409,21 +420,25 @@ bool cmLocalNinjaGenerator::isRootMakefile() const void cmLocalNinjaGenerator::WriteBuildFileTop() { // We do that only once for the top CMakeLists.txt file. - if (!this->isRootMakefile()) + if(!this->isRootMakefile()) return; + // For the build file. this->WriteProjectHeader(this->GetBuildFileStream()); this->WriteNinjaFilesInclusion(this->GetBuildFileStream()); + + // For the rule file. + this->WriteProjectHeader(this->GetRulesFileStream()); } void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os) { cmGlobalNinjaGenerator::WriteDivider(os); os - << "# Project: " << this->GetMakefile()->GetProjectName() << "\n" - << "# Configuration: " << this->ConfigName << "\n" - << "\n" + << "# Project: " << this->GetMakefile()->GetProjectName() << std::endl + << "# Configuration: " << this->ConfigName << std::endl ; + cmGlobalNinjaGenerator::WriteDivider(os); } void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os) @@ -454,8 +469,20 @@ void cmLocalNinjaGenerator::SetConfigName() } } - void cmLocalNinjaGenerator::AddDependencyToAll(const std::string& dependency) { this->GetGlobalNinjaGenerator()->AddDependencyToAll(dependency); } + +void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) +{ + cmGlobalNinjaGenerator::WriteDivider(os); + os + << "# Write statements declared in CMakeLists.txt:" << std::endl + << "# " << this->Makefile->GetCurrentListFile() << std::endl + ; + if(this->isRootMakefile()) + os << "# Which is the root file." << std::endl; + cmGlobalNinjaGenerator::WriteDivider(os); + os << std::endl; +} diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index a3f517674f1..8d789fcc2c5 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -95,6 +95,11 @@ class cmLocalNinjaGenerator : public cmLocalGenerator /// @return whether we are processing the top CMakeLists.txt file. bool isRootMakefile() const; + /// @returns the relative path between the HomeOutputDirectory and this + /// local generators StartOutputDirectory. + std::string GetHomeRelativeOutputPath() const + { return this->HomeRelativeOutputPath; } + protected: /// Overloaded methods. @see cmLocalGenerator::OutputLinkLibraries() @@ -119,11 +124,13 @@ class cmLocalNinjaGenerator : public cmLocalGenerator void WriteProjectHeader(std::ostream& os); void WriteNinjaFilesInclusion(std::ostream& os); void AddDependencyToAll(const std::string& dependency); + void WriteProcessedMakefile(std::ostream& os); void SetConfigName(); private: std::string ConfigName; + std::string HomeRelativeOutputPath; }; #endif // ! cmLocalNinjaGenerator_h diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index f4114e16caa..395ff57e8fa 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -227,24 +227,20 @@ ::WriteObjectBuildStatement(cmSourceFile* source) std::string comment; const char* language = source->GetLanguage(); - // If we cannot get the language this is probably a non-source file provided in the list - // (typically an header file). + // If we cannot get the language this is probably a non-source file provided + // in the list (typically an header file). if (!language) return; std::string rule = this->LanguageCompilerRule(language); cmNinjaDeps outputs; - std::string objectFileName = - this->GetLocalGenerator()->GetObjectFileName(*this->GetTarget(), *source); + std::string objectFileName = this->GetObjectFilePath(source); outputs.push_back(objectFileName); // Add this object to the list of object files. this->Objects.push_back(objectFileName); cmNinjaDeps explicitDeps; - std::string sourceFileName = - this->GetLocalGenerator()->Convert(source->GetFullPath().c_str(), - cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE); + std::string sourceFileName = this->GetSourceFilePath(source); explicitDeps.push_back(sourceFileName); const char* linkLanguage = @@ -286,7 +282,7 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() // Compute outputs. cmNinjaDeps outputs; - outputs.push_back(this->TargetNameOut); + outputs.push_back(this->GetTargetFilePath(this->TargetNameOut)); // Add this executable to the all target. this->GetLocalGenerator()->AddDependencyToAll(this->TargetNameOut); diff --git a/Source/cmNinjaLibraryTargetGenerator.cxx b/Source/cmNinjaLibraryTargetGenerator.cxx index 80574dbc839..ded14fba8bd 100644 --- a/Source/cmNinjaLibraryTargetGenerator.cxx +++ b/Source/cmNinjaLibraryTargetGenerator.cxx @@ -234,24 +234,20 @@ ::WriteObjectBuildStatement(cmSourceFile* source) std::string comment; const char* language = source->GetLanguage(); - // If we cannot get the language this is probably a non-source file provided in the list - // (typically an header file). + // If we cannot get the language this is probably a non-source file provided + // in the list (typically an header file). if (!language) return; std::string rule = this->LanguageCompilerRule(language); cmNinjaDeps outputs; - std::string objectFileName = - this->GetLocalGenerator()->GetObjectFileName(*this->GetTarget(), *source); + std::string objectFileName = this->GetObjectFilePath(source); outputs.push_back(objectFileName); // Add this object to the list of object files. this->Objects.push_back(objectFileName); cmNinjaDeps explicitDeps; - std::string sourceFileName = - this->GetLocalGenerator()->Convert(source->GetFullPath().c_str(), - cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE); + std::string sourceFileName = this->GetSourceFilePath(source); explicitDeps.push_back(sourceFileName); const char* linkLanguage = @@ -293,7 +289,7 @@ void cmNinjaLibraryTargetGenerator::WriteLinkStatement() // Compute outputs. cmNinjaDeps outputs; - outputs.push_back(this->TargetNameOut); + outputs.push_back(this->GetTargetFilePath(this->TargetNameOut)); // Add this executable to the all target. this->GetLocalGenerator()->AddDependencyToAll(this->TargetNameOut); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 7550da398cd..23a9e118b57 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmComputeLinkInformation.h" +#include "cmSourceFile.h" cmNinjaTargetGenerator * cmNinjaTargetGenerator::New(cmTarget* target) @@ -254,15 +255,57 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const ItemVector const& items = cli->GetItems(); for(ItemVector::const_iterator li = items.begin(); li != items.end(); ++li) { + std::string filename; if(li->IsPath) { - linkDeps.push_back(this->LocalGenerator->ConvertToLinkReference(li->Value)); + filename = this->LocalGenerator->ConvertToLinkReference(li->Value); } else { - linkDeps.push_back(li->Value); + filename = li->Value; } + std::string path = this->GetTargetOutputDir(); + if(!path.empty()) + path += "/"; + path += filename; + linkDeps.push_back(path); } return linkDeps; } + +std::string +cmNinjaTargetGenerator +::GetSourceFilePath(cmSourceFile* source) const +{ + return this->LocalGenerator->Convert(source->GetFullPath().c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); +} + +std::string +cmNinjaTargetGenerator +::GetObjectFilePath(cmSourceFile* source) const +{ + std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); + if(!path.empty()) + path += "/"; + path += this->LocalGenerator->GetObjectFileName(*this->Target, *source); + return path; +} + +std::string cmNinjaTargetGenerator::GetTargetOutputDir() const +{ + return this->LocalGenerator->GetHomeRelativeOutputPath(); +} + +std::string +cmNinjaTargetGenerator +::GetTargetFilePath(const std::string& name) const +{ + std::string path = this->GetTargetOutputDir(); + if(!path.empty()) + path += "/"; + path += name; + return path; +} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 5f0780195a5..b9f0e962c81 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -20,6 +20,7 @@ class cmLocalNinjaGenerator; class cmGlobalNinjaGenerator; class cmGeneratedFileStream; class cmMakefile; +class cmSourceFile; class cmNinjaTargetGenerator { @@ -85,6 +86,17 @@ class cmNinjaTargetGenerator /// @return the list of link dependency for the given target @a target. cmNinjaDeps ComputeLinkDeps() const; + /// @return the source file path for the given @a source. + std::string GetSourceFilePath(cmSourceFile* source) const; + + /// @return the object file path for the given @a source. + std::string GetObjectFilePath(cmSourceFile* source) const; + + /// @return the file path where the target named @a name is generated. + std::string GetTargetFilePath(const std::string& name) const; + + /// @return the output path for the target. + virtual std::string GetTargetOutputDir() const; private: cmTarget* Target; From 15318a29b161eab7c89422d330d6f668c779b96a Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Tue, 19 Apr 2011 17:37:53 +0200 Subject: [PATCH 431/539] Ninja: Generate shortcut target. --- Source/cmNinjaExecutableTargetGenerator.cxx | 6 ++- Source/cmNinjaLibraryTargetGenerator.cxx | 6 ++- Source/cmNinjaTargetGenerator.cxx | 42 +++++++++++++++++++++ Source/cmNinjaTargetGenerator.h | 7 ++++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index 395ff57e8fa..f7d698e2c0d 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -282,7 +282,8 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() // Compute outputs. cmNinjaDeps outputs; - outputs.push_back(this->GetTargetFilePath(this->TargetNameOut)); + std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); + outputs.push_back(targetOutput); // Add this executable to the all target. this->GetLocalGenerator()->AddDependencyToAll(this->TargetNameOut); @@ -318,6 +319,9 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() emptyDeps, emptyDeps, vars); + + // Write a shortcut rule with the target name. + this->WriteTargetBuild(this->TargetNameOut, targetOutput); } // TODO(Nicolas Despres): Most of the code is picked up from diff --git a/Source/cmNinjaLibraryTargetGenerator.cxx b/Source/cmNinjaLibraryTargetGenerator.cxx index ded14fba8bd..ecf04206fd3 100644 --- a/Source/cmNinjaLibraryTargetGenerator.cxx +++ b/Source/cmNinjaLibraryTargetGenerator.cxx @@ -289,7 +289,8 @@ void cmNinjaLibraryTargetGenerator::WriteLinkStatement() // Compute outputs. cmNinjaDeps outputs; - outputs.push_back(this->GetTargetFilePath(this->TargetNameOut)); + std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); + outputs.push_back(targetOutput); // Add this executable to the all target. this->GetLocalGenerator()->AddDependencyToAll(this->TargetNameOut); @@ -326,6 +327,9 @@ void cmNinjaLibraryTargetGenerator::WriteLinkStatement() emptyDeps, emptyDeps, vars); + + // Write a shortcut rule with the target name. + this->WriteTargetBuild(this->TargetNameOut, targetOutput); } // TODO(Nicolas Despres): Most of the code is picked up from diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 23a9e118b57..cc02a74ee4d 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -309,3 +309,45 @@ ::GetTargetFilePath(const std::string& name) const path += name; return path; } + +void +cmNinjaTargetGenerator +::WriteTargetBuild(const std::string& outputName, + const std::string& outputPath) +{ + cmNinjaDeps emptyDeps; + cmNinjaVars emptyVars; + + if(outputName != outputPath) + { + std::string comment = "Shortcut target for the output name."; + cmNinjaDeps outputs; + outputs.push_back(outputName); + cmNinjaDeps explicitDeps; + explicitDeps.push_back(outputPath); + cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), + comment, + outputs, + explicitDeps, + emptyDeps, + emptyDeps, + emptyVars); + } + + std::string targetName = this->Target->GetName(); + if(targetName != outputName) + { + std::string comment = "Shortcut target for the target name."; + cmNinjaDeps outputs; + outputs.push_back(targetName); + cmNinjaDeps explicitDeps; + explicitDeps.push_back(outputName); + cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), + comment, + outputs, + explicitDeps, + emptyDeps, + emptyDeps, + emptyVars); + } +} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index b9f0e962c81..4a3941018cb 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -98,6 +98,13 @@ class cmNinjaTargetGenerator /// @return the output path for the target. virtual std::string GetTargetOutputDir() const; + /** + * Write shortcut build statements for the target name with the target + * output name and the target output path. + */ + void WriteTargetBuild(const std::string& outputName, + const std::string& outputPath); + private: cmTarget* Target; cmMakefile* Makefile; From 2f486ea3621e71e5684c7fad2c2b52c692660614 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Tue, 19 Apr 2011 17:43:57 +0200 Subject: [PATCH 432/539] Ninja: Add convenient method GetTargetName(). --- Source/cmNinjaExecutableTargetGenerator.cxx | 8 ++++---- Source/cmNinjaLibraryTargetGenerator.cxx | 10 +++++----- Source/cmNinjaTargetGenerator.cxx | 7 ++++++- Source/cmNinjaTargetGenerator.h | 2 ++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index f7d698e2c0d..ce9a8e03b25 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -58,7 +58,7 @@ void cmNinjaExecutableTargetGenerator::WriteLanguagesRules() << "# Rules for each languages for " << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) << " target " - << this->GetTarget()->GetName() + << this->GetTargetName() << "\n\n"; std::set languages; @@ -139,7 +139,7 @@ ::WriteLinkRule(const std::string& language) vars.Language = lang.c_str(); vars.Objects = "$in"; std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); - objdir += this->GetTarget()->GetName(); + objdir += this->GetTargetName(); objdir += ".dir"; objdir = this->GetLocalGenerator()->Convert(objdir.c_str(), cmLocalGenerator::START_OUTPUT, @@ -206,7 +206,7 @@ ::WriteObjectBuildStatements() << "# Object build statements for " << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) << " target " - << this->GetTarget()->GetName() + << this->GetTargetName() << "\n\n"; // For each source files of this target. @@ -270,7 +270,7 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() << "# Link build statements for " << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) << " target " - << this->GetTarget()->GetName() + << this->GetTargetName() << "\n\n"; cmNinjaDeps emptyDeps; diff --git a/Source/cmNinjaLibraryTargetGenerator.cxx b/Source/cmNinjaLibraryTargetGenerator.cxx index ecf04206fd3..72569047cda 100644 --- a/Source/cmNinjaLibraryTargetGenerator.cxx +++ b/Source/cmNinjaLibraryTargetGenerator.cxx @@ -46,7 +46,7 @@ void cmNinjaLibraryTargetGenerator::Generate() // Write the build statements this->WriteObjectBuildStatements(); - // // Write the link statement. + // Write the link statement. this->WriteLinkStatement(); this->GetBuildFileStream() << "\n"; @@ -60,7 +60,7 @@ void cmNinjaLibraryTargetGenerator::WriteLanguagesRules() << "# Rules for each languages for " << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) << " target " - << this->GetTarget()->GetName() + << this->GetTargetName() << "\n\n"; std::set languages; @@ -143,7 +143,7 @@ ::WriteLinkRule(const std::string& language) vars.Language = lang.c_str(); vars.Objects = "$in"; std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); - objdir += this->GetTarget()->GetName(); + objdir += this->GetTargetName(); objdir += ".dir"; objdir = this->GetLocalGenerator()->Convert(objdir.c_str(), cmLocalGenerator::START_OUTPUT, @@ -213,7 +213,7 @@ ::WriteObjectBuildStatements() << "# Object build statements for " << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) << " target " - << this->GetTarget()->GetName() + << this->GetTargetName() << "\n\n"; // For each source files of this target. @@ -277,7 +277,7 @@ void cmNinjaLibraryTargetGenerator::WriteLinkStatement() << "# Link build statements for " << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) << " target " - << this->GetTarget()->GetName() + << this->GetTargetName() << "\n\n"; cmNinjaDeps emptyDeps; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cc02a74ee4d..a36683f70d5 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -334,7 +334,7 @@ ::WriteTargetBuild(const std::string& outputName, emptyVars); } - std::string targetName = this->Target->GetName(); + std::string targetName = this->GetTargetName(); if(targetName != outputName) { std::string comment = "Shortcut target for the target name."; @@ -351,3 +351,8 @@ ::WriteTargetBuild(const std::string& outputName, emptyVars); } } + +std::string cmNinjaTargetGenerator::GetTargetName() const +{ + return this->Target->GetName(); +} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 4a3941018cb..8995112642b 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -43,6 +43,8 @@ class cmNinjaTargetGenerator cmTarget* GetTarget() const { return this->Target; } + std::string GetTargetName() const; + cmLocalNinjaGenerator* GetLocalGenerator() const { return this->LocalGenerator; } From 1b526db8ed40e83168baadd88db6d1b027d30c86 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Tue, 19 Apr 2011 17:47:15 +0200 Subject: [PATCH 433/539] Ninja: Target 'all' depends on target names not output. --- Source/cmNinjaExecutableTargetGenerator.cxx | 2 +- Source/cmNinjaLibraryTargetGenerator.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index ce9a8e03b25..a0e3880cc6a 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -285,7 +285,7 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); outputs.push_back(targetOutput); // Add this executable to the all target. - this->GetLocalGenerator()->AddDependencyToAll(this->TargetNameOut); + this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); const char* linkLanguage = this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); diff --git a/Source/cmNinjaLibraryTargetGenerator.cxx b/Source/cmNinjaLibraryTargetGenerator.cxx index 72569047cda..159bd753989 100644 --- a/Source/cmNinjaLibraryTargetGenerator.cxx +++ b/Source/cmNinjaLibraryTargetGenerator.cxx @@ -292,7 +292,7 @@ void cmNinjaLibraryTargetGenerator::WriteLinkStatement() std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); outputs.push_back(targetOutput); // Add this executable to the all target. - this->GetLocalGenerator()->AddDependencyToAll(this->TargetNameOut); + this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); const char* linkLanguage = this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); From d17e4db8d30d598b68d3a9f2e524844761bbbd4e Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Tue, 19 Apr 2011 18:10:10 +0200 Subject: [PATCH 434/539] Ninja: Factor common code between executable and library targets. --- Source/cmNinjaExecutableTargetGenerator.cxx | 198 +------------------ Source/cmNinjaExecutableTargetGenerator.h | 12 +- Source/cmNinjaLibraryTargetGenerator.cxx | 200 +------------------- Source/cmNinjaLibraryTargetGenerator.h | 12 +- Source/cmNinjaTargetGenerator.cxx | 193 +++++++++++++++++++ Source/cmNinjaTargetGenerator.h | 14 ++ 6 files changed, 213 insertions(+), 416 deletions(-) diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index a0e3880cc6a..64e3706d98d 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -23,7 +23,6 @@ cmNinjaExecutableTargetGenerator(cmTarget* target) , TargetNameReal() , TargetNameImport() , TargetNamePDB() - , Objects() { this->GetTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, @@ -51,83 +50,6 @@ void cmNinjaExecutableTargetGenerator::Generate() this->GetRulesFileStream() << "\n"; } -void cmNinjaExecutableTargetGenerator::WriteLanguagesRules() -{ - cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream()); - this->GetRulesFileStream() - << "# Rules for each languages for " - << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) - << " target " - << this->GetTargetName() - << "\n\n"; - - std::set languages; - this->GetTarget()->GetLanguages(languages); - for(std::set::const_iterator l = languages.begin(); - l != languages.end(); - ++l) - this->WriteLanguageRules(*l); -} - -void -cmNinjaExecutableTargetGenerator -::WriteLanguageRules(const std::string& language) -{ - this->GetRulesFileStream() - << "# Rules for language " << language << "\n\n"; - this->WriteCompileRule(language); - this->GetRulesFileStream() << "\n"; - this->WriteLinkRule(language); -} - -void -cmNinjaExecutableTargetGenerator -::WriteCompileRule(const std::string& language) -{ - cmLocalGenerator::RuleVariables vars; - vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; - vars.CMTarget = this->GetTarget(); - std::string lang = language; - vars.Language = lang.c_str(); - vars.Source = "$in"; - vars.Object = "$out"; - - // FIXME(Nicolas Despres): Factor flags construction with the - // cmMakefileTargetGenerator::WriteObjectBuildFile - // This is mandatory to use a local variables because the string must be - // in memory until ExpandRuleVariables() is called. - std::string flags = this->LanguageFlagsVarName(language, true); - vars.Flags = flags.c_str(); - // FIXME(Nicolas Despres): Factor defines construction with the - // cmMakefileTargetGenerator::WriteObjectBuildFile - std::string defines = this->LanguageDefinesVarName(language, true); - vars.Defines = defines.c_str(); - - // Rule for compiling object file. - std::string compileCmdVar = "CMAKE_"; - compileCmdVar += language; - compileCmdVar += "_COMPILE_OBJECT"; - std::string compileCmd = - this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str()); - std::cout << "DEBUG NINJA: COMPILE CMD: " << compileCmd << std::endl; - - this->GetLocalGenerator()->ExpandRuleVariables(compileCmd, vars); - - // Write the rule for compiling file of the given language. - std::ostringstream comment; - comment << "Rule for compiling " << language << " files."; - std::ostringstream description; - description << "Building " << language << " object $out"; - std::string depfile = ""; - cmNinjaVars emptyVars; - this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), - compileCmd, - comment.str(), - description.str(), - depfile, - emptyVars); -} - void cmNinjaExecutableTargetGenerator ::WriteLinkRule(const std::string& language) @@ -196,72 +118,6 @@ ::WriteLinkRule(const std::string& language) emptyVars); } -void -cmNinjaExecutableTargetGenerator -::WriteObjectBuildStatements() -{ - // Write comments. - cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); - this->GetBuildFileStream() - << "# Object build statements for " - << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) - << " target " - << this->GetTargetName() - << "\n\n"; - - // For each source files of this target. - for(std::vector::const_iterator i = - this->GetTarget()->GetSourceFiles().begin(); - i != this->GetTarget()->GetSourceFiles().end(); - ++i) - this->WriteObjectBuildStatement(*i); - - this->GetBuildFileStream() << "\n"; -} - -void -cmNinjaExecutableTargetGenerator -::WriteObjectBuildStatement(cmSourceFile* source) -{ - cmNinjaDeps emptyDeps; - - std::string comment; - const char* language = source->GetLanguage(); - // If we cannot get the language this is probably a non-source file provided - // in the list (typically an header file). - if (!language) - return; - std::string rule = this->LanguageCompilerRule(language); - - cmNinjaDeps outputs; - std::string objectFileName = this->GetObjectFilePath(source); - outputs.push_back(objectFileName); - // Add this object to the list of object files. - this->Objects.push_back(objectFileName); - - cmNinjaDeps explicitDeps; - std::string sourceFileName = this->GetSourceFilePath(source); - explicitDeps.push_back(sourceFileName); - - const char* linkLanguage = - this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); - - cmNinjaVars vars; - vars[this->LanguageFlagsVarName(linkLanguage)] = - this->ComputeFlagsForObject(linkLanguage); - vars[this->LanguageDefinesVarName(linkLanguage)] = - this->ComputeDefines(linkLanguage); - - cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - comment, - rule, - outputs, - explicitDeps, - emptyDeps, - emptyDeps, - vars); -} - void cmNinjaExecutableTargetGenerator::WriteLinkStatement() { // Write comments. @@ -291,7 +147,7 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); // Compute specific libraries to link with. - cmNinjaDeps explicitDeps = this->Objects; + cmNinjaDeps explicitDeps = this->GetObjects(); { cmNinjaDeps linkDeps = this->ComputeLinkDeps(); for(cmNinjaDeps::const_iterator i = linkDeps.begin(); @@ -323,55 +179,3 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() // Write a shortcut rule with the target name. this->WriteTargetBuild(this->TargetNameOut, targetOutput); } - -// TODO(Nicolas Despres): Most of the code is picked up from -// void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink). -// Refactor it. -std::string -cmNinjaExecutableTargetGenerator -::ComputeLinkFlags(const std::string& linkLanguage) -{ - // The returned variables. - std::string linkFlags; - // Convenience variables. - cmLocalNinjaGenerator* lg = this->GetLocalGenerator(); - cmTarget* target = this->GetTarget(); - cmMakefile* makefile = this->GetMakefile(); - - // Add flags to create an executable. - lg->AddConfigVariableFlags(linkFlags, - "CMAKE_EXE_LINKER_FLAGS", - this->GetConfigName()); - - if(target->GetPropertyAsBool("WIN32_EXECUTABLE")) - lg->AppendFlags(linkFlags, - makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE")); - else - lg->AppendFlags(linkFlags, - makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE")); - - // Add symbol export flags if necessary. - if(target->IsExecutableWithExports()) - { - std::string export_flag_var = "CMAKE_EXE_EXPORTS_"; - export_flag_var += linkLanguage; - export_flag_var += "_FLAG"; - lg->AppendFlags(linkFlags, - makefile->GetDefinition(export_flag_var.c_str())); - } - - // Target specific link flags. - lg->AppendFlags(linkFlags, target->GetProperty("LINK_FLAGS")); - - // Configuration specific link flags. - std::string linkFlagsConfig = "LINK_FLAGS_"; - linkFlagsConfig += cmSystemTools::UpperCase(this->GetConfigName()); - lg->AppendFlags(linkFlags, target->GetProperty(linkFlagsConfig.c_str())); - - // TODO(Nicolas Despres): Let's see later for the definition files. - // It looks like something specific to Windows and Ninja is not available - // on Windows yet. - // this->AddModuleDefinitionFlag(linkFlags); - - return linkFlags; -} diff --git a/Source/cmNinjaExecutableTargetGenerator.h b/Source/cmNinjaExecutableTargetGenerator.h index 7199ac86ca0..09bab678bbf 100644 --- a/Source/cmNinjaExecutableTargetGenerator.h +++ b/Source/cmNinjaExecutableTargetGenerator.h @@ -27,14 +27,8 @@ class cmNinjaExecutableTargetGenerator : public cmNinjaTargetGenerator virtual void Generate(); private: - void WriteLanguagesRules(); - void WriteLanguageRules(const std::string& language); - void WriteCompileRule(const std::string& language); - void WriteLinkRule(const std::string& language); - void WriteObjectBuildStatements(); - void WriteObjectBuildStatement(cmSourceFile* source); - void WriteLinkStatement(); - std::string ComputeLinkFlags(const std::string& linkLanguage); + virtual void WriteLinkRule(const std::string& language); + virtual void WriteLinkStatement(); private: // Target name info. @@ -42,8 +36,6 @@ class cmNinjaExecutableTargetGenerator : public cmNinjaTargetGenerator std::string TargetNameReal; std::string TargetNameImport; std::string TargetNamePDB; - /// List of object files for this target. - cmNinjaDeps Objects; }; #endif // ! cmNinjaExecutableTargetGenerator_h diff --git a/Source/cmNinjaLibraryTargetGenerator.cxx b/Source/cmNinjaLibraryTargetGenerator.cxx index 159bd753989..e85e82e7816 100644 --- a/Source/cmNinjaLibraryTargetGenerator.cxx +++ b/Source/cmNinjaLibraryTargetGenerator.cxx @@ -24,7 +24,6 @@ cmNinjaLibraryTargetGenerator(cmTarget* target) , TargetNameReal() , TargetNameImport() , TargetNamePDB() - , Objects() { this->GetTarget()->GetLibraryNames(this->TargetNameOut, this->TargetNameSO, @@ -53,85 +52,6 @@ void cmNinjaLibraryTargetGenerator::Generate() this->GetRulesFileStream() << "\n"; } -void cmNinjaLibraryTargetGenerator::WriteLanguagesRules() -{ - cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream()); - this->GetRulesFileStream() - << "# Rules for each languages for " - << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) - << " target " - << this->GetTargetName() - << "\n\n"; - - std::set languages; - this->GetTarget()->GetLanguages(languages); - for(std::set::const_iterator l = languages.begin(); - l != languages.end(); - ++l) - this->WriteLanguageRules(*l); -} - -void -cmNinjaLibraryTargetGenerator -::WriteLanguageRules(const std::string& language) -{ - this->GetRulesFileStream() - << "# Rules for language " << language << "\n\n"; - this->WriteCompileRule(language); - this->GetRulesFileStream() << "\n"; - this->WriteLinkRule(language); -} - -// TODO(Nicolas Despres): Refactor with -// void cmNinjaExecutableTargetGenerator::WriteCompileRule(const std::string& language); -void -cmNinjaLibraryTargetGenerator -::WriteCompileRule(const std::string& language) -{ - cmLocalGenerator::RuleVariables vars; - vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; - vars.CMTarget = this->GetTarget(); - std::string lang = language; - vars.Language = lang.c_str(); - vars.Source = "$in"; - vars.Object = "$out"; - - // FIXME(Nicolas Despres): Factor flags construction with the - // cmMakefileTargetGenerator::WriteObjectBuildFile - // This is mandatory to use a local variables because the string must be - // in memory until ExpandRuleVariables() is called. - std::string flags = this->LanguageFlagsVarName(language, true); - vars.Flags = flags.c_str(); - // FIXME(Nicolas Despres): Factor defines construction with the - // cmMakefileTargetGenerator::WriteObjectBuildFile - std::string defines = this->LanguageDefinesVarName(language, true); - vars.Defines = defines.c_str(); - - // Rule for compiling object file. - std::string compileCmdVar = "CMAKE_"; - compileCmdVar += language; - compileCmdVar += "_COMPILE_OBJECT"; - std::string compileCmd = - this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str()); - std::cout << "DEBUG NINJA: COMPILE CMD: " << compileCmd << std::endl; - - this->GetLocalGenerator()->ExpandRuleVariables(compileCmd, vars); - - // Write the rule for compiling file of the given language. - std::ostringstream comment; - comment << "Rule for compiling " << language << " files."; - std::ostringstream description; - description << "Building " << language << " object $out"; - std::string depfile = ""; - cmNinjaVars emptyVars; - this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), - compileCmd, - comment.str(), - description.str(), - depfile, - emptyVars); -} - void cmNinjaLibraryTargetGenerator ::WriteLinkRule(const std::string& language) @@ -203,72 +123,6 @@ ::WriteLinkRule(const std::string& language) emptyVars); } -void -cmNinjaLibraryTargetGenerator -::WriteObjectBuildStatements() -{ - // Write comments. - cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); - this->GetBuildFileStream() - << "# Object build statements for " - << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) - << " target " - << this->GetTargetName() - << "\n\n"; - - // For each source files of this target. - for(std::vector::const_iterator i = - this->GetTarget()->GetSourceFiles().begin(); - i != this->GetTarget()->GetSourceFiles().end(); - ++i) - this->WriteObjectBuildStatement(*i); - - this->GetBuildFileStream() << "\n"; -} - -void -cmNinjaLibraryTargetGenerator -::WriteObjectBuildStatement(cmSourceFile* source) -{ - cmNinjaDeps emptyDeps; - - std::string comment; - const char* language = source->GetLanguage(); - // If we cannot get the language this is probably a non-source file provided - // in the list (typically an header file). - if (!language) - return; - std::string rule = this->LanguageCompilerRule(language); - - cmNinjaDeps outputs; - std::string objectFileName = this->GetObjectFilePath(source); - outputs.push_back(objectFileName); - // Add this object to the list of object files. - this->Objects.push_back(objectFileName); - - cmNinjaDeps explicitDeps; - std::string sourceFileName = this->GetSourceFilePath(source); - explicitDeps.push_back(sourceFileName); - - const char* linkLanguage = - this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); - - cmNinjaVars vars; - vars[this->LanguageFlagsVarName(linkLanguage)] = - this->ComputeFlagsForObject(linkLanguage); - vars[this->LanguageDefinesVarName(linkLanguage)] = - this->ComputeDefines(linkLanguage); - - cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - comment, - rule, - outputs, - explicitDeps, - emptyDeps, - emptyDeps, - vars); -} - void cmNinjaLibraryTargetGenerator::WriteLinkStatement() { // Write comments. @@ -298,7 +152,7 @@ void cmNinjaLibraryTargetGenerator::WriteLinkStatement() this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); // Compute specific libraries to link with. - cmNinjaDeps explicitDeps = this->Objects; + cmNinjaDeps explicitDeps = this->GetObjects(); { cmNinjaDeps linkDeps = this->ComputeLinkDeps(); for(cmNinjaDeps::const_iterator i = linkDeps.begin(); @@ -331,55 +185,3 @@ void cmNinjaLibraryTargetGenerator::WriteLinkStatement() // Write a shortcut rule with the target name. this->WriteTargetBuild(this->TargetNameOut, targetOutput); } - -// TODO(Nicolas Despres): Most of the code is picked up from -// void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink). -// Refactor it. -std::string -cmNinjaLibraryTargetGenerator -::ComputeLinkFlags(const std::string& linkLanguage) -{ - // The returned variables. - std::string linkFlags; - // Convenience variables. - cmLocalNinjaGenerator* lg = this->GetLocalGenerator(); - cmTarget* target = this->GetTarget(); - cmMakefile* makefile = this->GetMakefile(); - - // Add flags to create an executable. - lg->AddConfigVariableFlags(linkFlags, - "CMAKE_EXE_LINKER_FLAGS", - this->GetConfigName()); - - if(target->GetPropertyAsBool("WIN32_EXECUTABLE")) - lg->AppendFlags(linkFlags, - makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE")); - else - lg->AppendFlags(linkFlags, - makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE")); - - // Add symbol export flags if necessary. - if(target->IsExecutableWithExports()) - { - std::string export_flag_var = "CMAKE_EXE_EXPORTS_"; - export_flag_var += linkLanguage; - export_flag_var += "_FLAG"; - lg->AppendFlags(linkFlags, - makefile->GetDefinition(export_flag_var.c_str())); - } - - // Target specific link flags. - lg->AppendFlags(linkFlags, target->GetProperty("LINK_FLAGS")); - - // Configuration specific link flags. - std::string linkFlagsConfig = "LINK_FLAGS_"; - linkFlagsConfig += cmSystemTools::UpperCase(this->GetConfigName()); - lg->AppendFlags(linkFlags, target->GetProperty(linkFlagsConfig.c_str())); - - // TODO(Nicolas Despres): Let's see later for the definition files. - // It looks like something specific to Windows and Ninja is not available - // on Windows yet. - // this->AddModuleDefinitionFlag(linkFlags); - - return linkFlags; -} diff --git a/Source/cmNinjaLibraryTargetGenerator.h b/Source/cmNinjaLibraryTargetGenerator.h index 35d67214d60..95369b705e2 100644 --- a/Source/cmNinjaLibraryTargetGenerator.h +++ b/Source/cmNinjaLibraryTargetGenerator.h @@ -27,14 +27,8 @@ class cmNinjaLibraryTargetGenerator : public cmNinjaTargetGenerator virtual void Generate(); private: - void WriteLanguagesRules(); - void WriteLanguageRules(const std::string& language); - void WriteCompileRule(const std::string& language); - void WriteLinkRule(const std::string& language); - void WriteObjectBuildStatements(); - void WriteObjectBuildStatement(cmSourceFile* source); - void WriteLinkStatement(); - std::string ComputeLinkFlags(const std::string& linkLanguage); + virtual void WriteLinkRule(const std::string& language); + virtual void WriteLinkStatement(); private: // Target name info. @@ -43,8 +37,6 @@ class cmNinjaLibraryTargetGenerator : public cmNinjaTargetGenerator std::string TargetNameReal; std::string TargetNameImport; std::string TargetNamePDB; - /// List of object files for this target. - cmNinjaDeps Objects; }; #endif // ! cmNinjaLibraryTargetGenerator_h diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index a36683f70d5..1b648a2c66c 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -40,6 +40,7 @@ cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmTarget* target) : Target(target) , Makefile(target->GetMakefile()) , LocalGenerator(static_cast(Makefile->GetLocalGenerator())) + , Objects() { } @@ -356,3 +357,195 @@ std::string cmNinjaTargetGenerator::GetTargetName() const { return this->Target->GetName(); } + +void cmNinjaTargetGenerator::WriteLanguagesRules() +{ + cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream()); + this->GetRulesFileStream() + << "# Rules for each languages for " + << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << " target " + << this->GetTargetName() + << "\n\n"; + + std::set languages; + this->GetTarget()->GetLanguages(languages); + for(std::set::const_iterator l = languages.begin(); + l != languages.end(); + ++l) + this->WriteLanguageRules(*l); +} + +void +cmNinjaTargetGenerator +::WriteLanguageRules(const std::string& language) +{ + this->GetRulesFileStream() + << "# Rules for language " << language << "\n\n"; + this->WriteCompileRule(language); + this->GetRulesFileStream() << "\n"; + this->WriteLinkRule(language); +} + +void +cmNinjaTargetGenerator +::WriteCompileRule(const std::string& language) +{ + cmLocalGenerator::RuleVariables vars; + vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; + vars.CMTarget = this->GetTarget(); + std::string lang = language; + vars.Language = lang.c_str(); + vars.Source = "$in"; + vars.Object = "$out"; + + // FIXME(Nicolas Despres): Factor flags construction with the + // cmMakefileTargetGenerator::WriteObjectBuildFile + // This is mandatory to use a local variables because the string must be + // in memory until ExpandRuleVariables() is called. + std::string flags = this->LanguageFlagsVarName(language, true); + vars.Flags = flags.c_str(); + // FIXME(Nicolas Despres): Factor defines construction with the + // cmMakefileTargetGenerator::WriteObjectBuildFile + std::string defines = this->LanguageDefinesVarName(language, true); + vars.Defines = defines.c_str(); + + // Rule for compiling object file. + std::string compileCmdVar = "CMAKE_"; + compileCmdVar += language; + compileCmdVar += "_COMPILE_OBJECT"; + std::string compileCmd = + this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str()); + std::cout << "DEBUG NINJA: COMPILE CMD: " << compileCmd << std::endl; + + this->GetLocalGenerator()->ExpandRuleVariables(compileCmd, vars); + + // Write the rule for compiling file of the given language. + std::ostringstream comment; + comment << "Rule for compiling " << language << " files."; + std::ostringstream description; + description << "Building " << language << " object $out"; + std::string depfile = ""; + cmNinjaVars emptyVars; + this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), + compileCmd, + comment.str(), + description.str(), + depfile, + emptyVars); +} + +void +cmNinjaTargetGenerator +::WriteObjectBuildStatements() +{ + // Write comments. + cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); + this->GetBuildFileStream() + << "# Object build statements for " + << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << " target " + << this->GetTargetName() + << "\n\n"; + + // For each source files of this target. + for(std::vector::const_iterator i = + this->GetTarget()->GetSourceFiles().begin(); + i != this->GetTarget()->GetSourceFiles().end(); + ++i) + this->WriteObjectBuildStatement(*i); + + this->GetBuildFileStream() << "\n"; +} + +void +cmNinjaTargetGenerator +::WriteObjectBuildStatement(cmSourceFile* source) +{ + cmNinjaDeps emptyDeps; + + std::string comment; + const char* language = source->GetLanguage(); + // If we cannot get the language this is probably a non-source file provided + // in the list (typically an header file). + if (!language) + return; + std::string rule = this->LanguageCompilerRule(language); + + cmNinjaDeps outputs; + std::string objectFileName = this->GetObjectFilePath(source); + outputs.push_back(objectFileName); + // Add this object to the list of object files. + this->Objects.push_back(objectFileName); + + cmNinjaDeps explicitDeps; + std::string sourceFileName = this->GetSourceFilePath(source); + explicitDeps.push_back(sourceFileName); + + const char* linkLanguage = + this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); + + cmNinjaVars vars; + vars[this->LanguageFlagsVarName(linkLanguage)] = + this->ComputeFlagsForObject(linkLanguage); + vars[this->LanguageDefinesVarName(linkLanguage)] = + this->ComputeDefines(linkLanguage); + + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + comment, + rule, + outputs, + explicitDeps, + emptyDeps, + emptyDeps, + vars); +} + +std::string +cmNinjaTargetGenerator +::ComputeLinkFlags(const std::string& linkLanguage) +{ + // The returned variables. + std::string linkFlags; + // Convenience variables. + cmLocalNinjaGenerator* lg = this->GetLocalGenerator(); + cmTarget* target = this->GetTarget(); + cmMakefile* makefile = this->GetMakefile(); + + // Add flags to create an executable. + lg->AddConfigVariableFlags(linkFlags, + "CMAKE_EXE_LINKER_FLAGS", + this->GetConfigName()); + + if(target->GetPropertyAsBool("WIN32_EXECUTABLE")) + lg->AppendFlags(linkFlags, + makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE")); + else + lg->AppendFlags(linkFlags, + makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE")); + + // Add symbol export flags if necessary. + if(target->IsExecutableWithExports()) + { + std::string export_flag_var = "CMAKE_EXE_EXPORTS_"; + export_flag_var += linkLanguage; + export_flag_var += "_FLAG"; + lg->AppendFlags(linkFlags, + makefile->GetDefinition(export_flag_var.c_str())); + } + + // Target specific link flags. + lg->AppendFlags(linkFlags, target->GetProperty("LINK_FLAGS")); + + // Configuration specific link flags. + std::string linkFlagsConfig = "LINK_FLAGS_"; + linkFlagsConfig += cmSystemTools::UpperCase(this->GetConfigName()); + lg->AppendFlags(linkFlags, target->GetProperty(linkFlagsConfig.c_str())); + + // TODO(Nicolas Despres): Let's see later for the definition files. + // It looks like something specific to Windows and Ninja is not available + // on Windows yet. + // this->AddModuleDefinitionFlag(linkFlags); + + return linkFlags; +} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 8995112642b..b780b4e49a4 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -107,10 +107,24 @@ class cmNinjaTargetGenerator void WriteTargetBuild(const std::string& outputName, const std::string& outputPath); + void WriteLanguagesRules(); + void WriteLanguageRules(const std::string& language); + void WriteCompileRule(const std::string& language); + virtual void WriteLinkRule(const std::string& language) = 0; + void WriteObjectBuildStatements(); + void WriteObjectBuildStatement(cmSourceFile* source); + virtual void WriteLinkStatement() = 0; + std::string ComputeLinkFlags(const std::string& linkLanguage); + + cmNinjaDeps GetObjects() const + { return this->Objects; } + private: cmTarget* Target; cmMakefile* Makefile; cmLocalNinjaGenerator* LocalGenerator; + /// List of object files for this target. + cmNinjaDeps Objects; }; #endif // ! cmNinjaTargetGenerator_h From ba41ad909f81ecfdefd8ec7b89efb182e96267c9 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Tue, 19 Apr 2011 18:37:29 +0200 Subject: [PATCH 435/539] Ninja: Print the real target output in the comment. --- Source/cmNinjaExecutableTargetGenerator.cxx | 5 +++-- Source/cmNinjaLibraryTargetGenerator.cxx | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index 64e3706d98d..bf2e6c76fd9 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -132,13 +132,14 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() cmNinjaDeps emptyDeps; cmNinjaVars vars; + std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); + // Compute the comment. std::ostringstream comment; - comment << "Link the executable " << this->TargetNameOut; + comment << "Link the executable " << targetOutput; // Compute outputs. cmNinjaDeps outputs; - std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); outputs.push_back(targetOutput); // Add this executable to the all target. this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); diff --git a/Source/cmNinjaLibraryTargetGenerator.cxx b/Source/cmNinjaLibraryTargetGenerator.cxx index e85e82e7816..e53aa4759c4 100644 --- a/Source/cmNinjaLibraryTargetGenerator.cxx +++ b/Source/cmNinjaLibraryTargetGenerator.cxx @@ -137,13 +137,14 @@ void cmNinjaLibraryTargetGenerator::WriteLinkStatement() cmNinjaDeps emptyDeps; cmNinjaVars vars; + std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); + // Compute the comment. std::ostringstream comment; - comment << "Link the shared library " << this->TargetNameOut; + comment << "Link the shared library " << targetOutput; // Compute outputs. cmNinjaDeps outputs; - std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); outputs.push_back(targetOutput); // Add this executable to the all target. this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); From d660989e942ad72f1b1ffa3b26fed4619314d3bf Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Tue, 19 Apr 2011 18:52:25 +0200 Subject: [PATCH 436/539] Ninja: Use order-only dependencies for shortcut targets. --- Source/cmNinjaTargetGenerator.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 1b648a2c66c..d28f76afbf5 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -324,14 +324,14 @@ ::WriteTargetBuild(const std::string& outputName, std::string comment = "Shortcut target for the output name."; cmNinjaDeps outputs; outputs.push_back(outputName); - cmNinjaDeps explicitDeps; - explicitDeps.push_back(outputPath); + cmNinjaDeps deps; + deps.push_back(outputPath); cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), comment, outputs, - explicitDeps, emptyDeps, emptyDeps, + deps, emptyVars); } @@ -341,14 +341,14 @@ ::WriteTargetBuild(const std::string& outputName, std::string comment = "Shortcut target for the target name."; cmNinjaDeps outputs; outputs.push_back(targetName); - cmNinjaDeps explicitDeps; - explicitDeps.push_back(outputName); + cmNinjaDeps deps; + deps.push_back(outputName); cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), comment, outputs, - explicitDeps, emptyDeps, emptyDeps, + deps, emptyVars); } } From 75220f5fb8a38658263b434b74a1b4666a174ca5 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Thu, 21 Apr 2011 09:25:24 +0200 Subject: [PATCH 437/539] Ninja: Factor the generate() methods. --- Source/cmNinjaExecutableTargetGenerator.cxx | 15 --------------- Source/cmNinjaExecutableTargetGenerator.h | 2 -- Source/cmNinjaLibraryTargetGenerator.cxx | 15 --------------- Source/cmNinjaLibraryTargetGenerator.h | 2 -- Source/cmNinjaTargetGenerator.cxx | 15 +++++++++++++++ Source/cmNinjaTargetGenerator.h | 2 +- 6 files changed, 16 insertions(+), 35 deletions(-) diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index bf2e6c76fd9..5018eee2819 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -35,21 +35,6 @@ cmNinjaExecutableTargetGenerator::~cmNinjaExecutableTargetGenerator() { } -void cmNinjaExecutableTargetGenerator::Generate() -{ - // Write the rules for each language. - this->WriteLanguagesRules(); - - // Write the build statements - this->WriteObjectBuildStatements(); - - // Write the link statement. - this->WriteLinkStatement(); - - this->GetBuildFileStream() << "\n"; - this->GetRulesFileStream() << "\n"; -} - void cmNinjaExecutableTargetGenerator ::WriteLinkRule(const std::string& language) diff --git a/Source/cmNinjaExecutableTargetGenerator.h b/Source/cmNinjaExecutableTargetGenerator.h index 09bab678bbf..2109fa512e2 100644 --- a/Source/cmNinjaExecutableTargetGenerator.h +++ b/Source/cmNinjaExecutableTargetGenerator.h @@ -24,8 +24,6 @@ class cmNinjaExecutableTargetGenerator : public cmNinjaTargetGenerator cmNinjaExecutableTargetGenerator(cmTarget* target); ~cmNinjaExecutableTargetGenerator(); - virtual void Generate(); - private: virtual void WriteLinkRule(const std::string& language); virtual void WriteLinkStatement(); diff --git a/Source/cmNinjaLibraryTargetGenerator.cxx b/Source/cmNinjaLibraryTargetGenerator.cxx index e53aa4759c4..c20b4acd566 100644 --- a/Source/cmNinjaLibraryTargetGenerator.cxx +++ b/Source/cmNinjaLibraryTargetGenerator.cxx @@ -37,21 +37,6 @@ cmNinjaLibraryTargetGenerator::~cmNinjaLibraryTargetGenerator() { } -void cmNinjaLibraryTargetGenerator::Generate() -{ - // Write the rules for each language. - this->WriteLanguagesRules(); - - // Write the build statements - this->WriteObjectBuildStatements(); - - // Write the link statement. - this->WriteLinkStatement(); - - this->GetBuildFileStream() << "\n"; - this->GetRulesFileStream() << "\n"; -} - void cmNinjaLibraryTargetGenerator ::WriteLinkRule(const std::string& language) diff --git a/Source/cmNinjaLibraryTargetGenerator.h b/Source/cmNinjaLibraryTargetGenerator.h index 95369b705e2..83774612a49 100644 --- a/Source/cmNinjaLibraryTargetGenerator.h +++ b/Source/cmNinjaLibraryTargetGenerator.h @@ -24,8 +24,6 @@ class cmNinjaLibraryTargetGenerator : public cmNinjaTargetGenerator cmNinjaLibraryTargetGenerator(cmTarget* target); ~cmNinjaLibraryTargetGenerator(); - virtual void Generate(); - private: virtual void WriteLinkRule(const std::string& language); virtual void WriteLinkStatement(); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index d28f76afbf5..980d79b07ab 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -48,6 +48,21 @@ cmNinjaTargetGenerator::~cmNinjaTargetGenerator() { } +void cmNinjaTargetGenerator::Generate() +{ + // Write the rules for each language. + this->WriteLanguagesRules(); + + // Write the build statements + this->WriteObjectBuildStatements(); + + // Write the link statement. + this->WriteLinkStatement(); + + this->GetBuildFileStream() << "\n"; + this->GetRulesFileStream() << "\n"; +} + cmGeneratedFileStream& cmNinjaTargetGenerator::GetBuildFileStream() const { return *this->GetGlobalGenerator()->GetBuildFileStream(); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index b780b4e49a4..348dc7cd62e 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -34,7 +34,7 @@ class cmNinjaTargetGenerator /// Destructor. ~cmNinjaTargetGenerator(); - virtual void Generate() = 0; + virtual void Generate(); protected: cmGeneratedFileStream& GetBuildFileStream() const; From f8380ba6bffc2729941deada771326c61b6db68b Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Thu, 21 Apr 2011 09:36:26 +0200 Subject: [PATCH 438/539] Ninja: Rename cmNinjaLibraryTargetGenerator... ... to cmNinjaSharedLibraryTargetGenerator. --- Source/CMakeLists.txt | 4 ++-- Source/cmLocalNinjaGenerator.h | 2 +- ...r.cxx => cmNinjaSharedLibraryTargetGenerator.cxx} | 12 ++++++------ ...rator.h => cmNinjaSharedLibraryTargetGenerator.h} | 12 ++++++------ Source/cmNinjaTargetGenerator.cxx | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) rename Source/{cmNinjaLibraryTargetGenerator.cxx => cmNinjaSharedLibraryTargetGenerator.cxx} (94%) rename Source/{cmNinjaLibraryTargetGenerator.h => cmNinjaSharedLibraryTargetGenerator.h} (75%) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index afc28e6f584..d5025a010b6 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -215,8 +215,8 @@ SET(SRCS cmNinjaTargetGenerator.h cmNinjaExecutableTargetGenerator.cxx cmNinjaExecutableTargetGenerator.h - cmNinjaLibraryTargetGenerator.cxx - cmNinjaLibraryTargetGenerator.h + cmNinjaSharedLibraryTargetGenerator.cxx + cmNinjaSharedLibraryTargetGenerator.h cmMakeDepend.cxx cmMakeDepend.h cmMakefile.cxx diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 8d789fcc2c5..df77b5741fe 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -114,7 +114,7 @@ class cmLocalNinjaGenerator : public cmLocalGenerator // In order to access to protected member of the local generator. friend class cmNinjaTargetGenerator; friend class cmNinjaExecutableTargetGenerator; - friend class cmNinjaLibraryTargetGenerator; + friend class cmNinjaSharedLibraryTargetGenerator; private: cmGeneratedFileStream& GetBuildFileStream() const; diff --git a/Source/cmNinjaLibraryTargetGenerator.cxx b/Source/cmNinjaSharedLibraryTargetGenerator.cxx similarity index 94% rename from Source/cmNinjaLibraryTargetGenerator.cxx rename to Source/cmNinjaSharedLibraryTargetGenerator.cxx index c20b4acd566..3cb546c9be2 100644 --- a/Source/cmNinjaLibraryTargetGenerator.cxx +++ b/Source/cmNinjaSharedLibraryTargetGenerator.cxx @@ -9,15 +9,15 @@ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more information. ============================================================================*/ -#include "cmNinjaLibraryTargetGenerator.h" +#include "cmNinjaSharedLibraryTargetGenerator.h" #include "cmLocalNinjaGenerator.h" #include "cmGlobalNinjaGenerator.h" #include "cmSourceFile.h" #include "cmGeneratedFileStream.h" #include "cmMakefile.h" -cmNinjaLibraryTargetGenerator:: -cmNinjaLibraryTargetGenerator(cmTarget* target) +cmNinjaSharedLibraryTargetGenerator:: +cmNinjaSharedLibraryTargetGenerator(cmTarget* target) : cmNinjaTargetGenerator(target) , TargetNameOut() , TargetNameSO() @@ -33,12 +33,12 @@ cmNinjaLibraryTargetGenerator(cmTarget* target) GetLocalGenerator()->GetConfigName()); } -cmNinjaLibraryTargetGenerator::~cmNinjaLibraryTargetGenerator() +cmNinjaSharedLibraryTargetGenerator::~cmNinjaSharedLibraryTargetGenerator() { } void -cmNinjaLibraryTargetGenerator +cmNinjaSharedLibraryTargetGenerator ::WriteLinkRule(const std::string& language) { cmLocalGenerator::RuleVariables vars; @@ -108,7 +108,7 @@ ::WriteLinkRule(const std::string& language) emptyVars); } -void cmNinjaLibraryTargetGenerator::WriteLinkStatement() +void cmNinjaSharedLibraryTargetGenerator::WriteLinkStatement() { // Write comments. cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); diff --git a/Source/cmNinjaLibraryTargetGenerator.h b/Source/cmNinjaSharedLibraryTargetGenerator.h similarity index 75% rename from Source/cmNinjaLibraryTargetGenerator.h rename to Source/cmNinjaSharedLibraryTargetGenerator.h index 83774612a49..caff68c8aa7 100644 --- a/Source/cmNinjaLibraryTargetGenerator.h +++ b/Source/cmNinjaSharedLibraryTargetGenerator.h @@ -9,20 +9,20 @@ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more information. ============================================================================*/ -#ifndef cmNinjaLibraryTargetGenerator_h -# define cmNinjaLibraryTargetGenerator_h +#ifndef cmNinjaSharedLibraryTargetGenerator_h +# define cmNinjaSharedLibraryTargetGenerator_h # include "cmNinjaTargetGenerator.h" # include "cmNinjaTypes.h" class cmSourceFile; -class cmNinjaLibraryTargetGenerator : public cmNinjaTargetGenerator +class cmNinjaSharedLibraryTargetGenerator : public cmNinjaTargetGenerator { public: /// Build a NinjaTargetGenerator. - cmNinjaLibraryTargetGenerator(cmTarget* target); - ~cmNinjaLibraryTargetGenerator(); + cmNinjaSharedLibraryTargetGenerator(cmTarget* target); + ~cmNinjaSharedLibraryTargetGenerator(); private: virtual void WriteLinkRule(const std::string& language); @@ -37,4 +37,4 @@ class cmNinjaLibraryTargetGenerator : public cmNinjaTargetGenerator std::string TargetNamePDB; }; -#endif // ! cmNinjaLibraryTargetGenerator_h +#endif // ! cmNinjaSharedLibraryTargetGenerator_h diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 980d79b07ab..665348a4676 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -14,7 +14,7 @@ #include "cmLocalNinjaGenerator.h" #include "cmGeneratedFileStream.h" #include "cmNinjaExecutableTargetGenerator.h" -#include "cmNinjaLibraryTargetGenerator.h" +#include "cmNinjaSharedLibraryTargetGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmComputeLinkInformation.h" @@ -29,7 +29,7 @@ cmNinjaTargetGenerator::New(cmTarget* target) return new cmNinjaExecutableTargetGenerator(target); case cmTarget::SHARED_LIBRARY: - return new cmNinjaLibraryTargetGenerator(target); + return new cmNinjaSharedLibraryTargetGenerator(target); default: return 0; From fda0a4d16b974c95fe3897918c73c0ee3c16f698 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Thu, 21 Apr 2011 13:13:39 +0200 Subject: [PATCH 439/539] Ninja: Support static libraries. --- Source/CMakeLists.txt | 2 + Source/cmLocalNinjaGenerator.h | 1 + .../cmNinjaStaticLibraryTargetGenerator.cxx | 235 ++++++++++++++++++ Source/cmNinjaStaticLibraryTargetGenerator.h | 41 +++ Source/cmNinjaTargetGenerator.cxx | 4 + 5 files changed, 283 insertions(+) create mode 100644 Source/cmNinjaStaticLibraryTargetGenerator.cxx create mode 100644 Source/cmNinjaStaticLibraryTargetGenerator.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index d5025a010b6..01a72bab396 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -217,6 +217,8 @@ SET(SRCS cmNinjaExecutableTargetGenerator.h cmNinjaSharedLibraryTargetGenerator.cxx cmNinjaSharedLibraryTargetGenerator.h + cmNinjaStaticLibraryTargetGenerator.cxx + cmNinjaStaticLibraryTargetGenerator.h cmMakeDepend.cxx cmMakeDepend.h cmMakefile.cxx diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index df77b5741fe..532d5734577 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -115,6 +115,7 @@ class cmLocalNinjaGenerator : public cmLocalGenerator friend class cmNinjaTargetGenerator; friend class cmNinjaExecutableTargetGenerator; friend class cmNinjaSharedLibraryTargetGenerator; + friend class cmNinjaStaticLibraryTargetGenerator; private: cmGeneratedFileStream& GetBuildFileStream() const; diff --git a/Source/cmNinjaStaticLibraryTargetGenerator.cxx b/Source/cmNinjaStaticLibraryTargetGenerator.cxx new file mode 100644 index 00000000000..44b8b51cc90 --- /dev/null +++ b/Source/cmNinjaStaticLibraryTargetGenerator.cxx @@ -0,0 +1,235 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmNinjaStaticLibraryTargetGenerator.h" +#include "cmLocalNinjaGenerator.h" +#include "cmGlobalNinjaGenerator.h" +#include "cmSourceFile.h" +#include "cmGeneratedFileStream.h" +#include "cmMakefile.h" + +cmNinjaStaticLibraryTargetGenerator:: +cmNinjaStaticLibraryTargetGenerator(cmTarget* target) + : cmNinjaTargetGenerator(target) + , TargetNameOut() + , TargetNameSO() + , TargetNameReal() + , TargetNameImport() + , TargetNamePDB() +{ + this->GetTarget()->GetLibraryNames(this->TargetNameOut, + this->TargetNameSO, + this->TargetNameReal, + this->TargetNameImport, + this->TargetNamePDB, + GetLocalGenerator()->GetConfigName()); +} + +cmNinjaStaticLibraryTargetGenerator::~cmNinjaStaticLibraryTargetGenerator() +{ +} + +void +cmNinjaStaticLibraryTargetGenerator +::WriteLinkRule(const std::string& language) +{ + cmLocalGenerator::RuleVariables vars; + vars.RuleLauncher = "RULE_LAUNCH_LINK"; + vars.CMTarget = this->GetTarget(); + std::string lang = language; + vars.Language = lang.c_str(); + vars.Objects = "$in"; + std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); + objdir += this->GetTargetName(); + objdir += ".dir"; + objdir = this->GetLocalGenerator()->Convert(objdir.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + vars.ObjectDir = objdir.c_str(); + vars.Target = "$out"; + + // Setup the target version. + std::string targetVersionMajor; + std::string targetVersionMinor; + { + cmOStringStream majorStream; + cmOStringStream minorStream; + int major; + int minor; + this->GetTarget()->GetTargetVersion(major, minor); + majorStream << major; + minorStream << minor; + targetVersionMajor = majorStream.str(); + targetVersionMinor = minorStream.str(); + } + vars.TargetVersionMajor = targetVersionMajor.c_str(); + vars.TargetVersionMinor = targetVersionMinor.c_str(); + + vars.LinkLibraries = "$LDLIBS"; + + // Add language feature flags. + // This is mandatory to use a local variables because the string must be + // in memory until ExpandRuleVariables() is called. + std::string langFlags = this->LanguageFlagsVarName(language, true); + vars.LanguageCompileFlags = langFlags.c_str(); + vars.LinkFlags = "$LDFLAGS"; + + // Rule for linking library. + std::vector linkCmds = this->ComputeLinkCmd(language); + std::string linkCmd; + bool isLast = false; + for(std::vector::const_iterator i = linkCmds.begin(); + i != linkCmds.end(); + ++i) + { + if(!isLast && i + 1 == linkCmds.end()) + isLast = true; + std::string cmd = *i; + this->GetLocalGenerator()->ExpandRuleVariables(cmd, vars); + linkCmd += cmd; + // TODO(Nicolas Despres): This will work only on Unix platforms. I don't + // want to use a link.txt file because I will loose the benefit of the + // $in variables. A discussion about dealing with multiple commands in + // a rule is started here: + // http://groups.google.com/group/ninja-build/browse_thread/thread/d515f23a78986008 + if(!isLast) + linkCmd += " && "; + } + + // Write the rule for linking an library. + std::ostringstream comment; + comment << "Rule for linking " << language << " static library."; + std::ostringstream description; + description << "Linking " << language << " static library $out"; + std::string depfile = ""; + cmNinjaVars emptyVars; + this->GetGlobalGenerator()->AddRule(this->LanguageLinkerRule(language), + linkCmd, + comment.str(), + description.str(), + depfile, + emptyVars); +} + +std::vector +cmNinjaStaticLibraryTargetGenerator +::ComputeLinkCmd(const std::string& language) +{ + std::vector linkCmds; + // Check if you have a non archive way to create the static library. + { + std::string linkCmdVar = "CMAKE_"; + linkCmdVar += language; + linkCmdVar += "_CREATE_STATIC_LIBRARY"; + std::string linkCmd = + this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + if(!linkCmd.empty()) + { + linkCmds.push_back(linkCmd); + return linkCmds; + } + } + + // We have archive link commands set. + { + std::string linkCmdVar = "CMAKE_"; + linkCmdVar += language; + linkCmdVar += "_ARCHIVE_CREATE"; + std::string linkCmd = + this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + std::cout << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; + linkCmds.push_back(linkCmd); + } + // TODO(Nicolas Despres): I'll see later how to deals with that. + // { + // std::string linkCmdVar = "CMAKE_"; + // linkCmdVar += language; + // linkCmdVar += "_ARCHIVE_APPEND"; + // std::string linkCmd = + // this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + // std::cout << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; + // linkCmds.push_back(linkCmd); + // } + { + std::string linkCmdVar = "CMAKE_"; + linkCmdVar += language; + linkCmdVar += "_ARCHIVE_FINISH"; + std::string linkCmd = + this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + std::cout << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; + linkCmds.push_back(linkCmd); + } + return linkCmds; +} + +void cmNinjaStaticLibraryTargetGenerator::WriteLinkStatement() +{ + // Write comments. + cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); + this->GetBuildFileStream() + << "# Link build statements for " + << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << " target " + << this->GetTargetName() + << "\n\n"; + + cmNinjaDeps emptyDeps; + cmNinjaVars vars; + + std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); + + // Compute the comment. + std::ostringstream comment; + comment << "Link the static library " << targetOutput; + + // Compute outputs. + cmNinjaDeps outputs; + outputs.push_back(targetOutput); + // Add this executable to the all target. + this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); + + const char* linkLanguage = + this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); + + // Compute specific libraries to link with. + cmNinjaDeps explicitDeps = this->GetObjects(); + { + cmNinjaDeps linkDeps = this->ComputeLinkDeps(); + for(cmNinjaDeps::const_iterator i = linkDeps.begin(); + i != linkDeps.end(); + ++i) + explicitDeps.push_back(*i); + std::ostringstream linkLibraries; + this->GetLocalGenerator()->OutputLinkLibraries(linkLibraries, + *this->GetTarget(), + false); + vars["LDLIBS"] = linkLibraries.str(); + } + + // Compute specific link flags. + vars[this->LanguageFlagsVarName(linkLanguage)] = + this->ComputeFlagsForLink(linkLanguage); + vars["LDFLAGS"] = this->ComputeLinkFlags(linkLanguage); + vars["SONAME"] = this->TargetNameSO; + + // Write the build statement for this target. + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + comment.str(), + this->LanguageLinkerRule(linkLanguage), + outputs, + explicitDeps, + emptyDeps, + emptyDeps, + vars); + + // Write a shortcut rule with the target name. + this->WriteTargetBuild(this->TargetNameOut, targetOutput); +} diff --git a/Source/cmNinjaStaticLibraryTargetGenerator.h b/Source/cmNinjaStaticLibraryTargetGenerator.h new file mode 100644 index 00000000000..690452ce852 --- /dev/null +++ b/Source/cmNinjaStaticLibraryTargetGenerator.h @@ -0,0 +1,41 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmNinjaStaticLibraryTargetGenerator_h +# define cmNinjaStaticLibraryTargetGenerator_h + +# include "cmNinjaTargetGenerator.h" +# include "cmNinjaTypes.h" + +class cmSourceFile; + +class cmNinjaStaticLibraryTargetGenerator : public cmNinjaTargetGenerator +{ +public: + /// Build a NinjaTargetGenerator. + cmNinjaStaticLibraryTargetGenerator(cmTarget* target); + ~cmNinjaStaticLibraryTargetGenerator(); + +private: + virtual void WriteLinkRule(const std::string& language); + virtual void WriteLinkStatement(); + std::vector ComputeLinkCmd(const std::string& language); + +private: + // Target name info. + std::string TargetNameOut; + std::string TargetNameSO; + std::string TargetNameReal; + std::string TargetNameImport; + std::string TargetNamePDB; +}; + +#endif // ! cmNinjaStaticLibraryTargetGenerator_h diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 665348a4676..72129a32c58 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -15,6 +15,7 @@ #include "cmGeneratedFileStream.h" #include "cmNinjaExecutableTargetGenerator.h" #include "cmNinjaSharedLibraryTargetGenerator.h" +#include "cmNinjaStaticLibraryTargetGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmComputeLinkInformation.h" @@ -31,6 +32,9 @@ cmNinjaTargetGenerator::New(cmTarget* target) case cmTarget::SHARED_LIBRARY: return new cmNinjaSharedLibraryTargetGenerator(target); + case cmTarget::STATIC_LIBRARY: + return new cmNinjaStaticLibraryTargetGenerator(target); + default: return 0; } From ef59936cf40dc77ccfca71a90ea0d09452f103f3 Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Thu, 21 Apr 2011 13:30:15 +0200 Subject: [PATCH 440/539] Ninja: Reject other languages than C and CXX. --- Source/cmGlobalNinjaGenerator.cxx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index b734d8db391..24e23498673 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -342,9 +342,24 @@ ::EnableLanguage(std::vectorconst& languages, std::cout << "DEBUG NINJA: ARG: optional: " << optional << std::endl; this->cmGlobalGenerator::EnableLanguage(languages, mf, optional); - // NOTE: cmGlobalUnixMakefileGenerator3::EnableLanguage seems to - // do some checking and cleaning about the CMAKE__COMPILER - // variables. Maybe we should add it too?? + std::string path; + for(std::vector::const_iterator l = languages.begin(); + l != languages.end(); ++l) + { + if(*l == "NONE") + { + continue; + } + if(*l != "C" && *l != "CXX") + { + std::string message = "The \""; + message += this->GetName(); + message += "\" generator does not support the language \""; + message += *l; + message += "\" yet."; + cmSystemTools::Error(message.c_str()); + } + } std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } From 5eaca713ae94c5329da640e06c255acb5e5e208c Mon Sep 17 00:00:00 2001 From: Nicolas Despres Date: Tue, 16 Aug 2011 14:36:56 +0200 Subject: [PATCH 441/539] Ninja: Improve documentation. --- Source/cmGlobalNinjaGenerator.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 60dfb4d7dbb..b4900b25526 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -26,8 +26,16 @@ class cmGeneratedFileStream; * generator family are: * - We don't care about VERBOSE variable or RULE_MESSAGES property since * it is handle by Ninja's -v option. - * - We don't care about computing any progress status since ninja manages + * - We don't care about computing any progress status since Ninja manages * it itself. + * - We don't care about generating a clean target since Ninja already have + * a clean tool. + * - We generate one build.ninja and one rules.ninja per project. + * - We try to minimize the number of generated rules: one per target and + * language. + * - We use Ninja special variable $in and $out to produce nice output. + * - We extensively use Ninja variable overloading system to minimize the + * number of generated rules. */ class cmGlobalNinjaGenerator : public cmGlobalGenerator { From aad17c1593b40199df003415dbe6e8cded1ef182 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sat, 20 Aug 2011 22:11:43 +0100 Subject: [PATCH 442/539] Use std::cerr here --- Source/cmGlobalNinjaGenerator.cxx | 80 +++++++++---------- Source/cmLocalNinjaGenerator.cxx | 76 +++++++++--------- Source/cmNinjaExecutableTargetGenerator.cxx | 2 +- .../cmNinjaSharedLibraryTargetGenerator.cxx | 2 +- .../cmNinjaStaticLibraryTargetGenerator.cxx | 6 +- Source/cmNinjaTargetGenerator.cxx | 2 +- 6 files changed, 84 insertions(+), 84 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 24e23498673..d6ccb696648 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -292,9 +292,9 @@ ::GetDocumentation(cmDocumentationEntry& entry) const // Source/cmake.cxx void cmGlobalNinjaGenerator::Configure() { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; cmGlobalGenerator::Configure(); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // Implemented in all cmGlobaleGenerator sub-classes. @@ -303,7 +303,7 @@ void cmGlobalNinjaGenerator::Configure() // Source/cmake.cxx void cmGlobalNinjaGenerator::Generate() { - std::cout << "DEBUG NINJA: BEGIN: " + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << " (" << this << ")" << std::endl; @@ -317,7 +317,7 @@ void cmGlobalNinjaGenerator::Generate() this->CloseRulesFileStream(); this->CloseBuildFileStream(); - std::cout << "DEBUG NINJA: END: " + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << " (" << this << ")" << std::endl; } @@ -330,16 +330,16 @@ ::EnableLanguage(std::vectorconst& languages, cmMakefile *mf, bool optional) { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: languages: "; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: ARG: languages: "; for (std::vector::const_iterator l = languages.begin(); l != languages.end(); ++l) - std::cout << "'" << *l << "', "; - std::cout << std::endl; - std::cout << "DEBUG NINJA: ARG: cmMakefile: " << mf + std::cerr << "'" << *l << "', "; + std::cerr << std::endl; + std::cerr << "DEBUG NINJA: ARG: cmMakefile: " << mf << " project: '" << mf->GetProjectName() << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: optional: " << optional << std::endl; + std::cerr << "DEBUG NINJA: ARG: optional: " << optional << std::endl; this->cmGlobalGenerator::EnableLanguage(languages, mf, optional); std::string path; @@ -361,7 +361,7 @@ ::EnableLanguage(std::vectorconst& languages, } } - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // Not implemented in none of cmLocalGenerator sub-classes. @@ -370,15 +370,15 @@ void cmGlobalNinjaGenerator ::EnableLanguagesFromGenerator(cmGlobalGenerator* gen, cmMakefile* mf) { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: cmGlobaleGenerator: " << gen + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: ARG: cmGlobaleGenerator: " << gen << " name: '" << gen->GetName() << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: mf: " << mf + std::cerr << "DEBUG NINJA: ARG: mf: " << mf << " project: '" << mf->GetProjectName() << "'" << std::endl; cmGlobalGenerator::EnableLanguagesFromGenerator(gen, mf); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // Not implemented in none of cmLocalGenerator sub-classes. @@ -392,13 +392,13 @@ int cmGlobalNinjaGenerator::TryCompile(const char* srcdir, std::string* output, cmMakefile* mf) { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: srcdir: '" << srcdir << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: bindir: '" << bindir << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: projectName: '" << projectName << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: fast: '" << fast << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: output: '" << *output << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: mf: " << mf + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: ARG: srcdir: '" << srcdir << "'" << std::endl; + std::cerr << "DEBUG NINJA: ARG: bindir: '" << bindir << "'" << std::endl; + std::cerr << "DEBUG NINJA: ARG: projectName: '" << projectName << "'" << std::endl; + std::cerr << "DEBUG NINJA: ARG: fast: '" << fast << "'" << std::endl; + std::cerr << "DEBUG NINJA: ARG: output: '" << *output << "'" << std::endl; + std::cerr << "DEBUG NINJA: ARG: mf: " << mf << " project: '" << mf->GetProjectName() << "'" << std::endl; int ret = cmGlobalGenerator::TryCompile(srcdir, @@ -409,7 +409,7 @@ int cmGlobalNinjaGenerator::TryCompile(const char* srcdir, output, mf); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; return ret; } @@ -430,13 +430,13 @@ ::GenerateBuildCommand(const char* makeProgram, bool ignoreErrors, bool fast) { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: makeProgram: '" << makeProgram << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: projectName: '" << projectName << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: additionalOptions: '" << (additionalOptions ? additionalOptions : "NULL") << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: targetName: '" << targetName << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: ignoreErrors: '" << ignoreErrors << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: fast: '" << fast << "'" << std::endl; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: ARG: makeProgram: '" << makeProgram << "'" << std::endl; + std::cerr << "DEBUG NINJA: ARG: projectName: '" << projectName << "'" << std::endl; + std::cerr << "DEBUG NINJA: ARG: additionalOptions: '" << (additionalOptions ? additionalOptions : "NULL") << "'" << std::endl; + std::cerr << "DEBUG NINJA: ARG: targetName: '" << targetName << "'" << std::endl; + std::cerr << "DEBUG NINJA: ARG: ignoreErrors: '" << ignoreErrors << "'" << std::endl; + std::cerr << "DEBUG NINJA: ARG: fast: '" << fast << "'" << std::endl; // Project name and config are not used yet. (void)projectName; @@ -460,7 +460,7 @@ ::GenerateBuildCommand(const char* makeProgram, makeCommand += targetName; } - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << " RESULT='" << makeCommand << "'" << std::endl; return makeCommand; } @@ -500,46 +500,46 @@ void cmGlobalNinjaGenerator::GetTargetSets(TargetDependSet& projectTargets, cmLocalGenerator* root, GeneratorVector const& generators) { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; cmGlobalGenerator::GetTargetSets(projectTargets, originalTargets, root, generators); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // Not implemented in UnixMakefile generator. bool cmGlobalNinjaGenerator::IsRootOnlyTarget(cmTarget* target) { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: target: " << target + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: ARG: target: " << target << " name: '" << target->GetName() << "'" << " type: '" << cmTarget::TargetTypeNames(target->GetType()) << "'" << std::endl; bool ret = cmGlobalGenerator::IsRootOnlyTarget(target); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; return ret; } // Not implemented in UnixMakefile generator. bool cmGlobalNinjaGenerator::ComputeTargetDepends() { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; bool ret = cmGlobalGenerator::ComputeTargetDepends(); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; return ret; } // Not implemented in UnixMakefile generator. const char* cmGlobalNinjaGenerator::GetPredefinedTargetsFolder() { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; const char* ret = cmGlobalGenerator::GetPredefinedTargetsFolder(); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; return ret; } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 1c5a2374e7b..bd851416a7a 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -32,20 +32,20 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator() cmLocalNinjaGenerator::~cmLocalNinjaGenerator() { - std::cout << "DEBUG NINJA: LOCAL GENERATOR DESTRUCTOR: " + std::cerr << "DEBUG NINJA: LOCAL GENERATOR DESTRUCTOR: " << this << std::endl; } void cmLocalNinjaGenerator::Generate() { - std::cout << "DEBUG NINJA: BEGIN: " + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << " (" << this << ")" << std::endl; - std::cout << "DEBUG NINJA: CURRENT DIRECTORY: " + std::cerr << "DEBUG NINJA: CURRENT DIRECTORY: " << this->Makefile->GetCurrentDirectory() << std::endl; - std::cout << "DEBUG NINJA: CURRENT OUTPUT DIRECTORY: " + std::cerr << "DEBUG NINJA: CURRENT OUTPUT DIRECTORY: " << this->Makefile->GetCurrentOutputDirectory() << std::endl; - std::cout << "DEBUG NINJA: CURRENT LIST FILE: " + std::cerr << "DEBUG NINJA: CURRENT LIST FILE: " << this->Makefile->GetCurrentListFile() << std::endl; @@ -67,7 +67,7 @@ void cmLocalNinjaGenerator::Generate() } } - std::cout << "DEBUG NINJA: END: " + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << " (" << this << ")" << std::endl; } @@ -79,7 +79,7 @@ void cmLocalNinjaGenerator::Generate() // Source/cmGlobalGenerator.cxx void cmLocalNinjaGenerator::Configure() { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; // Compute the path to use when referencing the current output // directory from the top output directory. @@ -91,55 +91,55 @@ void cmLocalNinjaGenerator::Configure() } this->cmLocalGenerator::Configure(); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // Not implemented in none of cmLocalGenerator sub-classes. void cmLocalNinjaGenerator::TraceDependencies() { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; cmLocalGenerator::TraceDependencies(); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // Implemented only in some VisualStudio local generator. void cmLocalNinjaGenerator::AddHelperCommands() { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; cmLocalGenerator::AddHelperCommands(); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // Implemented only in some VisualStudio local generator. void cmLocalNinjaGenerator::ConfigureFinalPass() { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; cmLocalGenerator::ConfigureFinalPass(); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // Not implemented in none of cmLocalGenerator sub-classes. void cmLocalNinjaGenerator::GenerateInstallRules() { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; cmLocalGenerator::GenerateInstallRules(); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // Not implemented in none of cmLocalGenerator sub-classes. void cmLocalNinjaGenerator::GenerateTestFiles() { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; cmLocalGenerator::GenerateTestFiles(); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // Not implemented in none of cmLocalGenerator sub-classes. void cmLocalNinjaGenerator::GenerateTargetManifest() { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; cmLocalGenerator::GenerateTargetManifest(); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // Implemented only in UnixMakefile local generator. @@ -148,14 +148,14 @@ void cmLocalNinjaGenerator::GenerateTargetManifest() void cmLocalNinjaGenerator::ClearDependencies(cmMakefile* mf, bool verbose) { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: cmMakefile: " << mf + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: ARG: cmMakefile: " << mf << " project: '" << mf->GetProjectName() << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: verbose: " << verbose << std::endl; + std::cerr << "DEBUG NINJA: ARG: verbose: " << verbose << std::endl; cmLocalGenerator::ClearDependencies(mf, verbose); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // Implemented only in UnixMakefile local generator. @@ -165,14 +165,14 @@ bool cmLocalNinjaGenerator::UpdateDependencies(const char* tgtInfo, bool verbose, bool color) { - std::cout << "DEBUG NINJA: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: tgtInfo: '" << tgtInfo << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: verbose: " << verbose << std::endl; - std::cout << "DEBUG NINJA: ARG: color: " << color << std::endl; + std::cerr << "DEBUG NINJA: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: ARG: tgtInfo: '" << tgtInfo << "'" << std::endl; + std::cerr << "DEBUG NINJA: ARG: verbose: " << verbose << std::endl; + std::cerr << "DEBUG NINJA: ARG: color: " << color << std::endl; bool ret = cmLocalGenerator::UpdateDependencies(tgtInfo, verbose, color); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; return ret; } @@ -183,21 +183,21 @@ void cmLocalNinjaGenerator ::GetTargetObjectFileDirectories(cmTarget* target, std::vector& dirs) { - std::cout << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: target: " << target + std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: ARG: target: " << target << " name: '" << target->GetName() << "'" << " type: '" << cmTarget::TargetTypeNames(target->GetType()) << "'" << std::endl; - std::cout << "DEBUG NINJA: ARG: dirs: "; + std::cerr << "DEBUG NINJA: ARG: dirs: "; for(std::vector::const_iterator d = dirs.begin(); d != dirs.end(); ++d) - std::cout << "'" << *d << "', "; - std::cout << std::endl; + std::cerr << "'" << *d << "', "; + std::cerr << std::endl; cmLocalGenerator::GetTargetObjectFileDirectories(target, dirs); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // TODO(Nicolas Despres): Picked up from cmLocalUnixMakefileGenerator3. @@ -384,12 +384,12 @@ void cmLocalNinjaGenerator::OutputLinkLibraries(std::ostream& fout, // Source/cmLocalVisualStudio6Generator.cxx bool cmLocalNinjaGenerator::CheckDefinition(std::string const& define) const { - std::cout << "DEBUG NINJA: " << __PRETTY_FUNCTION__ << std::endl; - std::cout << "DEBUG NINJA: ARG: define: '" << define << "'" << std::endl; + std::cerr << "DEBUG NINJA: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: ARG: define: '" << define << "'" << std::endl; bool ret = cmLocalGenerator::CheckDefinition(define); - std::cout << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; + std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; return ret; } diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index 5018eee2819..8283d06df6b 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -84,7 +84,7 @@ ::WriteLinkRule(const std::string& language) linkCmdVar += "_LINK_EXECUTABLE"; std::string linkCmd = this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - std::cout << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; + std::cerr << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; this->GetLocalGenerator()->ExpandRuleVariables(linkCmd, vars); diff --git a/Source/cmNinjaSharedLibraryTargetGenerator.cxx b/Source/cmNinjaSharedLibraryTargetGenerator.cxx index 3cb546c9be2..6398277b3ee 100644 --- a/Source/cmNinjaSharedLibraryTargetGenerator.cxx +++ b/Source/cmNinjaSharedLibraryTargetGenerator.cxx @@ -89,7 +89,7 @@ ::WriteLinkRule(const std::string& language) linkCmdVar += "_CREATE_SHARED_LIBRARY"; std::string linkCmd = this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - std::cout << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; + std::cerr << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; this->GetLocalGenerator()->ExpandRuleVariables(linkCmd, vars); diff --git a/Source/cmNinjaStaticLibraryTargetGenerator.cxx b/Source/cmNinjaStaticLibraryTargetGenerator.cxx index 44b8b51cc90..89f826813b6 100644 --- a/Source/cmNinjaStaticLibraryTargetGenerator.cxx +++ b/Source/cmNinjaStaticLibraryTargetGenerator.cxx @@ -145,7 +145,7 @@ ::ComputeLinkCmd(const std::string& language) linkCmdVar += "_ARCHIVE_CREATE"; std::string linkCmd = this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - std::cout << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; + std::cerr << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; linkCmds.push_back(linkCmd); } // TODO(Nicolas Despres): I'll see later how to deals with that. @@ -155,7 +155,7 @@ ::ComputeLinkCmd(const std::string& language) // linkCmdVar += "_ARCHIVE_APPEND"; // std::string linkCmd = // this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - // std::cout << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; + // std::cerr << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; // linkCmds.push_back(linkCmd); // } { @@ -164,7 +164,7 @@ ::ComputeLinkCmd(const std::string& language) linkCmdVar += "_ARCHIVE_FINISH"; std::string linkCmd = this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - std::cout << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; + std::cerr << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; linkCmds.push_back(linkCmd); } return linkCmds; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 72129a32c58..2185ee06de8 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -435,7 +435,7 @@ ::WriteCompileRule(const std::string& language) compileCmdVar += "_COMPILE_OBJECT"; std::string compileCmd = this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str()); - std::cout << "DEBUG NINJA: COMPILE CMD: " << compileCmd << std::endl; + std::cerr << "DEBUG NINJA: COMPILE CMD: " << compileCmd << std::endl; this->GetLocalGenerator()->ExpandRuleVariables(compileCmd, vars); From cf5d915b14e1e2c6e7b416708dfb13dc28ff40aa Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sun, 21 Aug 2011 01:01:54 +0100 Subject: [PATCH 443/539] Partially fix link rules Previously, we would attempt to add all link libraries to the explicit dep list. This is wrong, because this includes -l libraries, which don't belong in the dep list. If we added only non- -l deps to the explicit dep list, we'd mess up the link order, which may be significant for some builds. Furthermore, not all targets put $LINK_LIBRARIES right after $OBJECTS, possibly for good reasons. Instead, add the library dependency list as implicit deps and pass a full $LINK_LIBRARIES to the link rule. This allows the CHECK_SYMBOL_EXISTS and various other tests performed by cmake's own build system to pass, causing the configuration to succeed. There's still a remaining issue of absolute vs relative paths which prevents the resultant build.ninja from working. --- Source/cmLocalNinjaGenerator.cxx | 120 ------------------ Source/cmLocalNinjaGenerator.h | 5 - Source/cmNinjaExecutableTargetGenerator.cxx | 44 +++---- .../cmNinjaSharedLibraryTargetGenerator.cxx | 44 +++---- .../cmNinjaStaticLibraryTargetGenerator.cxx | 44 +++---- Source/cmNinjaTargetGenerator.cxx | 54 +------- Source/cmNinjaTargetGenerator.h | 7 - 7 files changed, 63 insertions(+), 255 deletions(-) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index bd851416a7a..87334155b9d 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -258,126 +258,6 @@ ::GetObjectFileName(const cmTarget& target, //---------------------------------------------------------------------------- // Virtual protected methods. -// TODO(Nicolas Despres): Refactor with -// void cmLocalNinjaGenerator::OutputLinkLibraries(std::ostream& fout, -// cmTarget& tgt, -// bool relink); -// -// Actually do not want the list of .so files to show up here since I want -// to use them as explicit dependencies of the link and thus to be bind to -// the $in variable. So I keep here only the the flags. -// -// The list of dependent targets is compute by -// cmNinjaTargetGenerator::ComputeLinkDeps(). -void cmLocalNinjaGenerator::OutputLinkLibraries(std::ostream& fout, - cmTarget& tgt, - bool relink) -{ - const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); - cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); - if(!pcli) - { - return; - } - cmComputeLinkInformation& cli = *pcli; - - // Collect library linking flags command line options. - std::string linkLibs; - - const char* linkLanguage = cli.GetLinkLanguage(); - - std::string libPathFlag = - this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); - std::string libPathTerminator = - this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); - - // Flags to link an executable to shared libraries. - std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_"; - linkFlagsVar += linkLanguage; - linkFlagsVar += "_FLAGS"; - if( tgt.GetType() == cmTarget::EXECUTABLE ) - { - linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar.c_str()); - linkLibs += " "; - } - - // Append the framework search path flags. - std::vector const& fwDirs = cli.GetFrameworkPaths(); - for(std::vector::const_iterator fdi = fwDirs.begin(); - fdi != fwDirs.end(); ++fdi) - { - linkLibs += "-F"; - linkLibs += this->Convert(fdi->c_str(), NONE, SHELL, false); - linkLibs += " "; - } - - // Append the library search path flags. - std::vector const& libDirs = cli.GetDirectories(); - for(std::vector::const_iterator libDir = libDirs.begin(); - libDir != libDirs.end(); ++libDir) - { - std::string libpath = this->ConvertToOutputForExisting(libDir->c_str()); - linkLibs += libPathFlag; - linkLibs += libpath; - linkLibs += libPathTerminator; - linkLibs += " "; - } - - // Write the library flags to the build rule. - fout << linkLibs; - - // Get the RPATH entries. - std::vector runtimeDirs; - cli.GetRPath(runtimeDirs, relink); - - // Check what kind of rpath flags to use. - if(cli.GetRuntimeSep().empty()) - { - // Each rpath entry gets its own option ("-R a -R b -R c") - std::string rpath; - for(std::vector::iterator ri = runtimeDirs.begin(); - ri != runtimeDirs.end(); ++ri) - { - rpath += cli.GetRuntimeFlag(); - rpath += this->Convert(ri->c_str(), NONE, SHELL, false); - rpath += " "; - } - fout << rpath; - } - else - { - // All rpath entries are combined ("-Wl,-rpath,a:b:c"). - std::string rpath = cli.GetRPathString(relink); - - // Store the rpath option in the stream. - if(!rpath.empty()) - { - fout << cli.GetRuntimeFlag(); - fout << this->EscapeForShell(rpath.c_str(), true); - fout << " "; - } - } - - // Add the linker runtime search path if any. - std::string rpath_link = cli.GetRPathLinkString(); - if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) - { - fout << cli.GetRPathLinkFlag(); - fout << this->EscapeForShell(rpath_link.c_str(), true); - fout << " "; - } - - // Add standard libraries for this language. - std::string standardLibsVar = "CMAKE_"; - standardLibsVar += cli.GetLinkLanguage(); - standardLibsVar += "_STANDARD_LIBRARIES"; - if(const char* stdLibs = - this->Makefile->GetDefinition(standardLibsVar.c_str())) - { - fout << stdLibs << " "; - } -} - // Implemented only in cmLocalVisualStudio6Generator. // Used in: // Source/cmLocalGenerator.cxx diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 532d5734577..c08fb47d212 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -102,11 +102,6 @@ class cmLocalNinjaGenerator : public cmLocalGenerator protected: - /// Overloaded methods. @see cmLocalGenerator::OutputLinkLibraries() - virtual void OutputLinkLibraries(std::ostream& fout, - cmTarget& tgt, - bool relink); - /// Overloaded methods. @see cmLocalGenerator::CheckDefinition() virtual bool CheckDefinition(std::string const& define) const; diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index 8283d06df6b..bba5d9084c8 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -71,12 +71,15 @@ ::WriteLinkRule(const std::string& language) vars.TargetVersionMajor = targetVersionMajor.c_str(); vars.TargetVersionMinor = targetVersionMinor.c_str(); - vars.LinkLibraries = "$LDLIBS"; - // This is mandatory to use a local variables because the string must be - // in memory until ExpandRuleVariables() is called. - std::string flags = this->LanguageFlagsVarName(language, true); - vars.Flags = flags.c_str(); - vars.LinkFlags = "$LDFLAGS"; + vars.LinkLibraries = "$LINK_LIBRARIES"; + vars.Flags = "$FLAGS"; + vars.LinkFlags = "$LINK_FLAGS"; + + std::string langFlags; + this->GetLocalGenerator()->AddLanguageFlags(langFlags, language.c_str(), + this->GetConfigName()); + langFlags += "$ARCHITECTURE_FLAGS"; + vars.LanguageCompileFlags = langFlags.c_str(); // Rule for linking executable. std::string linkCmdVar = "CMAKE_"; @@ -133,24 +136,19 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); // Compute specific libraries to link with. - cmNinjaDeps explicitDeps = this->GetObjects(); - { - cmNinjaDeps linkDeps = this->ComputeLinkDeps(); - for(cmNinjaDeps::const_iterator i = linkDeps.begin(); - i != linkDeps.end(); - ++i) - explicitDeps.push_back(*i); - std::ostringstream linkLibraries; - this->GetLocalGenerator()->OutputLinkLibraries(linkLibraries, - *this->GetTarget(), - false); - vars["LDLIBS"] = linkLibraries.str(); - } + cmNinjaDeps explicitDeps = this->GetObjects(), + implicitDeps = this->ComputeLinkDeps(); + + this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], + vars["FLAGS"], + vars["LINK_FLAGS"], + *this->GetTarget()); // Compute specific link flags. - vars[this->LanguageFlagsVarName(linkLanguage)] = - this->ComputeFlagsForLink(linkLanguage); - vars["LDFLAGS"] = this->ComputeLinkFlags(linkLanguage); + this->GetLocalGenerator()->AddArchitectureFlags(vars["ARCHITECTURE_FLAGS"], + this->GetTarget(), + linkLanguage, + this->GetConfigName()); // Write the build statement for this target. cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), @@ -158,7 +156,7 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() this->LanguageLinkerRule(linkLanguage), outputs, explicitDeps, - emptyDeps, + implicitDeps, emptyDeps, vars); diff --git a/Source/cmNinjaSharedLibraryTargetGenerator.cxx b/Source/cmNinjaSharedLibraryTargetGenerator.cxx index 6398277b3ee..2077feea993 100644 --- a/Source/cmNinjaSharedLibraryTargetGenerator.cxx +++ b/Source/cmNinjaSharedLibraryTargetGenerator.cxx @@ -74,14 +74,15 @@ ::WriteLinkRule(const std::string& language) vars.TargetVersionMajor = targetVersionMajor.c_str(); vars.TargetVersionMinor = targetVersionMinor.c_str(); - vars.LinkLibraries = "$LDLIBS"; - - // Add language feature flags. - // This is mandatory to use a local variables because the string must be - // in memory until ExpandRuleVariables() is called. - std::string langFlags = this->LanguageFlagsVarName(language, true); + vars.LinkLibraries = "$LINK_LIBRARIES"; + vars.Flags = "$FLAGS"; + vars.LinkFlags = "$LINK_FLAGS"; + + std::string langFlags; + this->GetLocalGenerator()->AddLanguageFlags(langFlags, language.c_str(), + this->GetConfigName()); + langFlags += "$ARCHITECTURE_FLAGS"; vars.LanguageCompileFlags = langFlags.c_str(); - vars.LinkFlags = "$LDFLAGS"; // Rule for linking library. std::string linkCmdVar = "CMAKE_"; @@ -138,24 +139,19 @@ void cmNinjaSharedLibraryTargetGenerator::WriteLinkStatement() this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); // Compute specific libraries to link with. - cmNinjaDeps explicitDeps = this->GetObjects(); - { - cmNinjaDeps linkDeps = this->ComputeLinkDeps(); - for(cmNinjaDeps::const_iterator i = linkDeps.begin(); - i != linkDeps.end(); - ++i) - explicitDeps.push_back(*i); - std::ostringstream linkLibraries; - this->GetLocalGenerator()->OutputLinkLibraries(linkLibraries, - *this->GetTarget(), - false); - vars["LDLIBS"] = linkLibraries.str(); - } + cmNinjaDeps explicitDeps = this->GetObjects(), + implicitDeps = this->ComputeLinkDeps(); + + this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], + vars["FLAGS"], + vars["LINK_FLAGS"], + *this->GetTarget()); // Compute specific link flags. - vars[this->LanguageFlagsVarName(linkLanguage)] = - this->ComputeFlagsForLink(linkLanguage); - vars["LDFLAGS"] = this->ComputeLinkFlags(linkLanguage); + this->GetLocalGenerator()->AddArchitectureFlags(vars["ARCHITECTURE_FLAGS"], + this->GetTarget(), + linkLanguage, + this->GetConfigName()); vars["SONAME"] = this->TargetNameSO; // Write the build statement for this target. @@ -164,7 +160,7 @@ void cmNinjaSharedLibraryTargetGenerator::WriteLinkStatement() this->LanguageLinkerRule(linkLanguage), outputs, explicitDeps, - emptyDeps, + implicitDeps, emptyDeps, vars); diff --git a/Source/cmNinjaStaticLibraryTargetGenerator.cxx b/Source/cmNinjaStaticLibraryTargetGenerator.cxx index 89f826813b6..2784fbfa5b0 100644 --- a/Source/cmNinjaStaticLibraryTargetGenerator.cxx +++ b/Source/cmNinjaStaticLibraryTargetGenerator.cxx @@ -73,14 +73,15 @@ ::WriteLinkRule(const std::string& language) vars.TargetVersionMajor = targetVersionMajor.c_str(); vars.TargetVersionMinor = targetVersionMinor.c_str(); - vars.LinkLibraries = "$LDLIBS"; - - // Add language feature flags. - // This is mandatory to use a local variables because the string must be - // in memory until ExpandRuleVariables() is called. - std::string langFlags = this->LanguageFlagsVarName(language, true); + vars.LinkLibraries = "$LINK_LIBRARIES"; + vars.Flags = "$FLAGS"; + vars.LinkFlags = "$LINK_FLAGS"; + + std::string langFlags; + this->GetLocalGenerator()->AddLanguageFlags(langFlags, language.c_str(), + this->GetConfigName()); + langFlags += "$ARCHITECTURE_FLAGS"; vars.LanguageCompileFlags = langFlags.c_str(); - vars.LinkFlags = "$LDFLAGS"; // Rule for linking library. std::vector linkCmds = this->ComputeLinkCmd(language); @@ -200,24 +201,19 @@ void cmNinjaStaticLibraryTargetGenerator::WriteLinkStatement() this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); // Compute specific libraries to link with. - cmNinjaDeps explicitDeps = this->GetObjects(); - { - cmNinjaDeps linkDeps = this->ComputeLinkDeps(); - for(cmNinjaDeps::const_iterator i = linkDeps.begin(); - i != linkDeps.end(); - ++i) - explicitDeps.push_back(*i); - std::ostringstream linkLibraries; - this->GetLocalGenerator()->OutputLinkLibraries(linkLibraries, - *this->GetTarget(), - false); - vars["LDLIBS"] = linkLibraries.str(); - } + cmNinjaDeps explicitDeps = this->GetObjects(), + implicitDeps = this->ComputeLinkDeps(); + + this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], + vars["FLAGS"], + vars["LINK_FLAGS"], + *this->GetTarget()); // Compute specific link flags. - vars[this->LanguageFlagsVarName(linkLanguage)] = - this->ComputeFlagsForLink(linkLanguage); - vars["LDFLAGS"] = this->ComputeLinkFlags(linkLanguage); + this->GetLocalGenerator()->AddArchitectureFlags(vars["ARCHITECTURE_FLAGS"], + this->GetTarget(), + linkLanguage, + this->GetConfigName()); vars["SONAME"] = this->TargetNameSO; // Write the build statement for this target. @@ -226,7 +222,7 @@ void cmNinjaStaticLibraryTargetGenerator::WriteLinkStatement() this->LanguageLinkerRule(linkLanguage), outputs, explicitDeps, - emptyDeps, + implicitDeps, emptyDeps, vars); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 2185ee06de8..8126107559d 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -195,32 +195,6 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(const std::string& language) return flags; } -// TODO(Nicolas Despres): Most of the code is picked up from -// void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink), -// void cmMakefileTargetGenerator::WriteTargetLanguageFlags() -// Refactor it. -std::string -cmNinjaTargetGenerator::ComputeFlagsForLink(const std::string& language) -{ - std::string flags; - - this->AddFeatureFlags(flags, language.c_str()); - - this->GetLocalGenerator()->AddArchitectureFlags(flags, - this->GetTarget(), - language.c_str(), - this->GetConfigName()); - - // TODO(Nicolas Despres): Will see later for the Fortran support. - // // Fortran-specific flags computed for this target. - // if(*l == "Fortran") - // { - // this->AddFortranFlags(flags); - // } - - return flags; -} - // TODO(Nicolas Despres): Refact with // void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). std::string @@ -262,36 +236,12 @@ ComputeDefines(const std::string& language) cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const { - cmNinjaDeps linkDeps; - cmComputeLinkInformation* cli = this->Target->GetLinkInformation(this->GetConfigName()); if(!cli) - return linkDeps; - - - // Append the link items. - typedef cmComputeLinkInformation::ItemVector ItemVector; - ItemVector const& items = cli->GetItems(); - for(ItemVector::const_iterator li = items.begin(); li != items.end(); ++li) - { - std::string filename; - if(li->IsPath) - { - filename = this->LocalGenerator->ConvertToLinkReference(li->Value); - } - else - { - filename = li->Value; - } - std::string path = this->GetTargetOutputDir(); - if(!path.empty()) - path += "/"; - path += filename; - linkDeps.push_back(path); - } + return cmNinjaDeps(); - return linkDeps; + return cli->GetDepends(); } std::string diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 348dc7cd62e..372fc140a59 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -76,13 +76,6 @@ class cmNinjaTargetGenerator */ std::string ComputeFlagsForObject(const std::string& language); - /** - * Compute the flags for the linking of a target for a given @a language. - * @note Generally it is the value of the variable whose name is computed - * by LanguageFlagsVarName(). - */ - std::string ComputeFlagsForLink(const std::string& language); - std::string ComputeDefines(const std::string& language); /// @return the list of link dependency for the given target @a target. From 538a1d01be8f9b5c0b6e674edeb2496e584dbacd Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 22 Aug 2011 04:14:42 +0100 Subject: [PATCH 444/539] Convert link dependencies to HOME_OUTPUT-relative paths Fixes dependency problems in cmake build. Next problem seems to be that CFLAGS are set incorrectly. --- Source/cmNinjaTargetGenerator.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 8126107559d..a1dbadf407b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -241,7 +241,15 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const if(!cli) return cmNinjaDeps(); - return cli->GetDepends(); + const std::vector &deps = cli->GetDepends(); + cmNinjaDeps result; + for (std::vector::const_iterator i = deps.begin(); + i != deps.end(); ++i) { + result.push_back(this->LocalGenerator->Convert(i->c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE)); + } + return result; } std::string From 908afdd3456b7fa62936dd2f1f13054990bca159 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 22 Aug 2011 13:45:02 +0100 Subject: [PATCH 445/539] Stop naming FLAGS and DEFINES variables after source language It was causing problems compiling objects where the source language didn't match the link language. Besides, there didn't seem to be much point in doing so. --- Source/cmNinjaTargetGenerator.cxx | 40 ++++--------------------------- Source/cmNinjaTargetGenerator.h | 5 ---- 2 files changed, 4 insertions(+), 41 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index a1dbadf407b..f73769a2e0b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -97,28 +97,6 @@ ::LanguageLinkerRule(const std::string& lang) const + "_LINKER"; } -std::string -cmNinjaTargetGenerator -::LanguageFlagsVarName(const std::string& language, bool ref) const -{ - std::ostringstream varname; - if(ref) - varname << "$"; - varname << language << "_FLAGS"; - return varname.str(); -} - -std::string -cmNinjaTargetGenerator -::LanguageDefinesVarName(const std::string& language, bool ref) const -{ - std::ostringstream varname; - if(ref) - varname << "$"; - varname << language << "_DEFINES"; - return varname.str(); -} - // TODO(Nicolas Despres): Picked up from cmMakefileTargetGenerator. // Refactor it. const char* cmNinjaTargetGenerator::GetFeature(const char* feature) @@ -376,16 +354,8 @@ ::WriteCompileRule(const std::string& language) vars.Source = "$in"; vars.Object = "$out"; - // FIXME(Nicolas Despres): Factor flags construction with the - // cmMakefileTargetGenerator::WriteObjectBuildFile - // This is mandatory to use a local variables because the string must be - // in memory until ExpandRuleVariables() is called. - std::string flags = this->LanguageFlagsVarName(language, true); - vars.Flags = flags.c_str(); - // FIXME(Nicolas Despres): Factor defines construction with the - // cmMakefileTargetGenerator::WriteObjectBuildFile - std::string defines = this->LanguageDefinesVarName(language, true); - vars.Defines = defines.c_str(); + vars.Flags = "$FLAGS"; + vars.Defines = "$DEFINES"; // Rule for compiling object file. std::string compileCmdVar = "CMAKE_"; @@ -463,10 +433,8 @@ ::WriteObjectBuildStatement(cmSourceFile* source) this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); cmNinjaVars vars; - vars[this->LanguageFlagsVarName(linkLanguage)] = - this->ComputeFlagsForObject(linkLanguage); - vars[this->LanguageDefinesVarName(linkLanguage)] = - this->ComputeDefines(linkLanguage); + vars["FLAGS"] = this->ComputeFlagsForObject(linkLanguage); + vars["DEFINES"] = this->ComputeDefines(linkLanguage); cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), comment, diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 372fc140a59..3e37a060f85 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -60,11 +60,6 @@ class cmNinjaTargetGenerator std::string LanguageLinkerRule(const std::string& lang) const; - std::string LanguageFlagsVarName(const std::string& language, - bool ref = false) const; - std::string LanguageDefinesVarName(const std::string& language, - bool ref = false) const; - const char* GetFeature(const char* feature); bool GetFeatureAsBool(const char* feature); void AddFeatureFlags(std::string& flags, const char* lang); From 057fbb632c13bd071b2bcd0716a88f963a841bf1 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 22 Aug 2011 14:02:20 +0100 Subject: [PATCH 446/539] Have the Ninja generator build link references relative to HOME_OUTPUT Accomplished by making cmLocalGenerator::ConvertToLinkReference virtual, and overriding in cmLocalNinjaGenerator. --- Source/cmLocalNinjaGenerator.cxx | 5 +++++ Source/cmLocalNinjaGenerator.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 87334155b9d..891451dcead 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -273,6 +273,11 @@ bool cmLocalNinjaGenerator::CheckDefinition(std::string const& define) const return ret; } +std::string cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib) +{ + return this->Convert(lib.c_str(), HOME_OUTPUT, SHELL); +} + //---------------------------------------------------------------------------- // Private methods. diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index c08fb47d212..5d3381dc51a 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -105,6 +105,8 @@ class cmLocalNinjaGenerator : public cmLocalGenerator /// Overloaded methods. @see cmLocalGenerator::CheckDefinition() virtual bool CheckDefinition(std::string const& define) const; + virtual std::string ConvertToLinkReference(std::string const& lib); + private: // In order to access to protected member of the local generator. friend class cmNinjaTargetGenerator; From f6dab74593f7f7173611f4615b67385e0c8f1344 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 23 Aug 2011 01:09:44 +0100 Subject: [PATCH 447/539] Pick up the DEFINES and FLAGS from the source and target --- Source/cmNinjaTargetGenerator.cxx | 23 +++++++++++++++++++---- Source/cmNinjaTargetGenerator.h | 5 +++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index f73769a2e0b..cf5df51c616 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -130,7 +130,8 @@ void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, // void cmMakefileTargetGenerator::WriteTargetLanguageFlags() // Refactor it. std::string -cmNinjaTargetGenerator::ComputeFlagsForObject(const std::string& language) +cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, + const std::string& language) { std::string flags; @@ -166,6 +167,12 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(const std::string& language) // Append old-style preprocessor definition flags. this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags()); + // Add target-specific and source-specific flags. + this->LocalGenerator->AppendFlags(flags, + this->Target->GetProperty("COMPILE_FLAGS")); + this->LocalGenerator->AppendFlags(flags, + source->GetProperty("COMPILE_FLAGS")); + // TODO(Nicolas Despres): Handle Apple frameworks. // Add include directory flags. // this->LocalGenerator->AppendFlags(flags, this->GetFrameworkFlags().c_str()); @@ -177,7 +184,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(const std::string& language) // void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). std::string cmNinjaTargetGenerator:: -ComputeDefines(const std::string& language) +ComputeDefines(cmSourceFile *source, const std::string& language) { std::string defines; @@ -196,6 +203,10 @@ ComputeDefines(const std::string& language) (defines, this->Target->GetProperty("COMPILE_DEFINITIONS"), language.c_str()); + this->LocalGenerator->AppendDefines + (defines, + source->GetProperty("COMPILE_DEFINITIONS"), + language.c_str()); { std::string defPropName = "COMPILE_DEFINITIONS_"; defPropName += cmSystemTools::UpperCase(this->GetConfigName()); @@ -207,6 +218,10 @@ ComputeDefines(const std::string& language) (defines, this->Target->GetProperty(defPropName.c_str()), language.c_str()); + this->LocalGenerator->AppendDefines + (defines, + source->GetProperty(defPropName.c_str()), + language.c_str()); } return defines; @@ -433,8 +448,8 @@ ::WriteObjectBuildStatement(cmSourceFile* source) this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); cmNinjaVars vars; - vars["FLAGS"] = this->ComputeFlagsForObject(linkLanguage); - vars["DEFINES"] = this->ComputeDefines(linkLanguage); + vars["FLAGS"] = this->ComputeFlagsForObject(source, linkLanguage); + vars["DEFINES"] = this->ComputeDefines(source, linkLanguage); cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), comment, diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 3e37a060f85..692b07b3a9e 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -69,9 +69,10 @@ class cmNinjaTargetGenerator * @note Generally it is the value of the variable whose name is computed * by LanguageFlagsVarName(). */ - std::string ComputeFlagsForObject(const std::string& language); + std::string ComputeFlagsForObject(cmSourceFile *source, + const std::string& language); - std::string ComputeDefines(const std::string& language); + std::string ComputeDefines(cmSourceFile *source, const std::string& language); /// @return the list of link dependency for the given target @a target. cmNinjaDeps ComputeLinkDeps() const; From a117cb960038461b658be3a90ab7b0069689be64 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 23 Aug 2011 02:41:05 +0100 Subject: [PATCH 448/539] Use cmTarget::GetDirectory to get correct target output directory --- Source/cmNinjaTargetGenerator.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cf5df51c616..30c9b2e541f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -267,7 +267,11 @@ ::GetObjectFilePath(cmSourceFile* source) const std::string cmNinjaTargetGenerator::GetTargetOutputDir() const { - return this->LocalGenerator->GetHomeRelativeOutputPath(); + std::string dir = this->Target->GetDirectory(this->GetConfigName()); + cmSystemTools::MakeDirectory(dir.c_str()); + return this->LocalGenerator->Convert(dir.c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); } std::string From 3b43a6c7dafcd26441970cd3f087193a882ae386 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 25 Aug 2011 02:50:17 +0100 Subject: [PATCH 449/539] Support for creating symlinks, with nasty duplicated code --- Source/cmNinjaExecutableTargetGenerator.cxx | 27 +++++++++++++++-- .../cmNinjaSharedLibraryTargetGenerator.cxx | 29 +++++++++++++++++-- .../cmNinjaStaticLibraryTargetGenerator.cxx | 29 +++++++++++++++++-- 3 files changed, 79 insertions(+), 6 deletions(-) diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index bba5d9084c8..1da3431e16a 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -104,6 +104,17 @@ ::WriteLinkRule(const std::string& language) description.str(), depfile, emptyVars); + + std::string cmakeCommand = + this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); + this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_EXECUTABLE", + cmakeCommand + + " -E cmake_symlink_executable" + " $in $out", + "Rule for creating executable symlink.", + "Creating executable symlink $out", + depfile, + emptyVars); } void cmNinjaExecutableTargetGenerator::WriteLinkStatement() @@ -121,14 +132,15 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() cmNinjaVars vars; std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); + std::string targetOutputReal = this->GetTargetFilePath(this->TargetNameReal); // Compute the comment. std::ostringstream comment; - comment << "Link the executable " << targetOutput; + comment << "Link the executable " << targetOutputReal; // Compute outputs. cmNinjaDeps outputs; - outputs.push_back(targetOutput); + outputs.push_back(targetOutputReal); // Add this executable to the all target. this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); @@ -160,6 +172,17 @@ void cmNinjaExecutableTargetGenerator::WriteLinkStatement() emptyDeps, vars); + if (targetOutput != targetOutputReal) { + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + "Create executable symlink " + targetOutput, + "CMAKE_SYMLINK_EXECUTABLE", + cmNinjaDeps(1, targetOutput), + cmNinjaDeps(1, targetOutputReal), + emptyDeps, + emptyDeps, + cmNinjaVars()); + } + // Write a shortcut rule with the target name. this->WriteTargetBuild(this->TargetNameOut, targetOutput); } diff --git a/Source/cmNinjaSharedLibraryTargetGenerator.cxx b/Source/cmNinjaSharedLibraryTargetGenerator.cxx index 2077feea993..f92fe682ee6 100644 --- a/Source/cmNinjaSharedLibraryTargetGenerator.cxx +++ b/Source/cmNinjaSharedLibraryTargetGenerator.cxx @@ -107,6 +107,17 @@ ::WriteLinkRule(const std::string& language) description.str(), depfile, emptyVars); + + std::string cmakeCommand = + this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); + this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", + cmakeCommand + + " -E cmake_symlink_library" + " $in $SONAME $out", + "Rule for creating library symlink.", + "Creating library symlink $out", + depfile, + emptyVars); } void cmNinjaSharedLibraryTargetGenerator::WriteLinkStatement() @@ -124,14 +135,15 @@ void cmNinjaSharedLibraryTargetGenerator::WriteLinkStatement() cmNinjaVars vars; std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); + std::string targetOutputReal = this->GetTargetFilePath(this->TargetNameReal); // Compute the comment. std::ostringstream comment; - comment << "Link the shared library " << targetOutput; + comment << "Link the shared library " << targetOutputReal; // Compute outputs. cmNinjaDeps outputs; - outputs.push_back(targetOutput); + outputs.push_back(targetOutputReal); // Add this executable to the all target. this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); @@ -164,6 +176,19 @@ void cmNinjaSharedLibraryTargetGenerator::WriteLinkStatement() emptyDeps, vars); + if (targetOutput != targetOutputReal) { + cmNinjaVars symlinkVars; + symlinkVars["SONAME"] = this->TargetNameSO; + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + "Create library symlink " + targetOutput, + "CMAKE_SYMLINK_LIBRARY", + cmNinjaDeps(1, targetOutput), + cmNinjaDeps(1, targetOutputReal), + emptyDeps, + emptyDeps, + symlinkVars); + } + // Write a shortcut rule with the target name. this->WriteTargetBuild(this->TargetNameOut, targetOutput); } diff --git a/Source/cmNinjaStaticLibraryTargetGenerator.cxx b/Source/cmNinjaStaticLibraryTargetGenerator.cxx index 2784fbfa5b0..4cb8cb8e114 100644 --- a/Source/cmNinjaStaticLibraryTargetGenerator.cxx +++ b/Source/cmNinjaStaticLibraryTargetGenerator.cxx @@ -118,6 +118,17 @@ ::WriteLinkRule(const std::string& language) description.str(), depfile, emptyVars); + + std::string cmakeCommand = + this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); + this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", + cmakeCommand + + " -E cmake_symlink_library" + " $in $SONAME $out", + "Rule for creating library symlink.", + "Creating library symlink $out", + depfile, + emptyVars); } std::vector @@ -186,14 +197,15 @@ void cmNinjaStaticLibraryTargetGenerator::WriteLinkStatement() cmNinjaVars vars; std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); + std::string targetOutputReal = this->GetTargetFilePath(this->TargetNameReal); // Compute the comment. std::ostringstream comment; - comment << "Link the static library " << targetOutput; + comment << "Link the static library " << targetOutputReal; // Compute outputs. cmNinjaDeps outputs; - outputs.push_back(targetOutput); + outputs.push_back(targetOutputReal); // Add this executable to the all target. this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); @@ -226,6 +238,19 @@ void cmNinjaStaticLibraryTargetGenerator::WriteLinkStatement() emptyDeps, vars); + if (targetOutput != targetOutputReal) { + cmNinjaVars symlinkVars; + symlinkVars["SONAME"] = this->TargetNameSO; + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + "Create library symlink " + targetOutput, + "CMAKE_SYMLINK_LIBRARY", + cmNinjaDeps(1, targetOutput), + cmNinjaDeps(1, targetOutputReal), + emptyDeps, + emptyDeps, + symlinkVars); + } + // Write a shortcut rule with the target name. this->WriteTargetBuild(this->TargetNameOut, targetOutput); } From 58b2ed367b16e618d6663b7ab6af39cc540c342a Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 26 Aug 2011 03:42:48 +0100 Subject: [PATCH 450/539] Target ordering for utilities The "utility" (a.k.a. add_dependencies) targets must be built before any object file in the depending target (for example, if the utility target generates a header file used by one or more of the source files of the depending target). Enforce this constraint by adding the utility targets as implicit dependencies of every object file in the depending target. This fixes a missing dependency issue with LLVM. Still to do are custom targets, without which this does not really help at all. --- Source/cmNinjaTargetGenerator.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 30c9b2e541f..5343b38da10 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -448,6 +448,12 @@ ::WriteObjectBuildStatement(cmSourceFile* source) std::string sourceFileName = this->GetSourceFilePath(source); explicitDeps.push_back(sourceFileName); + // Ensure that the utilities for this target are built before any source file + // in the target. + cmNinjaDeps implicitDeps; + std::set const& utils = this->Target->GetUtilities(); + implicitDeps.insert(implicitDeps.end(), utils.begin(), utils.end()); + const char* linkLanguage = this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); @@ -460,7 +466,7 @@ ::WriteObjectBuildStatement(cmSourceFile* source) rule, outputs, explicitDeps, - emptyDeps, + implicitDeps, emptyDeps, vars); } From 2ab501dca417110b0cbcfa4eb4bb60fd32a9a0f3 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 26 Aug 2011 17:47:23 +0100 Subject: [PATCH 451/539] Remove ninja debugging output and unused overridden methods --- Source/cmGlobalNinjaGenerator.cxx | 144 ------------------ Source/cmGlobalNinjaGenerator.h | 31 +--- Source/cmLocalNinjaGenerator.cxx | 126 --------------- Source/cmLocalNinjaGenerator.h | 33 ---- Source/cmNinjaExecutableTargetGenerator.cxx | 1 - .../cmNinjaSharedLibraryTargetGenerator.cxx | 1 - .../cmNinjaStaticLibraryTargetGenerator.cxx | 3 - Source/cmNinjaTargetGenerator.cxx | 1 - 8 files changed, 1 insertion(+), 339 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index d6ccb696648..9e8dab50b7d 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -285,28 +285,12 @@ ::GetDocumentation(cmDocumentationEntry& entry) const "\"all\" target. An \"install\" target is also provided."; } -// Implemented by: -// cmGlobalVisualStudio7Generator -// cmGlobalVisualStudio8Generator -// Used in: -// Source/cmake.cxx -void cmGlobalNinjaGenerator::Configure() -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - cmGlobalGenerator::Configure(); - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - // Implemented in all cmGlobaleGenerator sub-classes. // Used in: // Source/cmLocalGenerator.cxx // Source/cmake.cxx void cmGlobalNinjaGenerator::Generate() { - std::cerr << "DEBUG NINJA: BEGIN: " - << __PRETTY_FUNCTION__ - << " (" << this << ")" << std::endl; - this->OpenBuildFileStream(); this->OpenRulesFileStream(); @@ -316,10 +300,6 @@ void cmGlobalNinjaGenerator::Generate() this->CloseRulesFileStream(); this->CloseBuildFileStream(); - - std::cerr << "DEBUG NINJA: END: " - << __PRETTY_FUNCTION__ - << " (" << this << ")" << std::endl; } // Implemented in all cmGlobaleGenerator sub-classes. @@ -330,17 +310,6 @@ ::EnableLanguage(std::vectorconst& languages, cmMakefile *mf, bool optional) { - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cerr << "DEBUG NINJA: ARG: languages: "; - for (std::vector::const_iterator l = languages.begin(); - l != languages.end(); - ++l) - std::cerr << "'" << *l << "', "; - std::cerr << std::endl; - std::cerr << "DEBUG NINJA: ARG: cmMakefile: " << mf - << " project: '" << mf->GetProjectName() << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: optional: " << optional << std::endl; - this->cmGlobalGenerator::EnableLanguage(languages, mf, optional); std::string path; for(std::vector::const_iterator l = languages.begin(); @@ -360,57 +329,6 @@ ::EnableLanguage(std::vectorconst& languages, cmSystemTools::Error(message.c_str()); } } - - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - -// Not implemented in none of cmLocalGenerator sub-classes. -// Used nowhere. -void cmGlobalNinjaGenerator -::EnableLanguagesFromGenerator(cmGlobalGenerator* gen, - cmMakefile* mf) -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cerr << "DEBUG NINJA: ARG: cmGlobaleGenerator: " << gen - << " name: '" << gen->GetName() << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: mf: " << mf - << " project: '" << mf->GetProjectName() << "'" << std::endl; - - cmGlobalGenerator::EnableLanguagesFromGenerator(gen, mf); - - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - -// Not implemented in none of cmLocalGenerator sub-classes. -// Used in: -// Source/cmMakefile.cxx -int cmGlobalNinjaGenerator::TryCompile(const char* srcdir, - const char* bindir, - const char* projectName, - const char* targetName, - bool fast, - std::string* output, - cmMakefile* mf) -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cerr << "DEBUG NINJA: ARG: srcdir: '" << srcdir << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: bindir: '" << bindir << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: projectName: '" << projectName << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: fast: '" << fast << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: output: '" << *output << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: mf: " << mf - << " project: '" << mf->GetProjectName() << "'" << std::endl; - - int ret = cmGlobalGenerator::TryCompile(srcdir, - bindir, - projectName, - targetName, - fast, - output, - mf); - - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; - return ret; } // Implemented by: @@ -430,14 +348,6 @@ ::GenerateBuildCommand(const char* makeProgram, bool ignoreErrors, bool fast) { - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cerr << "DEBUG NINJA: ARG: makeProgram: '" << makeProgram << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: projectName: '" << projectName << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: additionalOptions: '" << (additionalOptions ? additionalOptions : "NULL") << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: targetName: '" << targetName << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: ignoreErrors: '" << ignoreErrors << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: fast: '" << fast << "'" << std::endl; - // Project name and config are not used yet. (void)projectName; (void)config; @@ -460,8 +370,6 @@ ::GenerateBuildCommand(const char* makeProgram, makeCommand += targetName; } - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ - << " RESULT='" << makeCommand << "'" << std::endl; return makeCommand; } @@ -491,58 +399,6 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, } -//---------------------------------------------------------------------------- -// Virtual protected methods. - -// Not implemented in UnixMakefile generator. -void cmGlobalNinjaGenerator::GetTargetSets(TargetDependSet& projectTargets, - TargetDependSet& originalTargets, - cmLocalGenerator* root, - GeneratorVector const& generators) -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - - cmGlobalGenerator::GetTargetSets(projectTargets, - originalTargets, - root, - generators); - - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - -// Not implemented in UnixMakefile generator. -bool cmGlobalNinjaGenerator::IsRootOnlyTarget(cmTarget* target) -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cerr << "DEBUG NINJA: ARG: target: " << target - << " name: '" << target->GetName() << "'" - << " type: '" << cmTarget::TargetTypeNames(target->GetType()) << "'" - << std::endl; - - bool ret = cmGlobalGenerator::IsRootOnlyTarget(target); - - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; - return ret; -} - -// Not implemented in UnixMakefile generator. -bool cmGlobalNinjaGenerator::ComputeTargetDepends() -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - bool ret = cmGlobalGenerator::ComputeTargetDepends(); - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; - return ret; -} - -// Not implemented in UnixMakefile generator. -const char* cmGlobalNinjaGenerator::GetPredefinedTargetsFolder() -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - const char* ret = cmGlobalGenerator::GetPredefinedTargetsFolder(); - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; - return ret; -} - //---------------------------------------------------------------------------- // Private methods diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index b4900b25526..63dc5a93954 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -145,10 +145,7 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() virtual void GetDocumentation(cmDocumentationEntry& entry) const; - /// Overloaded methods. @see cmGlobalGenerator::Configure() - virtual void Configure(); - - /// Overloaded methods. @see cmGlobalGenerator::Gonfigure() + /// Overloaded methods. @see cmGlobalGenerator::Generate() virtual void Generate(); /// Overloaded methods. @see cmGlobalGenerator::EnableLanguage() @@ -156,18 +153,6 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator cmMakefile* mf, bool optional); - /// Overloaded methods. @see cmGlobalGenerator::EnableLanguagesFromGenerator() - virtual void EnableLanguagesFromGenerator(cmGlobalGenerator* gen, - cmMakefile* mf); - - /// Overloaded methods. @see cmGlobalGenerator::TryCompile() - virtual int TryCompile(const char* srcdir, - const char* bindir, - const char* projectName, - const char* targetName, - bool fast, std::string* output, - cmMakefile* mf); - /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand() virtual std::string GenerateBuildCommand(const char* makeProgram, const char* projectName, @@ -211,24 +196,10 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator protected: - /// Overloaded methods. @see cmGlobalGenerator::GetTargetSets() - virtual void GetTargetSets(TargetDependSet& projectTargets, - TargetDependSet& originalTargets, - cmLocalGenerator* root, - GeneratorVector const& generators); - /// Overloaded methods. @see cmGlobalGenerator::IsRootOnlyTarget() - virtual bool IsRootOnlyTarget(cmTarget* target); - - /// Overloaded methods. @see cmGlobalGenerator::ComputeTargetDepends() - virtual bool ComputeTargetDepends(); - /// Overloaded methods. /// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { return true; } - /// Overloaded methods. @see cmGlobalGenerator::GetPredefinedTargetsFolder() - virtual const char* GetPredefinedTargetsFolder(); - private: // In order to access the AddDependencyToAll() functions and co. friend class cmLocalNinjaGenerator; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 891451dcead..c5d5093c285 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -32,21 +32,10 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator() cmLocalNinjaGenerator::~cmLocalNinjaGenerator() { - std::cerr << "DEBUG NINJA: LOCAL GENERATOR DESTRUCTOR: " - << this << std::endl; } void cmLocalNinjaGenerator::Generate() { - std::cerr << "DEBUG NINJA: BEGIN: " - << __PRETTY_FUNCTION__ - << " (" << this << ")" << std::endl; - std::cerr << "DEBUG NINJA: CURRENT DIRECTORY: " - << this->Makefile->GetCurrentDirectory() << std::endl; - std::cerr << "DEBUG NINJA: CURRENT OUTPUT DIRECTORY: " - << this->Makefile->GetCurrentOutputDirectory() << std::endl; - std::cerr << "DEBUG NINJA: CURRENT LIST FILE: " - << this->Makefile->GetCurrentListFile() << std::endl; this->SetConfigName(); @@ -67,9 +56,6 @@ void cmLocalNinjaGenerator::Generate() } } - std::cerr << "DEBUG NINJA: END: " - << __PRETTY_FUNCTION__ - << " (" << this << ")" << std::endl; } // Implemented in: @@ -79,8 +65,6 @@ void cmLocalNinjaGenerator::Generate() // Source/cmGlobalGenerator.cxx void cmLocalNinjaGenerator::Configure() { - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - // Compute the path to use when referencing the current output // directory from the top output directory. this->HomeRelativeOutputPath = @@ -91,113 +75,6 @@ void cmLocalNinjaGenerator::Configure() } this->cmLocalGenerator::Configure(); - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - -// Not implemented in none of cmLocalGenerator sub-classes. -void cmLocalNinjaGenerator::TraceDependencies() -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - cmLocalGenerator::TraceDependencies(); - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - -// Implemented only in some VisualStudio local generator. -void cmLocalNinjaGenerator::AddHelperCommands() -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - cmLocalGenerator::AddHelperCommands(); - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - -// Implemented only in some VisualStudio local generator. -void cmLocalNinjaGenerator::ConfigureFinalPass() -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - cmLocalGenerator::ConfigureFinalPass(); - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - -// Not implemented in none of cmLocalGenerator sub-classes. -void cmLocalNinjaGenerator::GenerateInstallRules() -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - cmLocalGenerator::GenerateInstallRules(); - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - -// Not implemented in none of cmLocalGenerator sub-classes. -void cmLocalNinjaGenerator::GenerateTestFiles() -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - cmLocalGenerator::GenerateTestFiles(); - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - -// Not implemented in none of cmLocalGenerator sub-classes. -void cmLocalNinjaGenerator::GenerateTargetManifest() -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - cmLocalGenerator::GenerateTargetManifest(); - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - -// Implemented only in UnixMakefile local generator. -// Used in: -// Source/cmake.cxx -void cmLocalNinjaGenerator::ClearDependencies(cmMakefile* mf, - bool verbose) -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cerr << "DEBUG NINJA: ARG: cmMakefile: " << mf - << " project: '" << mf->GetProjectName() << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: verbose: " << verbose << std::endl; - - cmLocalGenerator::ClearDependencies(mf, verbose); - - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; -} - -// Implemented only in UnixMakefile local generator. -// Used in: -// Source/cmake.cxx -bool cmLocalNinjaGenerator::UpdateDependencies(const char* tgtInfo, - bool verbose, - bool color) -{ - std::cerr << "DEBUG NINJA: " << __PRETTY_FUNCTION__ << std::endl; - std::cerr << "DEBUG NINJA: ARG: tgtInfo: '" << tgtInfo << "'" << std::endl; - std::cerr << "DEBUG NINJA: ARG: verbose: " << verbose << std::endl; - std::cerr << "DEBUG NINJA: ARG: color: " << color << std::endl; - - bool ret = cmLocalGenerator::UpdateDependencies(tgtInfo, verbose, color); - - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; - return ret; -} - -// Implemented in almost all cmLocalGenerator sub-classes. -// Used in: -// Source/cmTarget.cxx: -void cmLocalNinjaGenerator -::GetTargetObjectFileDirectories(cmTarget* target, - std::vector& dirs) -{ - std::cerr << "DEBUG NINJA: BEGIN: " << __PRETTY_FUNCTION__ << std::endl; - std::cerr << "DEBUG NINJA: ARG: target: " << target - << " name: '" << target->GetName() << "'" - << " type: '" << cmTarget::TargetTypeNames(target->GetType()) << "'" - << std::endl; - std::cerr << "DEBUG NINJA: ARG: dirs: "; - for(std::vector::const_iterator d = dirs.begin(); - d != dirs.end(); - ++d) - std::cerr << "'" << *d << "', "; - std::cerr << std::endl; - - cmLocalGenerator::GetTargetObjectFileDirectories(target, dirs); - - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; } // TODO(Nicolas Despres): Picked up from cmLocalUnixMakefileGenerator3. @@ -264,12 +141,9 @@ ::GetObjectFileName(const cmTarget& target, // Source/cmLocalVisualStudio6Generator.cxx bool cmLocalNinjaGenerator::CheckDefinition(std::string const& define) const { - std::cerr << "DEBUG NINJA: " << __PRETTY_FUNCTION__ << std::endl; - std::cerr << "DEBUG NINJA: ARG: define: '" << define << "'" << std::endl; bool ret = cmLocalGenerator::CheckDefinition(define); - std::cerr << "DEBUG NINJA: END: " << __PRETTY_FUNCTION__ << std::endl; return ret; } diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 5d3381dc51a..0eab6c87f64 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -41,39 +41,6 @@ class cmLocalNinjaGenerator : public cmLocalGenerator /// Overloaded methods. @see cmLocalGenerator::Configure() virtual void Configure(); - /// Overloaded methods. @see cmLocalGenerator::TraceDependencies() - virtual void TraceDependencies(); - - /// Overloaded methods. @see cmLocalGenerator::AddHelperCommands() - virtual void AddHelperCommands(); - - /// Overloaded methods. @see cmLocalGenerator::ConfigureFinalPass() - virtual void ConfigureFinalPass(); - - /// Overloaded methods. @see cmLocalGenerator::GenerateInstallRules() - virtual void GenerateInstallRules(); - - /// Overloaded methods. @see cmLocalGenerator::GenerateTestFiles() - virtual void GenerateTestFiles(); - - /// Overloaded methods. @see cmLocalGenerator::GenerateTargetManifest() - virtual void GenerateTargetManifest(); - - /// Overloaded methods. @see cmLocalGenerator::ClearDependencies() - virtual void ClearDependencies(cmMakefile* mf, bool verbose); - - /// Overloaded methods. @see cmLocalGenerator::UpdateDependencies() - virtual bool UpdateDependencies(const char* tgtInfo, - bool verbose, - bool color); - - /// Overloaded methods. - /// @see cmLocalGenerator::GetTargetObjectFileDirectories() - /// Get the directories into which the .o files will go for this target. - virtual void - GetTargetObjectFileDirectories(cmTarget* target, - std::vector& dirs); - /// Overloaded methods. @see cmLocalGenerator::GetTargetDirectory() virtual std::string GetTargetDirectory(cmTarget const& target) const; diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx index 1da3431e16a..df38a00ca40 100644 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ b/Source/cmNinjaExecutableTargetGenerator.cxx @@ -87,7 +87,6 @@ ::WriteLinkRule(const std::string& language) linkCmdVar += "_LINK_EXECUTABLE"; std::string linkCmd = this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - std::cerr << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; this->GetLocalGenerator()->ExpandRuleVariables(linkCmd, vars); diff --git a/Source/cmNinjaSharedLibraryTargetGenerator.cxx b/Source/cmNinjaSharedLibraryTargetGenerator.cxx index f92fe682ee6..ca75eccdca0 100644 --- a/Source/cmNinjaSharedLibraryTargetGenerator.cxx +++ b/Source/cmNinjaSharedLibraryTargetGenerator.cxx @@ -90,7 +90,6 @@ ::WriteLinkRule(const std::string& language) linkCmdVar += "_CREATE_SHARED_LIBRARY"; std::string linkCmd = this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - std::cerr << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; this->GetLocalGenerator()->ExpandRuleVariables(linkCmd, vars); diff --git a/Source/cmNinjaStaticLibraryTargetGenerator.cxx b/Source/cmNinjaStaticLibraryTargetGenerator.cxx index 4cb8cb8e114..ce769bdb197 100644 --- a/Source/cmNinjaStaticLibraryTargetGenerator.cxx +++ b/Source/cmNinjaStaticLibraryTargetGenerator.cxx @@ -157,7 +157,6 @@ ::ComputeLinkCmd(const std::string& language) linkCmdVar += "_ARCHIVE_CREATE"; std::string linkCmd = this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - std::cerr << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; linkCmds.push_back(linkCmd); } // TODO(Nicolas Despres): I'll see later how to deals with that. @@ -167,7 +166,6 @@ ::ComputeLinkCmd(const std::string& language) // linkCmdVar += "_ARCHIVE_APPEND"; // std::string linkCmd = // this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - // std::cerr << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; // linkCmds.push_back(linkCmd); // } { @@ -176,7 +174,6 @@ ::ComputeLinkCmd(const std::string& language) linkCmdVar += "_ARCHIVE_FINISH"; std::string linkCmd = this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - std::cerr << "DEBUG NINJA: " << linkCmdVar << " = " << linkCmd << std::endl; linkCmds.push_back(linkCmd); } return linkCmds; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 5343b38da10..4df1302cef1 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -382,7 +382,6 @@ ::WriteCompileRule(const std::string& language) compileCmdVar += "_COMPILE_OBJECT"; std::string compileCmd = this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str()); - std::cerr << "DEBUG NINJA: COMPILE CMD: " << compileCmd << std::endl; this->GetLocalGenerator()->ExpandRuleVariables(compileCmd, vars); From be22c4211d6f0cd1375fbbaa6dd6e78d0175f67a Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 26 Aug 2011 18:27:51 +0100 Subject: [PATCH 452/539] Use cmMakefile::GetDefinition here to avoid spurious error messages --- Source/cmNinjaStaticLibraryTargetGenerator.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/cmNinjaStaticLibraryTargetGenerator.cxx b/Source/cmNinjaStaticLibraryTargetGenerator.cxx index ce769bdb197..b75bbc7028e 100644 --- a/Source/cmNinjaStaticLibraryTargetGenerator.cxx +++ b/Source/cmNinjaStaticLibraryTargetGenerator.cxx @@ -141,9 +141,8 @@ ::ComputeLinkCmd(const std::string& language) std::string linkCmdVar = "CMAKE_"; linkCmdVar += language; linkCmdVar += "_CREATE_STATIC_LIBRARY"; - std::string linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - if(!linkCmd.empty()) + if (const char *linkCmd = + this->GetMakefile()->GetDefinition(linkCmdVar.c_str())) { linkCmds.push_back(linkCmd); return linkCmds; From 4b353af7e8cb3085adde2c5c73ffce788a919869 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 26 Aug 2011 21:41:55 +0100 Subject: [PATCH 453/539] Unify the executable, shared and static target generators --- Source/CMakeLists.txt | 8 +- Source/cmGlobalNinjaGenerator.cxx | 7 +- Source/cmGlobalNinjaGenerator.h | 2 + Source/cmLocalNinjaGenerator.h | 4 +- Source/cmNinjaExecutableTargetGenerator.cxx | 187 ---------- Source/cmNinjaExecutableTargetGenerator.h | 39 --- Source/cmNinjaNormalTargetGenerator.cxx | 326 ++++++++++++++++++ ...rator.h => cmNinjaNormalTargetGenerator.h} | 14 +- .../cmNinjaSharedLibraryTargetGenerator.cxx | 193 ----------- Source/cmNinjaSharedLibraryTargetGenerator.h | 40 --- .../cmNinjaStaticLibraryTargetGenerator.cxx | 252 -------------- Source/cmNinjaTargetGenerator.cxx | 22 +- Source/cmNinjaTargetGenerator.h | 4 +- 13 files changed, 348 insertions(+), 750 deletions(-) delete mode 100644 Source/cmNinjaExecutableTargetGenerator.cxx delete mode 100644 Source/cmNinjaExecutableTargetGenerator.h create mode 100644 Source/cmNinjaNormalTargetGenerator.cxx rename Source/{cmNinjaStaticLibraryTargetGenerator.h => cmNinjaNormalTargetGenerator.h} (75%) delete mode 100644 Source/cmNinjaSharedLibraryTargetGenerator.cxx delete mode 100644 Source/cmNinjaSharedLibraryTargetGenerator.h delete mode 100644 Source/cmNinjaStaticLibraryTargetGenerator.cxx diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 01a72bab396..d5478fe77dd 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -213,12 +213,8 @@ SET(SRCS cmLocalNinjaGenerator.h cmNinjaTargetGenerator.cxx cmNinjaTargetGenerator.h - cmNinjaExecutableTargetGenerator.cxx - cmNinjaExecutableTargetGenerator.h - cmNinjaSharedLibraryTargetGenerator.cxx - cmNinjaSharedLibraryTargetGenerator.h - cmNinjaStaticLibraryTargetGenerator.cxx - cmNinjaStaticLibraryTargetGenerator.h + cmNinjaNormalTargetGenerator.cxx + cmNinjaNormalTargetGenerator.h cmMakeDepend.cxx cmMakeDepend.h cmMakefile.cxx diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 9e8dab50b7d..bfb8bd40475 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -384,8 +384,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, const cmNinjaVars& variables) { // Do not add twice the same rule. - RulesSetType::const_iterator rule = this->Rules.find(name); - if (rule != this->Rules.end()) + if (this->HasRule(name)) return; this->Rules.insert(name); @@ -398,6 +397,10 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, variables); } +bool cmGlobalNinjaGenerator::HasRule(const std::string &name) { + RulesSetType::const_iterator rule = this->Rules.find(name); + return (rule != this->Rules.end()); +} //---------------------------------------------------------------------------- // Private methods diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 63dc5a93954..6f553f24a12 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -194,6 +194,8 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator const std::string& depfile, const cmNinjaVars& variables); + bool HasRule(const std::string& name); + protected: /// Overloaded methods. diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 0eab6c87f64..8b5194b2e99 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -77,9 +77,7 @@ class cmLocalNinjaGenerator : public cmLocalGenerator private: // In order to access to protected member of the local generator. friend class cmNinjaTargetGenerator; - friend class cmNinjaExecutableTargetGenerator; - friend class cmNinjaSharedLibraryTargetGenerator; - friend class cmNinjaStaticLibraryTargetGenerator; + friend class cmNinjaNormalTargetGenerator; private: cmGeneratedFileStream& GetBuildFileStream() const; diff --git a/Source/cmNinjaExecutableTargetGenerator.cxx b/Source/cmNinjaExecutableTargetGenerator.cxx deleted file mode 100644 index df38a00ca40..00000000000 --- a/Source/cmNinjaExecutableTargetGenerator.cxx +++ /dev/null @@ -1,187 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2011 Nicolas Despres - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#include "cmNinjaExecutableTargetGenerator.h" -#include "cmLocalNinjaGenerator.h" -#include "cmGlobalNinjaGenerator.h" -#include "cmSourceFile.h" -#include "cmGeneratedFileStream.h" -#include "cmMakefile.h" - -cmNinjaExecutableTargetGenerator:: -cmNinjaExecutableTargetGenerator(cmTarget* target) - : cmNinjaTargetGenerator(target) - , TargetNameOut() - , TargetNameReal() - , TargetNameImport() - , TargetNamePDB() -{ - this->GetTarget()->GetExecutableNames(this->TargetNameOut, - this->TargetNameReal, - this->TargetNameImport, - this->TargetNamePDB, - GetLocalGenerator()->GetConfigName()); -} - -cmNinjaExecutableTargetGenerator::~cmNinjaExecutableTargetGenerator() -{ -} - -void -cmNinjaExecutableTargetGenerator -::WriteLinkRule(const std::string& language) -{ - cmLocalGenerator::RuleVariables vars; - vars.RuleLauncher = "RULE_LAUNCH_LINK"; - vars.CMTarget = this->GetTarget(); - std::string lang = language; - vars.Language = lang.c_str(); - vars.Objects = "$in"; - std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); - objdir += this->GetTargetName(); - objdir += ".dir"; - objdir = this->GetLocalGenerator()->Convert(objdir.c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); - vars.ObjectDir = objdir.c_str(); - vars.Target = "$out"; - - // Setup the target version. - std::string targetVersionMajor; - std::string targetVersionMinor; - { - cmOStringStream majorStream; - cmOStringStream minorStream; - int major; - int minor; - this->GetTarget()->GetTargetVersion(major, minor); - majorStream << major; - minorStream << minor; - targetVersionMajor = majorStream.str(); - targetVersionMinor = minorStream.str(); - } - vars.TargetVersionMajor = targetVersionMajor.c_str(); - vars.TargetVersionMinor = targetVersionMinor.c_str(); - - vars.LinkLibraries = "$LINK_LIBRARIES"; - vars.Flags = "$FLAGS"; - vars.LinkFlags = "$LINK_FLAGS"; - - std::string langFlags; - this->GetLocalGenerator()->AddLanguageFlags(langFlags, language.c_str(), - this->GetConfigName()); - langFlags += "$ARCHITECTURE_FLAGS"; - vars.LanguageCompileFlags = langFlags.c_str(); - - // Rule for linking executable. - std::string linkCmdVar = "CMAKE_"; - linkCmdVar += language; - linkCmdVar += "_LINK_EXECUTABLE"; - std::string linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - - this->GetLocalGenerator()->ExpandRuleVariables(linkCmd, vars); - - // Write the rule for linking an executable. - std::ostringstream comment; - comment << "Rule for linking " << language << " executable."; - std::ostringstream description; - description << "Linking " << language << " executable $out"; - std::string depfile = ""; - cmNinjaVars emptyVars; - this->GetGlobalGenerator()->AddRule(this->LanguageLinkerRule(language), - linkCmd, - comment.str(), - description.str(), - depfile, - emptyVars); - - std::string cmakeCommand = - this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); - this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_EXECUTABLE", - cmakeCommand + - " -E cmake_symlink_executable" - " $in $out", - "Rule for creating executable symlink.", - "Creating executable symlink $out", - depfile, - emptyVars); -} - -void cmNinjaExecutableTargetGenerator::WriteLinkStatement() -{ - // Write comments. - cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); - this->GetBuildFileStream() - << "# Link build statements for " - << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) - << " target " - << this->GetTargetName() - << "\n\n"; - - cmNinjaDeps emptyDeps; - cmNinjaVars vars; - - std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); - std::string targetOutputReal = this->GetTargetFilePath(this->TargetNameReal); - - // Compute the comment. - std::ostringstream comment; - comment << "Link the executable " << targetOutputReal; - - // Compute outputs. - cmNinjaDeps outputs; - outputs.push_back(targetOutputReal); - // Add this executable to the all target. - this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); - - const char* linkLanguage = - this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); - - // Compute specific libraries to link with. - cmNinjaDeps explicitDeps = this->GetObjects(), - implicitDeps = this->ComputeLinkDeps(); - - this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], - vars["FLAGS"], - vars["LINK_FLAGS"], - *this->GetTarget()); - - // Compute specific link flags. - this->GetLocalGenerator()->AddArchitectureFlags(vars["ARCHITECTURE_FLAGS"], - this->GetTarget(), - linkLanguage, - this->GetConfigName()); - - // Write the build statement for this target. - cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - comment.str(), - this->LanguageLinkerRule(linkLanguage), - outputs, - explicitDeps, - implicitDeps, - emptyDeps, - vars); - - if (targetOutput != targetOutputReal) { - cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - "Create executable symlink " + targetOutput, - "CMAKE_SYMLINK_EXECUTABLE", - cmNinjaDeps(1, targetOutput), - cmNinjaDeps(1, targetOutputReal), - emptyDeps, - emptyDeps, - cmNinjaVars()); - } - - // Write a shortcut rule with the target name. - this->WriteTargetBuild(this->TargetNameOut, targetOutput); -} diff --git a/Source/cmNinjaExecutableTargetGenerator.h b/Source/cmNinjaExecutableTargetGenerator.h deleted file mode 100644 index 2109fa512e2..00000000000 --- a/Source/cmNinjaExecutableTargetGenerator.h +++ /dev/null @@ -1,39 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2011 Nicolas Despres - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef cmNinjaExecutableTargetGenerator_h -# define cmNinjaExecutableTargetGenerator_h - -# include "cmNinjaTargetGenerator.h" -# include "cmNinjaTypes.h" - -class cmSourceFile; - -class cmNinjaExecutableTargetGenerator : public cmNinjaTargetGenerator -{ -public: - /// Build a NinjaTargetGenerator. - cmNinjaExecutableTargetGenerator(cmTarget* target); - ~cmNinjaExecutableTargetGenerator(); - -private: - virtual void WriteLinkRule(const std::string& language); - virtual void WriteLinkStatement(); - -private: - // Target name info. - std::string TargetNameOut; - std::string TargetNameReal; - std::string TargetNameImport; - std::string TargetNamePDB; -}; - -#endif // ! cmNinjaExecutableTargetGenerator_h diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx new file mode 100644 index 00000000000..8ab17f67ad6 --- /dev/null +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -0,0 +1,326 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmNinjaNormalTargetGenerator.h" +#include "cmLocalNinjaGenerator.h" +#include "cmGlobalNinjaGenerator.h" +#include "cmSourceFile.h" +#include "cmGeneratedFileStream.h" +#include "cmMakefile.h" + +cmNinjaNormalTargetGenerator:: +cmNinjaNormalTargetGenerator(cmTarget* target) + : cmNinjaTargetGenerator(target) + , TargetNameOut() + , TargetNameSO() + , TargetNameReal() + , TargetNameImport() + , TargetNamePDB() + , TargetLinkLanguage(target->GetLinkerLanguage(this->GetConfigName())) +{ + if (target->GetType() == cmTarget::EXECUTABLE) + target->GetExecutableNames(this->TargetNameOut, + this->TargetNameReal, + this->TargetNameImport, + this->TargetNamePDB, + GetLocalGenerator()->GetConfigName()); + else + target->GetLibraryNames(this->TargetNameOut, + this->TargetNameSO, + this->TargetNameReal, + this->TargetNameImport, + this->TargetNamePDB, + GetLocalGenerator()->GetConfigName()); +} + +cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() +{ +} + +const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const { + switch (this->GetTarget()->GetType()) { + case cmTarget::STATIC_LIBRARY: + return "static library"; + case cmTarget::SHARED_LIBRARY: + return "shared library"; + case cmTarget::EXECUTABLE: + return "executable"; + default: + return 0; + } +} + +std::string +cmNinjaNormalTargetGenerator +::LanguageLinkerRule() const +{ + return std::string(this->TargetLinkLanguage) + + "_" + + cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + + "_LINKER"; +} + +void +cmNinjaNormalTargetGenerator +::WriteLinkRule() +{ + std::string ruleName = this->LanguageLinkerRule(); + + if (!this->GetGlobalGenerator()->HasRule(ruleName)) { + cmLocalGenerator::RuleVariables vars; + vars.RuleLauncher = "RULE_LAUNCH_LINK"; + vars.CMTarget = this->GetTarget(); + vars.Language = this->TargetLinkLanguage; + vars.Objects = "$in"; + std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); + objdir += this->GetTargetName(); + objdir += ".dir"; + objdir = this->GetLocalGenerator()->Convert(objdir.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + vars.ObjectDir = objdir.c_str(); + vars.Target = "$out"; + + // Setup the target version. + std::string targetVersionMajor; + std::string targetVersionMinor; + { + cmOStringStream majorStream; + cmOStringStream minorStream; + int major; + int minor; + this->GetTarget()->GetTargetVersion(major, minor); + majorStream << major; + minorStream << minor; + targetVersionMajor = majorStream.str(); + targetVersionMinor = minorStream.str(); + } + vars.TargetVersionMajor = targetVersionMajor.c_str(); + vars.TargetVersionMinor = targetVersionMinor.c_str(); + + vars.LinkLibraries = "$LINK_LIBRARIES"; + vars.Flags = "$FLAGS"; + vars.LinkFlags = "$LINK_FLAGS"; + + std::string langFlags; + this->GetLocalGenerator()->AddLanguageFlags(langFlags, + this->TargetLinkLanguage, + this->GetConfigName()); + langFlags += "$ARCHITECTURE_FLAGS"; + vars.LanguageCompileFlags = langFlags.c_str(); + + // Rule for linking library. + std::vector linkCmds = this->ComputeLinkCmd(); + std::string linkCmd; + bool isLast = false; + for(std::vector::const_iterator i = linkCmds.begin(); + i != linkCmds.end(); + ++i) + { + if(!isLast && i + 1 == linkCmds.end()) + isLast = true; + std::string cmd = *i; + this->GetLocalGenerator()->ExpandRuleVariables(cmd, vars); + linkCmd += cmd; + // TODO(Nicolas Despres): This will work only on Unix platforms. I don't + // want to use a link.txt file because I will loose the benefit of the + // $in variables. A discussion about dealing with multiple commands in + // a rule is started here: + // http://groups.google.com/group/ninja-build/browse_thread/thread/d515f23a78986008 + if(!isLast) + linkCmd += " && "; + } + + // Write the linker rule. + std::ostringstream comment; + comment << "Rule for linking " << this->TargetLinkLanguage << " " + << this->GetVisibleTypeName() << "."; + std::ostringstream description; + description << "Linking " << this->TargetLinkLanguage << " " + << this->GetVisibleTypeName() << " $out"; + this->GetGlobalGenerator()->AddRule(ruleName, + linkCmd, + comment.str(), + description.str(), + /*depfile*/ "", + cmNinjaVars()); + } + + if (this->TargetNameOut != this->TargetNameReal) { + std::string cmakeCommand = + this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); + if (this->GetTarget()->GetType() == cmTarget::EXECUTABLE) + this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_EXECUTABLE", + cmakeCommand + + " -E cmake_symlink_executable" + " $in $out", + "Rule for creating executable symlink.", + "Creating executable symlink $out", + /*depfile*/ "", + cmNinjaVars()); + else + this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", + cmakeCommand + + " -E cmake_symlink_library" + " $in $SONAME $out", + "Rule for creating library symlink.", + "Creating library symlink $out", + /*depfile*/ "", + cmNinjaVars()); + } +} + +std::vector +cmNinjaNormalTargetGenerator +::ComputeLinkCmd() +{ + switch (this->GetTarget()->GetType()) { + case cmTarget::STATIC_LIBRARY: { + // Check if you have a non archive way to create the static library. + { + std::string linkCmdVar = "CMAKE_"; + linkCmdVar += this->TargetLinkLanguage; + linkCmdVar += "_CREATE_STATIC_LIBRARY"; + if (const char *linkCmd = + this->GetMakefile()->GetDefinition(linkCmdVar.c_str())) + { + return std::vector(1, linkCmd); + } + } + + // We have archive link commands set. + std::vector linkCmds; + { + std::string linkCmdVar = "CMAKE_"; + linkCmdVar += this->TargetLinkLanguage; + linkCmdVar += "_ARCHIVE_CREATE"; + const char *linkCmd = + this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + linkCmds.push_back(linkCmd); + } + // TODO(Nicolas Despres): I'll see later how to deals with that. + // { + // std::string linkCmdVar = "CMAKE_"; + // linkCmdVar += this->TargetLinkLanguage; + // linkCmdVar += "_ARCHIVE_APPEND"; + // const char *linkCmd = + // this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + // linkCmds.push_back(linkCmd); + // } + { + std::string linkCmdVar = "CMAKE_"; + linkCmdVar += this->TargetLinkLanguage; + linkCmdVar += "_ARCHIVE_FINISH"; + const char *linkCmd = + this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + linkCmds.push_back(linkCmd); + } + return linkCmds; + } + case cmTarget::SHARED_LIBRARY: { + std::string linkCmdVar = "CMAKE_"; + linkCmdVar += this->TargetLinkLanguage; + linkCmdVar += "_CREATE_SHARED_LIBRARY"; + const char *linkCmd = + this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + return std::vector(1, linkCmd); + } + case cmTarget::EXECUTABLE: { + std::string linkCmdVar = "CMAKE_"; + linkCmdVar += this->TargetLinkLanguage; + linkCmdVar += "_LINK_EXECUTABLE"; + const char *linkCmd = + this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); + return std::vector(1, linkCmd); + } + } +} + +void cmNinjaNormalTargetGenerator::WriteLinkStatement() +{ + // Write comments. + cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); + this->GetBuildFileStream() + << "# Link build statements for " + << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << " target " + << this->GetTargetName() + << "\n\n"; + + cmNinjaDeps emptyDeps; + cmNinjaVars vars; + + std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); + std::string targetOutputReal = this->GetTargetFilePath(this->TargetNameReal); + + // Compute the comment. + std::ostringstream comment; + comment << "Link the " << this->GetVisibleTypeName() << " " << targetOutputReal; + + // Compute outputs. + cmNinjaDeps outputs; + outputs.push_back(targetOutputReal); + // Add this executable to the all target. + this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); + + // Compute specific libraries to link with. + cmNinjaDeps explicitDeps = this->GetObjects(), + implicitDeps = this->ComputeLinkDeps(); + + this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], + vars["FLAGS"], + vars["LINK_FLAGS"], + *this->GetTarget()); + + // Compute specific link flags. + this->GetLocalGenerator()->AddArchitectureFlags(vars["ARCHITECTURE_FLAGS"], + this->GetTarget(), + this->TargetLinkLanguage, + this->GetConfigName()); + vars["SONAME"] = this->TargetNameSO; + + // Write the build statement for this target. + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + comment.str(), + this->LanguageLinkerRule(), + outputs, + explicitDeps, + implicitDeps, + emptyDeps, + vars); + + if (targetOutput != targetOutputReal) { + if (this->GetTarget()->GetType() == cmTarget::EXECUTABLE) { + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + "Create executable symlink " + targetOutput, + "CMAKE_SYMLINK_EXECUTABLE", + cmNinjaDeps(1, targetOutput), + cmNinjaDeps(1, targetOutputReal), + emptyDeps, + emptyDeps, + cmNinjaVars()); + } else { + cmNinjaVars symlinkVars; + symlinkVars["SONAME"] = this->TargetNameSO; + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + "Create library symlink " + targetOutput, + "CMAKE_SYMLINK_LIBRARY", + cmNinjaDeps(1, targetOutput), + cmNinjaDeps(1, targetOutputReal), + emptyDeps, + emptyDeps, + symlinkVars); + } + } + + // Write a shortcut rule with the target name. + this->WriteTargetBuild(this->TargetNameOut, targetOutput); +} diff --git a/Source/cmNinjaStaticLibraryTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h similarity index 75% rename from Source/cmNinjaStaticLibraryTargetGenerator.h rename to Source/cmNinjaNormalTargetGenerator.h index 690452ce852..ef0cc33a74a 100644 --- a/Source/cmNinjaStaticLibraryTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -17,17 +17,18 @@ class cmSourceFile; -class cmNinjaStaticLibraryTargetGenerator : public cmNinjaTargetGenerator +class cmNinjaNormalTargetGenerator : public cmNinjaTargetGenerator { public: - /// Build a NinjaTargetGenerator. - cmNinjaStaticLibraryTargetGenerator(cmTarget* target); - ~cmNinjaStaticLibraryTargetGenerator(); + cmNinjaNormalTargetGenerator(cmTarget* target); + ~cmNinjaNormalTargetGenerator(); private: - virtual void WriteLinkRule(const std::string& language); + std::string LanguageLinkerRule() const; + const char* GetVisibleTypeName() const; + virtual void WriteLinkRule(); virtual void WriteLinkStatement(); - std::vector ComputeLinkCmd(const std::string& language); + std::vector ComputeLinkCmd(); private: // Target name info. @@ -36,6 +37,7 @@ class cmNinjaStaticLibraryTargetGenerator : public cmNinjaTargetGenerator std::string TargetNameReal; std::string TargetNameImport; std::string TargetNamePDB; + const char *TargetLinkLanguage; }; #endif // ! cmNinjaStaticLibraryTargetGenerator_h diff --git a/Source/cmNinjaSharedLibraryTargetGenerator.cxx b/Source/cmNinjaSharedLibraryTargetGenerator.cxx deleted file mode 100644 index ca75eccdca0..00000000000 --- a/Source/cmNinjaSharedLibraryTargetGenerator.cxx +++ /dev/null @@ -1,193 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2011 Nicolas Despres - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#include "cmNinjaSharedLibraryTargetGenerator.h" -#include "cmLocalNinjaGenerator.h" -#include "cmGlobalNinjaGenerator.h" -#include "cmSourceFile.h" -#include "cmGeneratedFileStream.h" -#include "cmMakefile.h" - -cmNinjaSharedLibraryTargetGenerator:: -cmNinjaSharedLibraryTargetGenerator(cmTarget* target) - : cmNinjaTargetGenerator(target) - , TargetNameOut() - , TargetNameSO() - , TargetNameReal() - , TargetNameImport() - , TargetNamePDB() -{ - this->GetTarget()->GetLibraryNames(this->TargetNameOut, - this->TargetNameSO, - this->TargetNameReal, - this->TargetNameImport, - this->TargetNamePDB, - GetLocalGenerator()->GetConfigName()); -} - -cmNinjaSharedLibraryTargetGenerator::~cmNinjaSharedLibraryTargetGenerator() -{ -} - -void -cmNinjaSharedLibraryTargetGenerator -::WriteLinkRule(const std::string& language) -{ - cmLocalGenerator::RuleVariables vars; - vars.RuleLauncher = "RULE_LAUNCH_LINK"; - vars.CMTarget = this->GetTarget(); - std::string lang = language; - vars.Language = lang.c_str(); - vars.Objects = "$in"; - std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); - objdir += this->GetTargetName(); - objdir += ".dir"; - objdir = this->GetLocalGenerator()->Convert(objdir.c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); - vars.ObjectDir = objdir.c_str(); - vars.Target = "$out"; - vars.TargetSOName = "$SONAME"; - - // Setup the target version. - std::string targetVersionMajor; - std::string targetVersionMinor; - { - cmOStringStream majorStream; - cmOStringStream minorStream; - int major; - int minor; - this->GetTarget()->GetTargetVersion(major, minor); - majorStream << major; - minorStream << minor; - targetVersionMajor = majorStream.str(); - targetVersionMinor = minorStream.str(); - } - vars.TargetVersionMajor = targetVersionMajor.c_str(); - vars.TargetVersionMinor = targetVersionMinor.c_str(); - - vars.LinkLibraries = "$LINK_LIBRARIES"; - vars.Flags = "$FLAGS"; - vars.LinkFlags = "$LINK_FLAGS"; - - std::string langFlags; - this->GetLocalGenerator()->AddLanguageFlags(langFlags, language.c_str(), - this->GetConfigName()); - langFlags += "$ARCHITECTURE_FLAGS"; - vars.LanguageCompileFlags = langFlags.c_str(); - - // Rule for linking library. - std::string linkCmdVar = "CMAKE_"; - linkCmdVar += language; - linkCmdVar += "_CREATE_SHARED_LIBRARY"; - std::string linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - - this->GetLocalGenerator()->ExpandRuleVariables(linkCmd, vars); - - // Write the rule for linking an library. - std::ostringstream comment; - comment << "Rule for linking " << language << " shared library."; - std::ostringstream description; - description << "Linking " << language << " shared library $out"; - std::string depfile = ""; - cmNinjaVars emptyVars; - this->GetGlobalGenerator()->AddRule(this->LanguageLinkerRule(language), - linkCmd, - comment.str(), - description.str(), - depfile, - emptyVars); - - std::string cmakeCommand = - this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); - this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", - cmakeCommand + - " -E cmake_symlink_library" - " $in $SONAME $out", - "Rule for creating library symlink.", - "Creating library symlink $out", - depfile, - emptyVars); -} - -void cmNinjaSharedLibraryTargetGenerator::WriteLinkStatement() -{ - // Write comments. - cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); - this->GetBuildFileStream() - << "# Link build statements for " - << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) - << " target " - << this->GetTargetName() - << "\n\n"; - - cmNinjaDeps emptyDeps; - cmNinjaVars vars; - - std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); - std::string targetOutputReal = this->GetTargetFilePath(this->TargetNameReal); - - // Compute the comment. - std::ostringstream comment; - comment << "Link the shared library " << targetOutputReal; - - // Compute outputs. - cmNinjaDeps outputs; - outputs.push_back(targetOutputReal); - // Add this executable to the all target. - this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); - - const char* linkLanguage = - this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); - - // Compute specific libraries to link with. - cmNinjaDeps explicitDeps = this->GetObjects(), - implicitDeps = this->ComputeLinkDeps(); - - this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], - vars["FLAGS"], - vars["LINK_FLAGS"], - *this->GetTarget()); - - // Compute specific link flags. - this->GetLocalGenerator()->AddArchitectureFlags(vars["ARCHITECTURE_FLAGS"], - this->GetTarget(), - linkLanguage, - this->GetConfigName()); - vars["SONAME"] = this->TargetNameSO; - - // Write the build statement for this target. - cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - comment.str(), - this->LanguageLinkerRule(linkLanguage), - outputs, - explicitDeps, - implicitDeps, - emptyDeps, - vars); - - if (targetOutput != targetOutputReal) { - cmNinjaVars symlinkVars; - symlinkVars["SONAME"] = this->TargetNameSO; - cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - "Create library symlink " + targetOutput, - "CMAKE_SYMLINK_LIBRARY", - cmNinjaDeps(1, targetOutput), - cmNinjaDeps(1, targetOutputReal), - emptyDeps, - emptyDeps, - symlinkVars); - } - - // Write a shortcut rule with the target name. - this->WriteTargetBuild(this->TargetNameOut, targetOutput); -} diff --git a/Source/cmNinjaSharedLibraryTargetGenerator.h b/Source/cmNinjaSharedLibraryTargetGenerator.h deleted file mode 100644 index caff68c8aa7..00000000000 --- a/Source/cmNinjaSharedLibraryTargetGenerator.h +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2011 Nicolas Despres - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef cmNinjaSharedLibraryTargetGenerator_h -# define cmNinjaSharedLibraryTargetGenerator_h - -# include "cmNinjaTargetGenerator.h" -# include "cmNinjaTypes.h" - -class cmSourceFile; - -class cmNinjaSharedLibraryTargetGenerator : public cmNinjaTargetGenerator -{ -public: - /// Build a NinjaTargetGenerator. - cmNinjaSharedLibraryTargetGenerator(cmTarget* target); - ~cmNinjaSharedLibraryTargetGenerator(); - -private: - virtual void WriteLinkRule(const std::string& language); - virtual void WriteLinkStatement(); - -private: - // Target name info. - std::string TargetNameOut; - std::string TargetNameSO; - std::string TargetNameReal; - std::string TargetNameImport; - std::string TargetNamePDB; -}; - -#endif // ! cmNinjaSharedLibraryTargetGenerator_h diff --git a/Source/cmNinjaStaticLibraryTargetGenerator.cxx b/Source/cmNinjaStaticLibraryTargetGenerator.cxx deleted file mode 100644 index b75bbc7028e..00000000000 --- a/Source/cmNinjaStaticLibraryTargetGenerator.cxx +++ /dev/null @@ -1,252 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2011 Nicolas Despres - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#include "cmNinjaStaticLibraryTargetGenerator.h" -#include "cmLocalNinjaGenerator.h" -#include "cmGlobalNinjaGenerator.h" -#include "cmSourceFile.h" -#include "cmGeneratedFileStream.h" -#include "cmMakefile.h" - -cmNinjaStaticLibraryTargetGenerator:: -cmNinjaStaticLibraryTargetGenerator(cmTarget* target) - : cmNinjaTargetGenerator(target) - , TargetNameOut() - , TargetNameSO() - , TargetNameReal() - , TargetNameImport() - , TargetNamePDB() -{ - this->GetTarget()->GetLibraryNames(this->TargetNameOut, - this->TargetNameSO, - this->TargetNameReal, - this->TargetNameImport, - this->TargetNamePDB, - GetLocalGenerator()->GetConfigName()); -} - -cmNinjaStaticLibraryTargetGenerator::~cmNinjaStaticLibraryTargetGenerator() -{ -} - -void -cmNinjaStaticLibraryTargetGenerator -::WriteLinkRule(const std::string& language) -{ - cmLocalGenerator::RuleVariables vars; - vars.RuleLauncher = "RULE_LAUNCH_LINK"; - vars.CMTarget = this->GetTarget(); - std::string lang = language; - vars.Language = lang.c_str(); - vars.Objects = "$in"; - std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); - objdir += this->GetTargetName(); - objdir += ".dir"; - objdir = this->GetLocalGenerator()->Convert(objdir.c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); - vars.ObjectDir = objdir.c_str(); - vars.Target = "$out"; - - // Setup the target version. - std::string targetVersionMajor; - std::string targetVersionMinor; - { - cmOStringStream majorStream; - cmOStringStream minorStream; - int major; - int minor; - this->GetTarget()->GetTargetVersion(major, minor); - majorStream << major; - minorStream << minor; - targetVersionMajor = majorStream.str(); - targetVersionMinor = minorStream.str(); - } - vars.TargetVersionMajor = targetVersionMajor.c_str(); - vars.TargetVersionMinor = targetVersionMinor.c_str(); - - vars.LinkLibraries = "$LINK_LIBRARIES"; - vars.Flags = "$FLAGS"; - vars.LinkFlags = "$LINK_FLAGS"; - - std::string langFlags; - this->GetLocalGenerator()->AddLanguageFlags(langFlags, language.c_str(), - this->GetConfigName()); - langFlags += "$ARCHITECTURE_FLAGS"; - vars.LanguageCompileFlags = langFlags.c_str(); - - // Rule for linking library. - std::vector linkCmds = this->ComputeLinkCmd(language); - std::string linkCmd; - bool isLast = false; - for(std::vector::const_iterator i = linkCmds.begin(); - i != linkCmds.end(); - ++i) - { - if(!isLast && i + 1 == linkCmds.end()) - isLast = true; - std::string cmd = *i; - this->GetLocalGenerator()->ExpandRuleVariables(cmd, vars); - linkCmd += cmd; - // TODO(Nicolas Despres): This will work only on Unix platforms. I don't - // want to use a link.txt file because I will loose the benefit of the - // $in variables. A discussion about dealing with multiple commands in - // a rule is started here: - // http://groups.google.com/group/ninja-build/browse_thread/thread/d515f23a78986008 - if(!isLast) - linkCmd += " && "; - } - - // Write the rule for linking an library. - std::ostringstream comment; - comment << "Rule for linking " << language << " static library."; - std::ostringstream description; - description << "Linking " << language << " static library $out"; - std::string depfile = ""; - cmNinjaVars emptyVars; - this->GetGlobalGenerator()->AddRule(this->LanguageLinkerRule(language), - linkCmd, - comment.str(), - description.str(), - depfile, - emptyVars); - - std::string cmakeCommand = - this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"); - this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", - cmakeCommand + - " -E cmake_symlink_library" - " $in $SONAME $out", - "Rule for creating library symlink.", - "Creating library symlink $out", - depfile, - emptyVars); -} - -std::vector -cmNinjaStaticLibraryTargetGenerator -::ComputeLinkCmd(const std::string& language) -{ - std::vector linkCmds; - // Check if you have a non archive way to create the static library. - { - std::string linkCmdVar = "CMAKE_"; - linkCmdVar += language; - linkCmdVar += "_CREATE_STATIC_LIBRARY"; - if (const char *linkCmd = - this->GetMakefile()->GetDefinition(linkCmdVar.c_str())) - { - linkCmds.push_back(linkCmd); - return linkCmds; - } - } - - // We have archive link commands set. - { - std::string linkCmdVar = "CMAKE_"; - linkCmdVar += language; - linkCmdVar += "_ARCHIVE_CREATE"; - std::string linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - linkCmds.push_back(linkCmd); - } - // TODO(Nicolas Despres): I'll see later how to deals with that. - // { - // std::string linkCmdVar = "CMAKE_"; - // linkCmdVar += language; - // linkCmdVar += "_ARCHIVE_APPEND"; - // std::string linkCmd = - // this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - // linkCmds.push_back(linkCmd); - // } - { - std::string linkCmdVar = "CMAKE_"; - linkCmdVar += language; - linkCmdVar += "_ARCHIVE_FINISH"; - std::string linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - linkCmds.push_back(linkCmd); - } - return linkCmds; -} - -void cmNinjaStaticLibraryTargetGenerator::WriteLinkStatement() -{ - // Write comments. - cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); - this->GetBuildFileStream() - << "# Link build statements for " - << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) - << " target " - << this->GetTargetName() - << "\n\n"; - - cmNinjaDeps emptyDeps; - cmNinjaVars vars; - - std::string targetOutput = this->GetTargetFilePath(this->TargetNameOut); - std::string targetOutputReal = this->GetTargetFilePath(this->TargetNameReal); - - // Compute the comment. - std::ostringstream comment; - comment << "Link the static library " << targetOutputReal; - - // Compute outputs. - cmNinjaDeps outputs; - outputs.push_back(targetOutputReal); - // Add this executable to the all target. - this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); - - const char* linkLanguage = - this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); - - // Compute specific libraries to link with. - cmNinjaDeps explicitDeps = this->GetObjects(), - implicitDeps = this->ComputeLinkDeps(); - - this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"], - vars["FLAGS"], - vars["LINK_FLAGS"], - *this->GetTarget()); - - // Compute specific link flags. - this->GetLocalGenerator()->AddArchitectureFlags(vars["ARCHITECTURE_FLAGS"], - this->GetTarget(), - linkLanguage, - this->GetConfigName()); - vars["SONAME"] = this->TargetNameSO; - - // Write the build statement for this target. - cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - comment.str(), - this->LanguageLinkerRule(linkLanguage), - outputs, - explicitDeps, - implicitDeps, - emptyDeps, - vars); - - if (targetOutput != targetOutputReal) { - cmNinjaVars symlinkVars; - symlinkVars["SONAME"] = this->TargetNameSO; - cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - "Create library symlink " + targetOutput, - "CMAKE_SYMLINK_LIBRARY", - cmNinjaDeps(1, targetOutput), - cmNinjaDeps(1, targetOutputReal), - emptyDeps, - emptyDeps, - symlinkVars); - } - - // Write a shortcut rule with the target name. - this->WriteTargetBuild(this->TargetNameOut, targetOutput); -} diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4df1302cef1..97da639a5cc 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -13,9 +13,7 @@ #include "cmGlobalNinjaGenerator.h" #include "cmLocalNinjaGenerator.h" #include "cmGeneratedFileStream.h" -#include "cmNinjaExecutableTargetGenerator.h" -#include "cmNinjaSharedLibraryTargetGenerator.h" -#include "cmNinjaStaticLibraryTargetGenerator.h" +#include "cmNinjaNormalTargetGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmComputeLinkInformation.h" @@ -27,13 +25,9 @@ cmNinjaTargetGenerator::New(cmTarget* target) switch (target->GetType()) { case cmTarget::EXECUTABLE: - return new cmNinjaExecutableTargetGenerator(target); - case cmTarget::SHARED_LIBRARY: - return new cmNinjaSharedLibraryTargetGenerator(target); - case cmTarget::STATIC_LIBRARY: - return new cmNinjaStaticLibraryTargetGenerator(target); + return new cmNinjaNormalTargetGenerator(target); default: return 0; @@ -87,16 +81,6 @@ const char* cmNinjaTargetGenerator::GetConfigName() const return this->LocalGenerator->ConfigName.c_str(); } -std::string -cmNinjaTargetGenerator -::LanguageLinkerRule(const std::string& lang) const -{ - return lang - + "_" - + cmTarget::TargetTypeNames(this->GetTarget()->GetType()) - + "_LINKER"; -} - // TODO(Nicolas Despres): Picked up from cmMakefileTargetGenerator. // Refactor it. const char* cmNinjaTargetGenerator::GetFeature(const char* feature) @@ -348,6 +332,7 @@ void cmNinjaTargetGenerator::WriteLanguagesRules() l != languages.end(); ++l) this->WriteLanguageRules(*l); + this->WriteLinkRule(); } void @@ -358,7 +343,6 @@ ::WriteLanguageRules(const std::string& language) << "# Rules for language " << language << "\n\n"; this->WriteCompileRule(language); this->GetRulesFileStream() << "\n"; - this->WriteLinkRule(language); } void diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 692b07b3a9e..d95c15433c6 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -58,8 +58,6 @@ class cmNinjaTargetGenerator std::string LanguageCompilerRule(const std::string& lang) const { return lang + "_COMPILER"; } - std::string LanguageLinkerRule(const std::string& lang) const; - const char* GetFeature(const char* feature); bool GetFeatureAsBool(const char* feature); void AddFeatureFlags(std::string& flags, const char* lang); @@ -99,7 +97,7 @@ class cmNinjaTargetGenerator void WriteLanguagesRules(); void WriteLanguageRules(const std::string& language); void WriteCompileRule(const std::string& language); - virtual void WriteLinkRule(const std::string& language) = 0; + virtual void WriteLinkRule() = 0; void WriteObjectBuildStatements(); void WriteObjectBuildStatement(cmSourceFile* source); virtual void WriteLinkStatement() = 0; From 9563539eedc098f8e81430f9fc90174ff27f69d9 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 26 Aug 2011 21:46:35 +0100 Subject: [PATCH 454/539] Prevent cmNinjaTargetGenerator::GetTargetFilePath from returning paths of the form "./blah" --- Source/cmNinjaTargetGenerator.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 97da639a5cc..e17ae929316 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -263,8 +263,9 @@ cmNinjaTargetGenerator ::GetTargetFilePath(const std::string& name) const { std::string path = this->GetTargetOutputDir(); - if(!path.empty()) - path += "/"; + if (path.empty() || path == ".") + return name; + path += "/"; path += name; return path; } From c811053fcede652295bcd80ec8dd92d3d0779802 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sun, 28 Aug 2011 03:35:14 +0100 Subject: [PATCH 455/539] Small refactor, and start using STL functors --- Source/cmNinjaTargetGenerator.cxx | 26 +++++++++++++------------- Source/cmNinjaTargetGenerator.h | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index e17ae929316..3c99e7445bd 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -19,6 +19,8 @@ #include "cmComputeLinkInformation.h" #include "cmSourceFile.h" +#include + cmNinjaTargetGenerator * cmNinjaTargetGenerator::New(cmTarget* target) { @@ -211,6 +213,13 @@ ComputeDefines(cmSourceFile *source, const std::string& language) return defines; } +std::string cmNinjaTargetGenerator::ConvertToNinjaPath(const char *path) const +{ + return this->LocalGenerator->Convert(path, + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); +} + cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const { cmComputeLinkInformation* cli = @@ -219,13 +228,8 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const return cmNinjaDeps(); const std::vector &deps = cli->GetDepends(); - cmNinjaDeps result; - for (std::vector::const_iterator i = deps.begin(); - i != deps.end(); ++i) { - result.push_back(this->LocalGenerator->Convert(i->c_str(), - cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE)); - } + cmNinjaDeps result(deps.size()); + std::transform(deps.begin(), deps.end(), result.begin(), MapToNinjaPath()); return result; } @@ -233,9 +237,7 @@ std::string cmNinjaTargetGenerator ::GetSourceFilePath(cmSourceFile* source) const { - return this->LocalGenerator->Convert(source->GetFullPath().c_str(), - cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE); + return ConvertToNinjaPath(source->GetFullPath().c_str()); } std::string @@ -253,9 +255,7 @@ std::string cmNinjaTargetGenerator::GetTargetOutputDir() const { std::string dir = this->Target->GetDirectory(this->GetConfigName()); cmSystemTools::MakeDirectory(dir.c_str()); - return this->LocalGenerator->Convert(dir.c_str(), - cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE); + return ConvertToNinjaPath(dir.c_str()); } std::string diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index d95c15433c6..b117a8de0b9 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -72,6 +72,21 @@ class cmNinjaTargetGenerator std::string ComputeDefines(cmSourceFile *source, const std::string& language); + std::string ConvertToNinjaPath(const char *path) const; + + struct map_to_ninja_path { + const cmNinjaTargetGenerator *TargetGenerator; + map_to_ninja_path(const cmNinjaTargetGenerator *TargetGenerator) + : TargetGenerator(TargetGenerator) {} + std::string operator()(const std::string &path) { + return TargetGenerator->ConvertToNinjaPath(path.c_str()); + } + }; + + map_to_ninja_path MapToNinjaPath() const { + return map_to_ninja_path(this); + } + /// @return the list of link dependency for the given target @a target. cmNinjaDeps ComputeLinkDeps() const; From 6ee49e38f3e99e90837cde7409eacb1b61a89a66 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sun, 28 Aug 2011 03:41:29 +0100 Subject: [PATCH 456/539] Forward declare cmCustomCommand here --- Source/cmSourceFile.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 55147e19272..cd630a67daf 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -13,10 +13,10 @@ #define cmSourceFile_h #include "cmSourceFileLocation.h" -#include "cmCustomCommand.h" #include "cmPropertyMap.h" class cmake; +class cmCustomCommand; /** \class cmSourceFile * \brief Represent a class loaded from a makefile. From bdfeda3ba0592100ef8546dc4edb738ffffaaad4 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sun, 28 Aug 2011 04:35:59 +0100 Subject: [PATCH 457/539] Start on custom commands --- Source/cmNinjaTargetGenerator.cxx | 53 +++++++++++++++++++++++++++++++ Source/cmNinjaTargetGenerator.h | 2 ++ 2 files changed, 55 insertions(+) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 3c99e7445bd..016988e971c 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -412,6 +412,9 @@ void cmNinjaTargetGenerator ::WriteObjectBuildStatement(cmSourceFile* source) { + if (cmCustomCommand *cc = source->GetCustomCommand()) + WriteCustomCommandBuildStatement(cc); + cmNinjaDeps emptyDeps; std::string comment; @@ -503,3 +506,53 @@ ::ComputeLinkFlags(const std::string& linkLanguage) return linkFlags; } + +void +cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { + this->GetGlobalGenerator()->AddRule("CUSTOM_COMMAND", + "$COMMAND", + "Rule for running custom commands.", + "$DESC", + /*depfile*/ "", + cmNinjaVars()); + + const std::vector &outputs = cc->GetOutputs(); + const std::vector &deps = cc->GetDepends(); + cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps; + + std::transform(outputs.begin(), outputs.end(), + ninjaOutputs.begin(), MapToNinjaPath()); + for (std::vector::const_iterator i = deps.begin(); + i != deps.end(); ++i) { + std::string dep; + if (this->LocalGenerator->GetRealDependency(i->c_str(), + this->GetConfigName(), dep)) + ninjaDeps.push_back(ConvertToNinjaPath(dep.c_str())); + } + + std::ostringstream cmd; + for (cmCustomCommandLines::const_iterator li = cc->GetCommandLines().begin(); + li != cc->GetCommandLines().end(); ++li) { + if (li != cc->GetCommandLines().begin()) + cmd << " && "; + for (cmCustomCommandLine::const_iterator wi = li->begin(); + wi != li->end(); ++wi) { + if (wi != li->begin()) + cmd << " "; + cmd << *wi; + } + } + + cmNinjaVars vars; + vars["COMMAND"] = cmd.str(); + vars["DESC"] = this->LocalGenerator->ConstructComment(*cc); + + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + "Custom command for " + ninjaOutputs[0], + "CUSTOM_COMMAND", + ninjaOutputs, + ninjaDeps, + cmNinjaDeps(), + cmNinjaDeps(), + vars); +} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index b117a8de0b9..11a8bac1f43 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -21,6 +21,7 @@ class cmGlobalNinjaGenerator; class cmGeneratedFileStream; class cmMakefile; class cmSourceFile; +class cmCustomCommand; class cmNinjaTargetGenerator { @@ -116,6 +117,7 @@ class cmNinjaTargetGenerator void WriteObjectBuildStatements(); void WriteObjectBuildStatement(cmSourceFile* source); virtual void WriteLinkStatement() = 0; + void WriteCustomCommandBuildStatement(cmCustomCommand *cc); std::string ComputeLinkFlags(const std::string& linkLanguage); cmNinjaDeps GetObjects() const From 6e39836e2701cf6c8c84643fe30dbbe628e8d90f Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 29 Aug 2011 02:51:50 +0100 Subject: [PATCH 458/539] Move some code to cmNinjaNormalTargetGenerator This simplifies the implementation of subclasses, with a single pure virtual method (void Generate()). Note: there is still a lot of code in cmNinjaTargetGenerator that belongs in Normal. --- Source/cmNinjaNormalTargetGenerator.cxx | 34 +++++++++++++++++++++++++ Source/cmNinjaNormalTargetGenerator.h | 7 +++-- Source/cmNinjaTargetGenerator.cxx | 34 ------------------------- Source/cmNinjaTargetGenerator.h | 5 +--- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 8ab17f67ad6..d25cd2297fe 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -45,6 +45,40 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() { } +void cmNinjaNormalTargetGenerator::Generate() +{ + // Write the rules for each language. + this->WriteLanguagesRules(); + + // Write the build statements + this->WriteObjectBuildStatements(); + + // Write the link statement. + this->WriteLinkStatement(); + + this->GetBuildFileStream() << "\n"; + this->GetRulesFileStream() << "\n"; +} + +void cmNinjaNormalTargetGenerator::WriteLanguagesRules() +{ + cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream()); + this->GetRulesFileStream() + << "# Rules for each languages for " + << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << " target " + << this->GetTargetName() + << "\n\n"; + + std::set languages; + this->GetTarget()->GetLanguages(languages); + for(std::set::const_iterator l = languages.begin(); + l != languages.end(); + ++l) + this->WriteLanguageRules(*l); + this->WriteLinkRule(); +} + const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const { switch (this->GetTarget()->GetType()) { case cmTarget::STATIC_LIBRARY: diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index ef0cc33a74a..a139ea64586 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -23,11 +23,14 @@ class cmNinjaNormalTargetGenerator : public cmNinjaTargetGenerator cmNinjaNormalTargetGenerator(cmTarget* target); ~cmNinjaNormalTargetGenerator(); + void Generate(); + private: std::string LanguageLinkerRule() const; const char* GetVisibleTypeName() const; - virtual void WriteLinkRule(); - virtual void WriteLinkStatement(); + void WriteLanguagesRules(); + void WriteLinkRule(); + void WriteLinkStatement(); std::vector ComputeLinkCmd(); private: diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 016988e971c..c70f22a6d10 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -48,21 +48,6 @@ cmNinjaTargetGenerator::~cmNinjaTargetGenerator() { } -void cmNinjaTargetGenerator::Generate() -{ - // Write the rules for each language. - this->WriteLanguagesRules(); - - // Write the build statements - this->WriteObjectBuildStatements(); - - // Write the link statement. - this->WriteLinkStatement(); - - this->GetBuildFileStream() << "\n"; - this->GetRulesFileStream() << "\n"; -} - cmGeneratedFileStream& cmNinjaTargetGenerator::GetBuildFileStream() const { return *this->GetGlobalGenerator()->GetBuildFileStream(); @@ -317,25 +302,6 @@ std::string cmNinjaTargetGenerator::GetTargetName() const return this->Target->GetName(); } -void cmNinjaTargetGenerator::WriteLanguagesRules() -{ - cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream()); - this->GetRulesFileStream() - << "# Rules for each languages for " - << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) - << " target " - << this->GetTargetName() - << "\n\n"; - - std::set languages; - this->GetTarget()->GetLanguages(languages); - for(std::set::const_iterator l = languages.begin(); - l != languages.end(); - ++l) - this->WriteLanguageRules(*l); - this->WriteLinkRule(); -} - void cmNinjaTargetGenerator ::WriteLanguageRules(const std::string& language) diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 11a8bac1f43..69b219d4833 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -35,7 +35,7 @@ class cmNinjaTargetGenerator /// Destructor. ~cmNinjaTargetGenerator(); - virtual void Generate(); + virtual void Generate() = 0; protected: cmGeneratedFileStream& GetBuildFileStream() const; @@ -110,13 +110,10 @@ class cmNinjaTargetGenerator void WriteTargetBuild(const std::string& outputName, const std::string& outputPath); - void WriteLanguagesRules(); void WriteLanguageRules(const std::string& language); void WriteCompileRule(const std::string& language); - virtual void WriteLinkRule() = 0; void WriteObjectBuildStatements(); void WriteObjectBuildStatement(cmSourceFile* source); - virtual void WriteLinkStatement() = 0; void WriteCustomCommandBuildStatement(cmCustomCommand *cc); std::string ComputeLinkFlags(const std::string& linkLanguage); From 023e5d235e9d4e1c7531a73896833eb3795408a6 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 29 Aug 2011 03:25:40 +0100 Subject: [PATCH 459/539] Fix header guard --- Source/cmNinjaNormalTargetGenerator.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index a139ea64586..96378cc080a 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -9,8 +9,8 @@ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more information. ============================================================================*/ -#ifndef cmNinjaStaticLibraryTargetGenerator_h -# define cmNinjaStaticLibraryTargetGenerator_h +#ifndef cmNinjaNormalTargetGenerator_h +# define cmNinjaNormalTargetGenerator_h # include "cmNinjaTargetGenerator.h" # include "cmNinjaTypes.h" @@ -43,4 +43,4 @@ class cmNinjaNormalTargetGenerator : public cmNinjaTargetGenerator const char *TargetLinkLanguage; }; -#endif // ! cmNinjaStaticLibraryTargetGenerator_h +#endif // ! cmNinjaNormalTargetGenerator_h From fdea8b3b3674185e97a6c6c247d638a32d67bd0f Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 30 Aug 2011 03:18:50 +0100 Subject: [PATCH 460/539] Eliminate restriction that there be at least one input file This restriction is not mandated by Ninja, and bogus. For example, the global edit_cache rule does not need input files. --- Source/cmGlobalNinjaGenerator.cxx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index bfb8bd40475..9104ac1758a 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -76,15 +76,6 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, return; } - // Make sure there is at least one input file. - if(explicitDeps.empty() && implicitDeps.empty() && orderOnlyDeps.empty()) - { - cmSystemTools::Error("No input files for WriteBuildStatement! called " - "with comment: ", - comment.c_str()); - return; - } - cmGlobalNinjaGenerator::WriteComment(os, comment); // TODO(Nicolas Despres): Write one file per line when there is multiple From d1d09e348f24522cf62bf8597bfc138a371e14c7 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 30 Aug 2011 04:01:53 +0100 Subject: [PATCH 461/539] Factor some code out of cmNinjaTargetGenerator::WriteCustomCommandBuildStatement --- Source/cmNinjaNormalTargetGenerator.cxx | 18 ++----- Source/cmNinjaTargetGenerator.cxx | 62 ++++++++++++++++++------- Source/cmNinjaTargetGenerator.h | 5 ++ 3 files changed, 53 insertions(+), 32 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index d25cd2297fe..b178c58b555 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -153,25 +153,13 @@ ::WriteLinkRule() // Rule for linking library. std::vector linkCmds = this->ComputeLinkCmd(); - std::string linkCmd; - bool isLast = false; - for(std::vector::const_iterator i = linkCmds.begin(); + for(std::vector::iterator i = linkCmds.begin(); i != linkCmds.end(); ++i) { - if(!isLast && i + 1 == linkCmds.end()) - isLast = true; - std::string cmd = *i; - this->GetLocalGenerator()->ExpandRuleVariables(cmd, vars); - linkCmd += cmd; - // TODO(Nicolas Despres): This will work only on Unix platforms. I don't - // want to use a link.txt file because I will loose the benefit of the - // $in variables. A discussion about dealing with multiple commands in - // a rule is started here: - // http://groups.google.com/group/ninja-build/browse_thread/thread/d515f23a78986008 - if(!isLast) - linkCmd += " && "; + this->GetLocalGenerator()->ExpandRuleVariables(*i, vars); } + std::string linkCmd = BuildCommandLine(linkCmds); // Write the linker rule. std::ostringstream comment; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index c70f22a6d10..0f0b6b41b1a 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -473,21 +473,8 @@ ::ComputeLinkFlags(const std::string& linkLanguage) return linkFlags; } -void -cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { - this->GetGlobalGenerator()->AddRule("CUSTOM_COMMAND", - "$COMMAND", - "Rule for running custom commands.", - "$DESC", - /*depfile*/ "", - cmNinjaVars()); - - const std::vector &outputs = cc->GetOutputs(); +void cmNinjaTargetGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, cmNinjaDeps &ninjaDeps) { const std::vector &deps = cc->GetDepends(); - cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps; - - std::transform(outputs.begin(), outputs.end(), - ninjaOutputs.begin(), MapToNinjaPath()); for (std::vector::const_iterator i = deps.begin(); i != deps.end(); ++i) { std::string dep; @@ -495,22 +482,63 @@ cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { this->GetConfigName(), dep)) ninjaDeps.push_back(ConvertToNinjaPath(dep.c_str())); } +} +std::string cmNinjaTargetGenerator::BuildCommandLine(const std::vector &cmdLines) { + // TODO: This will work only on Unix platforms. I don't + // want to use a link.txt file because I will loose the benefit of the + // $in variables. A discussion about dealing with multiple commands in + // a rule is started here: + // http://groups.google.com/group/ninja-build/browse_thread/thread/d515f23a78986008 std::ostringstream cmd; + for (std::vector::const_iterator li = cmdLines.begin(); + li != cmdLines.end(); ++li) { + if (li != cmdLines.begin()) + cmd << " && "; + cmd << *li; + } + return cmd.str(); +} + +void cmNinjaTargetGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, std::vector &cmdLines) { for (cmCustomCommandLines::const_iterator li = cc->GetCommandLines().begin(); li != cc->GetCommandLines().end(); ++li) { - if (li != cc->GetCommandLines().begin()) - cmd << " && "; + std::ostringstream cmd; for (cmCustomCommandLine::const_iterator wi = li->begin(); wi != li->end(); ++wi) { if (wi != li->begin()) cmd << " "; cmd << *wi; } + cmdLines.push_back(cmd.str()); } +} + +void cmNinjaTargetGenerator::WriteCustomCommandRule() { + this->GetGlobalGenerator()->AddRule("CUSTOM_COMMAND", + "$COMMAND", + "Rule for running custom commands.", + "$DESC", + /*depfile*/ "", + cmNinjaVars()); +} + +void +cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { + this->WriteCustomCommandRule(); + + const std::vector &outputs = cc->GetOutputs(); + cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps; + + std::transform(outputs.begin(), outputs.end(), + ninjaOutputs.begin(), MapToNinjaPath()); + this->AppendCustomCommandDeps(cc, ninjaDeps); + + std::vector cmdLines; + this->AppendCustomCommandLines(cc, cmdLines); cmNinjaVars vars; - vars["COMMAND"] = cmd.str(); + vars["COMMAND"] = this->BuildCommandLine(cmdLines); vars["DESC"] = this->LocalGenerator->ConstructComment(*cc); cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 69b219d4833..418b4b2fed0 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -110,6 +110,11 @@ class cmNinjaTargetGenerator void WriteTargetBuild(const std::string& outputName, const std::string& outputPath); + void AppendCustomCommandDeps(const cmCustomCommand *cc, cmNinjaDeps &ninjaDeps); + std::string BuildCommandLine(const std::vector &cmdLines); + void AppendCustomCommandLines(const cmCustomCommand *cc, std::vector &cmdLines); + void WriteCustomCommandRule(); + void WriteLanguageRules(const std::string& language); void WriteCompileRule(const std::string& language); void WriteObjectBuildStatements(); From d477827bb0533a107f089a2ae09e1c1a496c1e93 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 30 Aug 2011 04:03:00 +0100 Subject: [PATCH 462/539] Use "all" as the name of the preinstall rule "preinstall" seems to just be a way to allow the recursive makefile system to rebuild "all" from HOME, which we can achieve in ninja just by using "all". I'm not 100% sure this is correct, though. --- Source/cmGlobalNinjaGenerator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 6f553f24a12..a4a39dda9c9 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -167,7 +167,7 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator virtual const char* GetInstallTargetName() const { return "install"; } virtual const char* GetInstallLocalTargetName() const { return "install/local"; } virtual const char* GetInstallStripTargetName() const { return "install/strip"; } - virtual const char* GetPreinstallTargetName() const { return "preinstall"; } + virtual const char* GetPreinstallTargetName() const { return "all"; } virtual const char* GetTestTargetName() const { return "test"; } virtual const char* GetPackageTargetName() const { return "package"; } virtual const char* GetPackageSourceTargetName() const { return "package_source"; } From 3efd7a83007f0baceff15ce4496f3d9648b6f2e3 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 30 Aug 2011 04:28:13 +0100 Subject: [PATCH 463/539] First stab at global targets --- Source/CMakeLists.txt | 2 + Source/cmNinjaTargetGenerator.cxx | 14 ++++ Source/cmNinjaUtilityTargetGenerator.cxx | 82 ++++++++++++++++++++++++ Source/cmNinjaUtilityTargetGenerator.h | 29 +++++++++ 4 files changed, 127 insertions(+) create mode 100644 Source/cmNinjaUtilityTargetGenerator.cxx create mode 100644 Source/cmNinjaUtilityTargetGenerator.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index d5478fe77dd..1f7d4bb0b4e 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -215,6 +215,8 @@ SET(SRCS cmNinjaTargetGenerator.h cmNinjaNormalTargetGenerator.cxx cmNinjaNormalTargetGenerator.h + cmNinjaUtilityTargetGenerator.cxx + cmNinjaUtilityTargetGenerator.h cmMakeDepend.cxx cmMakeDepend.h cmMakefile.cxx diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 0f0b6b41b1a..b1b8fbca1d4 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -14,6 +14,7 @@ #include "cmLocalNinjaGenerator.h" #include "cmGeneratedFileStream.h" #include "cmNinjaNormalTargetGenerator.h" +#include "cmNinjaUtilityTargetGenerator.h" #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmComputeLinkInformation.h" @@ -31,6 +32,19 @@ cmNinjaTargetGenerator::New(cmTarget* target) case cmTarget::STATIC_LIBRARY: return new cmNinjaNormalTargetGenerator(target); + case cmTarget::UTILITY: + return new cmNinjaUtilityTargetGenerator(target);; + + case cmTarget::GLOBAL_TARGET: { + // We only want to process global targets that live in the home + // (i.e. top-level) directory. CMake creates copies of these targets + // in every directory, which we don't need. + cmMakefile *mf = target->GetMakefile(); + if (strcmp(mf->GetStartDirectory(), mf->GetHomeDirectory()) == 0) + return new cmNinjaUtilityTargetGenerator(target);; + // else fallthrough + } + default: return 0; } diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx new file mode 100644 index 00000000000..50f8bcebe7a --- /dev/null +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -0,0 +1,82 @@ +#include "cmNinjaUtilityTargetGenerator.h" +#include "cmCustomCommand.h" +#include "cmGeneratedFileStream.h" +#include "cmGlobalNinjaGenerator.h" +#include "cmSourceFile.h" +#include "cmTarget.h" + +cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(cmTarget *target) + : cmNinjaTargetGenerator(target) {} + +cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() {} + +void cmNinjaUtilityTargetGenerator::Generate() { + std::vector commands; + cmNinjaDeps deps; + + const std::vector *cmdLists[2] = { + &this->GetTarget()->GetPreBuildCommands(), + &this->GetTarget()->GetPostBuildCommands() + }; + + for (unsigned i = 0; i != 2; ++i) { + for (std::vector::const_iterator ci = cmdLists[i]->begin(); + ci != cmdLists[i]->end(); ++ci) { + this->AppendCustomCommandDeps(&*ci, deps); + this->AppendCustomCommandLines(&*ci, commands); + } + } + + const std::vector& sources = + this->GetTarget()->GetSourceFiles(); + for(std::vector::const_iterator source = sources.begin(); + source != sources.end(); ++source) + { + if(cmCustomCommand* cc = (*source)->GetCustomCommand()) + { + this->WriteCustomCommandBuildStatement(cc); + + // Depend on all custom command outputs. + const std::vector& outputs = cc->GetOutputs(); + std::transform(outputs.begin(), outputs.end(), + std::back_inserter(deps), MapToNinjaPath()); + } + } + + std::set const& utils = this->GetTarget()->GetUtilities(); + deps.insert(deps.end(), utils.begin(), utils.end()); + + if (commands.empty()) { + cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), + "Utility command for " + this->GetTargetName(), + cmNinjaDeps(1, this->GetTargetName()), + deps, + cmNinjaDeps(), + cmNinjaDeps(), + cmNinjaVars()); + } else { + this->WriteCustomCommandRule(); + + cmNinjaVars vars; + vars["COMMAND"] = this->BuildCommandLine(commands); + const char *desc = this->GetTarget()->GetProperty("EchoString"); + if (desc) + vars["DESC"] = desc; + else + vars["DESC"] = "Running utility command for " + this->GetTargetName(); + + // TODO: fix problematic global targets. For now, filter out anything + // with a '$' in the command. + if (vars["COMMAND"].find('$') != std::string::npos) + return; + + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + "Utility command for " + this->GetTargetName(), + "CUSTOM_COMMAND", + cmNinjaDeps(1, this->GetTargetName()), + deps, + cmNinjaDeps(), + cmNinjaDeps(), + vars); + } +} diff --git a/Source/cmNinjaUtilityTargetGenerator.h b/Source/cmNinjaUtilityTargetGenerator.h new file mode 100644 index 00000000000..e216e4cae0a --- /dev/null +++ b/Source/cmNinjaUtilityTargetGenerator.h @@ -0,0 +1,29 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Nicolas Despres + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmNinjaUtilityTargetGenerator_h +# define cmNinjaUtilityTargetGenerator_h + +# include "cmNinjaTargetGenerator.h" +# include "cmNinjaTypes.h" + +class cmSourceFile; + +class cmNinjaUtilityTargetGenerator : public cmNinjaTargetGenerator +{ +public: + cmNinjaUtilityTargetGenerator(cmTarget* target); + ~cmNinjaUtilityTargetGenerator(); + + void Generate(); +}; + +#endif // ! cmNinjaUtilityTargetGenerator_h From d6d60d55d0498ba8f8fe8a3bdebc0bd755b961bb Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sun, 4 Sep 2011 02:32:14 +0100 Subject: [PATCH 464/539] Output a default target statement making "all" the default --- Source/cmGlobalNinjaGenerator.cxx | 15 +++++++++++++++ Source/cmGlobalNinjaGenerator.h | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 9104ac1758a..a5a479b7734 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -242,6 +242,17 @@ void cmGlobalNinjaGenerator::WriteInclude(std::ostream& os, os << "include " << filename << "\n"; } +void cmGlobalNinjaGenerator::WriteDefault(std::ostream& os, + const cmNinjaDeps& targets, + const std::string& comment) +{ + cmGlobalNinjaGenerator::WriteComment(os, comment); + os << "default"; + for(cmNinjaDeps::const_iterator i = targets.begin(); i != targets.end(); ++i) + os << " " << *i; + os << "\n"; +} + cmGlobalNinjaGenerator::cmGlobalNinjaGenerator() : cmGlobalGenerator() @@ -524,4 +535,8 @@ void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os) emptyDeps, this->AllDependencies, emptyVars); + + cmGlobalNinjaGenerator::WriteDefault(os, + outputs, + "Make the all target the default."); } diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index a4a39dda9c9..8fb479e0328 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -121,6 +121,14 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator const std::string& filename, const std::string& comment = ""); + /** + * Write a default target statement specifying @a targets as + * the default targets. + */ + static void WriteDefault(std::ostream& os, + const cmNinjaDeps& targets, + const std::string& comment = ""); + public: /// Default constructor. cmGlobalNinjaGenerator(); From d54c55f0d2f0098e9fafa2def18b5271ae50e471 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sun, 4 Sep 2011 21:37:03 +0100 Subject: [PATCH 465/539] Use cmCustomCommandGenerator to build custom command line --- Source/cmNinjaTargetGenerator.cxx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index b1b8fbca1d4..98f8ad1d2ce 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -19,6 +19,7 @@ #include "cmMakefile.h" #include "cmComputeLinkInformation.h" #include "cmSourceFile.h" +#include "cmCustomCommandGenerator.h" #include @@ -515,16 +516,11 @@ std::string cmNinjaTargetGenerator::BuildCommandLine(const std::vector &cmdLines) { - for (cmCustomCommandLines::const_iterator li = cc->GetCommandLines().begin(); - li != cc->GetCommandLines().end(); ++li) { - std::ostringstream cmd; - for (cmCustomCommandLine::const_iterator wi = li->begin(); - wi != li->end(); ++wi) { - if (wi != li->begin()) - cmd << " "; - cmd << *wi; - } - cmdLines.push_back(cmd.str()); + cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); + for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { + cmdLines.push_back(ccg.GetCommand(i)); + std::string& cmd = cmdLines.back(); + ccg.AppendArguments(i, cmd); } } From 30dd8ffcb56b5077a463e50c2b3f341cd669dd8c Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 5 Sep 2011 01:44:55 +0100 Subject: [PATCH 466/539] Add OBJECT_DEPENDS as implicit dependencies --- Source/cmNinjaTargetGenerator.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 98f8ad1d2ce..502f7e13b95 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -422,6 +422,13 @@ ::WriteObjectBuildStatement(cmSourceFile* source) std::set const& utils = this->Target->GetUtilities(); implicitDeps.insert(implicitDeps.end(), utils.begin(), utils.end()); + if(const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) { + std::vector depList; + cmSystemTools::ExpandListArgument(objectDeps, depList); + std::transform(depList.begin(), depList.end(), + std::back_inserter(implicitDeps), MapToNinjaPath()); + } + const char* linkLanguage = this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); From c9f157b933a06e1712b265ae4412dc100e15da4e Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 5 Sep 2011 02:16:09 +0100 Subject: [PATCH 467/539] Do not output a custom command more than once --- Source/cmGlobalNinjaGenerator.h | 11 +++++++++++ Source/cmNinjaTargetGenerator.cxx | 3 +++ 2 files changed, 14 insertions(+) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 8fb479e0328..fa3707f7c59 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -214,6 +214,9 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator // In order to access the AddDependencyToAll() functions and co. friend class cmLocalNinjaGenerator; + // In order to access the SeenCustomCommand() function. + friend class cmNinjaTargetGenerator; + private: void OpenBuildFileStream(); void CloseBuildFileStream(); @@ -229,6 +232,11 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator void WriteBuiltinTargets(std::ostream& os); void WriteTargetAll(std::ostream& os); + /// Return true if the global generator has seen the given custom command. + bool SeenCustomCommand(cmCustomCommand *cc) { + return !this->CustomCommands.insert(cc).second; + } + private: /// The file containing the build statement. (the relation ship of the /// compilation DAG). @@ -246,6 +254,9 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator /// The set of dependencies to add to the "all" target. cmNinjaDeps AllDependencies; + + /// The set of custom commands we have seen. + std::set CustomCommands; }; #endif // ! cmGlobalNinjaGenerator_h diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 502f7e13b95..02cf67a1917 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -542,6 +542,9 @@ void cmNinjaTargetGenerator::WriteCustomCommandRule() { void cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { + if (this->GetGlobalGenerator()->SeenCustomCommand(cc)) + return; + this->WriteCustomCommandRule(); const std::vector &outputs = cc->GetOutputs(); From eb2fa659cb0cf13774fca511b47808f8686621fb Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 5 Sep 2011 02:34:51 +0100 Subject: [PATCH 468/539] Give the generator a better name Whether or not the generator is experimental shouldn't affect its name. Also, update the documentation to fit reality. --- Source/cmGlobalNinjaGenerator.cxx | 4 ++-- Source/cmGlobalNinjaGenerator.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index a5a479b7734..19df05e44b2 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -280,9 +280,9 @@ void cmGlobalNinjaGenerator ::GetDocumentation(cmDocumentationEntry& entry) const { entry.Name = this->GetName(); - entry.Brief = "Generates build.ninja files."; + entry.Brief = "Generates build.ninja files (experimental)."; entry.Full = - "A hierarchy of build.ninja files is generated into the build tree. Any" + "A build.ninja file is generated into the build tree. Any" "version of the ninja program can build the project through the " "\"all\" target. An \"install\" target is also provided."; } diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index fa3707f7c59..67fde7e34e3 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -148,7 +148,7 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator return cmGlobalNinjaGenerator::GetActualName(); } /// @return the name of this generator. - static const char* GetActualName() { return "Ninja (Experimental)"; } + static const char* GetActualName() { return "Ninja"; } /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() virtual void GetDocumentation(cmDocumentationEntry& entry) const; From dc566c00902220120af163562766b117908b0847 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 5 Sep 2011 05:28:14 +0100 Subject: [PATCH 469/539] Teach Ninja how to rebuild its manifest --- Source/cmGlobalNinjaGenerator.cxx | 38 +++++++++++++++++++++++++++++++ Source/cmGlobalNinjaGenerator.h | 1 + 2 files changed, 39 insertions(+) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 19df05e44b2..97e7f321e4d 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -518,6 +518,7 @@ void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os) os << "# Built-in targets\n\n"; this->WriteTargetAll(os); + this->WriteTargetRebuildManifest(os); } void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os) @@ -540,3 +541,40 @@ void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os) outputs, "Make the all target the default."); } + +void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) +{ + cmMakefile* mfRoot = this->LocalGenerators[0]->GetMakefile(); + + std::ostringstream cmd; + cmd << mfRoot->GetRequiredDefinition("CMAKE_COMMAND") + << " -H" << mfRoot->GetHomeDirectory() + << " -B" << mfRoot->GetHomeOutputDirectory(); + WriteRule(*this->RulesFileStream, + "RERUN_CMAKE", + cmd.str(), + "Rule for re-running cmake.", + "Re-running CMake...", + "", + cmNinjaVars()); + + cmNinjaDeps implicitDeps; + for (std::vector::const_iterator i = + this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) { + const std::vector& lf = (*i)->GetMakefile()->GetListFiles(); + implicitDeps.insert(implicitDeps.end(), lf.begin(), lf.end()); + } + std::sort(implicitDeps.begin(), implicitDeps.end()); + implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()), + implicitDeps.end()); + implicitDeps.push_back("CMakeCache.txt"); + + WriteBuild(os, + "Re-run CMake if any of its inputs changed.", + "RERUN_CMAKE", + /*outputs=*/ cmNinjaDeps(1, "build.ninja"), + /*explicitDeps=*/ cmNinjaDeps(), + implicitDeps, + /*orderOnlyDeps=*/ cmNinjaDeps(), + /*variables=*/ cmNinjaVars()); +} diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 67fde7e34e3..6210344739d 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -231,6 +231,7 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator void WriteBuiltinTargets(std::ostream& os); void WriteTargetAll(std::ostream& os); + void WriteTargetRebuildManifest(std::ostream& os); /// Return true if the global generator has seen the given custom command. bool SeenCustomCommand(cmCustomCommand *cc) { From e35a38b2bc08b7575c71d529b12db3c94956f3bf Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 6 Sep 2011 02:36:33 +0100 Subject: [PATCH 470/539] Output custom commands with 0 command lines as phony targets --- Source/cmNinjaTargetGenerator.cxx | 39 ++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 02cf67a1917..a8bf0f06d87 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -545,8 +545,6 @@ cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { if (this->GetGlobalGenerator()->SeenCustomCommand(cc)) return; - this->WriteCustomCommandRule(); - const std::vector &outputs = cc->GetOutputs(); cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps; @@ -557,16 +555,29 @@ cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { std::vector cmdLines; this->AppendCustomCommandLines(cc, cmdLines); - cmNinjaVars vars; - vars["COMMAND"] = this->BuildCommandLine(cmdLines); - vars["DESC"] = this->LocalGenerator->ConstructComment(*cc); - - cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - "Custom command for " + ninjaOutputs[0], - "CUSTOM_COMMAND", - ninjaOutputs, - ninjaDeps, - cmNinjaDeps(), - cmNinjaDeps(), - vars); + if (cmdLines.empty()) { + cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), + "Phony custom command for " + + ninjaOutputs[0], + ninjaOutputs, + ninjaDeps, + cmNinjaDeps(), + cmNinjaDeps(), + cmNinjaVars()); + } else { + this->WriteCustomCommandRule(); + + cmNinjaVars vars; + vars["COMMAND"] = this->BuildCommandLine(cmdLines); + vars["DESC"] = this->LocalGenerator->ConstructComment(*cc); + + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + "Custom command for " + ninjaOutputs[0], + "CUSTOM_COMMAND", + ninjaOutputs, + ninjaDeps, + cmNinjaDeps(), + cmNinjaDeps(), + vars); + } } From 520d856baddcaa8b102616cb1f3dba06dcf7815e Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 6 Sep 2011 03:13:55 +0100 Subject: [PATCH 471/539] Run custom commands in the correct working directory --- Source/cmNinjaTargetGenerator.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index a8bf0f06d87..0d5ef03e969 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -567,6 +567,14 @@ cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { } else { this->WriteCustomCommandRule(); + std::ostringstream cdCmd; + cdCmd << "cd "; + if (const char* wd = cc->GetWorkingDirectory()) + cdCmd << wd; + else + cdCmd << this->GetMakefile()->GetStartOutputDirectory(); + cmdLines.insert(cmdLines.begin(), cdCmd.str()); + cmNinjaVars vars; vars["COMMAND"] = this->BuildCommandLine(cmdLines); vars["DESC"] = this->LocalGenerator->ConstructComment(*cc); From 079fec7a96ee0c5c25bc9389630e5772e70911ce Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 6 Sep 2011 13:28:49 +0100 Subject: [PATCH 472/539] Set RuleVariables::TargetSOName This was somehow missed in the unification. --- Source/cmNinjaNormalTargetGenerator.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b178c58b555..ae57a186cf5 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -122,6 +122,7 @@ ::WriteLinkRule() cmLocalGenerator::SHELL); vars.ObjectDir = objdir.c_str(); vars.Target = "$out"; + vars.TargetSOName = "$SONAME"; // Setup the target version. std::string targetVersionMajor; From cbb7bf81024c409a10e6e6d85eaeca248bd3407a Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 6 Sep 2011 14:52:18 +0100 Subject: [PATCH 473/539] Dependency tracking We eschew CMake's built-in support for dependency tracking in favour of the compiler's dependency tracking support, which is per-object (rather than per-target), more efficient, and integrates with Ninja better. Disadvantage is that it only works if the compiler actually supports dependency tracking. But this is true for most compilers nowadays. ...except Visual Studio, for which we'll probably need to do something like this: http://www.conifersystems.com/2008/10/09/dependencies-from-showincludes/ --- Source/cmNinjaTargetGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 0d5ef03e969..4a9cd81683b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -339,7 +339,7 @@ ::WriteCompileRule(const std::string& language) vars.Source = "$in"; vars.Object = "$out"; - vars.Flags = "$FLAGS"; + vars.Flags = "-MMD -MF $out.d $FLAGS"; vars.Defines = "$DEFINES"; // Rule for compiling object file. @@ -356,7 +356,7 @@ ::WriteCompileRule(const std::string& language) comment << "Rule for compiling " << language << " files."; std::ostringstream description; description << "Building " << language << " object $out"; - std::string depfile = ""; + std::string depfile = "$out.d"; cmNinjaVars emptyVars; this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), compileCmd, From e5bc6e821187417caba9a2367bfe351dc3b8f81e Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 6 Sep 2011 17:24:27 +0100 Subject: [PATCH 474/539] Re-work target ordering Now we use order-only dependencies to enforce target ordering. We also add all target dependencies, not just utilities (the only reason we really need them is that in some build systems they are used to mask utility dependencies). We also resolve the dependency to the actual files to avoid depending on a phony target, which is suboptimal, since phony targets are always out of date. . --- Source/cmNinjaTargetGenerator.cxx | 55 +++++++++++++++++++++++++++---- Source/cmNinjaTargetGenerator.h | 2 ++ 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4a9cd81683b..bac3424df27 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -270,6 +270,42 @@ ::GetTargetFilePath(const std::string& name) const return path; } +void +cmNinjaTargetGenerator +::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) const { + switch (target->GetType()) { + case cmTarget::EXECUTABLE: + case cmTarget::SHARED_LIBRARY: + case cmTarget::STATIC_LIBRARY: { + std::string name = target->GetFullName(this->GetConfigName()); + std::string dir = target->GetDirectory(this->GetConfigName()); + std::string path = ConvertToNinjaPath(dir.c_str()); + if (path.empty() || path == ".") + outputs.push_back(name); + else { + path += "/"; + path += name; + outputs.push_back(path); + } + break; + } + + case cmTarget::UTILITY: { + const std::vector& sources = target->GetSourceFiles(); + for(std::vector::const_iterator source = sources.begin(); + source != sources.end(); ++source) { + if(cmCustomCommand* cc = (*source)->GetCustomCommand()) { + if (!cc->GetCommandLines().empty()) { + const std::vector& ccoutputs = cc->GetOutputs(); + std::transform(ccoutputs.begin(), ccoutputs.end(), + std::back_inserter(outputs), MapToNinjaPath()); + } + } + } + } + } +} + void cmNinjaTargetGenerator ::WriteTargetBuild(const std::string& outputName, @@ -416,17 +452,22 @@ ::WriteObjectBuildStatement(cmSourceFile* source) std::string sourceFileName = this->GetSourceFilePath(source); explicitDeps.push_back(sourceFileName); - // Ensure that the utilities for this target are built before any source file - // in the target. - cmNinjaDeps implicitDeps; - std::set const& utils = this->Target->GetUtilities(); - implicitDeps.insert(implicitDeps.end(), utils.begin(), utils.end()); + // Ensure that the target dependencies are built before any source file in the + // target, using order-only dependencies. These dependencies should later + // resolve to direct header dependencies in the depfile. + cmNinjaDeps orderOnlyDeps; + cmTargetDependSet const& targetDeps = + this->GetGlobalGenerator()->GetTargetDirectDepends(*this->Target); + for (cmTargetDependSet::const_iterator i = targetDeps.begin(); + i != targetDeps.end(); ++i) { + this->AppendTargetOutputs(*i, orderOnlyDeps); + } if(const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) { std::vector depList; cmSystemTools::ExpandListArgument(objectDeps, depList); std::transform(depList.begin(), depList.end(), - std::back_inserter(implicitDeps), MapToNinjaPath()); + std::back_inserter(orderOnlyDeps), MapToNinjaPath()); } const char* linkLanguage = @@ -441,8 +482,8 @@ ::WriteObjectBuildStatement(cmSourceFile* source) rule, outputs, explicitDeps, - implicitDeps, emptyDeps, + orderOnlyDeps, vars); } diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 418b4b2fed0..33017156fea 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -103,6 +103,8 @@ class cmNinjaTargetGenerator /// @return the output path for the target. virtual std::string GetTargetOutputDir() const; + void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) const; + /** * Write shortcut build statements for the target name with the target * output name and the target output path. From ed6f6ee76a2bf01eb26ccba089205a69d8094789 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 6 Sep 2011 17:35:11 +0100 Subject: [PATCH 475/539] Make the shortcut and all targets use explicit dependencies Order-only dependencies make little sense here, since they can result in an incomplete build. --- Source/cmGlobalNinjaGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 97e7f321e4d..07662d29d21 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -532,9 +532,9 @@ void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os) cmGlobalNinjaGenerator::WritePhonyBuild(os, "The main all target.", outputs, + this->AllDependencies, emptyDeps, emptyDeps, - this->AllDependencies, emptyVars); cmGlobalNinjaGenerator::WriteDefault(os, diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index bac3424df27..fc9f86db720 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -324,9 +324,9 @@ ::WriteTargetBuild(const std::string& outputName, cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), comment, outputs, + deps, emptyDeps, emptyDeps, - deps, emptyVars); } @@ -341,9 +341,9 @@ ::WriteTargetBuild(const std::string& outputName, cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), comment, outputs, + deps, emptyDeps, emptyDeps, - deps, emptyVars); } } From 58bd3ca146b8f536ece5bea87c8adecf7e1ad137 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 6 Sep 2011 17:47:26 +0100 Subject: [PATCH 476/539] Output a phony build statement so that a missing CMake input file is not an error --- Source/cmGlobalNinjaGenerator.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 07662d29d21..9b041013c87 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -577,4 +577,12 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) implicitDeps, /*orderOnlyDeps=*/ cmNinjaDeps(), /*variables=*/ cmNinjaVars()); + + WritePhonyBuild(os, + "A missing CMake input file is not an error.", + implicitDeps, + cmNinjaDeps(), + cmNinjaDeps(), + cmNinjaDeps(), + cmNinjaVars()); } From 99b3ded3b221b9498dff416023ae126d326edcf5 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 6 Sep 2011 18:22:52 +0100 Subject: [PATCH 477/539] No link dependencies for static libraries --- Source/cmNinjaTargetGenerator.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index fc9f86db720..896f3fd788e 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -222,6 +222,10 @@ std::string cmNinjaTargetGenerator::ConvertToNinjaPath(const char *path) const cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const { + // Static libraries never depend on anything for linking. + if (this->Target->GetType() == cmTarget::STATIC_LIBRARY) + return cmNinjaDeps(); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(this->GetConfigName()); if(!cli) From ab4f5ca1720ffbcace319a25c14306b4379c3dd3 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 6 Sep 2011 23:13:27 +0100 Subject: [PATCH 478/539] Disable dependency tracking if the target is named "cmTryCompileExec" This is a nasty hack to work around the fact that older versions of gcc report a missing header file as a warning, causing check_header_file tests to always succeed. --- Source/cmNinjaTargetGenerator.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 896f3fd788e..c3e5ed41efc 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -379,7 +379,10 @@ ::WriteCompileRule(const std::string& language) vars.Source = "$in"; vars.Object = "$out"; - vars.Flags = "-MMD -MF $out.d $FLAGS"; + if (this->GetTargetName() == "cmTryCompileExec") + vars.Flags = "$FLAGS"; + else + vars.Flags = "-MMD -MF $out.d $FLAGS"; vars.Defines = "$DEFINES"; // Rule for compiling object file. From 087a10278ea84a0db0ca429650ed648eccfe1564 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 7 Sep 2011 01:32:30 +0100 Subject: [PATCH 479/539] Use FLAGS and DEFINES for the source file language Otherwise we will get compiler warnings for mixed C/C++ targets. --- Source/cmNinjaTargetGenerator.cxx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index c3e5ed41efc..2ae67662d3b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -477,12 +477,9 @@ ::WriteObjectBuildStatement(cmSourceFile* source) std::back_inserter(orderOnlyDeps), MapToNinjaPath()); } - const char* linkLanguage = - this->GetTarget()->GetLinkerLanguage(this->GetConfigName()); - cmNinjaVars vars; - vars["FLAGS"] = this->ComputeFlagsForObject(source, linkLanguage); - vars["DEFINES"] = this->ComputeDefines(source, linkLanguage); + vars["FLAGS"] = this->ComputeFlagsForObject(source, language); + vars["DEFINES"] = this->ComputeDefines(source, language); cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), comment, From e33b0a95f27a1d4d3d5cdc542e8b93f160c49f84 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 7 Sep 2011 02:48:53 +0100 Subject: [PATCH 480/539] Have the Ninja generator build header search paths relative to HOME_OUTPUT Not only is this more accurate, it also means that paths in depfiles will be relative when necessary. --- Source/cmLocalNinjaGenerator.cxx | 6 ++++++ Source/cmLocalNinjaGenerator.h | 1 + 2 files changed, 7 insertions(+) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index c5d5093c285..661856af415 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -152,6 +152,12 @@ std::string cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib return this->Convert(lib.c_str(), HOME_OUTPUT, SHELL); } +std::string +cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path) +{ + return this->Convert(path.c_str(), HOME_OUTPUT, SHELL); +} + //---------------------------------------------------------------------------- // Private methods. diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 8b5194b2e99..8dbaf295b4c 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -73,6 +73,7 @@ class cmLocalNinjaGenerator : public cmLocalGenerator virtual bool CheckDefinition(std::string const& define) const; virtual std::string ConvertToLinkReference(std::string const& lib); + virtual std::string ConvertToIncludeReference(std::string const& path); private: // In order to access to protected member of the local generator. From 25eac80aefecfd1838b39742b94e118a854aa7be Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 7 Sep 2011 06:20:54 +0100 Subject: [PATCH 481/539] Add order-only dependency on any header file with a custom command --- Source/cmNinjaTargetGenerator.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 2ae67662d3b..c741c73a6b4 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -477,6 +477,22 @@ ::WriteObjectBuildStatement(cmSourceFile* source) std::back_inserter(orderOnlyDeps), MapToNinjaPath()); } + // Add order-only dependency on any header file with a custom command. + { + const std::vector& sources = + this->GetTarget()->GetSourceFiles(); + for(std::vector::const_iterator si = sources.begin(); + si != sources.end(); ++si) { + if (!(*si)->GetLanguage()) { + if (cmCustomCommand* cc = (*si)->GetCustomCommand()) { + const std::vector& ccoutputs = cc->GetOutputs(); + std::transform(ccoutputs.begin(), ccoutputs.end(), + std::back_inserter(orderOnlyDeps), MapToNinjaPath()); + } + } + } + } + cmNinjaVars vars; vars["FLAGS"] = this->ComputeFlagsForObject(source, language); vars["DEFINES"] = this->ComputeDefines(source, language); From 74a52e745c1da2cbfbd426114dabe84f1ec702e4 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 7 Sep 2011 06:21:17 +0100 Subject: [PATCH 482/539] SONAME for a CMAKE_SYMLINK_LIBRARY rule should be a path --- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index ae57a186cf5..256fdfb15cb 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -332,7 +332,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmNinjaVars()); } else { cmNinjaVars symlinkVars; - symlinkVars["SONAME"] = this->TargetNameSO; + symlinkVars["SONAME"] = this->GetTargetFilePath(this->TargetNameSO); cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), "Create library symlink " + targetOutput, "CMAKE_SYMLINK_LIBRARY", From f52d078dcd61696947e714ec75f2e235daf79991 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 8 Sep 2011 16:26:10 +0100 Subject: [PATCH 483/539] Search/replace makefile vars --- Source/cmNinjaUtilityTargetGenerator.cxx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 50f8bcebe7a..9455668636c 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -2,6 +2,7 @@ #include "cmCustomCommand.h" #include "cmGeneratedFileStream.h" #include "cmGlobalNinjaGenerator.h" +#include "cmMakefile.h" #include "cmSourceFile.h" #include "cmTarget.h" @@ -10,6 +11,15 @@ cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(cmTarget *target) cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() {} +static void find_replace(std::string &str, const std::string &find, + const std::string &replace) { + std::string::size_type pos = 0; + while ((pos = str.find(find, pos)) != std::string::npos) { + str.replace(pos, find.size(), replace); + pos += replace.size(); + } +} + void cmNinjaUtilityTargetGenerator::Generate() { std::vector commands; cmNinjaDeps deps; @@ -65,8 +75,14 @@ void cmNinjaUtilityTargetGenerator::Generate() { else vars["DESC"] = "Running utility command for " + this->GetTargetName(); - // TODO: fix problematic global targets. For now, filter out anything - // with a '$' in the command. + // TODO: fix problematic global targets. For now, search and replace the + // makefile vars. + find_replace(vars["COMMAND"], "$(CMAKE_SOURCE_DIR)", + this->GetTarget()->GetMakefile()->GetHomeDirectory()); + find_replace(vars["COMMAND"], "$(CMAKE_BINARY_DIR)", + this->GetTarget()->GetMakefile()->GetHomeOutputDirectory()); + find_replace(vars["COMMAND"], "$(ARGS)", ""); + if (vars["COMMAND"].find('$') != std::string::npos) return; From 6a7100422bde1d7a2604807a81f7295b0c518fd1 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 8 Sep 2011 22:35:53 +0100 Subject: [PATCH 484/539] Give utility targets with commands a more unique output file name This avoids problems if the build tree already contains a file with that name. --- Source/cmNinjaUtilityTargetGenerator.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 9455668636c..efe46da3f1a 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -86,13 +86,24 @@ void cmNinjaUtilityTargetGenerator::Generate() { if (vars["COMMAND"].find('$') != std::string::npos) return; + std::string utilCommandName = cmake::GetCMakeFilesDirectoryPostSlash(); + utilCommandName += this->GetTargetName() + ".util"; + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), "Utility command for " + this->GetTargetName(), "CUSTOM_COMMAND", - cmNinjaDeps(1, this->GetTargetName()), + cmNinjaDeps(1, utilCommandName), deps, cmNinjaDeps(), cmNinjaDeps(), vars); + + cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), + "", + cmNinjaDeps(1, this->GetTargetName()), + cmNinjaDeps(1, utilCommandName), + cmNinjaDeps(), + cmNinjaDeps(), + cmNinjaVars()); } } From 342b400f8c7e45e665fa66fd49de3f7e4862f859 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 9 Sep 2011 20:52:52 +0100 Subject: [PATCH 485/539] Implement assumed source dependencies If a source file is GENERATED and no custom command specifies it as an output, assume that one of the target dependencies, OBJECT_DEPENDS or header file custom commands will rebuild the file, and write a phony rule causing them to be built first. TODO: mark the phony rule as restat. --- Source/cmGlobalNinjaGenerator.cxx | 16 +++++++++++++++ Source/cmGlobalNinjaGenerator.h | 33 ++++++++++++++++++++++++++++++- Source/cmNinjaTargetGenerator.cxx | 14 +++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 9b041013c87..f74308dd7c6 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -298,6 +298,7 @@ void cmGlobalNinjaGenerator::Generate() this->cmGlobalGenerator::Generate(); + this->WriteAssumedSourceDependencies(*this->BuildFileStream); this->WriteBuiltinTargets(*this->BuildFileStream); this->CloseRulesFileStream(); @@ -511,6 +512,21 @@ void cmGlobalNinjaGenerator::AddDependencyToAll(const std::string& dependency) this->AllDependencies.push_back(dependency); } +void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies(std::ostream& os) +{ + for (std::map >::iterator + i = this->AssumedSourceDependencies.begin(); + i != this->AssumedSourceDependencies.end(); ++i) { + WritePhonyBuild(os, + "Assume dependencies for generated source file.", + cmNinjaDeps(1, i->first), + cmNinjaDeps(), + cmNinjaDeps(), + cmNinjaDeps(i->second.begin(), i->second.end()), + cmNinjaVars()); + } +} + void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os) { // Write headers. diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 6210344739d..ecbc24ac804 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -229,15 +229,40 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator void AddDependencyToAll(const std::string& dependency); + void WriteAssumedSourceDependencies(std::ostream& os); void WriteBuiltinTargets(std::ostream& os); void WriteTargetAll(std::ostream& os); void WriteTargetRebuildManifest(std::ostream& os); - /// Return true if the global generator has seen the given custom command. + /// Called when we have seen the given custom command. Returns true + /// if we has seen it before. bool SeenCustomCommand(cmCustomCommand *cc) { return !this->CustomCommands.insert(cc).second; } + /// Called when we have seen the given custom command output. + void SeenCustomCommandOutput(const std::string &output) { + this->CustomCommandOutputs.insert(output); + // We don't need the assumed dependencies anymore, because we have + // an output. + this->AssumedSourceDependencies.erase(output); + } + + bool HasCustomCommandOutput(const std::string &output) { + return this->CustomCommandOutputs.find(output) != + this->CustomCommandOutputs.end(); + } + + + void AddAssumedSourceDependencies(const std::string &source, + const cmNinjaDeps &deps) { + std::set &ASD = this->AssumedSourceDependencies[source]; + // Because we may see the same source file multiple times (same source + // specified in multiple targets), compute the union of any assumed + // dependencies. + ASD.insert(deps.begin(), deps.end()); + } + private: /// The file containing the build statement. (the relation ship of the /// compilation DAG). @@ -258,6 +283,12 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator /// The set of custom commands we have seen. std::set CustomCommands; + + /// The set of custom command outputs we have seen. + std::set CustomCommandOutputs; + + /// The mapping from source file to assumed dependencies. + std::map > AssumedSourceDependencies; }; #endif // ! cmGlobalNinjaGenerator_h diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index c741c73a6b4..07ae209050b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -493,6 +493,16 @@ ::WriteObjectBuildStatement(cmSourceFile* source) } } + // If the source file is GENERATED and does not have a custom command + // (either attached to this source file or another one), assume that one of + // the target dependencies, OBJECT_DEPENDS or header file custom commands + // will rebuild the file. + if (source->GetPropertyAsBool("GENERATED") && !source->GetCustomCommand() && + !this->GetGlobalGenerator()->HasCustomCommandOutput(sourceFileName)) { + this->GetGlobalGenerator()->AddAssumedSourceDependencies(sourceFileName, + orderOnlyDeps); + } + cmNinjaVars vars; vars["FLAGS"] = this->ComputeFlagsForObject(source, language); vars["DEFINES"] = this->ComputeDefines(source, language); @@ -613,6 +623,10 @@ cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { ninjaOutputs.begin(), MapToNinjaPath()); this->AppendCustomCommandDeps(cc, ninjaDeps); + for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end(); + ++i) + this->GetGlobalGenerator()->SeenCustomCommandOutput(*i); + std::vector cmdLines; this->AppendCustomCommandLines(cc, cmdLines); From 210ab19ed54db379cd6282e606430d14da646809 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 9 Sep 2011 21:03:49 +0100 Subject: [PATCH 486/539] Move the "cd" command logic to cmNinjaTargetGenerator::AppendCustomCommandLines --- Source/cmNinjaTargetGenerator.cxx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 07ae209050b..8f051578309 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -595,6 +595,15 @@ std::string cmNinjaTargetGenerator::BuildCommandLine(const std::vector &cmdLines) { cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); + if (ccg.GetNumberOfCommands() > 0) { + std::ostringstream cdCmd; + cdCmd << "cd "; + if (const char* wd = cc->GetWorkingDirectory()) + cdCmd << wd; + else + cdCmd << this->GetMakefile()->GetStartOutputDirectory(); + cmdLines.push_back(cdCmd.str()); + } for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { cmdLines.push_back(ccg.GetCommand(i)); std::string& cmd = cmdLines.back(); @@ -642,14 +651,6 @@ cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { } else { this->WriteCustomCommandRule(); - std::ostringstream cdCmd; - cdCmd << "cd "; - if (const char* wd = cc->GetWorkingDirectory()) - cdCmd << wd; - else - cdCmd << this->GetMakefile()->GetStartOutputDirectory(); - cmdLines.insert(cmdLines.begin(), cdCmd.str()); - cmNinjaVars vars; vars["COMMAND"] = this->BuildCommandLine(cmdLines); vars["DESC"] = this->LocalGenerator->ConstructComment(*cc); From 01a2f2cd2cb6f894dee02d2893b6d283948388bc Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 9 Sep 2011 21:22:33 +0100 Subject: [PATCH 487/539] Support for POST_BUILD on normal targets --- Source/cmNinjaNormalTargetGenerator.cxx | 10 ++++++++++ Source/cmNinjaTargetGenerator.cxx | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 256fdfb15cb..e04f3d0367a 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -160,6 +160,7 @@ ::WriteLinkRule() { this->GetLocalGenerator()->ExpandRuleVariables(*i, vars); } + linkCmds.push_back("$POST_BUILD"); std::string linkCmd = BuildCommandLine(linkCmds); // Write the linker rule. @@ -310,6 +311,15 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->GetConfigName()); vars["SONAME"] = this->TargetNameSO; + std::vector &postBuildCmds = + this->GetTarget()->GetPostBuildCommands(); + std::vector postBuildCmdLines; + for (std::vector::const_iterator ci = postBuildCmds.begin(); + ci != postBuildCmds.end(); ++ci) { + this->AppendCustomCommandLines(&*ci, postBuildCmdLines); + } + vars["POST_BUILD"] = this->BuildCommandLine(postBuildCmdLines); + // Write the build statement for this target. cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), comment.str(), diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 8f051578309..01ff0aeda53 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -578,6 +578,12 @@ void cmNinjaTargetGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, } std::string cmNinjaTargetGenerator::BuildCommandLine(const std::vector &cmdLines) { + // If we have no commands but we need to build a command anyway, use "true". + // This happens when building a POST_BUILD value for link targets that + // don't use POST_BUILD. + if (cmdLines.empty()) + return "true"; + // TODO: This will work only on Unix platforms. I don't // want to use a link.txt file because I will loose the benefit of the // $in variables. A discussion about dealing with multiple commands in From b6ca15424b99729e4f1d1c206d18174f55abebde Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 9 Sep 2011 22:05:33 +0100 Subject: [PATCH 488/539] Add all targets (including utilities) except EXCLUDE_FROM_ALL to "all" --- Source/cmLocalNinjaGenerator.cxx | 3 +++ Source/cmNinjaNormalTargetGenerator.cxx | 2 -- Source/cmNinjaTargetGenerator.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 661856af415..8f35fd24040 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -52,6 +52,9 @@ void cmLocalNinjaGenerator::Generate() if(tg) { tg->Generate(); + // Add the target to "all" if required. + if (!t->second.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + this->AddDependencyToAll(tg->GetTargetName()); delete tg; } } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index e04f3d0367a..a83874cd6b6 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -292,8 +292,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // Compute outputs. cmNinjaDeps outputs; outputs.push_back(targetOutputReal); - // Add this executable to the all target. - this->GetLocalGenerator()->AddDependencyToAll(this->GetTargetName()); // Compute specific libraries to link with. cmNinjaDeps explicitDeps = this->GetObjects(), diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 33017156fea..674e09fc519 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -37,6 +37,8 @@ class cmNinjaTargetGenerator virtual void Generate() = 0; + std::string GetTargetName() const; + protected: cmGeneratedFileStream& GetBuildFileStream() const; cmGeneratedFileStream& GetRulesFileStream() const; @@ -44,8 +46,6 @@ class cmNinjaTargetGenerator cmTarget* GetTarget() const { return this->Target; } - std::string GetTargetName() const; - cmLocalNinjaGenerator* GetLocalGenerator() const { return this->LocalGenerator; } From bddaaab4ab548b3c39ed903efbba646f774d0b4c Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sat, 10 Sep 2011 04:09:12 +0100 Subject: [PATCH 489/539] Use ResolveLanguageCompiler in cmGlobalNinjaGenerator so that changing compilers works --- Source/cmGlobalNinjaGenerator.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index f74308dd7c6..69e6c7c4736 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -331,6 +331,7 @@ ::EnableLanguage(std::vectorconst& languages, message += "\" yet."; cmSystemTools::Error(message.c_str()); } + this->ResolveLanguageCompiler(*l, mf, optional); } } From f10ef0477943e1afc5c9a52317fffa5b09f896c7 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sat, 10 Sep 2011 05:06:19 +0100 Subject: [PATCH 490/539] Encode file names as identifiers in build statements --- Source/cmGlobalNinjaGenerator.cxx | 46 ++++++++++++++++++++++++------- Source/cmGlobalNinjaGenerator.h | 2 ++ 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 69e6c7c4736..b0c8c77335b 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -49,6 +49,28 @@ void cmGlobalNinjaGenerator::WriteComment(std::ostream& os, os << "# " << replace.substr(lpos) << "\n"; } +static bool IsIdentChar(char c) { + return + ('a' <= c && c <= 'z') || + ('+' <= c && c <= '9') || // +,-./ and numbers + ('A' <= c && c <= 'Z') || + (c == '_') || (c == '$') || (c == '\\'); +} + +std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string &ident, + std::ostream &vars) { + if (std::find_if(ident.begin(), ident.end(), + std::not1(std::ptr_fun(IsIdentChar))) != ident.end()) { + static unsigned VarNum = 0; + std::ostringstream names; + names << "ident" << VarNum++; + vars << names.str() << " = " << ident << "\n"; + return "$" + names.str(); + } else { + return ident; + } +} + void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, const std::string& comment, const std::string& rule, @@ -78,47 +100,51 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, cmGlobalNinjaGenerator::WriteComment(os, comment); + std::ostringstream builds; + // TODO(Nicolas Despres): Write one file per line when there is multiple // input/output files. // Write outputs files. - os << "build"; + builds << "build"; for(cmNinjaDeps::const_iterator i = outputs.begin(); i != outputs.end(); ++i) - os << " " << *i; - os << ":"; + builds << " " << EncodeIdent(*i, os); + builds << ":"; // Write the rule. - os << " " << rule; + builds << " " << rule; // Write explicit dependencies. for(cmNinjaDeps::const_iterator i = explicitDeps.begin(); i != explicitDeps.end(); ++i) - os << " " << *i; + builds << " " << EncodeIdent(*i, os); // Write implicit dependencies. if(!implicitDeps.empty()) { - os << " |"; + builds << " |"; for(cmNinjaDeps::const_iterator i = implicitDeps.begin(); i != implicitDeps.end(); ++i) - os << " " << *i; + builds << " " << EncodeIdent(*i, os); } // Write order-only dependencies. if(!orderOnlyDeps.empty()) { - os << " ||"; + builds << " ||"; for(cmNinjaDeps::const_iterator i = orderOnlyDeps.begin(); i != orderOnlyDeps.end(); ++i) - os << " " << *i; + builds << " " << EncodeIdent(*i, os); } - os << "\n"; + builds << "\n"; + + os << builds.str(); // Write the variables bound to this build statement. if(!variables.empty()) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index ecbc24ac804..b499685f9e7 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -56,6 +56,8 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator /// Write a divider in the given output stream @a os. static void WriteDivider(std::ostream& os); + static std::string EncodeIdent(const std::string &ident, std::ostream &vars); + /** * Write the given @a comment to the output stream @a os. It * handles new line character properly. From 1f190beaa6c330b57ca71e7a3428634a9d7b4685 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sun, 11 Sep 2011 03:58:49 +0100 Subject: [PATCH 491/539] Add a restat variable for custom commands --- Source/cmGlobalNinjaGenerator.cxx | 19 +++++++++++++------ Source/cmGlobalNinjaGenerator.h | 14 ++++++++------ Source/cmNinjaNormalTargetGenerator.cxx | 12 +++--------- Source/cmNinjaTargetGenerator.cxx | 10 ++++------ 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index b0c8c77335b..68adaac47fd 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -177,9 +177,10 @@ void cmGlobalNinjaGenerator::WritePhonyBuild(std::ostream& os, void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, const std::string& name, const std::string& command, - const std::string& comment, const std::string& description, + const std::string& comment, const std::string& depfile, + bool restat, const cmNinjaVars& variables) { // Make sure the rule has a name. @@ -223,6 +224,12 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, os << "description = " << description << "\n"; } + if(restat) + { + cmGlobalNinjaGenerator::Indent(os, 1); + os << "restat = 1\n"; + } + // Write the variables bound to this build statement. if(!variables.empty()) { @@ -408,9 +415,10 @@ ::GenerateBuildCommand(const char* makeProgram, void cmGlobalNinjaGenerator::AddRule(const std::string& name, const std::string& command, - const std::string& comment, const std::string& description, + const std::string& comment, const std::string& depfile, + bool restat, const cmNinjaVars& variables) { // Do not add twice the same rule. @@ -421,9 +429,10 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, cmGlobalNinjaGenerator::WriteRule(*this->RulesFileStream, name, command, - comment, description, + comment, depfile, + restat, variables); } @@ -596,10 +605,8 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) WriteRule(*this->RulesFileStream, "RERUN_CMAKE", cmd.str(), - "Rule for re-running cmake.", "Re-running CMake...", - "", - cmNinjaVars()); + "Rule for re-running cmake."); cmNinjaDeps implicitDeps; for (std::vector::const_iterator i = diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index b499685f9e7..1af3a41ca74 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -99,10 +99,11 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator static void WriteRule(std::ostream& os, const std::string& name, const std::string& command, - const std::string& comment, const std::string& description, - const std::string& depfile, - const cmNinjaVars& variables); + const std::string& comment = "", + const std::string& depfile = "", + bool restat = false, + const cmNinjaVars& variables = cmNinjaVars()); /** * Write a variable named @a name to @a os with value @a value and an @@ -199,10 +200,11 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator */ void AddRule(const std::string& name, const std::string& command, - const std::string& comment, const std::string& description, - const std::string& depfile, - const cmNinjaVars& variables); + const std::string& comment = "", + const std::string& depfile = "", + bool restat = false, + const cmNinjaVars& variables = cmNinjaVars()); bool HasRule(const std::string& name); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index a83874cd6b6..8f0e0751b68 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -172,10 +172,8 @@ ::WriteLinkRule() << this->GetVisibleTypeName() << " $out"; this->GetGlobalGenerator()->AddRule(ruleName, linkCmd, - comment.str(), description.str(), - /*depfile*/ "", - cmNinjaVars()); + comment.str()); } if (this->TargetNameOut != this->TargetNameReal) { @@ -186,19 +184,15 @@ ::WriteLinkRule() cmakeCommand + " -E cmake_symlink_executable" " $in $out", - "Rule for creating executable symlink.", "Creating executable symlink $out", - /*depfile*/ "", - cmNinjaVars()); + "Rule for creating executable symlink."); else this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", cmakeCommand + " -E cmake_symlink_library" " $in $SONAME $out", - "Rule for creating library symlink.", "Creating library symlink $out", - /*depfile*/ "", - cmNinjaVars()); + "Rule for creating library symlink."); } } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 01ff0aeda53..b2f476bd953 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -400,13 +400,11 @@ ::WriteCompileRule(const std::string& language) std::ostringstream description; description << "Building " << language << " object $out"; std::string depfile = "$out.d"; - cmNinjaVars emptyVars; this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), compileCmd, - comment.str(), description.str(), - depfile, - emptyVars); + comment.str(), + depfile); } void @@ -620,10 +618,10 @@ void cmNinjaTargetGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, void cmNinjaTargetGenerator::WriteCustomCommandRule() { this->GetGlobalGenerator()->AddRule("CUSTOM_COMMAND", "$COMMAND", - "Rule for running custom commands.", "$DESC", + "Rule for running custom commands.", /*depfile*/ "", - cmNinjaVars()); + /*restat*/ true); } void From 60027d7b36efce57bd6941de71e0e41b91aa5f60 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 19 Sep 2011 04:09:49 +0100 Subject: [PATCH 492/539] Add target dependencies to custom commands This isn't perfect yet. It breaks the LLVM/Clang build because it adds the same custom command to multiple targets with inconsistent dependency sets, one of which causes a dependency cycle (and which happens to be the one we see first). We probably need to take the intersection of all targets' dependencies when writing out the custom command rules. Yes, the intersection. *sigh* --- Source/cmNinjaTargetGenerator.cxx | 28 +++++++++++++++++----------- Source/cmNinjaTargetGenerator.h | 1 + 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index b2f476bd953..d60150ec865 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -310,6 +310,17 @@ ::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) const { } } +void +cmNinjaTargetGenerator +::AppendTargetDepends(cmNinjaDeps& outputs) const { + cmTargetDependSet const& targetDeps = + this->GetGlobalGenerator()->GetTargetDirectDepends(*this->Target); + for (cmTargetDependSet::const_iterator i = targetDeps.begin(); + i != targetDeps.end(); ++i) { + this->AppendTargetOutputs(*i, outputs); + } +} + void cmNinjaTargetGenerator ::WriteTargetBuild(const std::string& outputName, @@ -458,15 +469,9 @@ ::WriteObjectBuildStatement(cmSourceFile* source) explicitDeps.push_back(sourceFileName); // Ensure that the target dependencies are built before any source file in the - // target, using order-only dependencies. These dependencies should later - // resolve to direct header dependencies in the depfile. + // target, using order-only dependencies. cmNinjaDeps orderOnlyDeps; - cmTargetDependSet const& targetDeps = - this->GetGlobalGenerator()->GetTargetDirectDepends(*this->Target); - for (cmTargetDependSet::const_iterator i = targetDeps.begin(); - i != targetDeps.end(); ++i) { - this->AppendTargetOutputs(*i, orderOnlyDeps); - } + this->AppendTargetDepends(orderOnlyDeps); if(const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) { std::vector depList; @@ -630,7 +635,8 @@ cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { return; const std::vector &outputs = cc->GetOutputs(); - cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps; + cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps, orderOnlyDeps; + this->AppendTargetDepends(orderOnlyDeps); std::transform(outputs.begin(), outputs.end(), ninjaOutputs.begin(), MapToNinjaPath()); @@ -650,7 +656,7 @@ cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { ninjaOutputs, ninjaDeps, cmNinjaDeps(), - cmNinjaDeps(), + orderOnlyDeps, cmNinjaVars()); } else { this->WriteCustomCommandRule(); @@ -665,7 +671,7 @@ cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { ninjaOutputs, ninjaDeps, cmNinjaDeps(), - cmNinjaDeps(), + orderOnlyDeps, vars); } } diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 674e09fc519..f66fe8fa8f3 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -104,6 +104,7 @@ class cmNinjaTargetGenerator virtual std::string GetTargetOutputDir() const; void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) const; + void AppendTargetDepends(cmNinjaDeps& outputs) const; /** * Write shortcut build statements for the target name with the target From 8e09a8d64a2c1e44348fc5778de0d89d8d84186b Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 20 Sep 2011 15:17:00 +0100 Subject: [PATCH 493/539] Introduce new scheme for custom command target dependencies Now, we look at all targets to which the custom command and take the intersection of their target dependencies. This should work, if we assume all target dependencies are a superset of the true target dependencies for this custom command. One can imagine scenarios where they are not, mainly involving indirect dependencies. However this seems unlikely to arise in practice. At the same time, move a bunch of code to cmLocalNinjaGenerator. --- Source/cmLocalNinjaGenerator.cxx | 202 ++++++++++++++++++++++- Source/cmLocalNinjaGenerator.h | 31 ++++ Source/cmNinjaNormalTargetGenerator.cxx | 9 +- Source/cmNinjaTargetGenerator.cxx | 159 +----------------- Source/cmNinjaTargetGenerator.h | 30 +--- Source/cmNinjaUtilityTargetGenerator.cxx | 10 +- 6 files changed, 250 insertions(+), 191 deletions(-) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 8f35fd24040..742e2409544 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -10,6 +10,7 @@ See the License for more information. ============================================================================*/ #include "cmLocalNinjaGenerator.h" +#include "cmCustomCommandGenerator.h" #include "cmMakefile.h" #include "cmGlobalNinjaGenerator.h" #include "cmNinjaTargetGenerator.h" @@ -18,6 +19,8 @@ #include "cmComputeLinkInformation.h" #include "cmake.h" +#include + cmLocalNinjaGenerator::cmLocalNinjaGenerator() : cmLocalGenerator() , ConfigName("") @@ -36,8 +39,6 @@ cmLocalNinjaGenerator::~cmLocalNinjaGenerator() void cmLocalNinjaGenerator::Generate() { - - this->SetConfigName(); this->WriteProcessedMakefile(this->GetBuildFileStream()); @@ -59,6 +60,7 @@ void cmLocalNinjaGenerator::Generate() } } + this->WriteCustomCommandBuildStatements(); } // Implemented in: @@ -254,3 +256,199 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) cmGlobalNinjaGenerator::WriteDivider(os); os << std::endl; } + +std::string cmLocalNinjaGenerator::ConvertToNinjaPath(const char *path) +{ + return this->Convert(path, + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE); +} + +void +cmLocalNinjaGenerator +::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) { + switch (target->GetType()) { + case cmTarget::EXECUTABLE: + case cmTarget::SHARED_LIBRARY: + case cmTarget::STATIC_LIBRARY: { + std::string name = target->GetFullName(this->GetConfigName()); + std::string dir = target->GetDirectory(this->GetConfigName()); + std::string path = ConvertToNinjaPath(dir.c_str()); + if (path.empty() || path == ".") + outputs.push_back(name); + else { + path += "/"; + path += name; + outputs.push_back(path); + } + break; + } + + case cmTarget::UTILITY: { + const std::vector& sources = target->GetSourceFiles(); + for(std::vector::const_iterator source = sources.begin(); + source != sources.end(); ++source) { + if(cmCustomCommand* cc = (*source)->GetCustomCommand()) { + if (!cc->GetCommandLines().empty()) { + const std::vector& ccoutputs = cc->GetOutputs(); + std::transform(ccoutputs.begin(), ccoutputs.end(), + std::back_inserter(outputs), MapToNinjaPath()); + } + } + } + } + } +} + +void +cmLocalNinjaGenerator +::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) { + cmTargetDependSet const& targetDeps = + this->GetGlobalGenerator()->GetTargetDirectDepends(*target); + for (cmTargetDependSet::const_iterator i = targetDeps.begin(); + i != targetDeps.end(); ++i) { + this->AppendTargetOutputs(*i, outputs); + } +} + +void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, cmNinjaDeps &ninjaDeps) { + const std::vector &deps = cc->GetDepends(); + for (std::vector::const_iterator i = deps.begin(); + i != deps.end(); ++i) { + std::string dep; + if (this->GetRealDependency(i->c_str(), this->GetConfigName(), dep)) + ninjaDeps.push_back(ConvertToNinjaPath(dep.c_str())); + } +} + +std::string cmLocalNinjaGenerator::BuildCommandLine(const std::vector &cmdLines) { + // If we have no commands but we need to build a command anyway, use "true". + // This happens when building a POST_BUILD value for link targets that + // don't use POST_BUILD. + if (cmdLines.empty()) + return "true"; + + // TODO: This will work only on Unix platforms. I don't + // want to use a link.txt file because I will loose the benefit of the + // $in variables. A discussion about dealing with multiple commands in + // a rule is started here: + // http://groups.google.com/group/ninja-build/browse_thread/thread/d515f23a78986008 + std::ostringstream cmd; + for (std::vector::const_iterator li = cmdLines.begin(); + li != cmdLines.end(); ++li) { + if (li != cmdLines.begin()) + cmd << " && "; + cmd << *li; + } + return cmd.str(); +} + +void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, std::vector &cmdLines) { + cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); + if (ccg.GetNumberOfCommands() > 0) { + std::ostringstream cdCmd; + cdCmd << "cd "; + if (const char* wd = cc->GetWorkingDirectory()) + cdCmd << wd; + else + cdCmd << this->GetMakefile()->GetStartOutputDirectory(); + cmdLines.push_back(cdCmd.str()); + } + for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { + cmdLines.push_back(ccg.GetCommand(i)); + std::string& cmd = cmdLines.back(); + ccg.AppendArguments(i, cmd); + } +} + +void cmLocalNinjaGenerator::WriteCustomCommandRule() { + this->GetGlobalNinjaGenerator()->AddRule("CUSTOM_COMMAND", + "$COMMAND", + "$DESC", + "Rule for running custom commands.", + /*depfile*/ "", + /*restat*/ true); +} + +void +cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc, + const cmNinjaDeps& orderOnlyDeps) { + if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) + return; + + const std::vector &outputs = cc->GetOutputs(); + cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps; + + std::transform(outputs.begin(), outputs.end(), + ninjaOutputs.begin(), MapToNinjaPath()); + this->AppendCustomCommandDeps(cc, ninjaDeps); + + for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end(); + ++i) + this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i); + + std::vector cmdLines; + this->AppendCustomCommandLines(cc, cmdLines); + + if (cmdLines.empty()) { + cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), + "Phony custom command for " + + ninjaOutputs[0], + ninjaOutputs, + ninjaDeps, + cmNinjaDeps(), + orderOnlyDeps, + cmNinjaVars()); + } else { + this->WriteCustomCommandRule(); + + cmNinjaVars vars; + vars["COMMAND"] = this->BuildCommandLine(cmdLines); + vars["DESC"] = this->ConstructComment(*cc); + + cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), + "Custom command for " + ninjaOutputs[0], + "CUSTOM_COMMAND", + ninjaOutputs, + ninjaDeps, + cmNinjaDeps(), + orderOnlyDeps, + vars); + } +} + +void cmLocalNinjaGenerator::AddCustomCommandTarget(cmCustomCommand* cc, cmTarget* target) +{ + this->CustomCommandTargets[cc].insert(target); +} + +void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements() +{ + for (CustomCommandTargetMap::iterator i = this->CustomCommandTargets.begin(); + i != this->CustomCommandTargets.end(); ++i) { + // A custom command may appear on multiple targets. However, some build + // systems exist where the target dependencies on some of the targets are + // overspecified, leading to a dependency cycle. If we assume all target + // dependencies are a superset of the true target dependencies for this + // custom command, we can take the set intersection of all target dependencies + // to obtain a correct dependency list. + std::set::iterator j = i->second.begin(); + assert(j != i->second.end()); + std::vector ccTargetDeps; + this->AppendTargetDepends(*j, ccTargetDeps); + std::sort(ccTargetDeps.begin(), ccTargetDeps.end()); + ++j; + + for (; j != i->second.end(); ++j) { + std::vector jDeps, depsIntersection; + this->AppendTargetDepends(*j, jDeps); + std::sort(jDeps.begin(), jDeps.end()); + std::set_intersection(ccTargetDeps.begin(), ccTargetDeps.end(), + jDeps.begin(), jDeps.end(), + std::back_inserter(depsIntersection)); + ccTargetDeps = depsIntersection; + } + + this->WriteCustomCommandBuildStatement(i->first, ccTargetDeps); + } +} diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 8dbaf295b4c..0b3fb59911e 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -79,6 +79,7 @@ class cmLocalNinjaGenerator : public cmLocalGenerator // In order to access to protected member of the local generator. friend class cmNinjaTargetGenerator; friend class cmNinjaNormalTargetGenerator; + friend class cmNinjaUtilityTargetGenerator; private: cmGeneratedFileStream& GetBuildFileStream() const; @@ -92,9 +93,39 @@ class cmLocalNinjaGenerator : public cmLocalGenerator void SetConfigName(); + std::string ConvertToNinjaPath(const char *path); + + struct map_to_ninja_path { + cmLocalNinjaGenerator *LocalGenerator; + map_to_ninja_path(cmLocalNinjaGenerator *LocalGenerator) + : LocalGenerator(LocalGenerator) {} + std::string operator()(const std::string &path) { + return LocalGenerator->ConvertToNinjaPath(path.c_str()); + } + }; + map_to_ninja_path MapToNinjaPath() { + return map_to_ninja_path(this); + } + + void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs); + void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); + + void AppendCustomCommandDeps(const cmCustomCommand *cc, cmNinjaDeps &ninjaDeps); + std::string BuildCommandLine(const std::vector &cmdLines); + void AppendCustomCommandLines(const cmCustomCommand *cc, std::vector &cmdLines); + void WriteCustomCommandRule(); + void WriteCustomCommandBuildStatement(cmCustomCommand *cc, + const cmNinjaDeps& orderOnlyDeps); + + void AddCustomCommandTarget(cmCustomCommand* cc, cmTarget* target); + void WriteCustomCommandBuildStatements(); + private: std::string ConfigName; std::string HomeRelativeOutputPath; + + typedef std::map > CustomCommandTargetMap; + CustomCommandTargetMap CustomCommandTargets; }; #endif // ! cmLocalNinjaGenerator_h diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 8f0e0751b68..5b1cc52630b 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -161,7 +161,8 @@ ::WriteLinkRule() this->GetLocalGenerator()->ExpandRuleVariables(*i, vars); } linkCmds.push_back("$POST_BUILD"); - std::string linkCmd = BuildCommandLine(linkCmds); + std::string linkCmd = + this->GetLocalGenerator()->BuildCommandLine(linkCmds); // Write the linker rule. std::ostringstream comment; @@ -308,9 +309,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::vector postBuildCmdLines; for (std::vector::const_iterator ci = postBuildCmds.begin(); ci != postBuildCmds.end(); ++ci) { - this->AppendCustomCommandLines(&*ci, postBuildCmdLines); + this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, + postBuildCmdLines); } - vars["POST_BUILD"] = this->BuildCommandLine(postBuildCmdLines); + vars["POST_BUILD"] = + this->GetLocalGenerator()->BuildCommandLine(postBuildCmdLines); // Write the build statement for this target. cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index d60150ec865..4d00d5e0d59 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -273,54 +273,6 @@ ::GetTargetFilePath(const std::string& name) const path += name; return path; } - -void -cmNinjaTargetGenerator -::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) const { - switch (target->GetType()) { - case cmTarget::EXECUTABLE: - case cmTarget::SHARED_LIBRARY: - case cmTarget::STATIC_LIBRARY: { - std::string name = target->GetFullName(this->GetConfigName()); - std::string dir = target->GetDirectory(this->GetConfigName()); - std::string path = ConvertToNinjaPath(dir.c_str()); - if (path.empty() || path == ".") - outputs.push_back(name); - else { - path += "/"; - path += name; - outputs.push_back(path); - } - break; - } - - case cmTarget::UTILITY: { - const std::vector& sources = target->GetSourceFiles(); - for(std::vector::const_iterator source = sources.begin(); - source != sources.end(); ++source) { - if(cmCustomCommand* cc = (*source)->GetCustomCommand()) { - if (!cc->GetCommandLines().empty()) { - const std::vector& ccoutputs = cc->GetOutputs(); - std::transform(ccoutputs.begin(), ccoutputs.end(), - std::back_inserter(outputs), MapToNinjaPath()); - } - } - } - } - } -} - -void -cmNinjaTargetGenerator -::AppendTargetDepends(cmNinjaDeps& outputs) const { - cmTargetDependSet const& targetDeps = - this->GetGlobalGenerator()->GetTargetDirectDepends(*this->Target); - for (cmTargetDependSet::const_iterator i = targetDeps.begin(); - i != targetDeps.end(); ++i) { - this->AppendTargetOutputs(*i, outputs); - } -} - void cmNinjaTargetGenerator ::WriteTargetBuild(const std::string& outputName, @@ -446,7 +398,7 @@ cmNinjaTargetGenerator ::WriteObjectBuildStatement(cmSourceFile* source) { if (cmCustomCommand *cc = source->GetCustomCommand()) - WriteCustomCommandBuildStatement(cc); + this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); cmNinjaDeps emptyDeps; @@ -471,7 +423,7 @@ ::WriteObjectBuildStatement(cmSourceFile* source) // Ensure that the target dependencies are built before any source file in the // target, using order-only dependencies. cmNinjaDeps orderOnlyDeps; - this->AppendTargetDepends(orderOnlyDeps); + this->GetLocalGenerator()->AppendTargetDepends(this->Target, orderOnlyDeps); if(const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) { std::vector depList; @@ -568,110 +520,3 @@ ::ComputeLinkFlags(const std::string& linkLanguage) return linkFlags; } - -void cmNinjaTargetGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, cmNinjaDeps &ninjaDeps) { - const std::vector &deps = cc->GetDepends(); - for (std::vector::const_iterator i = deps.begin(); - i != deps.end(); ++i) { - std::string dep; - if (this->LocalGenerator->GetRealDependency(i->c_str(), - this->GetConfigName(), dep)) - ninjaDeps.push_back(ConvertToNinjaPath(dep.c_str())); - } -} - -std::string cmNinjaTargetGenerator::BuildCommandLine(const std::vector &cmdLines) { - // If we have no commands but we need to build a command anyway, use "true". - // This happens when building a POST_BUILD value for link targets that - // don't use POST_BUILD. - if (cmdLines.empty()) - return "true"; - - // TODO: This will work only on Unix platforms. I don't - // want to use a link.txt file because I will loose the benefit of the - // $in variables. A discussion about dealing with multiple commands in - // a rule is started here: - // http://groups.google.com/group/ninja-build/browse_thread/thread/d515f23a78986008 - std::ostringstream cmd; - for (std::vector::const_iterator li = cmdLines.begin(); - li != cmdLines.end(); ++li) { - if (li != cmdLines.begin()) - cmd << " && "; - cmd << *li; - } - return cmd.str(); -} - -void cmNinjaTargetGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, std::vector &cmdLines) { - cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); - if (ccg.GetNumberOfCommands() > 0) { - std::ostringstream cdCmd; - cdCmd << "cd "; - if (const char* wd = cc->GetWorkingDirectory()) - cdCmd << wd; - else - cdCmd << this->GetMakefile()->GetStartOutputDirectory(); - cmdLines.push_back(cdCmd.str()); - } - for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { - cmdLines.push_back(ccg.GetCommand(i)); - std::string& cmd = cmdLines.back(); - ccg.AppendArguments(i, cmd); - } -} - -void cmNinjaTargetGenerator::WriteCustomCommandRule() { - this->GetGlobalGenerator()->AddRule("CUSTOM_COMMAND", - "$COMMAND", - "$DESC", - "Rule for running custom commands.", - /*depfile*/ "", - /*restat*/ true); -} - -void -cmNinjaTargetGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc) { - if (this->GetGlobalGenerator()->SeenCustomCommand(cc)) - return; - - const std::vector &outputs = cc->GetOutputs(); - cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps, orderOnlyDeps; - this->AppendTargetDepends(orderOnlyDeps); - - std::transform(outputs.begin(), outputs.end(), - ninjaOutputs.begin(), MapToNinjaPath()); - this->AppendCustomCommandDeps(cc, ninjaDeps); - - for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end(); - ++i) - this->GetGlobalGenerator()->SeenCustomCommandOutput(*i); - - std::vector cmdLines; - this->AppendCustomCommandLines(cc, cmdLines); - - if (cmdLines.empty()) { - cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), - "Phony custom command for " + - ninjaOutputs[0], - ninjaOutputs, - ninjaDeps, - cmNinjaDeps(), - orderOnlyDeps, - cmNinjaVars()); - } else { - this->WriteCustomCommandRule(); - - cmNinjaVars vars; - vars["COMMAND"] = this->BuildCommandLine(cmdLines); - vars["DESC"] = this->LocalGenerator->ConstructComment(*cc); - - cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - "Custom command for " + ninjaOutputs[0], - "CUSTOM_COMMAND", - ninjaOutputs, - ninjaDeps, - cmNinjaDeps(), - orderOnlyDeps, - vars); - } -} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index f66fe8fa8f3..6a2d3fddbde 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -10,13 +10,13 @@ See the License for more information. ============================================================================*/ #ifndef cmNinjaTargetGenerator_h -# define cmNinjaTargetGenerator_h +#define cmNinjaTargetGenerator_h -# include "cmStandardIncludes.h" -# include "cmNinjaTypes.h" +#include "cmStandardIncludes.h" +#include "cmNinjaTypes.h" +#include "cmLocalNinjaGenerator.h" class cmTarget; -class cmLocalNinjaGenerator; class cmGlobalNinjaGenerator; class cmGeneratedFileStream; class cmMakefile; @@ -74,18 +74,8 @@ class cmNinjaTargetGenerator std::string ComputeDefines(cmSourceFile *source, const std::string& language); std::string ConvertToNinjaPath(const char *path) const; - - struct map_to_ninja_path { - const cmNinjaTargetGenerator *TargetGenerator; - map_to_ninja_path(const cmNinjaTargetGenerator *TargetGenerator) - : TargetGenerator(TargetGenerator) {} - std::string operator()(const std::string &path) { - return TargetGenerator->ConvertToNinjaPath(path.c_str()); - } - }; - - map_to_ninja_path MapToNinjaPath() const { - return map_to_ninja_path(this); + cmLocalNinjaGenerator::map_to_ninja_path MapToNinjaPath() const { + return this->GetLocalGenerator()->MapToNinjaPath(); } /// @return the list of link dependency for the given target @a target. @@ -103,9 +93,6 @@ class cmNinjaTargetGenerator /// @return the output path for the target. virtual std::string GetTargetOutputDir() const; - void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) const; - void AppendTargetDepends(cmNinjaDeps& outputs) const; - /** * Write shortcut build statements for the target name with the target * output name and the target output path. @@ -113,11 +100,6 @@ class cmNinjaTargetGenerator void WriteTargetBuild(const std::string& outputName, const std::string& outputPath); - void AppendCustomCommandDeps(const cmCustomCommand *cc, cmNinjaDeps &ninjaDeps); - std::string BuildCommandLine(const std::vector &cmdLines); - void AppendCustomCommandLines(const cmCustomCommand *cc, std::vector &cmdLines); - void WriteCustomCommandRule(); - void WriteLanguageRules(const std::string& language); void WriteCompileRule(const std::string& language); void WriteObjectBuildStatements(); diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index efe46da3f1a..fc8b9e4de4e 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -32,8 +32,8 @@ void cmNinjaUtilityTargetGenerator::Generate() { for (unsigned i = 0; i != 2; ++i) { for (std::vector::const_iterator ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) { - this->AppendCustomCommandDeps(&*ci, deps); - this->AppendCustomCommandLines(&*ci, commands); + this->GetLocalGenerator()->AppendCustomCommandDeps(&*ci, deps); + this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, commands); } } @@ -44,7 +44,7 @@ void cmNinjaUtilityTargetGenerator::Generate() { { if(cmCustomCommand* cc = (*source)->GetCustomCommand()) { - this->WriteCustomCommandBuildStatement(cc); + this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); // Depend on all custom command outputs. const std::vector& outputs = cc->GetOutputs(); @@ -65,10 +65,10 @@ void cmNinjaUtilityTargetGenerator::Generate() { cmNinjaDeps(), cmNinjaVars()); } else { - this->WriteCustomCommandRule(); + this->GetLocalGenerator()->WriteCustomCommandRule(); cmNinjaVars vars; - vars["COMMAND"] = this->BuildCommandLine(commands); + vars["COMMAND"] = this->GetLocalGenerator()->BuildCommandLine(commands); const char *desc = this->GetTarget()->GetProperty("EchoString"); if (desc) vars["DESC"] = desc; From e3353f17134bf977d9daeb7d323b54801e660cd5 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 20 Sep 2011 15:32:52 +0100 Subject: [PATCH 494/539] Write a CUSTOM_COMMAND (i.e. restat) for assumed dependencies --- Source/cmGlobalNinjaGenerator.cxx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 68adaac47fd..d3f5b453ce6 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -553,13 +553,14 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies(std::ostream& os) for (std::map >::iterator i = this->AssumedSourceDependencies.begin(); i != this->AssumedSourceDependencies.end(); ++i) { - WritePhonyBuild(os, - "Assume dependencies for generated source file.", - cmNinjaDeps(1, i->first), - cmNinjaDeps(), - cmNinjaDeps(), - cmNinjaDeps(i->second.begin(), i->second.end()), - cmNinjaVars()); + WriteBuild(os, + "Assume dependencies for generated source file.", + "CUSTOM_COMMAND", + cmNinjaDeps(1, i->first), + cmNinjaDeps(i->second.begin(), i->second.end()), + cmNinjaDeps(), + cmNinjaDeps(), + cmNinjaVars()); } } From aba4eaf03ec4dd753c3e33389a4270312f8feef7 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 21 Sep 2011 14:39:14 +0100 Subject: [PATCH 495/539] Remove an unused function --- Source/cmNinjaTargetGenerator.cxx | 49 ------------------------------- Source/cmNinjaTargetGenerator.h | 1 - 2 files changed, 50 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4d00d5e0d59..ee28f8dca09 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -471,52 +471,3 @@ ::WriteObjectBuildStatement(cmSourceFile* source) orderOnlyDeps, vars); } - -std::string -cmNinjaTargetGenerator -::ComputeLinkFlags(const std::string& linkLanguage) -{ - // The returned variables. - std::string linkFlags; - // Convenience variables. - cmLocalNinjaGenerator* lg = this->GetLocalGenerator(); - cmTarget* target = this->GetTarget(); - cmMakefile* makefile = this->GetMakefile(); - - // Add flags to create an executable. - lg->AddConfigVariableFlags(linkFlags, - "CMAKE_EXE_LINKER_FLAGS", - this->GetConfigName()); - - if(target->GetPropertyAsBool("WIN32_EXECUTABLE")) - lg->AppendFlags(linkFlags, - makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE")); - else - lg->AppendFlags(linkFlags, - makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE")); - - // Add symbol export flags if necessary. - if(target->IsExecutableWithExports()) - { - std::string export_flag_var = "CMAKE_EXE_EXPORTS_"; - export_flag_var += linkLanguage; - export_flag_var += "_FLAG"; - lg->AppendFlags(linkFlags, - makefile->GetDefinition(export_flag_var.c_str())); - } - - // Target specific link flags. - lg->AppendFlags(linkFlags, target->GetProperty("LINK_FLAGS")); - - // Configuration specific link flags. - std::string linkFlagsConfig = "LINK_FLAGS_"; - linkFlagsConfig += cmSystemTools::UpperCase(this->GetConfigName()); - lg->AppendFlags(linkFlags, target->GetProperty(linkFlagsConfig.c_str())); - - // TODO(Nicolas Despres): Let's see later for the definition files. - // It looks like something specific to Windows and Ninja is not available - // on Windows yet. - // this->AddModuleDefinitionFlag(linkFlags); - - return linkFlags; -} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 6a2d3fddbde..373aceda055 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -105,7 +105,6 @@ class cmNinjaTargetGenerator void WriteObjectBuildStatements(); void WriteObjectBuildStatement(cmSourceFile* source); void WriteCustomCommandBuildStatement(cmCustomCommand *cc); - std::string ComputeLinkFlags(const std::string& linkLanguage); cmNinjaDeps GetObjects() const { return this->Objects; } From 27921549343b6a5842669631c2ff9ff35c593839 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 21 Sep 2011 16:47:26 +0100 Subject: [PATCH 496/539] Add support for MODULE_LIBRARY --- Source/cmNinjaNormalTargetGenerator.cxx | 27 ++++++++++++++++--------- Source/cmNinjaTargetGenerator.cxx | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 5b1cc52630b..d8a44f2532c 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -85,6 +85,8 @@ const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const { return "static library"; case cmTarget::SHARED_LIBRARY: return "shared library"; + case cmTarget::MODULE_LIBRARY: + return "shared module"; case cmTarget::EXECUTABLE: return "executable"; default: @@ -201,7 +203,8 @@ std::vector cmNinjaNormalTargetGenerator ::ComputeLinkCmd() { - switch (this->GetTarget()->GetType()) { + cmTarget::TargetType targetType = this->GetTarget()->GetType(); + switch (targetType) { case cmTarget::STATIC_LIBRARY: { // Check if you have a non archive way to create the static library. { @@ -244,18 +247,22 @@ ::ComputeLinkCmd() } return linkCmds; } - case cmTarget::SHARED_LIBRARY: { - std::string linkCmdVar = "CMAKE_"; - linkCmdVar += this->TargetLinkLanguage; - linkCmdVar += "_CREATE_SHARED_LIBRARY"; - const char *linkCmd = - this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - return std::vector(1, linkCmd); - } + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: case cmTarget::EXECUTABLE: { std::string linkCmdVar = "CMAKE_"; linkCmdVar += this->TargetLinkLanguage; - linkCmdVar += "_LINK_EXECUTABLE"; + switch (targetType) { + case cmTarget::SHARED_LIBRARY: + linkCmdVar += "_CREATE_SHARED_LIBRARY"; + break; + case cmTarget::MODULE_LIBRARY: + linkCmdVar += "_CREATE_SHARED_MODULE"; + break; + case cmTarget::EXECUTABLE: + linkCmdVar += "_LINK_EXECUTABLE"; + break; + } const char *linkCmd = this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); return std::vector(1, linkCmd); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index ee28f8dca09..1c0dad6d213 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -31,6 +31,7 @@ cmNinjaTargetGenerator::New(cmTarget* target) case cmTarget::EXECUTABLE: case cmTarget::SHARED_LIBRARY: case cmTarget::STATIC_LIBRARY: + case cmTarget::MODULE_LIBRARY: return new cmNinjaNormalTargetGenerator(target); case cmTarget::UTILITY: From 53c4cd2f04ef93be7294634dbd1f2f9a456595d2 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 21 Sep 2011 18:11:05 +0100 Subject: [PATCH 497/539] Use the NINJA_BUILD_FILE constant here --- Source/cmGlobalNinjaGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index d3f5b453ce6..75062652ad7 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -623,7 +623,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) WriteBuild(os, "Re-run CMake if any of its inputs changed.", "RERUN_CMAKE", - /*outputs=*/ cmNinjaDeps(1, "build.ninja"), + /*outputs=*/ cmNinjaDeps(1, NINJA_BUILD_FILE), /*explicitDeps=*/ cmNinjaDeps(), implicitDeps, /*orderOnlyDeps=*/ cmNinjaDeps(), From 85f0b3e2a376419a0039af6ac853b5ee054706eb Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 21 Sep 2011 20:59:48 +0100 Subject: [PATCH 498/539] Consolidate all code for emitting custom commands Crucially, the description is encoded as a literal, so there is no need to do that everywhere. --- Source/cmGlobalNinjaGenerator.cxx | 52 ++++++++++++++++++++---- Source/cmGlobalNinjaGenerator.h | 10 +++++ Source/cmLocalNinjaGenerator.cxx | 30 ++++---------- Source/cmNinjaUtilityTargetGenerator.cxx | 49 ++++++++-------------- 4 files changed, 79 insertions(+), 62 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 75062652ad7..bb0157b587f 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -71,6 +71,12 @@ std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string &ident, } } +std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string &lit) { + std::string result = lit; + cmSystemTools::ReplaceString(result, "$", "$$"); + return result; +} + void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, const std::string& comment, const std::string& rule, @@ -174,6 +180,40 @@ void cmGlobalNinjaGenerator::WritePhonyBuild(std::ostream& os, variables); } +void cmGlobalNinjaGenerator::AddCustomCommandRule() +{ + this->AddRule("CUSTOM_COMMAND", + "$COMMAND", + "$DESC", + "Rule for running custom commands.", + /*depfile*/ "", + /*restat*/ true); +} + +void +cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command, + const std::string& description, + const std::string& comment, + const cmNinjaDeps& outputs, + const cmNinjaDeps& deps, + const cmNinjaDeps& orderOnlyDeps) +{ + this->AddCustomCommandRule(); + + cmNinjaVars vars; + vars["COMMAND"] = command; + vars["DESC"] = EncodeLiteral(description); + + cmGlobalNinjaGenerator::WriteBuild(*this->BuildFileStream, + comment, + "CUSTOM_COMMAND", + outputs, + deps, + cmNinjaDeps(), + orderOnlyDeps, + vars); +} + void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, const std::string& name, const std::string& command, @@ -553,14 +593,10 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies(std::ostream& os) for (std::map >::iterator i = this->AssumedSourceDependencies.begin(); i != this->AssumedSourceDependencies.end(); ++i) { - WriteBuild(os, - "Assume dependencies for generated source file.", - "CUSTOM_COMMAND", - cmNinjaDeps(1, i->first), - cmNinjaDeps(i->second.begin(), i->second.end()), - cmNinjaDeps(), - cmNinjaDeps(), - cmNinjaVars()); + WriteCustomCommandBuild(/*command=*/"", /*description=*/"", + "Assume dependencies for generated source file.", + cmNinjaDeps(1, i->first), + cmNinjaDeps(i->second.begin(), i->second.end())); } } diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 1af3a41ca74..5d0fdd25ec8 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -57,6 +57,7 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator static void WriteDivider(std::ostream& os); static std::string EncodeIdent(const std::string &ident, std::ostream &vars); + static std::string EncodeLiteral(const std::string &lit); /** * Write the given @a comment to the output stream @a os. It @@ -90,6 +91,13 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator const cmNinjaDeps& orderOnlyDeps, const cmNinjaVars& variables); + void WriteCustomCommandBuild(const std::string& command, + const std::string& description, + const std::string& comment, + const cmNinjaDeps& outputs, + const cmNinjaDeps& deps = cmNinjaDeps(), + const cmNinjaDeps& orderOnlyDeps = cmNinjaDeps()); + /** * Write a rule statement named @a name to @a os with the @a comment, * the mandatory @a command, the @a depfile and the @a description. @@ -208,6 +216,8 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator bool HasRule(const std::string& name); + void AddCustomCommandRule(); + protected: /// Overloaded methods. diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 742e2409544..0d51427d61a 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -361,15 +361,6 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, } } -void cmLocalNinjaGenerator::WriteCustomCommandRule() { - this->GetGlobalNinjaGenerator()->AddRule("CUSTOM_COMMAND", - "$COMMAND", - "$DESC", - "Rule for running custom commands.", - /*depfile*/ "", - /*restat*/ true); -} - void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc, const cmNinjaDeps& orderOnlyDeps) { @@ -400,20 +391,13 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc, orderOnlyDeps, cmNinjaVars()); } else { - this->WriteCustomCommandRule(); - - cmNinjaVars vars; - vars["COMMAND"] = this->BuildCommandLine(cmdLines); - vars["DESC"] = this->ConstructComment(*cc); - - cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - "Custom command for " + ninjaOutputs[0], - "CUSTOM_COMMAND", - ninjaOutputs, - ninjaDeps, - cmNinjaDeps(), - orderOnlyDeps, - vars); + this->GetGlobalNinjaGenerator()->WriteCustomCommandBuild( + this->BuildCommandLine(cmdLines), + this->ConstructComment(*cc), + "Custom command for " + ninjaOutputs[0], + ninjaOutputs, + ninjaDeps, + orderOnlyDeps); } } diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index fc8b9e4de4e..88f03fbccc1 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -11,15 +11,6 @@ cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(cmTarget *target) cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() {} -static void find_replace(std::string &str, const std::string &find, - const std::string &replace) { - std::string::size_type pos = 0; - while ((pos = str.find(find, pos)) != std::string::npos) { - str.replace(pos, find.size(), replace); - pos += replace.size(); - } -} - void cmNinjaUtilityTargetGenerator::Generate() { std::vector commands; cmNinjaDeps deps; @@ -65,38 +56,34 @@ void cmNinjaUtilityTargetGenerator::Generate() { cmNinjaDeps(), cmNinjaVars()); } else { - this->GetLocalGenerator()->WriteCustomCommandRule(); - - cmNinjaVars vars; - vars["COMMAND"] = this->GetLocalGenerator()->BuildCommandLine(commands); - const char *desc = this->GetTarget()->GetProperty("EchoString"); - if (desc) - vars["DESC"] = desc; + std::string command = this->GetLocalGenerator()->BuildCommandLine(commands); + const char *echoStr = this->GetTarget()->GetProperty("EchoString"); + std::string desc; + if (echoStr) + desc = echoStr; else - vars["DESC"] = "Running utility command for " + this->GetTargetName(); + desc = "Running utility command for " + this->GetTargetName(); // TODO: fix problematic global targets. For now, search and replace the // makefile vars. - find_replace(vars["COMMAND"], "$(CMAKE_SOURCE_DIR)", - this->GetTarget()->GetMakefile()->GetHomeDirectory()); - find_replace(vars["COMMAND"], "$(CMAKE_BINARY_DIR)", - this->GetTarget()->GetMakefile()->GetHomeOutputDirectory()); - find_replace(vars["COMMAND"], "$(ARGS)", ""); + cmSystemTools::ReplaceString(command, "$(CMAKE_SOURCE_DIR)", + this->GetTarget()->GetMakefile()->GetHomeDirectory()); + cmSystemTools::ReplaceString(command, "$(CMAKE_BINARY_DIR)", + this->GetTarget()->GetMakefile()->GetHomeOutputDirectory()); + cmSystemTools::ReplaceString(command, "$(ARGS)", ""); - if (vars["COMMAND"].find('$') != std::string::npos) + if (command.find('$') != std::string::npos) return; std::string utilCommandName = cmake::GetCMakeFilesDirectoryPostSlash(); utilCommandName += this->GetTargetName() + ".util"; - cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - "Utility command for " + this->GetTargetName(), - "CUSTOM_COMMAND", - cmNinjaDeps(1, utilCommandName), - deps, - cmNinjaDeps(), - cmNinjaDeps(), - vars); + this->GetGlobalGenerator()->WriteCustomCommandBuild( + command, + desc, + "Utility command for " + this->GetTargetName(), + cmNinjaDeps(1, utilCommandName), + deps); cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), "", From a5e75c2362279de1844efe484045c02931cda222 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 21 Sep 2011 21:57:30 +0100 Subject: [PATCH 499/539] Add support for external objects --- Source/cmNinjaTargetGenerator.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 1c0dad6d213..ad3a848da22 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -407,8 +407,11 @@ ::WriteObjectBuildStatement(cmSourceFile* source) const char* language = source->GetLanguage(); // If we cannot get the language this is probably a non-source file provided // in the list (typically an header file). - if (!language) + if (!language) { + if (source->GetPropertyAsBool("EXTERNAL_OBJECT")) + this->Objects.push_back(this->GetSourceFilePath(source)); return; + } std::string rule = this->LanguageCompilerRule(language); cmNinjaDeps outputs; From 3d7e1d2da14cb2d20435ef61f31d0ea8f497d956 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 21 Sep 2011 17:15:44 +0100 Subject: [PATCH 500/539] Error out if we could not determine the linker language --- Source/cmNinjaNormalTargetGenerator.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index d8a44f2532c..1e7f54c6af1 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -47,13 +47,19 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() void cmNinjaNormalTargetGenerator::Generate() { + if (!this->TargetLinkLanguage) { + cmSystemTools::Error("CMake can not determine linker language for target:", + this->GetTarget()->GetName()); + return; + } + // Write the rules for each language. this->WriteLanguagesRules(); // Write the build statements this->WriteObjectBuildStatements(); - // Write the link statement. + this->WriteLinkRule(); this->WriteLinkStatement(); this->GetBuildFileStream() << "\n"; @@ -76,7 +82,6 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() l != languages.end(); ++l) this->WriteLanguageRules(*l); - this->WriteLinkRule(); } const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const { From f3c92c52a90cd739b459c297c6d163e45ad09c83 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 01:46:28 +0100 Subject: [PATCH 501/539] Remove uselessly overridden method --- Source/cmLocalNinjaGenerator.cxx | 12 ------------ Source/cmLocalNinjaGenerator.h | 4 ---- 2 files changed, 16 deletions(-) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 0d51427d61a..f78f7399bb0 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -140,18 +140,6 @@ ::GetObjectFileName(const cmTarget& target, //---------------------------------------------------------------------------- // Virtual protected methods. -// Implemented only in cmLocalVisualStudio6Generator. -// Used in: -// Source/cmLocalGenerator.cxx -// Source/cmLocalVisualStudio6Generator.cxx -bool cmLocalNinjaGenerator::CheckDefinition(std::string const& define) const -{ - - bool ret = cmLocalGenerator::CheckDefinition(define); - - return ret; -} - std::string cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib) { return this->Convert(lib.c_str(), HOME_OUTPUT, SHELL); diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 0b3fb59911e..a382c6de7e6 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -68,10 +68,6 @@ class cmLocalNinjaGenerator : public cmLocalGenerator { return this->HomeRelativeOutputPath; } protected: - - /// Overloaded methods. @see cmLocalGenerator::CheckDefinition() - virtual bool CheckDefinition(std::string const& define) const; - virtual std::string ConvertToLinkReference(std::string const& lib); virtual std::string ConvertToIncludeReference(std::string const& path); From f916b70281ab25b0ccf34d0abd9b8583c7a12029 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 03:14:18 +0100 Subject: [PATCH 502/539] Changes to ExternalProject.cmake necessary to make it work with Ninja It seems to work and pass the tests (with Ninja and Make), in spite of comments admonishing against doing exactly what I did. --- Modules/ExternalProject.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index a37771b929a..d41693a5c21 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -833,6 +833,12 @@ function(ExternalProject_Add_StepTargets name) foreach(step ${steps}) add_custom_target(${name}-${step} DEPENDS ${stamp_dir}${cfgdir}/${name}-${step}) + + # Depend on other external projects (target-level). + get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS) + foreach(arg IN LISTS deps) + add_dependencies(${name}-${step} ${arg}) + endforeach() endforeach() endfunction(ExternalProject_Add_StepTargets) @@ -1453,6 +1459,7 @@ function(ExternalProject_Add name) # other external project targets. add_custom_command( OUTPUT ${cmf_dir}${cfgdir}/${name}-complete + ${stamp_dir}${cfgdir}/${name}-done COMMENT "Completed '${name}'" COMMAND ${CMAKE_COMMAND} -E make_directory ${cmf_dir}${cfgdir} COMMAND ${CMAKE_COMMAND} -E touch ${cmf_dir}${cfgdir}/${name}-complete From 58b060c3b6ffcfaaab0f76dc1db4331b11e14af8 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 04:30:25 +0100 Subject: [PATCH 503/539] Respect the HEADER_FILE_ONLY source file property --- Source/cmNinjaTargetGenerator.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index ad3a848da22..8bca60e8b35 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -412,6 +412,10 @@ ::WriteObjectBuildStatement(cmSourceFile* source) this->Objects.push_back(this->GetSourceFilePath(source)); return; } + + if (source->GetPropertyAsBool("HEADER_FILE_ONLY")) + return; + std::string rule = this->LanguageCompilerRule(language); cmNinjaDeps outputs; From 8bde25ad64f4adbf3bb4a5e0b24be02df6fa71a5 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 04:50:07 +0100 Subject: [PATCH 504/539] Run PRE_BUILD and PRE_LINK commands --- Source/cmNinjaNormalTargetGenerator.cxx | 36 ++++++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1e7f54c6af1..aaffa6792dd 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -167,6 +167,7 @@ ::WriteLinkRule() { this->GetLocalGenerator()->ExpandRuleVariables(*i, vars); } + linkCmds.insert(linkCmds.begin(), "$PRE_LINK"); linkCmds.push_back("$POST_BUILD"); std::string linkCmd = this->GetLocalGenerator()->BuildCommandLine(linkCmds); @@ -316,14 +317,35 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->GetConfigName()); vars["SONAME"] = this->TargetNameSO; - std::vector &postBuildCmds = - this->GetTarget()->GetPostBuildCommands(); - std::vector postBuildCmdLines; - for (std::vector::const_iterator ci = postBuildCmds.begin(); - ci != postBuildCmds.end(); ++ci) { - this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, - postBuildCmdLines); + std::vector *cmdLists[3] = { + &this->GetTarget()->GetPreBuildCommands(), + &this->GetTarget()->GetPreLinkCommands(), + &this->GetTarget()->GetPostBuildCommands() + }; + + std::vector preLinkCmdLines, postBuildCmdLines; + std::vector *cmdLineLists[3] = { + &preLinkCmdLines, + &preLinkCmdLines, + &postBuildCmdLines + }; + + for (unsigned i = 0; i != 3; ++i) { + for (std::vector::const_iterator ci = cmdLists[i]->begin(); + ci != cmdLists[i]->end(); ++ci) { + this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, + *cmdLineLists[i]); + } } + + // If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for + // the link commands. + if (!preLinkCmdLines.empty()) + preLinkCmdLines.push_back(std::string("cd ") + + this->GetMakefile()->GetHomeOutputDirectory()); + + vars["PRE_LINK"] = + this->GetLocalGenerator()->BuildCommandLine(preLinkCmdLines); vars["POST_BUILD"] = this->GetLocalGenerator()->BuildCommandLine(postBuildCmdLines); From dbe33bcf47ffeb013cc9e5d54989109d0424c796 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 05:00:04 +0100 Subject: [PATCH 505/539] Fix a bug in SystemTools::Trimmed, and give it a better name --- Source/cmGlobalNinjaGenerator.cxx | 2 +- Source/kwsys/SystemTools.cxx | 30 ++++++++++-------------------- Source/kwsys/SystemTools.hxx.in | 2 +- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index bb0157b587f..25f9f4368f6 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -296,7 +296,7 @@ void cmGlobalNinjaGenerator::WriteVariable(std::ostream& os, } // Do not add a variable if the value is empty. - std::string val = cmSystemTools::Trimmed(value); + std::string val = cmSystemTools::TrimWhitespace(value); if(val.empty()) { return; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index da07541e93a..c14eb3847ad 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1196,28 +1196,18 @@ kwsys_stl::string SystemTools::UpperCase(const kwsys_stl::string& s) } // Returns a string that has whitespace removed from the start and the end. -kwsys_stl::string SystemTools::Trimmed(const kwsys_stl::string& s) +kwsys_stl::string SystemTools::TrimWhitespace(const kwsys_stl::string& s) { - kwsys_stl::string::const_iterator i = s.begin(); - while(i != s.end() && *i == ' ') - ++i; - kwsys_stl::string::const_iterator start = i; - - kwsys_stl::string::const_iterator stop = i; - while(i != s.end()) - { - if(*i != ' ') - stop = i; - ++i; - } - - if(start != stop) - ++stop; + kwsys_stl::string::const_iterator start = s.begin(); + while(start != s.end() && *start == ' ') + ++start; + if (start == s.end()) + return ""; - kwsys_stl::string n; - n.resize(stop - start); - copy(start, stop, n.begin()); - return n; + kwsys_stl::string::const_iterator stop = s.end()-1; + while(*stop == ' ') + --stop; + return kwsys_stl::string(start, stop+1); } // Count char in string diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 9ba4ecd82dc..c03b8bca880 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -131,7 +131,7 @@ public: /** * Returns a string that has whitespace removed from the start and the end. */ - static kwsys_stl::string Trimmed(const kwsys_stl::string& s); + static kwsys_stl::string TrimWhitespace(const kwsys_stl::string& s); /** * Count char in string From 5a6404f2217eb1f2d4ae4d84da282b4e425c9082 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 04:51:02 +0100 Subject: [PATCH 506/539] ":" is shorter than "true" --- Source/cmLocalNinjaGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index f78f7399bb0..5b315efdf45 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -310,11 +310,11 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, c } std::string cmLocalNinjaGenerator::BuildCommandLine(const std::vector &cmdLines) { - // If we have no commands but we need to build a command anyway, use "true". + // If we have no commands but we need to build a command anyway, use ":". // This happens when building a POST_BUILD value for link targets that // don't use POST_BUILD. if (cmdLines.empty()) - return "true"; + return ":"; // TODO: This will work only on Unix platforms. I don't // want to use a link.txt file because I will loose the benefit of the From e81a789e93d9565a4aa6bcb5c4f63e79e216a00f Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 19:28:52 +0100 Subject: [PATCH 507/539] Mark the RERUN_CMAKE rule as a "generator" rule --- Source/cmGlobalNinjaGenerator.cxx | 14 +++++++++++++- Source/cmGlobalNinjaGenerator.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 25f9f4368f6..c48c51bcf2d 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -221,6 +221,7 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, const std::string& comment, const std::string& depfile, bool restat, + bool generator, const cmNinjaVars& variables) { // Make sure the rule has a name. @@ -270,6 +271,12 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, os << "restat = 1\n"; } + if(generator) + { + cmGlobalNinjaGenerator::Indent(os, 1); + os << "generator = 1\n"; + } + // Write the variables bound to this build statement. if(!variables.empty()) { @@ -459,6 +466,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, const std::string& comment, const std::string& depfile, bool restat, + bool generator, const cmNinjaVars& variables) { // Do not add twice the same rule. @@ -473,6 +481,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, comment, depfile, restat, + generator, variables); } @@ -643,7 +652,10 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) "RERUN_CMAKE", cmd.str(), "Re-running CMake...", - "Rule for re-running cmake."); + "Rule for re-running cmake.", + /*depfile=*/ "", + /*restat=*/ false, + /*generator=*/ true); cmNinjaDeps implicitDeps; for (std::vector::const_iterator i = diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 5d0fdd25ec8..1e3f6c1e71e 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -111,6 +111,7 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator const std::string& comment = "", const std::string& depfile = "", bool restat = false, + bool generator = false, const cmNinjaVars& variables = cmNinjaVars()); /** @@ -212,6 +213,7 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator const std::string& comment = "", const std::string& depfile = "", bool restat = false, + bool generator = false, const cmNinjaVars& variables = cmNinjaVars()); bool HasRule(const std::string& name); From 5afa1a57c87ecf73ecb58116afdebb8fa1df8d42 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 19:31:10 +0100 Subject: [PATCH 508/539] Use the "clean" tool instead of the non-existent "clean" target --- Source/cmGlobalNinjaGenerator.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index c48c51bcf2d..c412eaffa17 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -450,8 +450,15 @@ ::GenerateBuildCommand(const char* makeProgram, } if(targetName) { - makeCommand += " "; - makeCommand += targetName; + if(strcmp(targetName, "clean") == 0) + { + makeCommand += " -t clean"; + } + else + { + makeCommand += " "; + makeCommand += targetName; + } } return makeCommand; From 40f3348f2c9851585785a120468895b16c095100 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 20:01:56 +0100 Subject: [PATCH 509/539] Switch to a more reliable way of detecting that we are in try-compile --- Source/cmNinjaTargetGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 8bca60e8b35..e7801e70541 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -343,7 +343,7 @@ ::WriteCompileRule(const std::string& language) vars.Source = "$in"; vars.Object = "$out"; - if (this->GetTargetName() == "cmTryCompileExec") + if (this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile()) vars.Flags = "$FLAGS"; else vars.Flags = "-MMD -MF $out.d $FLAGS"; From 13c2613ca9c246f015ed588d6aceb4be15db9770 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 20:07:55 +0100 Subject: [PATCH 510/539] The Ninja generator should not have a preinstall rule This causes it to respect CMAKE_SKIP_INSTALL_ALL_DEPENDENCY and CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY. --- Source/cmGlobalNinjaGenerator.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 1e3f6c1e71e..9b85efc2ab8 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -187,7 +187,6 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator virtual const char* GetInstallTargetName() const { return "install"; } virtual const char* GetInstallLocalTargetName() const { return "install/local"; } virtual const char* GetInstallStripTargetName() const { return "install/strip"; } - virtual const char* GetPreinstallTargetName() const { return "all"; } virtual const char* GetTestTargetName() const { return "test"; } virtual const char* GetPackageTargetName() const { return "package"; } virtual const char* GetPackageSourceTargetName() const { return "package_source"; } From 0eac279b2e40f5f7cf58592bb5fa6082d9e163c8 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 20:24:17 +0100 Subject: [PATCH 511/539] Attach POST_BUILD commands to symlink rule if we have to create a symlink --- Source/cmNinjaNormalTargetGenerator.cxx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index aaffa6792dd..d1eeaef1808 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -192,14 +192,14 @@ ::WriteLinkRule() this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_EXECUTABLE", cmakeCommand + " -E cmake_symlink_executable" - " $in $out", + " $in $out && $POST_BUILD", "Creating executable symlink $out", "Rule for creating executable symlink."); else this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", cmakeCommand + " -E cmake_symlink_library" - " $in $SONAME $out", + " $in $SONAME $out && $POST_BUILD", "Creating library symlink $out", "Rule for creating library symlink."); } @@ -346,9 +346,17 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["PRE_LINK"] = this->GetLocalGenerator()->BuildCommandLine(preLinkCmdLines); - vars["POST_BUILD"] = + std::string postBuildCmdLine = this->GetLocalGenerator()->BuildCommandLine(postBuildCmdLines); + cmNinjaVars symlinkVars; + if (targetOutput == targetOutputReal) { + vars["POST_BUILD"] = postBuildCmdLine; + } else { + vars["POST_BUILD"] = ":"; + symlinkVars["POST_BUILD"] = postBuildCmdLine; + } + // Write the build statement for this target. cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), comment.str(), @@ -368,9 +376,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmNinjaDeps(1, targetOutputReal), emptyDeps, emptyDeps, - cmNinjaVars()); + symlinkVars); } else { - cmNinjaVars symlinkVars; symlinkVars["SONAME"] = this->GetTargetFilePath(this->TargetNameSO); cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), "Create library symlink " + targetOutput, From d486803752b2a1f99f011b0ad80006bca70034c5 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 21:20:25 +0100 Subject: [PATCH 512/539] Use cmGlobalGenerator::IsExcluded to determine if a target should be excluded from all Now we respect the EXCLUDE_FROM_ALL property on directories. --- Source/cmLocalNinjaGenerator.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 5b315efdf45..28e48c5bfe8 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -54,7 +54,9 @@ void cmLocalNinjaGenerator::Generate() { tg->Generate(); // Add the target to "all" if required. - if (!t->second.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if (!this->GetGlobalNinjaGenerator()->IsExcluded( + this->GetGlobalNinjaGenerator()->LocalGenerators[0], + t->second)) this->AddDependencyToAll(tg->GetTargetName()); delete tg; } From a36273abd63c5cf1d7d517aa39b565c62c9e4499 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 21:34:40 +0100 Subject: [PATCH 513/539] Modify the SubProject-Stage2 test This test specifically checks that we output build system files in each directory, by running the test in a subdirectory of the build directory. Since the Ninja generator deliberately does not do this, run the test from the root build directory for Ninja only. --- Tests/CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 21d1196c022..e10e6f3b7b5 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -325,6 +325,13 @@ IF(BUILD_TESTING) --build-target car --test-command car ) + + IF(${CMAKE_TEST_GENERATOR} MATCHES "Ninja") + SET(SubProject_SUBDIR) + ELSE() + SET(SubProject_SUBDIR "/foo") + ENDIF() + # For stage 2, do not run cmake again. # Then build the foo sub project which should build # the bar library which should be referenced because @@ -332,13 +339,14 @@ IF(BUILD_TESTING) # directly in the foo sub project ADD_TEST(SubProject-Stage2 ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/SubProject/foo" - "${CMake_BINARY_DIR}/Tests/SubProject/foo" + "${CMake_SOURCE_DIR}/Tests/SubProject${SubProject_SUBDIR}" + "${CMake_BINARY_DIR}/Tests/SubProject${SubProject_SUBDIR}" --build-generator ${CMAKE_TEST_GENERATOR} --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-nocmake --build-project foo --build-target foo + --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubProject/foo" --test-command foo ) SET_TESTS_PROPERTIES ( SubProject-Stage2 PROPERTIES DEPENDS SubProject) From e3d58d8f5262ae1f391921cd1393bd7086759a35 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 22 Sep 2011 21:55:54 +0100 Subject: [PATCH 514/539] Make the OutOfSourceSubdir test more compatible with Ninja by reducing the length of the paths it generates. --- Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt index c7cc0901654..c362e79ba66 100644 --- a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt +++ b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt @@ -24,6 +24,12 @@ IF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}") MATH(EXPR MAXPATH "${MAXPATH} - 46") ENDIF() + # Ninja imposes a maximum path component count of 30. Permit more + # path components in the source path. + IF(${CMAKE_GENERATOR} MATCHES "Ninja") + MATH(EXPR MAXPATH "${MAXPATH} - 44") + ENDIF() + # MAXPATH less 25 for last /and/deeper/simple.cxx part and small safety MATH(EXPR MAXPATH "${MAXPATH} - 25") STRING(LENGTH "${DEEPDIR}" DEEPDIR_LEN) From 5692844d7b61b850dbd8f4553b2fc0b8d907edc4 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 23 Sep 2011 01:44:07 +0100 Subject: [PATCH 515/539] Now we have Make-style order-only deps, we can just depend on the target name --- Source/cmLocalNinjaGenerator.cxx | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 28e48c5bfe8..362dd4abfcc 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -274,19 +274,9 @@ ::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) { break; } - case cmTarget::UTILITY: { - const std::vector& sources = target->GetSourceFiles(); - for(std::vector::const_iterator source = sources.begin(); - source != sources.end(); ++source) { - if(cmCustomCommand* cc = (*source)->GetCustomCommand()) { - if (!cc->GetCommandLines().empty()) { - const std::vector& ccoutputs = cc->GetOutputs(); - std::transform(ccoutputs.begin(), ccoutputs.end(), - std::back_inserter(outputs), MapToNinjaPath()); - } - } - } - } + case cmTarget::UTILITY: + outputs.push_back(target->GetName()); + break; } } From dedc230d3bfa8feb60e7eb995a558010634ef892 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 23 Sep 2011 02:43:03 +0100 Subject: [PATCH 516/539] Have utilities depend on their target dependencies, rather than their utilities This helps filter out non-existent utilities (I'm looking at you, path64) and is more reliable for depending on an EXECUTABLE (etc.) "utility". --- Source/cmNinjaUtilityTargetGenerator.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 88f03fbccc1..50f0ea324b2 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -44,8 +44,7 @@ void cmNinjaUtilityTargetGenerator::Generate() { } } - std::set const& utils = this->GetTarget()->GetUtilities(); - deps.insert(deps.end(), utils.begin(), utils.end()); + this->GetLocalGenerator()->AppendTargetDepends(this->GetTarget(), deps); if (commands.empty()) { cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), From c007075dec71dd3dbe23342c230505239be70424 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 23 Sep 2011 05:27:37 +0100 Subject: [PATCH 517/539] Introduce new scheme for target aliases Each target has an alias for its name as well as the basename of the main file created. If an ambiguity arises then no alias is created at all. --- Source/cmGlobalNinjaGenerator.cxx | 104 +++++++++++++++++++++-- Source/cmGlobalNinjaGenerator.h | 21 +++-- Source/cmLocalNinjaGenerator.cxx | 36 +------- Source/cmLocalNinjaGenerator.h | 3 +- Source/cmNinjaNormalTargetGenerator.cxx | 5 +- Source/cmNinjaTargetGenerator.cxx | 41 --------- Source/cmNinjaTargetGenerator.h | 7 -- Source/cmNinjaUtilityTargetGenerator.cxx | 10 ++- 8 files changed, 126 insertions(+), 101 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index c412eaffa17..265a1277db0 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -379,6 +379,7 @@ void cmGlobalNinjaGenerator::Generate() this->cmGlobalGenerator::Generate(); this->WriteAssumedSourceDependencies(*this->BuildFileStream); + this->WriteTargetAliases(*this->BuildFileStream); this->WriteBuiltinTargets(*this->BuildFileStream); this->CloseRulesFileStream(); @@ -599,9 +600,9 @@ void cmGlobalNinjaGenerator::WriteDisclaimer(std::ostream& os) << cmVersion::GetMinorVersion() << "\n\n"; } -void cmGlobalNinjaGenerator::AddDependencyToAll(const std::string& dependency) +void cmGlobalNinjaGenerator::AddDependencyToAll(cmTarget* target) { - this->AllDependencies.push_back(dependency); + this->AppendTargetOutputs(target, this->AllDependencies); } void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies(std::ostream& os) @@ -616,6 +617,97 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies(std::ostream& os) } } +void +cmGlobalNinjaGenerator +::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) { + std::string name, dir; + const char* configName = + target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE"); + + switch (target->GetType()) { + case cmTarget::EXECUTABLE: + case cmTarget::SHARED_LIBRARY: + case cmTarget::STATIC_LIBRARY: + case cmTarget::MODULE_LIBRARY: + name = target->GetFullName(configName); + dir = target->GetDirectory(configName); + break; + + case cmTarget::UTILITY: + dir = target->GetMakefile()->GetStartOutputDirectory(); + case cmTarget::GLOBAL_TARGET: + // dir is always "" for GLOBAL_TARGETs so that we use the target in HOME + name = target->GetName(); + break; + + default: + return; + } + + std::string path = + static_cast(this->LocalGenerators[0]) + ->ConvertToNinjaPath(dir.c_str()); + if (path.empty() || path == ".") + outputs.push_back(name); + else { + path += "/"; + path += name; + outputs.push_back(path); + } +} + +void +cmGlobalNinjaGenerator +::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) { + if (target->GetType() == cmTarget::GLOBAL_TARGET) { + // Global targets only depend on other utilities, which may not appear in + // the TargetDepends set (e.g. "all"). + std::set const& utils = target->GetUtilities(); + outputs.insert(outputs.end(), utils.begin(), utils.end()); + } else { + cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(*target); + for (cmTargetDependSet::const_iterator i = targetDeps.begin(); + i != targetDeps.end(); ++i) { + this->AppendTargetOutputs(*i, outputs); + } + } +} + +void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias, + cmTarget* target) { + cmNinjaDeps outputs; + this->AppendTargetOutputs(target, outputs); + // Mark the target's outputs as ambiguous to ensure that no other target uses + // the output as an alias. + for (cmNinjaDeps::iterator i = outputs.begin(); i != outputs.end(); ++i) + TargetAliases[*i] = 0; + + // Insert the alias into the map. If the alias was already present in the + // map and referred to another target, mark it as ambiguous. + std::pair newAlias = + TargetAliases.insert(make_pair(alias, target)); + if (newAlias.second && newAlias.first->second != target) + newAlias.first->second = 0; +} + +void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) +{ + for (TargetAliasMap::iterator i = TargetAliases.begin(); + i != TargetAliases.end(); ++i) { + // Don't write ambiguous aliases. + if (!i->second) + continue; + + cmNinjaDeps deps; + this->AppendTargetOutputs(i->second, deps); + + cmGlobalNinjaGenerator::WritePhonyBuild(os, + "Target alias.", + cmNinjaDeps(1, i->first), + deps); + } +} + void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os) { // Write headers. @@ -628,19 +720,13 @@ void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os) void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os) { - cmNinjaDeps emptyDeps; - cmNinjaVars emptyVars; - cmNinjaDeps outputs; outputs.push_back("all"); cmGlobalNinjaGenerator::WritePhonyBuild(os, "The main all target.", outputs, - this->AllDependencies, - emptyDeps, - emptyDeps, - emptyVars); + this->AllDependencies); cmGlobalNinjaGenerator::WriteDefault(os, outputs, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 9b85efc2ab8..a657f674ac7 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -87,9 +87,9 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator const std::string& comment, const cmNinjaDeps& outputs, const cmNinjaDeps& explicitDeps, - const cmNinjaDeps& implicitDeps, - const cmNinjaDeps& orderOnlyDeps, - const cmNinjaVars& variables); + const cmNinjaDeps& implicitDeps = cmNinjaDeps(), + const cmNinjaDeps& orderOnlyDeps = cmNinjaDeps(), + const cmNinjaVars& variables = cmNinjaVars()); void WriteCustomCommandBuild(const std::string& command, const std::string& description, @@ -231,6 +231,8 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator // In order to access the SeenCustomCommand() function. friend class cmNinjaTargetGenerator; + friend class cmNinjaNormalTargetGenerator; + friend class cmNinjaUtilityTargetGenerator; private: void OpenBuildFileStream(); @@ -242,9 +244,16 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator /// Write the common disclaimer text at the top of each build file. void WriteDisclaimer(std::ostream& os); - void AddDependencyToAll(const std::string& dependency); + void AddDependencyToAll(cmTarget* target); void WriteAssumedSourceDependencies(std::ostream& os); + + void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs); + void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); + + void AddTargetAlias(const std::string& alias, cmTarget* target); + void WriteTargetAliases(std::ostream& os); + void WriteBuiltinTargets(std::ostream& os); void WriteTargetAll(std::ostream& os); void WriteTargetRebuildManifest(std::ostream& os); @@ -268,7 +277,6 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator this->CustomCommandOutputs.end(); } - void AddAssumedSourceDependencies(const std::string &source, const cmNinjaDeps &deps) { std::set &ASD = this->AssumedSourceDependencies[source]; @@ -304,6 +312,9 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator /// The mapping from source file to assumed dependencies. std::map > AssumedSourceDependencies; + + typedef std::map TargetAliasMap; + TargetAliasMap TargetAliases; }; #endif // ! cmGlobalNinjaGenerator_h diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 362dd4abfcc..62b2e6091bd 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -57,7 +57,7 @@ void cmLocalNinjaGenerator::Generate() if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->LocalGenerators[0], t->second)) - this->AddDependencyToAll(tg->GetTargetName()); + this->GetGlobalNinjaGenerator()->AddDependencyToAll(&t->second); delete tg; } } @@ -229,11 +229,6 @@ void cmLocalNinjaGenerator::SetConfigName() } } -void cmLocalNinjaGenerator::AddDependencyToAll(const std::string& dependency) -{ - this->GetGlobalNinjaGenerator()->AddDependencyToAll(dependency); -} - void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) { cmGlobalNinjaGenerator::WriteDivider(os); @@ -257,38 +252,13 @@ std::string cmLocalNinjaGenerator::ConvertToNinjaPath(const char *path) void cmLocalNinjaGenerator ::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) { - switch (target->GetType()) { - case cmTarget::EXECUTABLE: - case cmTarget::SHARED_LIBRARY: - case cmTarget::STATIC_LIBRARY: { - std::string name = target->GetFullName(this->GetConfigName()); - std::string dir = target->GetDirectory(this->GetConfigName()); - std::string path = ConvertToNinjaPath(dir.c_str()); - if (path.empty() || path == ".") - outputs.push_back(name); - else { - path += "/"; - path += name; - outputs.push_back(path); - } - break; - } - - case cmTarget::UTILITY: - outputs.push_back(target->GetName()); - break; - } + this->GetGlobalNinjaGenerator()->AppendTargetOutputs(target, outputs); } void cmLocalNinjaGenerator ::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) { - cmTargetDependSet const& targetDeps = - this->GetGlobalGenerator()->GetTargetDirectDepends(*target); - for (cmTargetDependSet::const_iterator i = targetDeps.begin(); - i != targetDeps.end(); ++i) { - this->AppendTargetOutputs(*i, outputs); - } + this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs); } void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, cmNinjaDeps &ninjaDeps) { diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index a382c6de7e6..45d78d87673 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -72,6 +72,8 @@ class cmLocalNinjaGenerator : public cmLocalGenerator virtual std::string ConvertToIncludeReference(std::string const& path); private: + friend class cmGlobalNinjaGenerator; + // In order to access to protected member of the local generator. friend class cmNinjaTargetGenerator; friend class cmNinjaNormalTargetGenerator; @@ -84,7 +86,6 @@ class cmLocalNinjaGenerator : public cmLocalGenerator void WriteBuildFileTop(); void WriteProjectHeader(std::ostream& os); void WriteNinjaFilesInclusion(std::ostream& os); - void AddDependencyToAll(const std::string& dependency); void WriteProcessedMakefile(std::ostream& os); void SetConfigName(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index d1eeaef1808..dc4c3e10581 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -390,6 +390,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } } - // Write a shortcut rule with the target name. - this->WriteTargetBuild(this->TargetNameOut, targetOutput); + // Add aliases for the file name and the target name. + this->GetGlobalGenerator()->AddTargetAlias(this->TargetNameOut, this->GetTarget()); + this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(), this->GetTarget()); } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index e7801e70541..c568226373f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -274,47 +274,6 @@ ::GetTargetFilePath(const std::string& name) const path += name; return path; } -void -cmNinjaTargetGenerator -::WriteTargetBuild(const std::string& outputName, - const std::string& outputPath) -{ - cmNinjaDeps emptyDeps; - cmNinjaVars emptyVars; - - if(outputName != outputPath) - { - std::string comment = "Shortcut target for the output name."; - cmNinjaDeps outputs; - outputs.push_back(outputName); - cmNinjaDeps deps; - deps.push_back(outputPath); - cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), - comment, - outputs, - deps, - emptyDeps, - emptyDeps, - emptyVars); - } - - std::string targetName = this->GetTargetName(); - if(targetName != outputName) - { - std::string comment = "Shortcut target for the target name."; - cmNinjaDeps outputs; - outputs.push_back(targetName); - cmNinjaDeps deps; - deps.push_back(outputName); - cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), - comment, - outputs, - deps, - emptyDeps, - emptyDeps, - emptyVars); - } -} std::string cmNinjaTargetGenerator::GetTargetName() const { diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 373aceda055..f1c067df489 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -93,13 +93,6 @@ class cmNinjaTargetGenerator /// @return the output path for the target. virtual std::string GetTargetOutputDir() const; - /** - * Write shortcut build statements for the target name with the target - * output name and the target output path. - */ - void WriteTargetBuild(const std::string& outputName, - const std::string& outputPath); - void WriteLanguageRules(const std::string& language); void WriteCompileRule(const std::string& language); void WriteObjectBuildStatements(); diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 50f0ea324b2..9f121fd6691 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -13,7 +13,7 @@ cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() {} void cmNinjaUtilityTargetGenerator::Generate() { std::vector commands; - cmNinjaDeps deps; + cmNinjaDeps deps, outputs; const std::vector *cmdLists[2] = { &this->GetTarget()->GetPreBuildCommands(), @@ -44,12 +44,13 @@ void cmNinjaUtilityTargetGenerator::Generate() { } } + this->GetLocalGenerator()->AppendTargetOutputs(this->GetTarget(), outputs); this->GetLocalGenerator()->AppendTargetDepends(this->GetTarget(), deps); if (commands.empty()) { cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), "Utility command for " + this->GetTargetName(), - cmNinjaDeps(1, this->GetTargetName()), + outputs, deps, cmNinjaDeps(), cmNinjaDeps(), @@ -86,10 +87,13 @@ void cmNinjaUtilityTargetGenerator::Generate() { cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), "", - cmNinjaDeps(1, this->GetTargetName()), + outputs, cmNinjaDeps(1, utilCommandName), cmNinjaDeps(), cmNinjaDeps(), cmNinjaVars()); } + + this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(), + this->GetTarget()); } From 0f378cd63cad21663a2ab2f49a6303761fe5a8ba Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 23 Sep 2011 22:37:56 +0100 Subject: [PATCH 518/539] Rename GetTargetTypeName locally --- Source/cmNinjaNormalTargetGenerator.cxx | 6 +++--- Source/cmNinjaTargetGenerator.cxx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index dc4c3e10581..64e44656893 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -71,7 +71,7 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream()); this->GetRulesFileStream() << "# Rules for each languages for " - << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << cmTarget::GetTargetTypeName(this->GetTarget()->GetType()) << " target " << this->GetTargetName() << "\n\n"; @@ -105,7 +105,7 @@ ::LanguageLinkerRule() const { return std::string(this->TargetLinkLanguage) + "_" - + cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + + cmTarget::GetTargetTypeName(this->GetTarget()->GetType()) + "_LINKER"; } @@ -282,7 +282,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); this->GetBuildFileStream() << "# Link build statements for " - << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << cmTarget::GetTargetTypeName(this->GetTarget()->GetType()) << " target " << this->GetTargetName() << "\n\n"; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index c568226373f..71e7f8c0a87 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -338,7 +338,7 @@ ::WriteObjectBuildStatements() cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); this->GetBuildFileStream() << "# Object build statements for " - << cmTarget::TargetTypeNames(this->GetTarget()->GetType()) + << cmTarget::GetTargetTypeName(this->GetTarget()->GetType()) << " target " << this->GetTargetName() << "\n\n"; From 2a79a8d75782ebe6cd190da0cb3c6bd824108416 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sat, 24 Sep 2011 21:44:55 +0100 Subject: [PATCH 519/539] Add a note to the readme file --- Readme.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Readme.txt b/Readme.txt index 11926bc53fc..cb418bc75bb 100644 --- a/Readme.txt +++ b/Readme.txt @@ -1,3 +1,19 @@ +Special note for ninja-generator branch +======================================= + +The Ninja generator on this branch is currently only compatible with my +'outputs-ready' branch of Ninja, which is available from GitHub here: + +https://github.com/pcc/ninja/tree/outputs-ready + +This implements the following CMake requirements: + - an alternative semantics for order-only dependencies + - restat rules + - generator rules +I'm planning to propose these changes for upstream Ninja soon. + +-------------------------------------------------------------- + This is CMake, the cross-platform, open-source make system. CMake is distributed under the BSD License, see Copyright.txt. For documentation see the Docs/ directory once you have built CMake From d00cab5cd75b79ae6c593bb1e01c034f326ada48 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sun, 25 Sep 2011 04:27:11 +0100 Subject: [PATCH 520/539] Address some constness issues from fixups --- Source/cmLocalNinjaGenerator.cxx | 15 +++++++++++++-- Source/cmLocalNinjaGenerator.h | 6 ++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 62b2e6091bd..f9cd2b9c8ff 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -102,7 +102,13 @@ ::GetTargetDirectory(cmTarget const& target) const //---------------------------------------------------------------------------- // Non-virtual public methods. -cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator() const +const cmGlobalNinjaGenerator* +cmLocalNinjaGenerator::GetGlobalNinjaGenerator() const +{ + return static_cast(this->GetGlobalGenerator()); +} + +cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator() { return static_cast(this->GetGlobalGenerator()); } @@ -166,7 +172,12 @@ cmGeneratedFileStream& cmLocalNinjaGenerator::GetRulesFileStream() const return *this->GetGlobalNinjaGenerator()->GetRulesFileStream(); } -cmake* cmLocalNinjaGenerator::GetCMakeInstance() const +const cmake* cmLocalNinjaGenerator::GetCMakeInstance() const +{ + return this->GetGlobalGenerator()->GetCMakeInstance(); +} + +cmake* cmLocalNinjaGenerator::GetCMakeInstance() { return this->GetGlobalGenerator()->GetCMakeInstance(); } diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 45d78d87673..1347e75654d 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -45,13 +45,15 @@ class cmLocalNinjaGenerator : public cmLocalGenerator virtual std::string GetTargetDirectory(cmTarget const& target) const; public: - cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const; + const cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const; + cmGlobalNinjaGenerator* GetGlobalNinjaGenerator(); /** * Shortcut to get the cmake instance throw the global generator. * @return an instance of the cmake object. */ - cmake* GetCMakeInstance() const; + const cmake* GetCMakeInstance() const; + cmake* GetCMakeInstance(); const char* GetConfigName() const { return this->ConfigName.c_str(); } From 241b15ac4326ad15f34bc8aec58be228adb08816 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sun, 25 Sep 2011 04:27:26 +0100 Subject: [PATCH 521/539] Nicer output for target aliases --- Source/cmGlobalNinjaGenerator.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 265a1277db0..8e5c9ba5b31 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -692,6 +692,9 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias, void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) { + cmGlobalNinjaGenerator::WriteDivider(os); + os << "# Target aliases.\n\n"; + for (TargetAliasMap::iterator i = TargetAliases.begin(); i != TargetAliases.end(); ++i) { // Don't write ambiguous aliases. @@ -702,7 +705,7 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) this->AppendTargetOutputs(i->second, deps); cmGlobalNinjaGenerator::WritePhonyBuild(os, - "Target alias.", + "", cmNinjaDeps(1, i->first), deps); } From 3b4d28ebc5d71e28c5ffa64e38d444b5d13206dd Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 7 Nov 2011 15:33:01 +0000 Subject: [PATCH 522/539] Delete existing static library archives before rebuilding them --- Source/cmNinjaNormalTargetGenerator.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 64e44656893..3ea656fc76b 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -224,8 +224,10 @@ ::ComputeLinkCmd() } } - // We have archive link commands set. + // We have archive link commands set. First, delete the existing archive. std::vector linkCmds; + linkCmds.push_back("rm -f $out"); + { std::string linkCmdVar = "CMAKE_"; linkCmdVar += this->TargetLinkLanguage; From 70da8dfb8666b7c8ede18c6dc1c377f65d07c81b Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 8 Nov 2011 15:37:35 +0000 Subject: [PATCH 523/539] Remove the note, outputs-ready is merged now --- Readme.txt | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Readme.txt b/Readme.txt index cb418bc75bb..11926bc53fc 100644 --- a/Readme.txt +++ b/Readme.txt @@ -1,19 +1,3 @@ -Special note for ninja-generator branch -======================================= - -The Ninja generator on this branch is currently only compatible with my -'outputs-ready' branch of Ninja, which is available from GitHub here: - -https://github.com/pcc/ninja/tree/outputs-ready - -This implements the following CMake requirements: - - an alternative semantics for order-only dependencies - - restat rules - - generator rules -I'm planning to propose these changes for upstream Ninja soon. - --------------------------------------------------------------- - This is CMake, the cross-platform, open-source make system. CMake is distributed under the BSD License, see Copyright.txt. For documentation see the Docs/ directory once you have built CMake From 6a03e2a26207b08403faaf2d38d4cc0400186d6c Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 9 Nov 2011 15:24:39 +0000 Subject: [PATCH 524/539] Clean up a few TODOs --- Source/cmGlobalNinjaGenerator.cxx | 5 +---- Source/cmLocalNinjaGenerator.cxx | 9 +++------ Source/cmNinjaNormalTargetGenerator.cxx | 10 +--------- Source/cmNinjaTargetGenerator.cxx | 19 ++++++++----------- 4 files changed, 13 insertions(+), 30 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 8e5c9ba5b31..78ace022ebf 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -108,8 +108,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, std::ostringstream builds; - // TODO(Nicolas Despres): Write one file per line when there is multiple - // input/output files. + // TODO: Better formatting for when there are multiple input/output files. // Write outputs files. builds << "build"; @@ -540,7 +539,6 @@ void cmGlobalNinjaGenerator::CloseBuildFileStream() } else { - // TODO(Nicolas Despres): Add the the name of the build filestream. cmSystemTools::Error("Build file stream was not open."); } } @@ -585,7 +583,6 @@ void cmGlobalNinjaGenerator::CloseRulesFileStream() } else { - // TODO(Nicolas Despres): Add the the name of the filestream. cmSystemTools::Error("Rules file stream was not open."); } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index f9cd2b9c8ff..1557f138cad 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -26,8 +26,7 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator() , ConfigName("") , HomeRelativeOutputPath("") { - // TODO(Nicolas Despres): Maybe I should set this one to true?? - this->IsMakefileGenerator = false; + this->IsMakefileGenerator = true; } //---------------------------------------------------------------------------- @@ -84,8 +83,7 @@ void cmLocalNinjaGenerator::Configure() } -// TODO(Nicolas Despres): Picked up from cmLocalUnixMakefileGenerator3. -// Refactor it. +// TODO: Picked up from cmLocalUnixMakefileGenerator3. Refactor it. std::string cmLocalNinjaGenerator ::GetTargetDirectory(cmTarget const& target) const { @@ -113,8 +111,7 @@ cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator() return static_cast(this->GetGlobalGenerator()); } -// TODO(Nicolas Despres): Picked up from cmLocalUnixMakefileGenerator3. -// Refactor it. +// TODO: Picked up from cmLocalUnixMakefileGenerator3. Refactor it. std::string cmLocalNinjaGenerator ::GetObjectFileName(const cmTarget& target, diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 3ea656fc76b..4497fdeb74b 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -228,6 +228,7 @@ ::ComputeLinkCmd() std::vector linkCmds; linkCmds.push_back("rm -f $out"); + // TODO: Use ARCHIVE_APPEND for archives over a certain size. { std::string linkCmdVar = "CMAKE_"; linkCmdVar += this->TargetLinkLanguage; @@ -236,15 +237,6 @@ ::ComputeLinkCmd() this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); linkCmds.push_back(linkCmd); } - // TODO(Nicolas Despres): I'll see later how to deals with that. - // { - // std::string linkCmdVar = "CMAKE_"; - // linkCmdVar += this->TargetLinkLanguage; - // linkCmdVar += "_ARCHIVE_APPEND"; - // const char *linkCmd = - // this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); - // linkCmds.push_back(linkCmd); - // } { std::string linkCmdVar = "CMAKE_"; linkCmdVar += this->TargetLinkLanguage; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 71e7f8c0a87..118a5a93cc4 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -84,22 +84,19 @@ const char* cmNinjaTargetGenerator::GetConfigName() const return this->LocalGenerator->ConfigName.c_str(); } -// TODO(Nicolas Despres): Picked up from cmMakefileTargetGenerator. -// Refactor it. +// TODO: Picked up from cmMakefileTargetGenerator. Refactor it. const char* cmNinjaTargetGenerator::GetFeature(const char* feature) { return this->Target->GetFeature(feature, this->GetConfigName()); } -// TODO(Nicolas Despres): Picked up from cmMakefileTargetGenerator. -// Refactor it. +// TODO: Picked up from cmMakefileTargetGenerator. Refactor it. bool cmNinjaTargetGenerator::GetFeatureAsBool(const char* feature) { return cmSystemTools::IsOn(this->GetFeature(feature)); } -// TODO(Nicolas Despres): Picked up from cmMakefileTargetGenerator. -// Refactor it. +// TODO: Picked up from cmMakefileTargetGenerator. Refactor it. void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, const char* lang) { @@ -112,7 +109,7 @@ void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, } } -// TODO(Nicolas Despres): Most of the code is picked up from +// TODO: Most of the code is picked up from // void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink), // void cmMakefileTargetGenerator::WriteTargetLanguageFlags() // Refactor it. @@ -129,7 +126,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, language.c_str(), this->GetConfigName()); - // TODO(Nicolas Despres): Will see later for the Fortran support. + // TODO: Fortran support. // // Fortran-specific flags computed for this target. // if(*l == "Fortran") // { @@ -143,7 +140,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, this->GetLocalGenerator()->AddSharedFlags(flags, language.c_str(), shared); } - // TODO(Nicolas Despres): Handle response file. + // TODO: Handle response file. // Add include directory flags. { std::string includeFlags = @@ -160,14 +157,14 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, this->LocalGenerator->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS")); - // TODO(Nicolas Despres): Handle Apple frameworks. + // TODO: Handle Apple frameworks. // Add include directory flags. // this->LocalGenerator->AppendFlags(flags, this->GetFrameworkFlags().c_str()); return flags; } -// TODO(Nicolas Despres): Refact with +// TODO: Refactor with // void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). std::string cmNinjaTargetGenerator:: From 6ed279aded5623297bf4e36798717131619d3886 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 9 Nov 2011 16:23:34 +0000 Subject: [PATCH 525/539] Only compile Ninja generator on UNIX. --- Source/CMakeLists.txt | 29 ++++++++++++++++++----------- Source/cmake.cxx | 8 -------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 1f7d4bb0b4e..95725ba4293 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -186,9 +186,6 @@ SET(SRCS cmGlobalGenerator.h cmGlobalUnixMakefileGenerator3.cxx cmGlobalUnixMakefileGenerator3.h - cmGlobalNinjaGenerator.cxx - cmGlobalNinjaGenerator.h - cmNinjaTypes.h cmGraphAdjacencyList.h cmGraphVizWriter.cxx cmGraphVizWriter.h @@ -209,14 +206,6 @@ SET(SRCS cmLocalGenerator.cxx cmLocalGenerator.h cmLocalUnixMakefileGenerator3.cxx - cmLocalNinjaGenerator.cxx - cmLocalNinjaGenerator.h - cmNinjaTargetGenerator.cxx - cmNinjaTargetGenerator.h - cmNinjaNormalTargetGenerator.cxx - cmNinjaNormalTargetGenerator.h - cmNinjaUtilityTargetGenerator.cxx - cmNinjaUtilityTargetGenerator.h cmMakeDepend.cxx cmMakeDepend.h cmMakefile.cxx @@ -357,6 +346,24 @@ IF (WIN32) ENDIF(NOT UNIX) ENDIF (WIN32) +# Ninja only works on UNIX. +IF(UNIX) + SET(SRCS ${SRCS} + cmGlobalNinjaGenerator.cxx + cmGlobalNinjaGenerator.h + cmNinjaTypes.h + cmLocalNinjaGenerator.cxx + cmLocalNinjaGenerator.h + cmNinjaTargetGenerator.cxx + cmNinjaTargetGenerator.h + cmNinjaNormalTargetGenerator.cxx + cmNinjaNormalTargetGenerator.h + cmNinjaUtilityTargetGenerator.cxx + cmNinjaUtilityTargetGenerator.h + ) + ADD_DEFINITIONS(-DCMAKE_USE_NINJA) +ENDIF(UNIX) + # create a library used by the command line and the GUI ADD_LIBRARY(CMakeLib ${SRCS}) TARGET_LINK_LIBRARIES(CMakeLib cmsys diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2643891178d..1d793d77683 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -51,14 +51,6 @@ # define CMAKE_USE_ECLIPSE #endif -// Only build Ninja generator on non-windows platforms (until Ninja is ported -// to Windows) and when not bootstrapping cmake. -#if !defined(_WIN32) -# if defined(CMAKE_BUILD_WITH_CMAKE) -# define CMAKE_USE_NINJA -# endif -#endif - #if defined(__MINGW32__) && !defined(CMAKE_BUILD_WITH_CMAKE) # define CMAKE_BOOT_MINGW #endif From 47647e1768b3205b44337a7d5b7da00dc5fff67f Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 10 Nov 2011 02:35:25 +0000 Subject: [PATCH 526/539] Store depfile flags in a language-specific variable (CMAKE_DEPFILE_FLAGS_${lang}), instead of hardcoding them. At the same time, fix the BuildDepends test by providing a way to force dependency tracking. --- Modules/Compiler/GNU.cmake | 9 +++++++++ Source/cmNinjaTargetGenerator.cxx | 19 +++++++++++++------ Tests/BuildDepends/CMakeLists.txt | 2 ++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 8d6f5dfb893..bdcaf9d621d 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -24,6 +24,15 @@ macro(__compiler_gnu lang) set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + # Older versions of gcc (< 4.5) contain a bug causing them to report a missing + # header file as a warning if depfiles are enabled, causing check_header_file + # tests to always succeed. Work around this by disabling dependency tracking + # in try_compile mode. + GET_PROPERTY(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE) + if(NOT _IN_TC OR CMAKE_FORCE_DEPFILES) + set(CMAKE_DEPFILE_FLAGS_${lang} "-MMD -MF ") + endif() + # Initial configuration flags. set(CMAKE_${lang}_FLAGS_INIT "") set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g") diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 118a5a93cc4..a2fc3311a17 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -298,13 +298,21 @@ ::WriteCompileRule(const std::string& language) vars.Language = lang.c_str(); vars.Source = "$in"; vars.Object = "$out"; - - if (this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile()) - vars.Flags = "$FLAGS"; - else - vars.Flags = "-MMD -MF $out.d $FLAGS"; + std::string flags = "$FLAGS"; vars.Defines = "$DEFINES"; + std::string depfile; + std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language; + const char *depfileFlags = + this->GetMakefile()->GetDefinition(depfileFlagsName.c_str()); + if (depfileFlags) { + std::string depfileFlagsStr = depfileFlags; + depfile = "$out.d"; + cmSystemTools::ReplaceString(depfileFlagsStr, "", depfile.c_str()); + flags += " " + depfileFlagsStr; + } + vars.Flags = flags.c_str(); + // Rule for compiling object file. std::string compileCmdVar = "CMAKE_"; compileCmdVar += language; @@ -319,7 +327,6 @@ ::WriteCompileRule(const std::string& language) comment << "Rule for compiling " << language << " files."; std::ostringstream description; description << "Building " << language << " object $out"; - std::string depfile = "$out.d"; this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), compileCmd, description.str(), diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 31392b5e4d7..aa32d67a00e 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -40,6 +40,8 @@ if("${CMAKE_GENERATOR}" MATCHES "Make") endif() list(APPEND _cmake_options "-DTEST_LINK_DEPENDS=${TEST_LINK_DEPENDS}") +list(APPEND _cmake_options "-DCMAKE_FORCE_DEPFILES=1") + file(MAKE_DIRECTORY ${BuildDepends_BINARY_DIR}/Project) message("Creating Project/foo.cxx") write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx From 37666db474fc6e897c30847805d71bdeb7b15ef4 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 10 Nov 2011 02:57:04 +0000 Subject: [PATCH 527/539] Clarify a comment --- Source/cmNinjaTargetGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index a2fc3311a17..ce2b80ccf26 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -220,7 +220,7 @@ std::string cmNinjaTargetGenerator::ConvertToNinjaPath(const char *path) const cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const { - // Static libraries never depend on anything for linking. + // Static libraries never depend on other targets for linking. if (this->Target->GetType() == cmTarget::STATIC_LIBRARY) return cmNinjaDeps(); From 160f7cc070535d4bb378be4c9962cc5710b9aa5b Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 10 Nov 2011 03:22:36 +0000 Subject: [PATCH 528/539] Remove an unnecessary (and ugly) call to cmSystemTools::MakeDirectory --- Source/cmNinjaTargetGenerator.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index ce2b80ccf26..3031e084179 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -256,7 +256,6 @@ ::GetObjectFilePath(cmSourceFile* source) const std::string cmNinjaTargetGenerator::GetTargetOutputDir() const { std::string dir = this->Target->GetDirectory(this->GetConfigName()); - cmSystemTools::MakeDirectory(dir.c_str()); return ConvertToNinjaPath(dir.c_str()); } From 3084b66fc1a9605fa4263f527a98da0a26aa83e7 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 10 Nov 2011 03:42:19 +0000 Subject: [PATCH 529/539] Only add the 'done' mark for Ninja generator, and add comments --- Modules/ExternalProject.cmake | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index d41693a5c21..d8c5b9a54a1 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1456,10 +1456,18 @@ function(ExternalProject_Add name) # depends on the 'done' mark so that it rebuilds when this project # rebuilds. It is important that 'done' is not the output of any # custom command so that CMake does not propagate build rules to - # other external project targets. + # other external project targets, which may cause problems during + # parallel builds. However, the Ninja generator needs to see the entire + # dependency graph, and can cope with custom commands belonging to + # multiple targets, so we add the 'done' mark as an output for Ninja only. + set(complete_outputs ${cmf_dir}${cfgdir}/${name}-complete) + if(${CMAKE_GENERATOR} MATCHES "Ninja") + set(complete_outputs + ${complete_outputs} ${stamp_dir}${cfgdir}/${name}-done) + endif() + add_custom_command( - OUTPUT ${cmf_dir}${cfgdir}/${name}-complete - ${stamp_dir}${cfgdir}/${name}-done + OUTPUT ${complete_outputs} COMMENT "Completed '${name}'" COMMAND ${CMAKE_COMMAND} -E make_directory ${cmf_dir}${cfgdir} COMMAND ${CMAKE_COMMAND} -E touch ${cmf_dir}${cfgdir}/${name}-complete From e422469a9250c9fe61f964546cd162633b267387 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 11 Nov 2011 01:59:30 +0000 Subject: [PATCH 530/539] Fix 79-col violations, comment typos and switch to CMake's indentation style --- Source/cmGlobalNinjaGenerator.cxx | 20 +++++++---- Source/cmGlobalNinjaGenerator.h | 22 ++++++++---- Source/cmLocalNinjaGenerator.cxx | 44 ++++++++++++++++-------- Source/cmLocalNinjaGenerator.h | 9 +++-- Source/cmNinjaNormalTargetGenerator.cxx | 25 ++++++++------ Source/cmNinjaTargetGenerator.cxx | 23 +++++++------ Source/cmNinjaTargetGenerator.h | 3 +- Source/cmNinjaUtilityTargetGenerator.cxx | 22 ++++++------ 8 files changed, 105 insertions(+), 63 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 78ace022ebf..75600420cba 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -49,7 +49,8 @@ void cmGlobalNinjaGenerator::WriteComment(std::ostream& os, os << "# " << replace.substr(lpos) << "\n"; } -static bool IsIdentChar(char c) { +static bool IsIdentChar(char c) +{ return ('a' <= c && c <= 'z') || ('+' <= c && c <= '9') || // +,-./ and numbers @@ -71,7 +72,8 @@ std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string &ident, } } -std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string &lit) { +std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string &lit) +{ std::string result = lit; cmSystemTools::ReplaceString(result, "$", "$$"); return result; @@ -195,7 +197,7 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command, const std::string& comment, const cmNinjaDeps& outputs, const cmNinjaDeps& deps, - const cmNinjaDeps& orderOnlyDeps) + const cmNinjaDeps& orderOnlyDeps) { this->AddCustomCommandRule(); @@ -492,7 +494,8 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, variables); } -bool cmGlobalNinjaGenerator::HasRule(const std::string &name) { +bool cmGlobalNinjaGenerator::HasRule(const std::string &name) +{ RulesSetType::const_iterator rule = this->Rules.find(name); return (rule != this->Rules.end()); } @@ -616,7 +619,8 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies(std::ostream& os) void cmGlobalNinjaGenerator -::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) { +::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) +{ std::string name, dir; const char* configName = target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE"); @@ -655,14 +659,16 @@ ::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) { void cmGlobalNinjaGenerator -::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) { +::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) +{ if (target->GetType() == cmTarget::GLOBAL_TARGET) { // Global targets only depend on other utilities, which may not appear in // the TargetDepends set (e.g. "all"). std::set const& utils = target->GetUtilities(); outputs.insert(outputs.end(), utils.begin(), utils.end()); } else { - cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(*target); + cmTargetDependSet const& targetDeps = + this->GetTargetDirectDepends(*target); for (cmTargetDependSet::const_iterator i = targetDeps.begin(); i != targetDeps.end(); ++i) { this->AppendTargetOutputs(*i, outputs); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index a657f674ac7..42967788303 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -96,7 +96,7 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator const std::string& comment, const cmNinjaDeps& outputs, const cmNinjaDeps& deps = cmNinjaDeps(), - const cmNinjaDeps& orderOnlyDeps = cmNinjaDeps()); + const cmNinjaDeps& orderOnlyDeps = cmNinjaDeps()); /** * Write a rule statement named @a name to @a os with the @a comment, @@ -185,13 +185,23 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator // Setup target names virtual const char* GetAllTargetName() const { return "all"; } virtual const char* GetInstallTargetName() const { return "install"; } - virtual const char* GetInstallLocalTargetName() const { return "install/local"; } - virtual const char* GetInstallStripTargetName() const { return "install/strip"; } + virtual const char* GetInstallLocalTargetName() const { + return "install/local"; + } + virtual const char* GetInstallStripTargetName() const { + return "install/strip"; + } virtual const char* GetTestTargetName() const { return "test"; } virtual const char* GetPackageTargetName() const { return "package"; } - virtual const char* GetPackageSourceTargetName() const { return "package_source"; } - virtual const char* GetEditCacheTargetName() const { return "edit_cache"; } - virtual const char* GetRebuildCacheTargetName() const { return "rebuild_cache"; } + virtual const char* GetPackageSourceTargetName() const { + return "package_source"; + } + virtual const char* GetEditCacheTargetName() const { + return "edit_cache"; + } + virtual const char* GetRebuildCacheTargetName() const { + return "rebuild_cache"; + } virtual const char* GetCleanTargetName() const { return "clean"; } public: diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 1557f138cad..acd9d265154 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -103,7 +103,8 @@ ::GetTargetDirectory(cmTarget const& target) const const cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator() const { - return static_cast(this->GetGlobalGenerator()); + return + static_cast(this->GetGlobalGenerator()); } cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator() @@ -145,7 +146,8 @@ ::GetObjectFileName(const cmTarget& target, //---------------------------------------------------------------------------- // Virtual protected methods. -std::string cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib) +std::string +cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib) { return this->Convert(lib.c_str(), HOME_OUTPUT, SHELL); } @@ -217,7 +219,7 @@ void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os) << "\n" ; cmGlobalNinjaGenerator::WriteInclude(os, - cmGlobalNinjaGenerator::NINJA_RULES_FILE, + cmGlobalNinjaGenerator::NINJA_RULES_FILE, "Include rules file."); os << "\n"; } @@ -225,7 +227,8 @@ void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os) void cmLocalNinjaGenerator::SetConfigName() { // Store the configuration name that will be generated. - if(const char* config = this->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE")) + if(const char* config = + this->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE")) { // Use the build type given by the user. this->ConfigName = config; @@ -259,17 +262,21 @@ std::string cmLocalNinjaGenerator::ConvertToNinjaPath(const char *path) void cmLocalNinjaGenerator -::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) { +::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) +{ this->GetGlobalNinjaGenerator()->AppendTargetOutputs(target, outputs); } void cmLocalNinjaGenerator -::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) { +::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) +{ this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs); } -void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, cmNinjaDeps &ninjaDeps) { +void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, + cmNinjaDeps &ninjaDeps) +{ const std::vector &deps = cc->GetDepends(); for (std::vector::const_iterator i = deps.begin(); i != deps.end(); ++i) { @@ -279,7 +286,9 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc, c } } -std::string cmLocalNinjaGenerator::BuildCommandLine(const std::vector &cmdLines) { +std::string cmLocalNinjaGenerator::BuildCommandLine( + const std::vector &cmdLines) +{ // If we have no commands but we need to build a command anyway, use ":". // This happens when building a POST_BUILD value for link targets that // don't use POST_BUILD. @@ -287,7 +296,7 @@ std::string cmLocalNinjaGenerator::BuildCommandLine(const std::vector &cmdLines) { +void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, + std::vector &cmdLines) +{ cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); if (ccg.GetNumberOfCommands() > 0) { std::ostringstream cdCmd; @@ -321,7 +332,8 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc, - const cmNinjaDeps& orderOnlyDeps) { + const cmNinjaDeps& orderOnlyDeps) +{ if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) return; @@ -359,7 +371,8 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(cmCustomCommand *cc, } } -void cmLocalNinjaGenerator::AddCustomCommandTarget(cmCustomCommand* cc, cmTarget* target) +void cmLocalNinjaGenerator::AddCustomCommandTarget(cmCustomCommand* cc, + cmTarget* target) { this->CustomCommandTargets[cc].insert(target); } @@ -372,8 +385,11 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements() // systems exist where the target dependencies on some of the targets are // overspecified, leading to a dependency cycle. If we assume all target // dependencies are a superset of the true target dependencies for this - // custom command, we can take the set intersection of all target dependencies - // to obtain a correct dependency list. + // custom command, we can take the set intersection of all target + // dependencies to obtain a correct dependency list. + // + // FIXME: This won't work in certain obscure scenarios involving indirect + // dependencies. std::set::iterator j = i->second.begin(); assert(j != i->second.end()); std::vector ccTargetDeps; diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 1347e75654d..19e3e19c64d 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -109,9 +109,11 @@ class cmLocalNinjaGenerator : public cmLocalGenerator void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs); void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); - void AppendCustomCommandDeps(const cmCustomCommand *cc, cmNinjaDeps &ninjaDeps); + void AppendCustomCommandDeps(const cmCustomCommand *cc, + cmNinjaDeps &ninjaDeps); std::string BuildCommandLine(const std::vector &cmdLines); - void AppendCustomCommandLines(const cmCustomCommand *cc, std::vector &cmdLines); + void AppendCustomCommandLines(const cmCustomCommand *cc, + std::vector &cmdLines); void WriteCustomCommandRule(); void WriteCustomCommandBuildStatement(cmCustomCommand *cc, const cmNinjaDeps& orderOnlyDeps); @@ -123,7 +125,8 @@ class cmLocalNinjaGenerator : public cmLocalGenerator std::string ConfigName; std::string HomeRelativeOutputPath; - typedef std::map > CustomCommandTargetMap; + typedef std::map > + CustomCommandTargetMap; CustomCommandTargetMap CustomCommandTargets; }; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 4497fdeb74b..e24d1840c47 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -84,7 +84,8 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() this->WriteLanguageRules(*l); } -const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const { +const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const +{ switch (this->GetTarget()->GetType()) { case cmTarget::STATIC_LIBRARY: return "static library"; @@ -194,14 +195,14 @@ ::WriteLinkRule() " -E cmake_symlink_executable" " $in $out && $POST_BUILD", "Creating executable symlink $out", - "Rule for creating executable symlink."); + "Rule for creating executable symlink."); else this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", cmakeCommand + " -E cmake_symlink_library" " $in $SONAME $out && $POST_BUILD", "Creating library symlink $out", - "Rule for creating library symlink."); + "Rule for creating library symlink."); } } @@ -224,7 +225,7 @@ ::ComputeLinkCmd() } } - // We have archive link commands set. First, delete the existing archive. + // We have archive link commands set. First, delete the existing archive. std::vector linkCmds; linkCmds.push_back("rm -f $out"); @@ -289,7 +290,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // Compute the comment. std::ostringstream comment; - comment << "Link the " << this->GetVisibleTypeName() << " " << targetOutputReal; + comment << "Link the " << this->GetVisibleTypeName() << " " + << targetOutputReal; // Compute outputs. cmNinjaDeps outputs; @@ -325,7 +327,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() }; for (unsigned i = 0; i != 3; ++i) { - for (std::vector::const_iterator ci = cmdLists[i]->begin(); + for (std::vector::const_iterator + ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) { this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, *cmdLineLists[i]); @@ -364,7 +367,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (targetOutput != targetOutputReal) { if (this->GetTarget()->GetType() == cmTarget::EXECUTABLE) { cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - "Create executable symlink " + targetOutput, + "Create executable symlink " + targetOutput, "CMAKE_SYMLINK_EXECUTABLE", cmNinjaDeps(1, targetOutput), cmNinjaDeps(1, targetOutputReal), @@ -374,7 +377,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } else { symlinkVars["SONAME"] = this->GetTargetFilePath(this->TargetNameSO); cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), - "Create library symlink " + targetOutput, + "Create library symlink " + targetOutput, "CMAKE_SYMLINK_LIBRARY", cmNinjaDeps(1, targetOutput), cmNinjaDeps(1, targetOutputReal), @@ -385,6 +388,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } // Add aliases for the file name and the target name. - this->GetGlobalGenerator()->AddTargetAlias(this->TargetNameOut, this->GetTarget()); - this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(), this->GetTarget()); + this->GetGlobalGenerator()->AddTargetAlias(this->TargetNameOut, + this->GetTarget()); + this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(), + this->GetTarget()); } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 3031e084179..010c6e7b01a 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -53,10 +53,11 @@ cmNinjaTargetGenerator::New(cmTarget* target) } cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmTarget* target) - : Target(target) - , Makefile(target->GetMakefile()) - , LocalGenerator(static_cast(Makefile->GetLocalGenerator())) - , Objects() + : Target(target), + Makefile(target->GetMakefile()), + LocalGenerator( + static_cast(Makefile->GetLocalGenerator())), + Objects() { } @@ -153,13 +154,11 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, // Add target-specific and source-specific flags. this->LocalGenerator->AppendFlags(flags, - this->Target->GetProperty("COMPILE_FLAGS")); + this->Target->GetProperty("COMPILE_FLAGS")); this->LocalGenerator->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS")); // TODO: Handle Apple frameworks. - // Add include directory flags. - // this->LocalGenerator->AppendFlags(flags, this->GetFrameworkFlags().c_str()); return flags; } @@ -175,7 +174,8 @@ ComputeDefines(cmSourceFile *source, const std::string& language) // Add the export symbol definition for shared library objects. if(const char* exportMacro = this->Target->GetExportMacro()) { - this->LocalGenerator->AppendDefines(defines, exportMacro, language.c_str()); + this->LocalGenerator->AppendDefines(defines, exportMacro, + language.c_str()); } // Add preprocessor definitions for this target and configuration. @@ -307,7 +307,8 @@ ::WriteCompileRule(const std::string& language) if (depfileFlags) { std::string depfileFlagsStr = depfileFlags; depfile = "$out.d"; - cmSystemTools::ReplaceString(depfileFlagsStr, "", depfile.c_str()); + cmSystemTools::ReplaceString(depfileFlagsStr, "", + depfile.c_str()); flags += " " + depfileFlagsStr; } vars.Flags = flags.c_str(); @@ -390,8 +391,8 @@ ::WriteObjectBuildStatement(cmSourceFile* source) std::string sourceFileName = this->GetSourceFilePath(source); explicitDeps.push_back(sourceFileName); - // Ensure that the target dependencies are built before any source file in the - // target, using order-only dependencies. + // Ensure that the target dependencies are built before any source file in + // the target, using order-only dependencies. cmNinjaDeps orderOnlyDeps; this->GetLocalGenerator()->AppendTargetDepends(this->Target, orderOnlyDeps); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index f1c067df489..369d60944be 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -71,7 +71,8 @@ class cmNinjaTargetGenerator std::string ComputeFlagsForObject(cmSourceFile *source, const std::string& language); - std::string ComputeDefines(cmSourceFile *source, const std::string& language); + std::string ComputeDefines(cmSourceFile *source, + const std::string& language); std::string ConvertToNinjaPath(const char *path) const; cmLocalNinjaGenerator::map_to_ninja_path MapToNinjaPath() const { diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 9f121fd6691..0a15834ceec 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -11,7 +11,8 @@ cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(cmTarget *target) cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() {} -void cmNinjaUtilityTargetGenerator::Generate() { +void cmNinjaUtilityTargetGenerator::Generate() +{ std::vector commands; cmNinjaDeps deps, outputs; @@ -21,8 +22,8 @@ void cmNinjaUtilityTargetGenerator::Generate() { }; for (unsigned i = 0; i != 2; ++i) { - for (std::vector::const_iterator ci = cmdLists[i]->begin(); - ci != cmdLists[i]->end(); ++ci) { + for (std::vector::const_iterator + ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) { this->GetLocalGenerator()->AppendCustomCommandDeps(&*ci, deps); this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, commands); } @@ -49,14 +50,13 @@ void cmNinjaUtilityTargetGenerator::Generate() { if (commands.empty()) { cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(), - "Utility command for " + this->GetTargetName(), + "Utility command for " + + this->GetTargetName(), outputs, - deps, - cmNinjaDeps(), - cmNinjaDeps(), - cmNinjaVars()); + deps); } else { - std::string command = this->GetLocalGenerator()->BuildCommandLine(commands); + std::string command = + this->GetLocalGenerator()->BuildCommandLine(commands); const char *echoStr = this->GetTarget()->GetProperty("EchoString"); std::string desc; if (echoStr) @@ -67,9 +67,9 @@ void cmNinjaUtilityTargetGenerator::Generate() { // TODO: fix problematic global targets. For now, search and replace the // makefile vars. cmSystemTools::ReplaceString(command, "$(CMAKE_SOURCE_DIR)", - this->GetTarget()->GetMakefile()->GetHomeDirectory()); + this->GetTarget()->GetMakefile()->GetHomeDirectory()); cmSystemTools::ReplaceString(command, "$(CMAKE_BINARY_DIR)", - this->GetTarget()->GetMakefile()->GetHomeOutputDirectory()); + this->GetTarget()->GetMakefile()->GetHomeOutputDirectory()); cmSystemTools::ReplaceString(command, "$(ARGS)", ""); if (command.find('$') != std::string::npos) From 6c27d34d34e77d3a5dc4fab851da8611e52c63f1 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 11 Nov 2011 02:38:23 +0000 Subject: [PATCH 531/539] Add a comment to this test case --- Tests/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index e10e6f3b7b5..4670526dd68 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -327,6 +327,8 @@ IF(BUILD_TESTING) ) IF(${CMAKE_TEST_GENERATOR} MATCHES "Ninja") + # The Ninja generator does not create a recursive build system. Start + # from the root directory. SET(SubProject_SUBDIR) ELSE() SET(SubProject_SUBDIR "/foo") From 2e00859a67ed2fa3e9149e862952d3a6e85468c6 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 11 Nov 2011 03:10:27 +0000 Subject: [PATCH 532/539] We don't need to forward declare this --- Source/cmSourceFile.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index cd630a67daf..55147e19272 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -13,10 +13,10 @@ #define cmSourceFile_h #include "cmSourceFileLocation.h" +#include "cmCustomCommand.h" #include "cmPropertyMap.h" class cmake; -class cmCustomCommand; /** \class cmSourceFile * \brief Represent a class loaded from a makefile. From da0d203840809de09912d7c3bf2c737e91652d4a Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 11 Nov 2011 03:19:43 +0000 Subject: [PATCH 533/539] Fix a few issues pointed out by clang warnings --- Source/cmNinjaNormalTargetGenerator.cxx | 4 ++++ Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.h | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index e24d1840c47..440c92d417b 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -263,11 +263,15 @@ ::ComputeLinkCmd() case cmTarget::EXECUTABLE: linkCmdVar += "_LINK_EXECUTABLE"; break; + default: + assert(0 && "Unexpected target type"); } const char *linkCmd = this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str()); return std::vector(1, linkCmd); } + default: + assert(0 && "Unexpected target type"); } } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 010c6e7b01a..5da5b3e1ffa 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -43,7 +43,7 @@ cmNinjaTargetGenerator::New(cmTarget* target) // in every directory, which we don't need. cmMakefile *mf = target->GetMakefile(); if (strcmp(mf->GetStartDirectory(), mf->GetHomeDirectory()) == 0) - return new cmNinjaUtilityTargetGenerator(target);; + return new cmNinjaUtilityTargetGenerator(target); // else fallthrough } diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 369d60944be..50a74401cea 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -33,7 +33,7 @@ class cmNinjaTargetGenerator cmNinjaTargetGenerator(cmTarget* target); /// Destructor. - ~cmNinjaTargetGenerator(); + virtual ~cmNinjaTargetGenerator(); virtual void Generate() = 0; From b1eb676f388750a340e038d4a98c1a90eb6ffd0e Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 11 Nov 2011 03:43:15 +0000 Subject: [PATCH 534/539] Copyright me --- Source/cmGlobalNinjaGenerator.cxx | 1 + Source/cmGlobalNinjaGenerator.h | 1 + Source/cmLocalNinjaGenerator.cxx | 1 + Source/cmLocalNinjaGenerator.h | 1 + Source/cmNinjaNormalTargetGenerator.cxx | 3 +++ Source/cmNinjaNormalTargetGenerator.h | 1 + Source/cmNinjaTargetGenerator.cxx | 1 + Source/cmNinjaTargetGenerator.h | 1 + Source/cmNinjaTypes.h | 1 + Source/cmNinjaUtilityTargetGenerator.h | 1 + 10 files changed, 12 insertions(+) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 75600420cba..2f6e01a5353 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1,5 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator + Copyright 2011 Peter Collingbourne Copyright 2011 Nicolas Despres Distributed under the OSI-approved BSD License (the "License"); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 42967788303..ec4608ba9a6 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -1,5 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator + Copyright 2011 Peter Collingbourne Copyright 2011 Nicolas Despres Distributed under the OSI-approved BSD License (the "License"); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index acd9d265154..6ae50322f63 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -1,5 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator + Copyright 2011 Peter Collingbourne Copyright 2011 Nicolas Despres Distributed under the OSI-approved BSD License (the "License"); diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 19e3e19c64d..218eee1f96b 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -1,5 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator + Copyright 2011 Peter Collingbourne Copyright 2011 Nicolas Despres Distributed under the OSI-approved BSD License (the "License"); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 440c92d417b..bdd4f3d67b5 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -1,5 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator + Copyright 2011 Peter Collingbourne Copyright 2011 Nicolas Despres Distributed under the OSI-approved BSD License (the "License"); @@ -16,6 +17,8 @@ #include "cmGeneratedFileStream.h" #include "cmMakefile.h" +#include + cmNinjaNormalTargetGenerator:: cmNinjaNormalTargetGenerator(cmTarget* target) : cmNinjaTargetGenerator(target) diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index 96378cc080a..99f5a133b68 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -1,5 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator + Copyright 2011 Peter Collingbourne Copyright 2011 Nicolas Despres Distributed under the OSI-approved BSD License (the "License"); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 5da5b3e1ffa..e48ac12d0cc 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1,5 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator + Copyright 2011 Peter Collingbourne Copyright 2011 Nicolas Despres Distributed under the OSI-approved BSD License (the "License"); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 50a74401cea..cf47abf1d17 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -1,5 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator + Copyright 2011 Peter Collingbourne Copyright 2011 Nicolas Despres Distributed under the OSI-approved BSD License (the "License"); diff --git a/Source/cmNinjaTypes.h b/Source/cmNinjaTypes.h index 99b2afd11f2..29ef153e384 100644 --- a/Source/cmNinjaTypes.h +++ b/Source/cmNinjaTypes.h @@ -1,5 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator + Copyright 2011 Peter Collingbourne Copyright 2011 Nicolas Despres Distributed under the OSI-approved BSD License (the "License"); diff --git a/Source/cmNinjaUtilityTargetGenerator.h b/Source/cmNinjaUtilityTargetGenerator.h index e216e4cae0a..8b82ce49a5e 100644 --- a/Source/cmNinjaUtilityTargetGenerator.h +++ b/Source/cmNinjaUtilityTargetGenerator.h @@ -1,5 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator + Copyright 2011 Peter Collingbourne Copyright 2011 Nicolas Despres Distributed under the OSI-approved BSD License (the "License"); From 39726bb0c65e28c3e6d2cf9645991638c5e745e2 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 11 Nov 2011 03:46:06 +0000 Subject: [PATCH 535/539] Document that only recent versions of ninja will work --- Source/cmGlobalNinjaGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 2f6e01a5353..ef042e51803 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -364,8 +364,8 @@ ::GetDocumentation(cmDocumentationEntry& entry) const entry.Name = this->GetName(); entry.Brief = "Generates build.ninja files (experimental)."; entry.Full = - "A build.ninja file is generated into the build tree. Any" - "version of the ninja program can build the project through the " + "A build.ninja file is generated into the build tree. Recent " + "versions of the ninja program can build the project through the " "\"all\" target. An \"install\" target is also provided."; } From eec2d9051ce8856e38ab219f6f0d565d11939e36 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 11 Nov 2011 03:47:51 +0000 Subject: [PATCH 536/539] We actually support any language other than Fortran --- Source/cmGlobalNinjaGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index ef042e51803..22645caab97 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -405,7 +405,7 @@ ::EnableLanguage(std::vectorconst& languages, { continue; } - if(*l != "C" && *l != "CXX") + if(*l == "Fortran") { std::string message = "The \""; message += this->GetName(); From 42aff86017ef70c1e2d50437f6824e147c75bc9c Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 11 Nov 2011 03:58:07 +0000 Subject: [PATCH 537/539] Rules do not have arbitrary variable bindings, and remove an unnecessary if statement --- Source/cmGlobalNinjaGenerator.cxx | 31 ++++++++----------------------- Source/cmGlobalNinjaGenerator.h | 6 ++---- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 22645caab97..2579c3c6fc2 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -155,13 +155,10 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, os << builds.str(); // Write the variables bound to this build statement. - if(!variables.empty()) - { - for(cmNinjaVars::const_iterator i = variables.begin(); - i != variables.end(); - ++i) - cmGlobalNinjaGenerator::WriteVariable(os, i->first, i->second, "", 1); - } + for(cmNinjaVars::const_iterator i = variables.begin(); + i != variables.end(); + ++i) + cmGlobalNinjaGenerator::WriteVariable(os, i->first, i->second, "", 1); } void cmGlobalNinjaGenerator::WritePhonyBuild(std::ostream& os, @@ -223,8 +220,7 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, const std::string& comment, const std::string& depfile, bool restat, - bool generator, - const cmNinjaVars& variables) + bool generator) { // Make sure the rule has a name. if(name.empty()) @@ -278,15 +274,6 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, cmGlobalNinjaGenerator::Indent(os, 1); os << "generator = 1\n"; } - - // Write the variables bound to this build statement. - if(!variables.empty()) - { - for(cmNinjaVars::const_iterator i = variables.begin(); - i != variables.end(); - ++i) - cmGlobalNinjaGenerator::WriteVariable(os, i->first, i->second, "", 1); - } } void cmGlobalNinjaGenerator::WriteVariable(std::ostream& os, @@ -476,10 +463,9 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, const std::string& comment, const std::string& depfile, bool restat, - bool generator, - const cmNinjaVars& variables) + bool generator) { - // Do not add twice the same rule. + // Do not add the same rule twice. if (this->HasRule(name)) return; @@ -491,8 +477,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, comment, depfile, restat, - generator, - variables); + generator); } bool cmGlobalNinjaGenerator::HasRule(const std::string &name) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index ec4608ba9a6..171d14b90ab 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -112,8 +112,7 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator const std::string& comment = "", const std::string& depfile = "", bool restat = false, - bool generator = false, - const cmNinjaVars& variables = cmNinjaVars()); + bool generator = false); /** * Write a variable named @a name to @a os with value @a value and an @@ -223,8 +222,7 @@ class cmGlobalNinjaGenerator : public cmGlobalGenerator const std::string& comment = "", const std::string& depfile = "", bool restat = false, - bool generator = false, - const cmNinjaVars& variables = cmNinjaVars()); + bool generator = false); bool HasRule(const std::string& name); From 92e6519268c29913015dff8d453682a6dbebe2c9 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 11 Nov 2011 19:11:38 +0000 Subject: [PATCH 538/539] Add support for executable with exports flags to cmLocalGenerator::GetTargetFlags --- Source/cmLocalGenerator.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 65d6fa6564f..ebdfdf560fa 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1583,6 +1583,16 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); linkFlags += " "; } + if (target.IsExecutableWithExports()) + { + std::string exportFlagVar = "CMAKE_EXE_EXPORTS_"; + exportFlagVar += linkLanguage; + exportFlagVar += "_FLAG"; + + linkFlags += + this->Makefile->GetSafeDefinition(exportFlagVar.c_str()); + linkFlags += " "; + } const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); if(targetLinkFlags) { From f5a4d1eb78d6800accc94fd70b2e0748af90727e Mon Sep 17 00:00:00 2001 From: Jamie Kirkpatrick Date: Mon, 30 Jan 2012 15:48:58 +0100 Subject: [PATCH 539/539] Ensure architecture flags are passed to the linker if specified --- Source/cmNinjaNormalTargetGenerator.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index bdd4f3d67b5..a09ec639381 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -152,8 +152,14 @@ ::WriteLinkRule() vars.TargetVersionMajor = targetVersionMajor.c_str(); vars.TargetVersionMinor = targetVersionMinor.c_str(); + std::string flags = "$FLAGS"; + this->GetLocalGenerator()->AddArchitectureFlags(flags, + this->GetTarget(), + this->TargetLinkLanguage, + this->GetConfigName()); + vars.Flags = flags.c_str(); + vars.LinkLibraries = "$LINK_LIBRARIES"; - vars.Flags = "$FLAGS"; vars.LinkFlags = "$LINK_FLAGS"; std::string langFlags;