diff options
52 files changed, 560 insertions, 114 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ea1c033..a67fb6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -585,6 +585,29 @@ option(CMAKE_STRICT "Perform strict testing to record property and variable access. Can be used to report any undefined properties or variables" OFF) mark_as_advanced(CMAKE_STRICT) +if(NOT CMake_VERSION_IS_RELEASE) + if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND + NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2) + set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts + -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security + -Wmissing-format-attribute -fno-common + ) + set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W + -Wshadow -Wpointer-arith -Wformat-security + ) + + foreach(FLAG_LANG C CXX) + foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST}) + if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ") + set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}") + endif() + endforeach() + endforeach() + + unset(C_FLAGS_LIST) + unset(CXX_FLAGS_LIST) + endif() +endif() # build the remaining subdirectories add_subdirectory(Source) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 8d57860..2355dac 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -402,6 +402,79 @@ endif() endfunction() +function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_repository work_dir) + file(WRITE ${script_filename} +"if(\"${git_tag}\" STREQUAL \"\") + message(FATAL_ERROR \"Tag for git checkout should not be empty.\") +endif() + +execute_process( + COMMAND \"${git_EXECUTABLE}\" rev-list --max-count=1 HEAD + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + OUTPUT_VARIABLE head_sha + ) +if(error_code) + message(FATAL_ERROR \"Failed to get the hash for HEAD\") +endif() + +execute_process( + COMMAND \"${git_EXECUTABLE}\" show-ref ${git_tag} + WORKING_DIRECTORY \"${work_dir}\" + OUTPUT_VARIABLE show_ref_output + ) +# If a remote ref is asked for, which can possibly move around, +# we must always do a fetch and checkout. +if(\"\${show_ref_output}\" MATCHES \"remotes\") + set(is_remote_ref 1) +else() + set(is_remote_ref 0) +endif() + +# This will fail if the tag does not exist (it probably has not been fetched +# yet). +execute_process( + COMMAND \"${git_EXECUTABLE}\" rev-list --max-count=1 ${git_tag} + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + OUTPUT_VARIABLE tag_sha + ) + +# Is the hash checkout out that we want? +if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\")) + execute_process( + COMMAND \"${git_EXECUTABLE}\" fetch + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR \"Failed to fetch repository '${git_repository}'\") + endif() + + execute_process( + COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag} + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\") + endif() + + execute_process( + COMMAND \"${git_EXECUTABLE}\" submodule update --recursive + WORKING_DIRECTORY \"${work_dir}/${src_name}\" + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\") + endif() +endif() + +" +) + +endfunction(_ep_write_gitupdate_script) + function(_ep_write_downloadfile_script script_filename remote local timeout hash tls_verify tls_cainfo) if(timeout) set(timeout_args TIMEOUT ${timeout}) @@ -1354,7 +1427,7 @@ endfunction() function(_ep_add_update_command name) - ExternalProject_Get_Property(${name} source_dir) + ExternalProject_Get_Property(${name} source_dir tmp_dir) get_property(cmd_set TARGET ${name} PROPERTY _EP_UPDATE_COMMAND SET) get_property(cmd TARGET ${name} PROPERTY _EP_UPDATE_COMMAND) @@ -1406,15 +1479,15 @@ function(_ep_add_update_command name) message(FATAL_ERROR "error: could not find git for fetch of ${name}") endif() set(work_dir ${source_dir}) - set(comment "Performing update step (git fetch) for '${name}'") + set(comment "Performing update step for '${name}'") get_property(git_tag TARGET ${name} PROPERTY _EP_GIT_TAG) if(NOT git_tag) set(git_tag "master") endif() - set(cmd ${GIT_EXECUTABLE} fetch - COMMAND ${GIT_EXECUTABLE} checkout ${git_tag} - COMMAND ${GIT_EXECUTABLE} submodule update --recursive + _ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake + ${GIT_EXECUTABLE} ${git_tag} ${git_repository} ${work_dir} ) + set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake) set(always 1) elseif(hg_repository) if(NOT HG_EXECUTABLE) diff --git a/Modules/FindSquish.cmake b/Modules/FindSquish.cmake index ad72958..b797805 100644 --- a/Modules/FindSquish.cmake +++ b/Modules/FindSquish.cmake @@ -221,7 +221,7 @@ function(SQUISH_V4_ADD_TEST testName) get_target_property(testAUTLocation ${_SQUISH_AUT} LOCATION) get_filename_component(testAUTDir ${testAUTLocation} PATH) - get_target_property(testAUTName ${_SQUISH_AUT} OUTPUT_NAME) + get_filename_component(testAUTName ${testAUTLocation} NAME) get_filename_component(absTestSuite "${_SQUISH_SUITE}" ABSOLUTE) if(NOT EXISTS "${absTestSuite}") diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index 4e7e99c..ed0b8af 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -263,6 +263,23 @@ set(CMAKE_SYSTEM_FRAMEWORK_PATH /Network/Library/Frameworks /System/Library/Frameworks) +# Warn about known system mis-configuration case. +if(CMAKE_OSX_SYSROOT) + get_property(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE) + if(NOT _IN_TC AND + NOT IS_SYMLINK "${CMAKE_OSX_SYSROOT}/Library/Frameworks" + AND IS_SYMLINK "${CMAKE_OSX_SYSROOT}/Library/Frameworks/Frameworks") + message(WARNING "The SDK Library/Frameworks path\n" + " ${CMAKE_OSX_SYSROOT}/Library/Frameworks\n" + "is not set up correctly on this system. " + "This is known to occur when installing Xcode 3.2.6:\n" + " http://bugs.python.org/issue14018\n" + "The problem may cause build errors that report missing system frameworks. " + "Fix your SDK symlinks to resolve this issue and avoid this warning." + ) + endif() +endif() + # default to searching for application bundles first if(NOT DEFINED CMAKE_FIND_APPBUNDLE) set(CMAKE_FIND_APPBUNDLE FIRST) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2b15059..300abd7 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20121108) +set(CMake_VERSION_TWEAK 20121120) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index e964696..6317fa0 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -97,7 +97,6 @@ int cmCPackGenerator::PrepareNames() } tempDirectory += this->GetOption("CPACK_GENERATOR"); std::string topDirectory = tempDirectory; - this->GetOption("CPACK_PACKAGE_FILE_NAME"); const char* pfname = this->GetOption("CPACK_PACKAGE_FILE_NAME"); if(!pfname) { @@ -208,7 +207,7 @@ int cmCPackGenerator::InstallProject() { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem creating temporary directory: " - << (tempInstallDirectory ? tempInstallDirectory : "(NULL}") + << (tempInstallDirectory ? tempInstallDirectory : "(NULL)") << std::endl); return 0; } diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx index 5c7414f..bd1ff71 100644 --- a/Source/CursesDialog/cmCursesStringWidget.cxx +++ b/Source/CursesDialog/cmCursesStringWidget.cxx @@ -175,7 +175,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm, } else if ( key == ctrl('d') ||key == KEY_DC ) { - if ( form->curcol > 0 ) + if ( form->curcol >= 0 ) { form_driver(form, REQ_DEL_CHAR); } diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index cd3ef59..d8ffb5e 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -277,6 +277,10 @@ cmComputeLinkInformation this->UseImportLibrary = this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")?true:false; + // Check whether we should skip dependencies on shared library files. + this->LinkDependsNoShared = + this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. @@ -650,7 +654,11 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) // Pass the full path to the target file. std::string lib = tgt->GetFullPath(config, implib, true); - this->Depends.push_back(lib); + if(!this->LinkDependsNoShared || + tgt->GetType() != cmTarget::SHARED_LIBRARY) + { + this->Depends.push_back(lib); + } this->AddTargetItem(lib, tgt); this->AddLibraryRuntimeInfo(lib, tgt); diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index f60f8d3..e0078af 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -82,6 +82,7 @@ private: // Configuration information. const char* Config; const char* LinkLanguage; + bool LinkDependsNoShared; // Modes for dealing with dependent shared libraries. enum SharedDepMode diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index 347174a..0393ecf 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -68,6 +68,9 @@ public: "If <output> names an existing directory the input file is placed " "in that directory with its original name. " "\n" + "If the <input> file is modified the build system will re-run CMake " + "to re-configure the file and generate the build system again." + "\n" "This command replaces any variables in the input file referenced as " "${VAR} or @VAR@ with their values as determined by CMake. If a " "variable is not defined, it will be replaced with nothing. " @@ -76,13 +79,18 @@ public: "will be C-style escaped. " "The file will be configured with the current values of CMake " "variables. If @ONLY is specified, only variables " - "of the form @VAR@ will be replaces and ${VAR} will be ignored. " - "This is useful for configuring scripts that use ${VAR}. " - "Any occurrences of #cmakedefine VAR will be replaced with " - "either #define VAR or /* #undef VAR */ depending on " - "the setting of VAR in CMake. Any occurrences of #cmakedefine01 VAR " - "will be replaced with either #define VAR 1 or #define VAR 0 " - "depending on whether VAR evaluates to TRUE or FALSE in CMake.\n" + "of the form @VAR@ will be replaced and ${VAR} will be ignored. " + "This is useful for configuring scripts that use ${VAR}." + "\n" + "Input file lines of the form \"#cmakedefine VAR ...\" " + "will be replaced with either \"#define VAR ...\" or " + "\"/* #undef VAR */\" depending on whether VAR is set in CMake to " + "any value not considered a false constant by the if() command. " + "(Content of \"...\", if any, is processed as above.) " + "Input file lines of the form \"#cmakedefine01 VAR\" " + "will be replaced with either \"#define VAR 1\" or " + "\"#define VAR 0\" similarly." + "\n" "With NEWLINE_STYLE the line ending could be adjusted: \n" " 'UNIX' or 'LF' for \\n, 'DOS', 'WIN32' or 'CRLF' for \\r\\n.\n" "COPYONLY must not be used with NEWLINE_STYLE.\n"; diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 8db0e8f..55d70f8 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1222,6 +1222,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables that Control the Build"); cm->DefineProperty + ("CMAKE_LINK_DEPENDS_NO_SHARED", cmProperty::VARIABLE, + "Whether to skip link dependencies on shared library files.", + "This variable initializes the LINK_DEPENDS_NO_SHARED " + "property on targets when they are created. " + "See that target property for additional information.", + 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 " diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index b4aa903..a0862ec 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -89,7 +89,8 @@ public: " [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS])\n" "WRITE will write a message into a file called 'filename'. It " "overwrites the file if it already exists, and creates the file " - "if it does not exist.\n" + "if it does not exist. (If the file is a build input, use " + "configure_file to update the file only when its content changes.)\n" "APPEND will write a message into a file same as WRITE, except " "it will append it to the end of the file\n" "READ will read the content of a file and store it into the " diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h index 730a7a7..0a029dc 100644 --- a/Source/cmFunctionCommand.h +++ b/Source/cmFunctionCommand.h @@ -90,7 +90,9 @@ public: "will have the actual values of the arguments passed in. This " "facilitates creating functions with optional arguments. Additionally " "ARGV holds the list of all arguments given to the function and ARGN " - "holds the list of argument past the last expected argument." + "holds the list of arguments past the last expected argument." + "\n" + "A function opens a new scope: see set(var PARENT_SCOPE) for details." "\n" "See the cmake_policy() command documentation for the behavior of " "policies inside functions." diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index e8ca788..0ec4850 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -200,7 +200,6 @@ void cmGlobalVisualStudio6Generator tt != orderedProjectTargets.end(); ++tt) { cmTarget* target = *tt; - cmMakefile* mf = target->GetMakefile(); // Write the project into the DSW file const char* expath = target->GetProperty("EXTERNAL_MSPROJECT"); if(expath) diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index bc2bbfb..c3ec3f2 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -204,7 +204,6 @@ void cmGlobalVisualStudio8Generator::AddCheckTarget() // overwritten by the CreateVCProjBuildRule. // (this could be avoided with per-target source files) const char* no_main_dependency = 0; - const char* no_working_directory = 0; if(cmSourceFile* file = mf->AddCustomCommandToOutput( stamps, listFiles, diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 0968b77..ea6757d 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -75,7 +75,6 @@ void cmGlobalVisualStudioGenerator::Generate() #endif // Now make all targets depend on the ALL_BUILD target - cmTargets targets; for(std::vector<cmLocalGenerator*>::iterator i = gen.begin(); i != gen.end(); ++i) { diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index 6751fc0..dd37b82 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -72,9 +72,12 @@ public: "CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. " "By using AFTER or BEFORE explicitly, you can select between " "appending and prepending, independent of the default. " + "\n" "If the SYSTEM option is given, the compiler will be told the " "directories are meant as system include directories on some " - "platforms."; + "platforms (signalling this setting might achieve effects such as " + "the compiler skipping warnings, or these fixed-install system files " + "not being considered in dependency calculations - see compiler docs)."; } cmTypeMacro(cmIncludeDirectoryCommand, cmCommand); diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index b2acf06..181b922 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -224,6 +224,10 @@ cmLoadedCommand::~cmLoadedCommand() bool cmLoadCommandCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { + this->Makefile->IssueMessage( + cmake::AUTHOR_WARNING, + "The \"load_command\" command will be removed in CMake 3.0. " + "See command documentation for details."); if(args.size() < 1 ) { return true; diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h index f0b34ee..bcd1831 100644 --- a/Source/cmLoadCommandCommand.h +++ b/Source/cmLoadCommandCommand.h @@ -47,7 +47,7 @@ public: */ virtual const char* GetTerseDocumentation() const { - return "Load a command into a running CMake."; + return "Deprecated. Use macro() or function() instead."; } /** @@ -56,6 +56,13 @@ public: virtual const char* GetFullDocumentation() const { return + "This command will be removed in CMake 3.0. " + "It works only when the target architecture matches the " + "running CMake binary. " + "Use macro() or function() to add commands. " + "Use execute_process() to run advanced computations " + "in external processes." + "\n" " load_command(COMMAND_NAME <loc1> [loc2 ...])\n" "The given locations are searched for a library whose name is " "cmCOMMAND_NAME. If found, it is loaded as a module and the command " @@ -67,6 +74,12 @@ public: "Otherwise the variable will not be set."; } + /** This command is kept for compatibility with older CMake versions. */ + virtual bool IsDiscouraged() const + { + return true; + } + cmTypeMacro(cmLoadCommandCommand, cmCommand); }; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index f15322b..9497e31 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -326,18 +326,18 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, { cmSystemTools::ReplaceString(source, "$(IntDir)/", ""); #if defined(_WIN32) || defined(__CYGWIN__) - std::ofstream fout(source.c_str(), + std::ofstream sourceFout(source.c_str(), std::ios::binary | std::ios::out | std::ios::trunc); #else - std::ofstream fout(source.c_str(), + std::ofstream sourceFout(source.c_str(), std::ios::out | std::ios::trunc); #endif - if(fout) + if(sourceFout) { - fout.write("# generated from CMake",22); - fout.flush(); - fout.close(); + sourceFout.write("# generated from CMake",22); + sourceFout.flush(); + sourceFout.close(); } } } @@ -710,6 +710,8 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b, switch(b) { + case WIN32_EXECUTABLE: + break; case STATIC_LIBRARY: this->DSPHeaderTemplate = root; this->DSPHeaderTemplate += "/staticLibHeader.dsptemplate"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f9a2d32..d954a52 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -914,12 +914,12 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, // for FAT32 file systems, which can cause an empty manifest // to be embedded into the resulting executable. See CMake // bug #2617. - const char* tool = "VCManifestTool"; + const char* manifestTool = "VCManifestTool"; if(this->FortranProject) { - tool = "VFManifestTool"; + manifestTool = "VFManifestTool"; } - fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n" + fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << manifestTool << "\"\n" << "\t\t\t\tUseFAT32Workaround=\"true\"\n" << "\t\t\t/>\n"; } @@ -1003,6 +1003,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } switch(target.GetType()) { + case cmTarget::UNKNOWN_LIBRARY: + break; case cmTarget::OBJECT_LIBRARY: { std::string libpath = this->GetTargetDirectory(target); diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 4bcf4de..ef2bb1d 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -84,7 +84,6 @@ cmLocalVisualStudioGenerator const char* newline_text) { bool useLocal = this->CustomCommandUseLocal(); - const cmCustomCommandLines& commandLines = cc.GetCommandLines(); const char* workingDirectory = cc.GetWorkingDirectory(); cmCustomCommandGenerator ccg(cc, configName, this->Makefile); RelativeRoot relativeRoot = workingDirectory? NONE : START_OUTPUT; diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h index f8c40c0..aedbb4d 100644 --- a/Source/cmMacroCommand.h +++ b/Source/cmMacroCommand.h @@ -92,12 +92,12 @@ public: "facilitates creating macros with optional arguments. Additionally " "${ARGV} holds the list of all arguments given to the macro and " "${ARGN} " - "holds the list of argument past the last expected argument. " + "holds the list of arguments past the last expected argument. " "Note that the parameters to a macro and values such as ARGN " "are not variables in the usual CMake sense. They are string " - "replacements much like the c preprocessor would do with a " - "macro. If you want true CMake variables you should look at " - "the function command." + "replacements much like the C preprocessor would do with a macro. " + "If you want true CMake variables and/or better CMake scope control " + "you should look at the function command." "\n" "See the cmake_policy() command documentation for the behavior of " "policies inside macros." diff --git a/Source/cmMathCommand.h b/Source/cmMathCommand.h index 27c5b6a..dc0ceb3 100644 --- a/Source/cmMathCommand.h +++ b/Source/cmMathCommand.h @@ -58,11 +58,11 @@ public: { return " math(EXPR <output variable> <math expression>)\n" - "EXPR evaluates mathematical expression and return result in the " + "EXPR evaluates mathematical expression and returns result in the " "output variable. Example mathematical expression is " "'5 * ( 10 + 13 )'. Supported operators are " "+ - * / % | & ^ ~ << >> * / %. They have the same meaning " - " as they do in c code."; + " as they do in C code."; } cmTypeMacro(cmMathCommand, cmCommand); diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h index 9f01eaf..fc61810 100644 --- a/Source/cmMessageCommand.h +++ b/Source/cmMessageCommand.h @@ -67,8 +67,9 @@ public: " STATUS = Incidental information\n" " WARNING = CMake Warning, continue processing\n" " AUTHOR_WARNING = CMake Warning (dev), continue processing\n" - " SEND_ERROR = CMake Error, continue but skip generation\n" - " FATAL_ERROR = CMake Error, stop all processing\n" + " SEND_ERROR = CMake Error, continue processing,\n" + " but skip generation\n" + " FATAL_ERROR = CMake Error, stop processing and generation\n" "The CMake command-line tool displays STATUS messages on stdout " "and all other message types on stderr. " "The CMake GUI displays all messages in its log area. " diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 6c54ced..853bc12 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -564,6 +564,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac commandLineLengthLimit = ((int)sysconf(_SC_ARG_MAX))-linkRuleLength-1000; #else + (void)linkRuleLength; commandLineLengthLimit = -1; #endif } diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 79af4d7..6aef502 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -457,7 +457,7 @@ cmPolicies::cmPolicies() "This makes sure that the modules belonging to " "CMake always get those files included which they expect, and against " "which they were developed and tested. " - "In call other cases, the files found in " + "In all other cases, the files found in " "CMAKE_MODULE_PATH still take precedence over the ones in " "the CMake module directory. " "The OLD behaviour is to always prefer files from CMAKE_MODULE_PATH over " diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index cc3b6d6..1d4b0c8 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -458,7 +458,7 @@ void cmSourceFile::DefineProperties(cmake *cm) "A property on a source file that indicates if the source file " "is a header file with no associated implementation. This is " "set automatically based on the file extension and is used by " - "CMake to determine is certain dependency information should be " + "CMake to determine if certain dependency information should be " "computed."); cm->DefineProperty diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index 6c87b71..9f6b7e4 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -68,7 +68,7 @@ public: "expression matches the file will be favored.\n" "The name of the group may contain backslashes to specify subgroups:\n" " source_group(outer\\\\inner ...)\n" - "For backwards compatibility, this command is also supports the " + "For backwards compatibility, this command also supports the " "format:\n" " source_group(name regex)"; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index bc50386..7c62ea8 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -666,6 +666,22 @@ void cmTarget::DefineProperties(cmake *cm) "custom Makefile link rules."); cm->DefineProperty + ("LINK_DEPENDS_NO_SHARED", cmProperty::TARGET, + "Do not depend on linked shared library files.", + "Set this property to true to tell CMake generators not to add " + "file-level dependencies on the shared library files linked by " + "this target. " + "Modification to the shared libraries will not be sufficient to " + "re-link this target. " + "Logical target-level dependencies will not be affected so the " + "linked shared libraries will still be brought up to date before " + "this target is built." + "\n" + "This property is initialized by the value of the variable " + "CMAKE_LINK_DEPENDS_NO_SHARED if it is set when a target is " + "created."); + + cm->DefineProperty ("LINK_INTERFACE_LIBRARIES", cmProperty::TARGET, "List public interface libraries for a shared library or executable.", "By default linking to a shared library target transitively " @@ -1329,6 +1345,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("OSX_ARCHITECTURES", 0); this->SetPropertyDefault("AUTOMOC", 0); this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0); + this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", 0); this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0); this->SetPropertyDefault("WIN32_EXECUTABLE", 0); this->SetPropertyDefault("MACOSX_BUNDLE", 0); diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 63114d2..8e5823c 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -100,11 +100,11 @@ public: "to the LINK_INTERFACE_LIBRARIES and its per-configuration equivalent " "target properties instead of using them for linking. " "Libraries specified as \"debug\" are appended to the " - "the LINK_INTERFACE_LIBRARIES_DEBUG property (or to the properties " + "LINK_INTERFACE_LIBRARIES_DEBUG property (or to the properties " "corresponding to configurations listed in the DEBUG_CONFIGURATIONS " "global property if it is set). " "Libraries specified as \"optimized\" are appended to the " - "the LINK_INTERFACE_LIBRARIES property. " + "LINK_INTERFACE_LIBRARIES property. " "Libraries specified as \"general\" (or without any keyword) are " "treated as if specified for both \"debug\" and \"optimized\"." "\n" diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index 7878729..13b9973 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -81,7 +81,7 @@ public: "the executable, but it will not try to run the executable. Instead it " "will create cache variables which must be filled by the user or by " "presetting them in some CMake script file to the values the " - "executable would have produced if it would have been run on its actual " + "executable would have produced if it had been run on its actual " "target platform. These variables are RUN_RESULT_VAR (explanation see " "above) and if RUN_OUTPUT_VARIABLE (or OUTPUT_VARIABLE) was used, an " "additional cache variable " diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index def4133..d3b3950 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -404,6 +404,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() case cmTarget::UTILITY: configType += "Utility"; break; + case cmTarget::GLOBAL_TARGET: + case cmTarget::UNKNOWN_LIBRARY: + break; } configType += "</ConfigurationType>\n"; this->WriteString(configType.c_str(), 2); @@ -425,8 +428,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() mfcLine += useOfMfcValue + "</UseOfMfc>\n"; this->WriteString(mfcLine.c_str(), 2); - if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY && - this->ClOptions[*i]->UsingUnicode() || + if((this->Target->GetType() <= cmTarget::OBJECT_LIBRARY && + this->ClOptions[*i]->UsingUnicode()) || this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) { this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2); @@ -907,7 +910,6 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( cmSourceFile* source) { cmSourceFile& sf = *source; - cmLocalVisualStudio7Generator* lg = this->LocalGenerator; std::string objectName; if(this->GeneratorTarget->ExplicitObjectName.find(&sf) diff --git a/Source/cmWin32ProcessExecution.cxx b/Source/cmWin32ProcessExecution.cxx index 9a536c1..5752ab6 100644 --- a/Source/cmWin32ProcessExecution.cxx +++ b/Source/cmWin32ProcessExecution.cxx @@ -271,13 +271,6 @@ bool cmWin32ProcessExecution::Wait(int timeout) return this->PrivateClose(timeout); } -/* - * Internal dictionary mapping popen* file pointers to process handles, - * for use when retrieving the process exit code. See _PyPclose() below - * for more information on this dictionary's use. - */ -static void *_PyPopenProcs = NULL; - static BOOL RealPopenCreateProcess(const char *cmdstring, const char *path, const char *szConsoleSpawn, @@ -679,18 +672,6 @@ bool cmWin32ProcessExecution::PrivateOpen(const char *cmdstring, } } - /* - * Insert the files we've created into the process dictionary - * all referencing the list with the process handle and the - * initial number of files (see description below in _PyPclose). - * Since if _PyPclose later tried to wait on a process when all - * handles weren't closed, it could create a deadlock with the - * child, we spend some energy here to try to ensure that we - * either insert all file handles into the dictionary or none - * at all. It's a little clumsy with the various popen modes - * and variable number of files involved. - */ - /* Child is launched. Close the parents copy of those pipe * handles that only the child should have open. You need to * make sure that no handles to the write end of the output pipe @@ -761,43 +742,6 @@ cmWin32ProcessExecution::~cmWin32ProcessExecution() this->CloseHandles(); } -/* - * Wrapper for fclose() to use for popen* files, so we can retrieve the - * exit code for the child process and return as a result of the close. - * - * This function uses the _PyPopenProcs dictionary in order to map the - * input file pointer to information about the process that was - * originally created by the popen* call that created the file pointer. - * The dictionary uses the file pointer as a key (with one entry - * inserted for each file returned by the original popen* call) and a - * single list object as the value for all files from a single call. - * The list object contains the Win32 process handle at [0], and a file - * count at [1], which is initialized to the total number of file - * handles using that list. - * - * This function closes whichever handle it is passed, and decrements - * the file count in the dictionary for the process handle pointed to - * by this file. On the last close (when the file count reaches zero), - * this function will wait for the child process and then return its - * exit code as the result of the close() operation. This permits the - * files to be closed in any order - it is always the close() of the - * final handle that will return the exit code. - */ - - /* RED_FLAG 31-Aug-2000 Tim - * This is always called (today!) between a pair of - * Py_BEGIN_ALLOW_THREADS/ Py_END_ALLOW_THREADS - * macros. So the thread running this has no valid thread state, as - * far as Python is concerned. However, this calls some Python API - * functions that cannot be called safely without a valid thread - * state, in particular PyDict_GetItem. - * As a temporary hack (although it may last for years ...), we - * *rely* on not having a valid thread state in this function, in - * order to create our own "from scratch". - * This will deadlock if _PyPclose is ever called by a thread - * holding the global lock. - */ - bool cmWin32ProcessExecution::PrivateClose(int /* timeout */) { HANDLE hProcess = this->ProcessHandle; diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index 34350bf..04dab59 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -237,12 +237,14 @@ int main() { // needed to suppress filename output of msvc tools std::string srcfilename; + { std::string::size_type pos = srcfile.rfind("\\"); if (pos == std::string::npos) { srcfilename = srcfile; } else { srcfilename = srcfile.substr(pos + 1); } + } std::string nol = " /nologo "; std::string show = " /showIncludes "; @@ -266,10 +268,12 @@ int main() { // call cl in object dir so the .i is generated there std::string objdir; + { std::string::size_type pos = objfile.rfind("\\"); if (pos != std::string::npos) { objdir = objfile.substr(0, pos); } + } // extract dependencies with cl.exe int exit_code = process(srcfilename, dfile, objfile, diff --git a/Source/cmw9xcom.cxx b/Source/cmw9xcom.cxx index e6014b3..ab238d5 100644 --- a/Source/cmw9xcom.cxx +++ b/Source/cmw9xcom.cxx @@ -31,14 +31,14 @@ int main (int argc, char *argv[]) int cc; for ( cc = 2; cc < argc; cc ++ ) { - std::string arg = argv[cc]; - if ( (arg.find_first_of(" ") != arg.npos) && - (arg.find_first_of("\"") == arg.npos) ) + std::string nextArg = argv[cc]; + if ( (nextArg.find_first_of(" ") != nextArg.npos) && + (nextArg.find_first_of("\"") == nextArg.npos) ) { - arg = "\"" + arg + "\""; + nextArg = "\"" + nextArg + "\""; } command += " "; - command += arg; + command += nextArg; } return cmWin32ProcessExecution::Windows9xHack(command.c_str()); diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 6b63b94..6d990a9 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -1323,7 +1323,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName( for (ifa=ifas; ifa!=NULL; ifa=ifa->ifa_next) { - int fam=ifa->ifa_addr->sa_family; + int fam = ifa->ifa_addr? ifa->ifa_addr->sa_family : -1; if ((fam==AF_INET) || (fam==AF_INET6)) { char host[NI_MAXHOST]={'\0'}; diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 2a70b6e..2792751 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -60,6 +60,12 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx "static const char* zot_macro_tgt = \"zot_macro_tgt\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_lib.h + "#define link_depends_no_shared_lib_value 1\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_exe.h + "#define link_depends_no_shared_exe_value 0\n") +set(link_depends_no_shared_check_txt ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_check.txt) + help_xcode_depends() message("Building project first time") @@ -125,6 +131,19 @@ else() message(SEND_ERROR "Project did not initially build properly: ${out}") endif() +if(EXISTS "${link_depends_no_shared_check_txt}") + file(STRINGS "${link_depends_no_shared_check_txt}" link_depends_no_shared_check LIMIT_COUNT 1) + if("${link_depends_no_shared_check}" STREQUAL "1") + message(STATUS "link_depends_no_shared_exe is newer than link_depends_no_shared_lib as expected.") + else() + message(SEND_ERROR "Project did not initially build properly: " + "link_depends_no_shared_exe is older than link_depends_no_shared_lib.") + endif() +else() + message(SEND_ERROR "Project did not initially build properly: " + "Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.") +endif() + message("Waiting 3 seconds...") # any additional argument will cause ${bar} to wait forever execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out) @@ -141,6 +160,9 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx "static const char* zot_macro_tgt = \"zot_macro_tgt changed\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_lib.h + "#define link_depends_no_shared_lib_value 0\n") + if(TEST_LINK_DEPENDS) file(WRITE ${TEST_LINK_DEPENDS} "2") endif() @@ -219,3 +241,15 @@ is not newer than dependency ") endif() endif() + +if(EXISTS "${link_depends_no_shared_check_txt}") + file(STRINGS "${link_depends_no_shared_check_txt}" link_depends_no_shared_check LIMIT_COUNT 1) + if("${link_depends_no_shared_check}" STREQUAL "0") + message(STATUS "link_depends_no_shared_exe is older than link_depends_no_shared_lib as expected.") + else() + message(SEND_ERROR "Project did not rebuild properly: link_depends_no_shared_exe is newer than link_depends_no_shared_lib.") + endif() +else() + message(SEND_ERROR "Project did not rebuild properly. " + "Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.") +endif() diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index 542c716..f8a3d15 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -108,3 +108,18 @@ if(TEST_LINK_DEPENDS) add_executable(linkdep linkdep.cxx) set_property(TARGET linkdep PROPERTY LINK_DEPENDS ${TEST_LINK_DEPENDS}) endif() + +add_library(link_depends_no_shared_lib SHARED link_depends_no_shared_lib.c + ${CMAKE_CURRENT_BINARY_DIR}/link_depends_no_shared_lib.h) +add_executable(link_depends_no_shared_exe link_depends_no_shared_exe.c + ${CMAKE_CURRENT_BINARY_DIR}/link_depends_no_shared_exe.h) +target_link_libraries(link_depends_no_shared_exe link_depends_no_shared_lib) +set_property(TARGET link_depends_no_shared_exe PROPERTY LINK_DEPENDS_NO_SHARED 1) +add_custom_target(link_depends_no_shared_check ALL + COMMAND ${CMAKE_COMMAND} + -Dlib=$<TARGET_FILE:link_depends_no_shared_lib> + -Dexe=$<TARGET_FILE:link_depends_no_shared_exe> + -Dout=${CMAKE_CURRENT_BINARY_DIR}/link_depends_no_shared_check.txt + -P ${CMAKE_CURRENT_SOURCE_DIR}/link_depends_no_shared_check.cmake + ) +add_dependencies(link_depends_no_shared_check link_depends_no_shared_exe) diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_check.cmake b/Tests/BuildDepends/Project/link_depends_no_shared_check.cmake new file mode 100644 index 0000000..3a61137 --- /dev/null +++ b/Tests/BuildDepends/Project/link_depends_no_shared_check.cmake @@ -0,0 +1,7 @@ +if(NOT EXISTS "${lib}" OR NOT EXISTS "${exe}") + file(REMOVE "${out}") +elseif("${exe}" IS_NEWER_THAN "${lib}") + file(WRITE "${out}" "1\n") +else() + file(WRITE "${out}" "0\n") +endif() diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_exe.c b/Tests/BuildDepends/Project/link_depends_no_shared_exe.c new file mode 100644 index 0000000..e9113a2 --- /dev/null +++ b/Tests/BuildDepends/Project/link_depends_no_shared_exe.c @@ -0,0 +1,9 @@ +#include "link_depends_no_shared_exe.h" +#ifdef _WIN32 +__declspec(dllimport) +#endif +int link_depends_no_shared_lib(void); +int main() +{ + return link_depends_no_shared_lib() + link_depends_no_shared_exe_value; +} diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_lib.c b/Tests/BuildDepends/Project/link_depends_no_shared_lib.c new file mode 100644 index 0000000..d226289 --- /dev/null +++ b/Tests/BuildDepends/Project/link_depends_no_shared_lib.c @@ -0,0 +1,8 @@ +#include "link_depends_no_shared_lib.h" +#ifdef _WIN32 +__declspec(dllexport) +#endif +int link_depends_no_shared_lib(void) +{ + return link_depends_no_shared_lib_value; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 1e8c228..f2a198c 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -983,6 +983,36 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ set_tests_properties(ExternalProject PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + add_test(ExternalProjectUpdateSetup ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate" + "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project ExternalProjectUpdateTest + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate" + --force-new-ctest-process + --test-command ${CMAKE_CTEST_COMMAND} -V + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate") + set_tests_properties(ExternalProjectUpdateSetup PROPERTIES + TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + + add_test(NAME ExternalProjectUpdate + COMMAND ${CMAKE_CMAKE_COMMAND} + -DExternalProjectUpdate_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate + -DExternalProjectUpdate_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate + -DCMAKE_TEST_GENERATOR=${CMAKE_TEST_GENERATOR} + -DCMAKE_TEST_MAKEPROGRAM=${CMAKE_TEST_MAKEPROGRAM} + -DCMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND} + -P ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate") + set_tests_properties(ExternalProjectUpdate PROPERTIES + TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT} + WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate + DEPENDS ExternalProjectUpdateSetup ) + # do each of the tutorial steps foreach(STP RANGE 1 7) add_test(TutorialStep${STP} ${CMAKE_CTEST_COMMAND} diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 3f8e827..e24a979 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -638,6 +638,17 @@ if(do_svn_tests) "${binary_base}/TutorialStep1-SVN-trunk/Tutorial" 98) endif() +if(do_git_tests) + add_test(TutorialStep1-GIT-byhash + "${binary_base}/TutorialStep1-GIT-byhash/Tutorial" 100) + + add_test(TutorialStep1-GIT-bytag + "${binary_base}/TutorialStep1-GIT-bytag/Tutorial" 99) + + add_test(TutorialStep1-GIT-master + "${binary_base}/TutorialStep1-GIT-master/Tutorial" 98) +endif() + # InstallTree tests: # diff --git a/Tests/ExternalProjectUpdate/CMakeLists.txt b/Tests/ExternalProjectUpdate/CMakeLists.txt new file mode 100644 index 0000000..c33e90b --- /dev/null +++ b/Tests/ExternalProjectUpdate/CMakeLists.txt @@ -0,0 +1,94 @@ +cmake_minimum_required(VERSION 2.8) +project(ExternalProjectUpdateTest NONE) + +include(ExternalProject) + +find_package(Git) + +option(ExternalProjectUpdateTest_USE_FOLDERS "Enable folder grouping in IDEs." ON) +if(ExternalProjectUpdateTest_USE_FOLDERS) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) +else() + set_property(GLOBAL PROPERTY USE_FOLDERS OFF) +endif() + +set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER + "CMakePredefinedTargets-in-ExternalProjectUpdateTest") + +set(base "${CMAKE_BINARY_DIR}/CMakeExternals") +set(binary_base "${base}/Build") +set_property(DIRECTORY PROPERTY EP_BASE ${base}) +set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) + +set(do_git_tests 0) + +if(GIT_EXECUTABLE) + set(do_git_tests 1) + + execute_process( + COMMAND "${GIT_EXECUTABLE}" --version + OUTPUT_VARIABLE ov + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string(REGEX REPLACE "^git version (.+)$" "\\1" git_version "${ov}") + message(STATUS "git_version='${git_version}'") + + if(git_version VERSION_LESS 1.6.5) + message(STATUS "No ExternalProject git tests with git client less than version 1.6.5") + set(do_git_tests 0) + endif() +endif() + +# This should be specified from the command line. +if(NOT TEST_GIT_TAG) + set(TEST_GIT_TAG origin/master) +endif() + +if(do_git_tests) + set(local_git_repo "../../LocalRepositories/GIT") + + # Unzip/untar the git repository in our source folder so that other + # projects below may use it to test git args of ExternalProject_Add + # + set(proj SetupLocalGITRepository) + ExternalProject_Add(${proj} + SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/LocalRepositories/GIT + URL ${CMAKE_CURRENT_SOURCE_DIR}/gitrepo.tgz + BUILD_COMMAND "" + CONFIGURE_COMMAND "${GIT_EXECUTABLE}" --version + INSTALL_COMMAND "" + ) + set_property(TARGET ${proj} + PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing") + + set(proj TutorialStep1-GIT) + ExternalProject_Add(${proj} + GIT_REPOSITORY "${local_git_repo}" + GIT_TAG ${TEST_GIT_TAG} + CMAKE_GENERATOR "${CMAKE_GENERATOR}" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> + INSTALL_COMMAND "" + DEPENDS "SetupLocalGITRepository" + ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") +endif() + + +# Test the testable built/installed products: +# +enable_testing() + + +# Do at least a smoke test of a built executable from each +# project's build directory... +# +# BuildTree tests: +# + +if(do_git_tests) + add_test(TutorialStep1-GIT + "${binary_base}/TutorialStep1-GIT/Tutorial" 81) +endif() + +message(STATUS "do_git_tests='${do_git_tests}'") +message(STATUS "GIT_EXECUTABLE='${GIT_EXECUTABLE}'") diff --git a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake new file mode 100644 index 0000000..5a6af57 --- /dev/null +++ b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake @@ -0,0 +1,94 @@ +# Set the ExternalProject GIT_TAG to desired_tag, and make sure the +# resulting checked out version is resulting_sha and rebuild. +# This check's the correct behavior of the ExternalProject UPDATE_COMMAND. +# Also verify that a fetch only occurs when fetch_expected is 1. +macro(check_a_tag desired_tag resulting_sha fetch_expected) + message( STATUS "Checking ExternalProjectUpdate to tag: ${desired_tag}" ) + + # Remove the FETCH_HEAD file, so we can check if it gets replaced with a 'git + # fetch'. + set( FETCH_HEAD_file ${ExternalProjectUpdate_BINARY_DIR}/CMakeExternals/Source/TutorialStep1-GIT/.git/FETCH_HEAD ) + file( REMOVE ${FETCH_HEAD_file} ) + + # Configure + execute_process(COMMAND ${CMAKE_COMMAND} + -G ${CMAKE_TEST_GENERATOR} + -DTEST_GIT_TAG:STRING=${desired_tag} + ${ExternalProjectUpdate_SOURCE_DIR} + WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR} + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR "Could not configure the project.") + endif() + + # Build + execute_process(COMMAND ${CMAKE_COMMAND} + --build ${ExternalProjectUpdate_BINARY_DIR} + RESULT_VARIABLE error_code + ) + if(error_code) + message(FATAL_ERROR "Could not build the project.") + endif() + + # Check the resulting SHA + execute_process(COMMAND ${GIT_EXECUTABLE} + rev-list --max-count=1 HEAD + WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR}/CMakeExternals/Source/TutorialStep1-GIT + RESULT_VARIABLE error_code + OUTPUT_VARIABLE tag_sha + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(error_code) + message(FATAL_ERROR "Could not check the sha.") + endif() + + if(NOT (${tag_sha} STREQUAL ${resulting_sha})) + message(FATAL_ERROR "UPDATE_COMMAND produced + ${tag_sha} +when + ${resulting_sha} +was expected." + ) + endif() + + if( NOT EXISTS ${FETCH_HEAD_file} AND ${fetch_expected}) + message( FATAL_ERROR "Fetch did NOT occur when it was expected.") + endif() + if( EXISTS ${FETCH_HEAD_file} AND NOT ${fetch_expected}) + message( FATAL_ERROR "Fetch DID occur when it was not expected.") + endif() +endmacro() + +find_package(Git) +set(do_git_tests 0) +if(GIT_EXECUTABLE) + set(do_git_tests 1) + + execute_process( + COMMAND "${GIT_EXECUTABLE}" --version + OUTPUT_VARIABLE ov + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string(REGEX REPLACE "^git version (.+)$" "\\1" git_version "${ov}") + message(STATUS "git_version='${git_version}'") + + if(git_version VERSION_LESS 1.6.5) + message(STATUS "No ExternalProject git tests with git client less than version 1.6.5") + set(do_git_tests 0) + endif() +endif() + +if(do_git_tests) + check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1) + check_a_tag(tag1 d1970730310fe8bc07e73f15dc570071f9f9654a 1) + # With the Git UPDATE_COMMAND performance patch, this will not required a + # 'git fetch' + check_a_tag(tag1 d1970730310fe8bc07e73f15dc570071f9f9654a 0) + check_a_tag(tag2 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1) + check_a_tag(d19707303 d1970730310fe8bc07e73f15dc570071f9f9654a 1) + check_a_tag(d19707303 d1970730310fe8bc07e73f15dc570071f9f9654a 0) + check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1) + # This is a remote symbolic ref, so it will always trigger a 'git fetch' + check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7 1) +endif() diff --git a/Tests/ExternalProjectUpdate/gitrepo.tgz b/Tests/ExternalProjectUpdate/gitrepo.tgz Binary files differnew file mode 100644 index 0000000..87090ab --- /dev/null +++ b/Tests/ExternalProjectUpdate/gitrepo.tgz diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 8c67625..360ad78 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -55,6 +55,7 @@ add_RunCMake_test(find_package) add_RunCMake_test(include) add_RunCMake_test(include_directories) add_RunCMake_test(list) +add_RunCMake_test(load_command) if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") add_RunCMake_test(include_external_msproject) diff --git a/Tests/RunCMake/load_command/CMakeLists.txt b/Tests/RunCMake/load_command/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/load_command/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/load_command/LoadCommandDeprecated-stderr.txt b/Tests/RunCMake/load_command/LoadCommandDeprecated-stderr.txt new file mode 100644 index 0000000..7d374b2 --- /dev/null +++ b/Tests/RunCMake/load_command/LoadCommandDeprecated-stderr.txt @@ -0,0 +1,6 @@ +CMake Warning \(dev\) at LoadCommandDeprecated.cmake:1 \(load_command\): + The "load_command" command will be removed in CMake 3.0. See command + documentation for details. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/load_command/LoadCommandDeprecated.cmake b/Tests/RunCMake/load_command/LoadCommandDeprecated.cmake new file mode 100644 index 0000000..9e9b1f4 --- /dev/null +++ b/Tests/RunCMake/load_command/LoadCommandDeprecated.cmake @@ -0,0 +1 @@ +load_command() diff --git a/Tests/RunCMake/load_command/RunCMakeTest.cmake b/Tests/RunCMake/load_command/RunCMakeTest.cmake new file mode 100644 index 0000000..9a0f98d --- /dev/null +++ b/Tests/RunCMake/load_command/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(LoadCommandDeprecated) |