diff options
40 files changed, 302 insertions, 36 deletions
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 891333c..02f596b 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -98,3 +98,4 @@ All Policies /policy/CMP0044 /policy/CMP0045 /policy/CMP0046 + /policy/CMP0047 diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index c0ec0fe..d315fcb 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -48,6 +48,7 @@ Properties on Directories /prop_dir/ADDITIONAL_MAKE_CLEAN_FILES /prop_dir/CACHE_VARIABLES /prop_dir/CLEAN_NO_CUSTOM + /prop_dir/CMAKE_CONFIGURE_DEPENDS /prop_dir/COMPILE_DEFINITIONS_CONFIG /prop_dir/COMPILE_DEFINITIONS /prop_dir/COMPILE_OPTIONS diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index d209b8b..5743ab7 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -39,7 +39,7 @@ Options that can be used on all systems. Run with -E help for the usage 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, + make_directory, md5sum, remove, remove_directory, rename, sleep, tar, time, touch, touch_nocreate. In addition, some platform specific commands are available. On Windows: delete_regv, write_regv. On UNIX: create_symlink. diff --git a/Help/policy/CMP0047.rst b/Help/policy/CMP0047.rst new file mode 100644 index 0000000..7b87c4d --- /dev/null +++ b/Help/policy/CMP0047.rst @@ -0,0 +1,16 @@ +CMP0047 +------- + +Use QCC compiler id for the qcc drivers on QNX. + +CMake 2.8.12 and lower assigned the QNX qcc and QCC compiler drivers the "GNU" +compiler id. + +The OLD behavior for this policy is to use the "GNU" compiler id for the qcc +and QCC compiler drivers. The NEW behavior for this policy is to use the "QCC" +compiler id for those drivers. + +This policy was introduced in CMake version 3.0.0. +CMake version |release| warns when the policy is not set and uses +OLD behavior. Use the cmake_policy command to set it to OLD or +NEW explicitly. diff --git a/Help/prop_dir/CMAKE_CONFIGURE_DEPENDS.rst b/Help/prop_dir/CMAKE_CONFIGURE_DEPENDS.rst new file mode 100644 index 0000000..b1aef19 --- /dev/null +++ b/Help/prop_dir/CMAKE_CONFIGURE_DEPENDS.rst @@ -0,0 +1,9 @@ +CMAKE_CONFIGURE_DEPENDS +----------------------- + +Tell CMake about additional input files to the configuration process. +If any named file is modified the build system will re-run CMake to +re-configure the file and generate the build system again. + +Specify files as a semicolon-separated list of paths. Relative paths +are interpreted as relative to the current source directory. diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index d53247a..52f9590 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -227,6 +227,10 @@ char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; #endif +#ifdef __QNXNTO__ +char const* qnxnto = "INFO" ":" "qnxnto"; +#endif + @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_C_COMPILER_ID_ERROR_FOR_TEST@ diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index b5d498d..25ceb3f 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -220,6 +220,10 @@ char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; #endif +#ifdef __QNXNTO__ +char const* qnxnto = "INFO" ":" "qnxnto"; +#endif + @CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_CXX_COMPILER_ID_ERROR_FOR_TEST@ diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 247de6f..ca7eb8b 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -124,7 +124,7 @@ endif() # e.g. powerpc-linux-gas, arm-elf-gas or i586-mingw32msvc-gas , optionally # with a 3-component version number at the end # The other tools of the toolchain usually have the same prefix -# NAME_WE cannot be used since then this test will fail for names lile +# NAME_WE cannot be used since then this test will fail for names like # "arm-unknown-nto-qnx6.3.0-gas.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" if (NOT _CMAKE_TOOLCHAIN_PREFIX) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 438a98a..c3f5a66 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -149,7 +149,7 @@ endif () # e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc, optionally # with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2). # The other tools of the toolchain usually have the same prefix -# NAME_WE cannot be used since then this test will fail for names lile +# NAME_WE cannot be used since then this test will fail for names like # "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 5f9d9bf..21864f1 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -145,7 +145,7 @@ endif () # e.g. powerpc-linux-g++, arm-elf-g++ or i586-mingw32msvc-g++ , optionally # with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2). # The other tools of the toolchain usually have the same prefix -# NAME_WE cannot be used since then this test will fail for names lile +# NAME_WE cannot be used since then this test will fail for names like # "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 2bcf3d1..067892d 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -48,6 +48,21 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) CMAKE_DETERMINE_COMPILER_ID_VENDOR(${lang}) endif() + if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL GNU) + execute_process( + COMMAND "${CMAKE_${lang}_COMPILER}" + -V + OUTPUT_VARIABLE output ERROR_VARIABLE output + RESULT_VARIABLE result + TIMEOUT 10 + ) + if (output MATCHES "targets available") + set(CMAKE_${lang}_COMPILER_ID QCC) + # http://community.qnx.com/sf/discussion/do/listPosts/projects.community/discussion.qnx_momentics_community_support.topc3555?_pagenum=2 + # The qcc driver does not itself have a version. + endif() + endif() + # if the format is unknown after all files have been checked, put "Unknown" in the cache if(NOT CMAKE_EXECUTABLE_FORMAT) set(CMAKE_EXECUTABLE_FORMAT "Unknown" CACHE INTERNAL "Executable file format") @@ -369,6 +384,9 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) string(REGEX REPLACE "^0+([0-9])" "\\1" SIMULATE_VERSION "${SIMULATE_VERSION}") string(REGEX REPLACE "\\.0+([0-9])" ".\\1" SIMULATE_VERSION "${SIMULATE_VERSION}") endif() + if("${info}" MATCHES ".*INFO:qnxnto") + set(COMPILER_QNXNTO 1) + endif() endforeach() # Detect the exact architecture from the PE header. @@ -459,6 +477,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) set(CMAKE_${lang}_SIMULATE_ID "${CMAKE_${lang}_SIMULATE_ID}" PARENT_SCOPE) set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE) set(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE) + set(COMPILER_QNXNTO "${COMPILER_QNXNTO}" PARENT_SCOPE) endfunction() #----------------------------------------------------------------------------- diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 8e2065d..4c8a8f2 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -193,7 +193,7 @@ endif () # e.g. powerpc-linux-gfortran, arm-elf-gfortran or i586-mingw32msvc-gfortran , optionally # with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2). # The other tools of the toolchain usually have the same prefix -# NAME_WE cannot be used since then this test will fail for names lile +# NAME_WE cannot be used since then this test will fail for names like # "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 63f1180..1c1bd2f 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -585,13 +585,30 @@ message(STATUS \"downloading... done\") endfunction() -function(_ep_write_verifyfile_script script_filename local hash) +function(_ep_write_verifyfile_script script_filename local hash retries download_script) if("${hash}" MATCHES "${_ep_hash_regex}") set(algo "${CMAKE_MATCH_1}") string(TOLOWER "${CMAKE_MATCH_2}" expect_value) set(script_content "set(expect_value \"${expect_value}\") -file(${algo} \"\${file}\" actual_value) -if(\"\${actual_value}\" STREQUAL \"\${expect_value}\") +set(attempt 0) +set(succeeded 0) +while(\${attempt} LESS ${retries} OR \${attempt} EQUAL ${retries} AND NOT \${succeeded}) + file(${algo} \"\${file}\" actual_value) + if(\"\${actual_value}\" STREQUAL \"\${expect_value}\") + set(succeeded 1) + elseif(\${attempt} LESS ${retries}) + message(STATUS \"${algo} hash of \${file} +does not match expected value + expected: \${expect_value} + actual: \${actual_value} +Retrying download. +\") + file(REMOVE \"\${file}\") + execute_process(COMMAND ${CMAKE_COMMAND} -P \"${download_script}\") + endif() +endwhile() + +if(\${succeeded}) message(STATUS \"verifying file... done\") else() message(FATAL_ERROR \"error: ${algo} hash of @@ -1394,6 +1411,8 @@ function(_ep_add_download_command name) set(repository "external project URL") set(module "${url}") set(tag "${hash}") + set(retries 0) + set(download_script "") configure_file( "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in" "${stamp_dir}/${name}-urlinfo.txt" @@ -1423,16 +1442,17 @@ function(_ep_add_download_command name) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) - _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" - "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}") - set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake + set(download_script "${stamp_dir}/download-${name}.cmake") + _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}") + set(cmd ${CMAKE_COMMAND} -P "${download_script}" COMMAND) + set(retries 3) set(comment "Performing download step (download, verify and extract) for '${name}'") else() set(file "${url}") set(comment "Performing download step (verify and extract) for '${name}'") endif() - _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}") + _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}" "${retries}" "${download_script}") list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake COMMAND) _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}") diff --git a/Modules/Platform/QNX-QCC-C.cmake b/Modules/Platform/QNX-QCC-C.cmake new file mode 100644 index 0000000..e5721a7 --- /dev/null +++ b/Modules/Platform/QNX-QCC-C.cmake @@ -0,0 +1,4 @@ + +include(Platform/QNX) + +__compiler_qcc(C) diff --git a/Modules/Platform/QNX-QCC-CXX.cmake b/Modules/Platform/QNX-QCC-CXX.cmake new file mode 100644 index 0000000..e490bbe --- /dev/null +++ b/Modules/Platform/QNX-QCC-CXX.cmake @@ -0,0 +1,4 @@ + +include(Platform/QNX) + +__compiler_qcc(CXX) diff --git a/Modules/Platform/QNX.cmake b/Modules/Platform/QNX.cmake index 9afde05..cc551bd 100644 --- a/Modules/Platform/QNX.cmake +++ b/Modules/Platform/QNX.cmake @@ -1,24 +1,6 @@ set(QNXNTO 1) -# The QNX GCC does not seem to have -isystem so remove the flag. -set(CMAKE_INCLUDE_SYSTEM_FLAG_C) -set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX) -# ... Nor does the driver support appropriate flags to create depfiles. -set(CMAKE_DEPFILE_FLAGS_C) -set(CMAKE_DEPFILE_FLAGS_CXX) - set(CMAKE_DL_LIBS "") -set(CMAKE_SHARED_LIBRARY_C_FLAGS "") -set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") -set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") -set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") -set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") -set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") -set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") -set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") -# http://www.qnx.com/developers/docs/6.4.0/neutrino/utilities/q/qcc.html#examples -set(CMAKE_C_COMPILE_OPTIONS_TARGET "-V") -set(CMAKE_CXX_COMPILE_OPTIONS_TARGET "-V") # Shared libraries with no builtin soname may not be linked safely by # specifying the file path. @@ -32,8 +14,22 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE) set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic") set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic") endforeach() -# force the language to be c++ since qnx only has gcc and not g++ and c++? -set(CMAKE_CXX_COMPILE_OBJECT - "<CMAKE_CXX_COMPILER> -x c++ <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>") -include(Platform/UnixPaths) +include(Platform/GNU) +unset(CMAKE_LIBRARY_ARCHITECTURE_REGEX) + +macro(__compiler_qcc lang) + # http://www.qnx.com/developers/docs/6.4.0/neutrino/utilities/q/qcc.html#examples + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-V") + + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-Wp,-isystem,") + set(CMAKE_DEPFILE_FLAGS_${lang} "-Wc,-MMD,<DEPFILE>,-MT,<OBJECT>,-MF,<DEPFILE>") + + if (lang STREQUAL CXX) + # If the toolchain uses qcc for CMAKE_CXX_COMPILER instead of QCC, the + # default for the driver is not c++. + set(CMAKE_CXX_COMPILE_OBJECT + "<CMAKE_CXX_COMPILER> -lang-c++ <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>") + endif() + +endmacro() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 731e592..301eff0 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 12) -set(CMake_VERSION_TWEAK 20140121) +set(CMake_VERSION_TWEAK 20140127) #set(CMake_VERSION_RC 1) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 311763b..e79bc6c 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2983,6 +2983,8 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) << " for file: [" << file << "]" << std::endl << " expected hash: [" << expectedHash << "]" << std::endl << " actual hash: [" << actualHash << "]" << std::endl + << " status: [" << (int)res << ";\"" + << ::curl_easy_strerror(res) << "\"]" << std::endl ; this->SetError(oss.str().c_str()); return false; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8a7eee4..03486d8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -748,7 +748,12 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, { std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID"; const char* compilerId = mf->GetDefinition(compilerIdVar.c_str()); - if(compilerId && strcmp(compilerId, "AppleClang") == 0) + if(!compilerId) + { + return; + } + + if(strcmp(compilerId, "AppleClang") == 0) { cmPolicies* policies = this->CMakeInstance->GetPolicies(); switch(mf->GetPolicyStatus(cmPolicies::CMP0025)) @@ -778,6 +783,37 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, break; } } + + if(strcmp(compilerId, "QCC") == 0) + { + cmPolicies* policies = this->CMakeInstance->GetPolicies(); + switch(mf->GetPolicyStatus(cmPolicies::CMP0047)) + { + case cmPolicies::WARN: + if(!this->CMakeInstance->GetIsInTryCompile()) + { + cmOStringStream w; + w << policies->GetPolicyWarning(cmPolicies::CMP0047) << "\n" + "Converting " << lang << + " compiler id \"QCC\" to \"GNU\" for compatibility." + ; + mf->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + case cmPolicies::OLD: + // OLD behavior is to convert QCC to GNU. + mf->AddDefinition(compilerIdVar.c_str(), "GNU"); + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + mf->IssueMessage( + cmake::FATAL_ERROR, + policies->GetRequiredPolicyError(cmPolicies::CMP0047) + ); + case cmPolicies::NEW: + // NEW behavior is to keep QCC. + break; + } + } } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index bd910e2..c13b8ee 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -114,6 +114,8 @@ void cmLocalGenerator::Configure() } } + this->Makefile->AddCMakeDependFilesFromUser(); + // Check whether relative paths should be used for optionally // relative paths. this->UseRelativePaths = this->Makefile->IsOn("CMAKE_USE_RELATIVE_PATHS"); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 222cdb6..856462e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3913,6 +3913,30 @@ cmTest* cmMakefile::GetTest(const char* testName) const return 0; } +void cmMakefile::AddCMakeDependFilesFromUser() +{ + std::vector<std::string> deps; + if(const char* deps_str = this->GetProperty("CMAKE_CONFIGURE_DEPENDS")) + { + cmSystemTools::ExpandListArgument(deps_str, deps); + } + for(std::vector<std::string>::iterator i = deps.begin(); + i != deps.end(); ++i) + { + if(cmSystemTools::FileIsFullPath(i->c_str())) + { + this->AddCMakeDependFile(*i); + } + else + { + std::string f = this->GetCurrentDirectory(); + f += "/"; + f += *i; + this->AddCMakeDependFile(f); + } + } +} + std::string cmMakefile::GetListFileStack() { cmOStringStream tmp; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 0232ffe..dadf7ff 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -650,6 +650,7 @@ public: ///! When the file changes cmake will be re-run from the build system. void AddCMakeDependFile(const std::string& file) { this->ListFiles.push_back(file);} + void AddCMakeDependFilesFromUser(); /** * Get the list file stack as a string diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 020a782..a1451f1 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -336,6 +336,11 @@ cmPolicies::cmPolicies() CMP0046, "CMP0046", "Error on non-existent dependency in add_dependencies.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0047, "CMP0047", + "Use QCC compiler id for the qcc drivers on QNX.", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 38f47f1..d1bba7b 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -100,6 +100,7 @@ public: CMP0044, ///< Case sensitive <LANG>_COMPILER_ID generator expressions CMP0045, ///< Error on non-existent target in get_target_property CMP0046, ///< Error on non-existent dependency in add_dependencies + CMP0047, ///< Use QCC compiler id for the qcc drivers on QNX. /** \brief Always the last entry. * diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index c1576c4..4ac1986 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -71,6 +71,7 @@ void CMakeCommandUsage(const char* program) "(on one volume)\n" << " tar [cxt][vfz][cvfj] file.tar [file/dir1 file/dir2 ...]\n" << " - create or extract a tar or zip archive\n" + << " sleep <number>... - sleep for given number of seconds\n" << " time command [args] ... - run command and return elapsed time\n" << " touch file - touch a file.\n" << " touch_nocreate file - touch a file but do not create it.\n" @@ -279,6 +280,33 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) return 0; } + // Sleep command + else if (args[1] == "sleep" && args.size() > 2) + { + double total = 0; + for(size_t i = 2; i < args.size(); ++i) + { + double num = 0.0; + char unit; + char extra; + int n = sscanf(args[i].c_str(), "%lg%c%c", &num, &unit, &extra); + if((n == 1 || (n == 2 && unit == 's')) && num >= 0) + { + total += num; + } + else + { + std::cerr << "Unknown sleep time format \"" << args[i] << "\".\n"; + return 1; + } + } + if(total > 0) + { + cmSystemTools::Delay(static_cast<unsigned int>(total*1000)); + } + return 0; + } + // Clock command else if (args[1] == "time" && args.size() > 2) { diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 41714f6..ce36830 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -38,6 +38,10 @@ AddCMakeTest(FileDownload "") set_property(TEST CMake.FileDownload PROPERTY PASS_REGULAR_EXPRESSION "file already exists with expected MD5 sum" ) +AddCMakeTest(FileDownloadBadHash "") +set_property(TEST CMake.FileDownloadBadHash PROPERTY + WILL_FAIL TRUE + ) AddCMakeTest(FileUpload "") diff --git a/Tests/CMakeTests/FileDownloadBadHashTest.cmake.in b/Tests/CMakeTests/FileDownloadBadHashTest.cmake.in new file mode 100644 index 0000000..4a47c06 --- /dev/null +++ b/Tests/CMakeTests/FileDownloadBadHashTest.cmake.in @@ -0,0 +1,10 @@ +set(url "file://@CMAKE_CURRENT_SOURCE_DIR@/FileDownloadInput.png") +set(dir "@CMAKE_CURRENT_BINARY_DIR@/downloads") + +file(DOWNLOAD + ${url} + ${dir}/file3.png + TIMEOUT 2 + STATUS status + EXPECTED_HASH SHA1=5555555555555555555555555555555555555555 + ) diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in index 91086c6..83ade2b 100644 --- a/Tests/CMakeTests/FileDownloadTest.cmake.in +++ b/Tests/CMakeTests/FileDownloadTest.cmake.in @@ -94,3 +94,16 @@ file(DOWNLOAD EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1 ) message(STATUS "${status}") + +message(STATUS "FileDownload:11") +file(DOWNLOAD + badhostname.png + ${dir}/file11.png + TIMEOUT 2 + STATUS status + ) +message(STATUS "${status}") +list(GET status 0 status_code) +if(NOT ${status_code} EQUAL 6) + message(SEND_ERROR "error: expected status code 6 for bad host name, got: ${status_code}") +endif() diff --git a/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-result.txt b/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-stderr.txt b/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-stderr.txt new file mode 100644 index 0000000..45e6ebc --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-stderr.txt @@ -0,0 +1 @@ +^Unknown sleep time format "x"\.$ diff --git a/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-result.txt b/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-stderr.txt b/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-stderr.txt new file mode 100644 index 0000000..399d47f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-stderr.txt @@ -0,0 +1 @@ +^Unknown sleep time format "-1"\.$ diff --git a/Tests/RunCMake/CommandLine/E_sleep-no-args-result.txt b/Tests/RunCMake/CommandLine/E_sleep-no-args-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sleep-no-args-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sleep-no-args-stderr.cmake b/Tests/RunCMake/CommandLine/E_sleep-no-args-stderr.cmake new file mode 100644 index 0000000..977f1ef --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sleep-no-args-stderr.cmake @@ -0,0 +1,2 @@ +Usage: .*/cmake -E \[command\] \[arguments \.\.\.\] +Available commands: diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index ee6cd99..ada4cab 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -23,3 +23,8 @@ if(UNIX) ${CMAKE_COMMAND} -E create_symlink T . ) endif() + +run_cmake_command(E_sleep-no-args ${CMAKE_COMMAND} -E sleep) +run_cmake_command(E_sleep-bad-arg1 ${CMAKE_COMMAND} -E sleep x) +run_cmake_command(E_sleep-bad-arg2 ${CMAKE_COMMAND} -E sleep 1 -1) +run_cmake_command(E_sleep-one-tenth ${CMAKE_COMMAND} -E sleep 0.1) diff --git a/Tests/RunCMake/Configure/RerunCMake-build1-check.cmake b/Tests/RunCMake/Configure/RerunCMake-build1-check.cmake new file mode 100644 index 0000000..dbf8f67 --- /dev/null +++ b/Tests/RunCMake/Configure/RerunCMake-build1-check.cmake @@ -0,0 +1,9 @@ +file(READ ${stamp} content) +if(NOT content STREQUAL 1) + set(RunCMake_TEST_FAILED "Expected stamp '1' but got: '${content}'") +endif() + +file(READ ${output} content) +if(NOT content STREQUAL 1) + set(RunCMake_TEST_FAILED "Expected output '1' but got: '${content}'") +endif() diff --git a/Tests/RunCMake/Configure/RerunCMake-build2-check.cmake b/Tests/RunCMake/Configure/RerunCMake-build2-check.cmake new file mode 100644 index 0000000..a4897e5 --- /dev/null +++ b/Tests/RunCMake/Configure/RerunCMake-build2-check.cmake @@ -0,0 +1,9 @@ +file(READ ${stamp} content) +if(NOT content STREQUAL 2) + set(RunCMake_TEST_FAILED "Expected stamp '2' but got: '${content}'") +endif() + +file(READ ${output} content) +if(NOT content STREQUAL 2) + set(RunCMake_TEST_FAILED "Expected output '2' but got: '${content}'") +endif() diff --git a/Tests/RunCMake/Configure/RerunCMake.cmake b/Tests/RunCMake/Configure/RerunCMake.cmake new file mode 100644 index 0000000..5a561bf --- /dev/null +++ b/Tests/RunCMake/Configure/RerunCMake.cmake @@ -0,0 +1,11 @@ +set(input ${CMAKE_CURRENT_BINARY_DIR}/CustomCMakeInput.txt) +set(stamp ${CMAKE_CURRENT_BINARY_DIR}/CustomCMakeStamp.txt) +file(READ ${input} content) +file(WRITE ${stamp} "${content}") + +set(depend ${CMAKE_CURRENT_BINARY_DIR}/CustomCMakeDepend.txt) +set(output ${CMAKE_CURRENT_BINARY_DIR}/CustomCMakeOutput.txt) +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${depend}) +file(READ ${depend} content) +file(WRITE ${output} "${content}") +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS RerunCMake.txt) diff --git a/Tests/RunCMake/Configure/RerunCMake.txt b/Tests/RunCMake/Configure/RerunCMake.txt new file mode 100644 index 0000000..15598c1 --- /dev/null +++ b/Tests/RunCMake/Configure/RerunCMake.txt @@ -0,0 +1 @@ +Source-tree dependency for "RerunCMake.cmake". diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake index 79e4060..5ef0384 100644 --- a/Tests/RunCMake/Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake @@ -2,3 +2,23 @@ include(RunCMake) run_cmake(ErrorLogs) run_cmake(FailCopyFileABI) + +# Use a single build tree for a few tests without cleaning. +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RerunCMake-build) +set(RunCMake_TEST_NO_CLEAN 1) +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") +file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") +set(input "${RunCMake_TEST_BINARY_DIR}/CustomCMakeInput.txt") +set(stamp "${RunCMake_TEST_BINARY_DIR}/CustomCMakeStamp.txt") +set(depend "${RunCMake_TEST_BINARY_DIR}/CustomCMakeDepend.txt") +set(output "${RunCMake_TEST_BINARY_DIR}/CustomCMakeOutput.txt") +file(WRITE "${input}" "1") +file(WRITE "${depend}" "1") +run_cmake(RerunCMake) +execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) # handle 1s resolution +file(WRITE "${input}" "2") +run_cmake_command(RerunCMake-build1 ${CMAKE_COMMAND} --build .) +file(WRITE "${depend}" "2") +run_cmake_command(RerunCMake-build2 ${CMAKE_COMMAND} --build .) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_NO_CLEAN) |