diff options
85 files changed, 663 insertions, 232 deletions
diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index 715676d..53681a9 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -44,7 +44,7 @@ syn keyword cmakeModule \ contained syn keyword cmakeKWExternalProject - \ ALGO ALWAYS BINARY_DIR BUILD_ALWAYS BUILD_BYPRODUCTS BUILD_COMMAND BUILD_IN_SOURCE BYPRODUCTS CMAKE_ARGS CMAKE_CACHE_ARGS CMAKE_CACHE_DEFAULT_ARGS COMMAND COMMENT CONFIGURE_COMMAND CVS CVSROOT CVS_ CVS_MODULE CVS_REPOSITORY CVS_TAG DEPENDEES DEPENDERS DEPENDS DIRECTORY DOWNLOAD_COMMAND DOWNLOAD_DIR DOWNLOAD_NAME DOWNLOAD_NO_PROGRESS EP_BASE EP_INDEPENDENT_STEP_TARGETS EP_PREFIX EP_STEP_TARGETS EP_UPDATE_DISCONNECTED EXCLUDE_FROM_ALL EXCLUDE_FROM_MAIN FORCE GIT_REMOTE_NAME GIT_REPOSITORY GIT_SUBMODULES GIT_TAG HG_REPOSITORY HG_TAG INDEPENDENT INDEPENDENT_STEP_TARGETS INSTALL_COMMAND INSTALL_DIR JOB_POOLS LIST_SEPARATOR LOG LOG_BUILD LOG_CONFIGURE LOG_DOWNLOAD LOG_INSTALL LOG_TEST LOG_UPDATE NO_DEPENDS PATCH_COMMAND PREFIX PROPERTY SOURCE_DIR STAMP_DIR STEP_TARGETS SVN_ SVN_PASSWORD SVN_REPOSITORY SVN_REVISION SVN_TRUST_CERT SVN_USERNAME TEST_AFTER_INSTALL TEST_BEFORE_INSTALL TEST_COMMAND TEST_EXCLUDE_FROM_MAIN TIMEOUT TLS_CAINFO TLS_VERIFY TMP_DIR UPDATE_COMMAND UPDATE_DISCONNECTED URL URL_HASH USES_TERMINAL USES_TERMINAL_BUILD USES_TERMINAL_CONFIGURE USES_TERMINAL_DOWNLOAD USES_TERMINAL_INSTALL USES_TERMINAL_TEST USES_TERMINAL_UPDATE WORKING_DIRECTORY _COMMAND _DIR + \ ALGO ALWAYS BINARY_DIR BUILD_ALWAYS BUILD_BYPRODUCTS BUILD_COMMAND BUILD_IN_SOURCE BYPRODUCTS CMAKE_ARGS CMAKE_CACHE_ARGS CMAKE_CACHE_DEFAULT_ARGS COMMAND COMMENT CONFIGURE_COMMAND CVS CVSROOT CVS_ CVS_MODULE CVS_REPOSITORY CVS_TAG DEPENDEES DEPENDERS DEPENDS DIRECTORY DOWNLOAD_COMMAND DOWNLOAD_DIR DOWNLOAD_NAME DOWNLOAD_NO_PROGRESS EP_BASE EP_INDEPENDENT_STEP_TARGETS EP_PREFIX EP_STEP_TARGETS EP_UPDATE_DISCONNECTED EXCLUDE_FROM_ALL EXCLUDE_FROM_MAIN FORCE GIT_REMOTE_NAME GIT_REPOSITORY GIT_SUBMODULES GIT_TAG HG_REPOSITORY HG_TAG INDEPENDENT INDEPENDENT_STEP_TARGETS INSTALL_COMMAND INSTALL_DIR JOB_POOLS LIST_SEPARATOR LOG LOG_BUILD LOG_CONFIGURE LOG_DOWNLOAD LOG_INSTALL LOG_TEST LOG_UPDATE NO_DEPENDS PATCH_COMMAND PREFIX PROPERTY SOURCE_DIR STAMP_DIR STEP_TARGETS SVN_ SVN_PASSWORD SVN_REPOSITORY SVN_REVISION SVN_TRUST_CERT SVN_USERNAME TEST_AFTER_INSTALL TEST_BEFORE_INSTALL TEST_COMMAND TEST_EXCLUDE_FROM_MAIN TIMEOUT TLS_CAINFO TLS_VERIFY TMP_DIR UPDATE_COMMAND UPDATE_DISCONNECTED URL URL_HASH HTTP_USERNAME HTTP_PASSWORD USES_TERMINAL USES_TERMINAL_BUILD USES_TERMINAL_CONFIGURE USES_TERMINAL_DOWNLOAD USES_TERMINAL_INSTALL USES_TERMINAL_TEST USES_TERMINAL_UPDATE WORKING_DIRECTORY _COMMAND _DIR \ contained syn keyword cmakeKWadd_compile_options diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ef2ca2..c8bd063 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR) +cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR) if(POLICY CMP0025) cmake_policy(SET CMP0025 NEW) endif() diff --git a/Help/command/file.rst b/Help/command/file.rst index f8727f0..77e9f62 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -225,6 +225,9 @@ Options to both ``DOWNLOAD`` and ``UPLOAD`` are: ``USERPWD <username>:<password>`` Set username and password for operation. +``HTTPHEADER <HTTP-header>`` + HTTP header for operation. Suboption can be repeated several times. + Additional options to ``DOWNLOAD`` are: ``EXPECTED_HASH ALGO=<value>`` diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index c44fe86..2cb1e5f 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -170,11 +170,21 @@ is acceptable the following variables are set: ``<package>_VERSION_COUNT`` number of version components, 0 to 4 -and the corresponding package configuration file is loaded. When -multiple package configuration files are available whose version files +and the corresponding package configuration file is loaded. +When multiple package configuration files are available whose version files claim compatibility with the version requested it is unspecified which -one is chosen. No attempt is made to choose a highest or closest -version number. +one is chosen: unless the variable :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER` +is set no attempt is made to choose a highest or closest version number. + +To control the order in which ``find_package`` checks for compatibiliy use +the two variables :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER` and +:variable:`CMAKE_FIND_PACKAGE_SORT_DIRECTION`. +For instance in order to select the highest version one can set:: + + SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) + SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) + +before calling ``find_package``. Config mode provides an elaborate interface and search procedure. Much of the interface is provided for completeness and for use diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 74c9265..9e0efe9 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -38,6 +38,8 @@ Variables that Provide Information /variable/CMAKE_EXTRA_GENERATOR /variable/CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES /variable/CMAKE_FIND_PACKAGE_NAME + /variable/CMAKE_FIND_PACKAGE_SORT_DIRECTION + /variable/CMAKE_FIND_PACKAGE_SORT_ORDER /variable/CMAKE_GENERATOR /variable/CMAKE_GENERATOR_PLATFORM /variable/CMAKE_GENERATOR_TOOLSET diff --git a/Help/release/dev/ExternalProject-http-credentials.rst b/Help/release/dev/ExternalProject-http-credentials.rst new file mode 100644 index 0000000..e3a362a --- /dev/null +++ b/Help/release/dev/ExternalProject-http-credentials.rst @@ -0,0 +1,5 @@ +ExternalProject-http-credentials +-------------------------------- + +* The :module:`ExternalProject` module gained ``HTTP_USERNAME`` and + ``HTTP_PASSWORD`` options to set http download credentials. diff --git a/Help/release/dev/file-curl-httpheader.rst b/Help/release/dev/file-curl-httpheader.rst new file mode 100644 index 0000000..2147d40 --- /dev/null +++ b/Help/release/dev/file-curl-httpheader.rst @@ -0,0 +1,5 @@ +file-curl-httpheader +-------------------- + +* The :command:`file(DOWNLOAD)` and :command:`file(UPLOAD)` commands + gained a ``HTTPHEADER <HTTP-header>`` option. diff --git a/Help/release/dev/find_package-dir-sort.rst b/Help/release/dev/find_package-dir-sort.rst new file mode 100644 index 0000000..67b93eb --- /dev/null +++ b/Help/release/dev/find_package-dir-sort.rst @@ -0,0 +1,13 @@ +find_package-dir-sort +--------------------- + +* The :command:`find_package` command gained the possibility of + sorting compatible libraries by ``NAME`` or by ``NATURAL`` sorting by + setting the two new variables :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER` + and :variable:`CMAKE_FIND_PACKAGE_SORT_DIRECTION`. + +* Variable :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER` was added to control + the sorting mode of the :command:`find_package` command. + +* Variable :variable:`CMAKE_FIND_PACKAGE_SORT_DIRECTION` was added to control + the sorting direction the :command:`find_package` command. diff --git a/Help/variable/CMAKE_FIND_PACKAGE_SORT_DIRECTION.rst b/Help/variable/CMAKE_FIND_PACKAGE_SORT_DIRECTION.rst new file mode 100644 index 0000000..99e4ec1 --- /dev/null +++ b/Help/variable/CMAKE_FIND_PACKAGE_SORT_DIRECTION.rst @@ -0,0 +1,16 @@ +CMAKE_FIND_PACKAGE_SORT_DIRECTION +--------------------------------- + +The sorting direction used by :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER`. +It can assume one of the following values: + +``DEC`` + Default. Ordering is done in descending mode. + The highest folder found will be tested first. + +``ASC`` + Ordering is done in ascending mode. + The lowest folder found will be tested first. + +If :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER` is not set or is set to ``NONE`` +this variable has no effect. diff --git a/Help/variable/CMAKE_FIND_PACKAGE_SORT_ORDER.rst b/Help/variable/CMAKE_FIND_PACKAGE_SORT_ORDER.rst new file mode 100644 index 0000000..ba5f3a8 --- /dev/null +++ b/Help/variable/CMAKE_FIND_PACKAGE_SORT_ORDER.rst @@ -0,0 +1,36 @@ +CMAKE_FIND_PACKAGE_SORT_ORDER +----------------------------- + +The default order for sorting packages found using :command:`find_package`. +It can assume one of the following values: + +``NONE`` + Default. No attempt is done to sort packages. + The first valid package found will be selected. + +``NAME`` + Sort packages lexicographically before selecting one. + +``NATURAL`` + Sort packages using natural order (see ``strverscmp(3)`` manual), + i.e. such that contiguous digits are compared as whole numbers. + +Natural sorting can be employed to return the highest version when multiple +versions of the same library are found by :command:`find_package`. For +example suppose that the following libraries have been found: + +* libX-1.1.0 +* libX-1.2.9 +* libX-1.2.10 + +By setting ``NATURAL`` order we can select the one with the highest +version number ``libX-1.2.10``. + +.. code-block:: cmake + + set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) + find_package(libX CONFIG) + +The sort direction can be controlled using the +:variable:`CMAKE_FIND_PACKAGE_SORT_DIRECTION` variable +(by default decrescent, e.g. lib-B will be tested before lib-A). diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject-download.cmake.in index 91d74e0..0e82adb 100644 --- a/Modules/ExternalProject-download.cmake.in +++ b/Modules/ExternalProject-download.cmake.in @@ -135,6 +135,7 @@ foreach(i RANGE ${retry_number}) @TIMEOUT_ARGS@ STATUS status LOG log + @USERPWD_ARGS@ ) list(GET status 0 status_code) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 5ea309f..31fa459 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -75,6 +75,10 @@ Create custom targets to build projects in external trees Hash of file at URL ``URL_MD5 md5`` Equivalent to URL_HASH MD5=md5 + ``HTTP_USERNAME <username>`` + Username for download operation + ``HTTP_PASSWORD <username>`` + Password for download operation ``TLS_VERIFY <bool>`` Should certificate for https be checked ``TLS_CAINFO <file>`` @@ -858,7 +862,7 @@ endif() endfunction(_ep_write_gitupdate_script) -function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo) +function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo userpwd) if(timeout) set(TIMEOUT_ARGS TIMEOUT ${timeout}) set(TIMEOUT_MSG "${timeout} seconds") @@ -906,6 +910,12 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${tls_cainfo}\")") endif() + if(userpwd STREQUAL ":") + set(USERPWD_ARGS) + else() + set(USERPWD_ARGS USERPWD "${userpwd}") + endif() + # Used variables: # * TLS_VERIFY_CODE # * TLS_CAINFO_CODE @@ -916,6 +926,7 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p # * SHOW_PROGRESS # * TIMEOUT_ARGS # * TIMEOUT_MSG + # * USERPWD_ARGS configure_file( "${_ExternalProject_SELF_DIR}/ExternalProject-download.cmake.in" "${script_filename}" @@ -1919,8 +1930,10 @@ function(_ep_add_download_command name) get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS) get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) + get_property(http_username TARGET ${name} PROPERTY _EP_HTTP_USERNAME) + get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD) set(download_script "${stamp_dir}/download-${name}.cmake") - _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}") + _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}") set(cmd ${CMAKE_COMMAND} -P "${download_script}" COMMAND) if (no_extract) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 09f55fa..dcce5e4 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 6) -set(CMake_VERSION_PATCH 20160916) +set(CMake_VERSION_PATCH 20160919) #set(CMake_VERSION_RC 1) diff --git a/Source/cmAddCompileOptionsCommand.cxx b/Source/cmAddCompileOptionsCommand.cxx index 2223cf4..cbba831 100644 --- a/Source/cmAddCompileOptionsCommand.cxx +++ b/Source/cmAddCompileOptionsCommand.cxx @@ -14,7 +14,7 @@ bool cmAddCompileOptionsCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { return true; } diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 9dc7c59..8e14966 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -18,7 +18,7 @@ bool cmAddCustomTargetCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmAddDefinitionsCommand.cxx b/Source/cmAddDefinitionsCommand.cxx index 2d0d026..5f2b32f 100644 --- a/Source/cmAddDefinitionsCommand.cxx +++ b/Source/cmAddDefinitionsCommand.cxx @@ -16,7 +16,7 @@ bool cmAddDefinitionsCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { // it is OK to have no arguments - if (args.size() < 1) { + if (args.empty()) { return true; } diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 4516ed2..5a40050 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -18,7 +18,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 63a9051..1a781cc 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -15,7 +15,7 @@ bool cmAddSubDirectoryCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index 9830867..6146053 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -27,7 +27,7 @@ bool cmBuildCommand::InitialPass(std::vector<std::string> const& args, bool cmBuildCommand::MainSignature(std::vector<std::string> const& args) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("requires at least one argument naming a CMake variable"); return false; } diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx index 27234d7..3d02034 100644 --- a/Source/cmBuildNameCommand.cxx +++ b/Source/cmBuildNameCommand.cxx @@ -22,7 +22,7 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args, "The build_name command should not be called; see CMP0036.")) { return true; } - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx index 07e0885..03c4a37 100644 --- a/Source/cmCMakePolicyCommand.cxx +++ b/Source/cmCMakePolicyCommand.cxx @@ -17,7 +17,7 @@ bool cmCMakePolicyCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("requires at least one argument."); return false; } diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 94f03e8..e670dc6 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -85,7 +85,7 @@ bool cmConditionEvaluator::IsTrue( errorString = ""; // handle empty invocation - if (args.size() < 1) { + if (args.empty()) { return false; } diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx index 484a970..3589529 100644 --- a/Source/cmDefinePropertyCommand.cxx +++ b/Source/cmDefinePropertyCommand.cxx @@ -17,7 +17,7 @@ bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmEnableLanguageCommand.cxx b/Source/cmEnableLanguageCommand.cxx index 0ebe778..9b7dd03 100644 --- a/Source/cmEnableLanguageCommand.cxx +++ b/Source/cmEnableLanguageCommand.cxx @@ -17,7 +17,7 @@ bool cmEnableLanguageCommand::InitialPass(std::vector<std::string> const& args, { bool optional = false; std::vector<std::string> languages; - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index 58bbc31..284f486 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -19,7 +19,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index d97b25f..81d8a1f 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -31,7 +31,7 @@ void cmExecuteProcessCommandAppend(std::vector<char>& output, const char* data, bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx index 3247cc8..96080a9 100644 --- a/Source/cmExportBuildAndroidMKGenerator.cxx +++ b/Source/cmExportBuildAndroidMKGenerator.cxx @@ -69,7 +69,7 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties( const ImportPropertyMap& properties) { std::string config = ""; - if (this->Configurations.size()) { + if (!this->Configurations.empty()) { config = this->Configurations[0]; } cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties( diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx index 8f815b7..10ba6ee 100644 --- a/Source/cmExportInstallAndroidMKGenerator.cxx +++ b/Source/cmExportInstallAndroidMKGenerator.cxx @@ -76,7 +76,7 @@ void cmExportInstallAndroidMKGenerator::GenerateImportTargetCode( os << "LOCAL_SRC_FILES := $(_IMPORT_PREFIX)/"; os << target->Target->GetProperty("__dest") << "/"; std::string config = ""; - if (this->Configurations.size()) { + if (!this->Configurations.empty()) { config = this->Configurations[0]; } os << target->GetFullName(config) << "\n"; @@ -103,7 +103,7 @@ void cmExportInstallAndroidMKGenerator::GenerateInterfaceProperties( const ImportPropertyMap& properties) { std::string config = ""; - if (this->Configurations.size()) { + if (!this->Configurations.empty()) { config = this->Configurations[0]; } cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties( diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index b422a2c..d9c30e7 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -27,7 +27,7 @@ bool cmExportLibraryDependenciesCommand::InitialPass( "see CMP0033.")) { return true; } - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 2c226cd..c10f426 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2483,6 +2483,8 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) bool showProgress = false; std::string userpwd; + std::list<std::string> curl_headers; + while (i != args.end()) { if (*i == "TIMEOUT") { ++i; @@ -2572,6 +2574,13 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) return false; } userpwd = *i; + } else if (*i == "HTTPHEADER") { + ++i; + if (i == args.end()) { + this->SetError("DOWNLOAD missing string for HTTPHEADER."); + return false; + } + curl_headers.push_back(*i); } else { // Do not return error for compatibility reason. std::string err = "Unexpected argument: "; @@ -2716,8 +2725,17 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) check_curl_result(res, "DOWNLOAD cannot set user password: "); } + struct curl_slist* headers = CM_NULLPTR; + for (std::list<std::string>::const_iterator h = curl_headers.begin(); + h != curl_headers.end(); ++h) { + headers = ::curl_slist_append(headers, h->c_str()); + } + ::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + res = ::curl_easy_perform(curl); + ::curl_slist_free_all(headers); + /* always cleanup */ g_curl.release(); ::curl_easy_cleanup(curl); @@ -2798,6 +2816,8 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) bool showProgress = false; std::string userpwd; + std::list<std::string> curl_headers; + while (i != args.end()) { if (*i == "TIMEOUT") { ++i; @@ -2838,6 +2858,13 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) return false; } userpwd = *i; + } else if (*i == "HTTPHEADER") { + ++i; + if (i == args.end()) { + this->SetError("UPLOAD missing string for HTTPHEADER."); + return false; + } + curl_headers.push_back(*i); } else { // Do not return error for compatibility reason. std::string err = "Unexpected argument: "; @@ -2956,8 +2983,17 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) check_curl_result(res, "UPLOAD cannot set user password: "); } + struct curl_slist* headers = CM_NULLPTR; + for (std::list<std::string>::const_iterator h = curl_headers.begin(); + h != curl_headers.end(); ++h) { + headers = ::curl_slist_append(headers, h->c_str()); + } + ::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); + res = ::curl_easy_perform(curl); + ::curl_slist_free_all(headers); + /* always cleanup */ g_curl.release(); ::curl_easy_cleanup(curl); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 8338c2a..405dce3 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -12,6 +12,7 @@ #include "cmFindPackageCommand.h" #include "cmAlgorithms.h" +#include <cmSystemTools.h> #include <cmsys/Directory.hxx> #include <cmsys/Encoding.hxx> #include <cmsys/RegularExpression.hxx> @@ -33,6 +34,45 @@ cmFindPackageCommand::PathLabel cmFindPackageCommand::PathLabel::Builds( cmFindPackageCommand::PathLabel cmFindPackageCommand::PathLabel::SystemRegistry("SYSTEM_PACKAGE_REGISTRY"); +struct StrverscmpGreater +{ + bool operator()(const std::string& lhs, const std::string& rhs) const + { + return cmSystemTools::strverscmp(lhs, rhs) > 0; + } +}; + +struct StrverscmpLesser +{ + bool operator()(const std::string& lhs, const std::string& rhs) const + { + return cmSystemTools::strverscmp(lhs, rhs) < 0; + } +}; + +void cmFindPackageCommand::Sort(std::vector<std::string>::iterator begin, + std::vector<std::string>::iterator end, + SortOrderType order, SortDirectionType dir) +{ + if (order == Name_order) { + if (dir == Dec) { + std::sort(begin, end, std::greater<std::string>()); + } else { + std::sort(begin, end); + } + } else if (order == Natural) + // natural order uses letters and numbers (contiguous numbers digit are + // compared such that e.g. 000 00 < 01 < 010 < 09 < 0 < 1 < 9 < 10 + { + if (dir == Dec) { + std::sort(begin, end, StrverscmpGreater()); + } else { + std::sort(begin, end, StrverscmpLesser()); + } + } + // else do not sort +} + cmFindPackageCommand::cmFindPackageCommand() { this->CMakePathName = "PACKAGE"; @@ -58,7 +98,8 @@ cmFindPackageCommand::cmFindPackageCommand() this->VersionFoundTweak = 0; this->VersionFoundCount = 0; this->RequiredCMakeVersion = 0; - + this->SortOrder = None; + this->SortDirection = Asc; this->AppendSearchPathGroups(); } @@ -89,7 +130,7 @@ void cmFindPackageCommand::AppendSearchPathGroups() bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } @@ -135,6 +176,23 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args, this->NoSystemRegistry = true; } + // Check if Sorting should be enabled + if (const char* so = + this->Makefile->GetDefinition("CMAKE_FIND_PACKAGE_SORT_ORDER")) { + + if (strcmp(so, "NAME") == 0) { + this->SortOrder = Name_order; + } else if (strcmp(so, "NATURAL") == 0) { + this->SortOrder = Natural; + } else { + this->SortOrder = None; + } + } + if (const char* sd = + this->Makefile->GetDefinition("CMAKE_FIND_PACKAGE_SORT_DIRECTION")) { + this->SortDirection = strcmp(sd, "ASC") == 0 ? Asc : Dec; + } + // Find the current root path mode. this->SelectDefaultRootPathMode(); @@ -1666,17 +1724,33 @@ private: class cmFileListGeneratorProject : public cmFileListGeneratorBase { public: - cmFileListGeneratorProject(std::vector<std::string> const& names) + cmFileListGeneratorProject(std::vector<std::string> const& names, + cmFindPackageCommand::SortOrderType so, + cmFindPackageCommand::SortDirectionType sd) : cmFileListGeneratorBase() , Names(names) { + this->SetSort(so, sd); } cmFileListGeneratorProject(cmFileListGeneratorProject const& r) : cmFileListGeneratorBase() , Names(r.Names) { + this->SetSort(r.SortOrder, r.SortDirection); + } + + void SetSort(cmFindPackageCommand::SortOrderType o, + cmFindPackageCommand::SortDirectionType d) + { + SortOrder = o; + SortDirection = d; } +protected: + // sort parameters + cmFindPackageCommand::SortOrderType SortOrder; + cmFindPackageCommand::SortDirectionType SortDirection; + private: std::vector<std::string> const& Names; bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE @@ -1698,6 +1772,13 @@ private: } } + // before testing the matches check if there is a specific sorting order to + // perform + if (this->SortOrder != cmFindPackageCommand::None) { + cmFindPackageCommand::Sort(matches.begin(), matches.end(), SortOrder, + SortDirection); + } + for (std::vector<std::string>::const_iterator i = matches.begin(); i != matches.end(); ++i) { if (this->Consider(parent + *i, lister)) { @@ -1895,7 +1976,8 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) { cmFindPackageFileList lister(this); lister / cmFileListGeneratorFixed(prefix) / - cmFileListGeneratorProject(this->Names); + cmFileListGeneratorProject(this->Names, this->SortOrder, + this->SortDirection); if (lister.Search()) { return true; } @@ -1905,7 +1987,8 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) { cmFindPackageFileList lister(this); lister / cmFileListGeneratorFixed(prefix) / - cmFileListGeneratorProject(this->Names) / + cmFileListGeneratorProject(this->Names, this->SortOrder, + this->SortDirection) / cmFileListGeneratorCaseInsensitive("cmake"); if (lister.Search()) { return true; @@ -1932,7 +2015,8 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) lister / cmFileListGeneratorFixed(prefix) / cmFileListGeneratorEnumerate(common) / cmFileListGeneratorFixed("cmake") / - cmFileListGeneratorProject(this->Names); + cmFileListGeneratorProject(this->Names, this->SortOrder, + this->SortDirection); if (lister.Search()) { return true; } @@ -1943,7 +2027,8 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) cmFindPackageFileList lister(this); lister / cmFileListGeneratorFixed(prefix) / cmFileListGeneratorEnumerate(common) / - cmFileListGeneratorProject(this->Names); + cmFileListGeneratorProject(this->Names, this->SortOrder, + this->SortDirection); if (lister.Search()) { return true; } @@ -1954,7 +2039,8 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) cmFindPackageFileList lister(this); lister / cmFileListGeneratorFixed(prefix) / cmFileListGeneratorEnumerate(common) / - cmFileListGeneratorProject(this->Names) / + cmFileListGeneratorProject(this->Names, this->SortOrder, + this->SortDirection) / cmFileListGeneratorCaseInsensitive("cmake"); if (lister.Search()) { return true; @@ -1965,10 +2051,12 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) { cmFindPackageFileList lister(this); lister / cmFileListGeneratorFixed(prefix) / - cmFileListGeneratorProject(this->Names) / + cmFileListGeneratorProject(this->Names, this->SortOrder, + this->SortDirection) / cmFileListGeneratorEnumerate(common) / cmFileListGeneratorFixed("cmake") / - cmFileListGeneratorProject(this->Names); + cmFileListGeneratorProject(this->Names, this->SortOrder, + this->SortDirection); if (lister.Search()) { return true; } @@ -1978,9 +2066,11 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) { cmFindPackageFileList lister(this); lister / cmFileListGeneratorFixed(prefix) / - cmFileListGeneratorProject(this->Names) / + cmFileListGeneratorProject(this->Names, this->SortOrder, + this->SortDirection) / cmFileListGeneratorEnumerate(common) / - cmFileListGeneratorProject(this->Names); + cmFileListGeneratorProject(this->Names, this->SortOrder, + this->SortDirection); if (lister.Search()) { return true; } @@ -1990,9 +2080,11 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) { cmFindPackageFileList lister(this); lister / cmFileListGeneratorFixed(prefix) / - cmFileListGeneratorProject(this->Names) / + cmFileListGeneratorProject(this->Names, this->SortOrder, + this->SortDirection) / cmFileListGeneratorEnumerate(common) / - cmFileListGeneratorProject(this->Names) / + cmFileListGeneratorProject(this->Names, this->SortOrder, + this->SortDirection) / cmFileListGeneratorCaseInsensitive("cmake"); if (lister.Search()) { return true; diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 087107e..babdd5a 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -24,6 +24,27 @@ class cmFindPackageFileList; class cmFindPackageCommand : public cmFindCommon { public: + /*! A sorting order strategy to be applied to recovered package folders (see + * FIND_PACKAGE_SORT_ORDER)*/ + enum /*class*/ SortOrderType + { + None, + Name_order, + Natural + }; + /*! A sorting direction to be applied to recovered package folders (see + * FIND_PACKAGE_SORT_DIRECTION)*/ + enum /*class*/ SortDirectionType + { + Asc, + Dec + }; + + /*! sorts a given list of string based on the input sort parameters */ + static void Sort(std::vector<std::string>::iterator begin, + std::vector<std::string>::iterator end, SortOrderType order, + SortDirectionType dir); + cmFindPackageCommand(); /** @@ -156,6 +177,11 @@ private: std::vector<std::string> Configs; std::set<std::string> IgnoredPaths; + /*! the selected sortOrder (None by default)*/ + SortOrderType SortOrder; + /*! the selected sortDirection (Asc by default)*/ + SortDirectionType SortDirection; + struct ConfigFileInfo { std::string filename; diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index c6e5f06..dadd080 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -113,7 +113,7 @@ bool cmForEachFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, bool cmForEachCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 40c54db..bda96aa 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -202,7 +202,7 @@ bool cmFunctionFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, bool cmFunctionCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4f8c036..1e21ac4 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1162,7 +1162,28 @@ bool cmGeneratorTarget::NeedRelinkBeforeInstall( // If either a build or install tree rpath is set then the rpath // will likely change between the build tree and install tree and // this target must be relinked. - return this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH(); + bool have_rpath = + this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH(); + bool is_ninja = + this->LocalGenerator->GetGlobalGenerator()->GetName() == "Ninja"; + + if (have_rpath && is_ninja) { + std::ostringstream w; + /* clang-format off */ + w << + "The install of the " << this->GetName() << " target requires " + "changing an RPATH from the build tree, but this is not supported " + "with the Ninja generator unless on an ELF-based platform. The " + "CMAKE_BUILD_WITH_INSTALL_RPATH variable may be set to avoid this " + "relinking step." + ; + /* clang-format on */ + + cmake* cm = this->LocalGenerator->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, w.str(), this->GetBacktrace()); + } + + return have_rpath; } bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3d2b60e..ed73450 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1061,16 +1061,16 @@ void cmGlobalGenerator::Configure() this->ConfigureDoneCMP0026AndCMP0024 = true; // Put a copy of each global target in every directory. - cmTargets globalTargets; - this->CreateDefaultGlobalTargets(&globalTargets); + std::vector<GlobalTargetInfo> globalTargets; + this->CreateDefaultGlobalTargets(globalTargets); for (unsigned int i = 0; i < this->Makefiles.size(); ++i) { cmMakefile* mf = this->Makefiles[i]; cmTargets* targets = &(mf->GetTargets()); - cmTargets::iterator tit; - for (tit = globalTargets.begin(); tit != globalTargets.end(); ++tit) { + for (std::vector<GlobalTargetInfo>::iterator gti = globalTargets.begin(); + gti != globalTargets.end(); ++gti) { targets->insert( - cmTargets::value_type(tit->first, tit->second.CopyForDirectory(mf))); + cmTargets::value_type(gti->Name, this->CreateGlobalTarget(*gti, mf))); } } @@ -2070,15 +2070,27 @@ inline std::string removeQuotes(const std::string& s) return s; } -void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) +void cmGlobalGenerator::CreateDefaultGlobalTargets( + std::vector<GlobalTargetInfo>& targets) +{ + this->AddGlobalTarget_Package(targets); + this->AddGlobalTarget_PackageSource(targets); + this->AddGlobalTarget_Test(targets); + this->AddGlobalTarget_EditCache(targets); + this->AddGlobalTarget_RebuildCache(targets); + this->AddGlobalTarget_Install(targets); +} + +void cmGlobalGenerator::AddGlobalTarget_Package( + std::vector<GlobalTargetInfo>& targets) { cmMakefile* mf = this->Makefiles[0]; const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir(); - - // CPack - std::string workingDir = mf->GetCurrentBinaryDirectory(); - cmCustomCommandLines cpackCommandLines; - std::vector<std::string> depends; + GlobalTargetInfo gti; + gti.Name = this->GetPackageTargetName(); + gti.Message = "Run CPack packaging tool..."; + gti.UsesTerminal = true; + gti.WorkingDir = mf->GetCurrentBinaryDirectory(); cmCustomCommandLine singleLine; singleLine.push_back(cmSystemTools::GetCPackCommand()); if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') { @@ -2087,60 +2099,61 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) } singleLine.push_back("--config"); std::string configFile = mf->GetCurrentBinaryDirectory(); - ; configFile += "/CPackConfig.cmake"; std::string relConfigFile = "./CPackConfig.cmake"; singleLine.push_back(relConfigFile); - cpackCommandLines.push_back(singleLine); + gti.CommandLines.push_back(singleLine); if (this->GetPreinstallTargetName()) { - depends.push_back(this->GetPreinstallTargetName()); + gti.Depends.push_back(this->GetPreinstallTargetName()); } else { const char* noPackageAll = mf->GetDefinition("CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY"); if (!noPackageAll || cmSystemTools::IsOff(noPackageAll)) { - depends.push_back(this->GetAllTargetName()); + gti.Depends.push_back(this->GetAllTargetName()); } } if (cmSystemTools::FileExists(configFile.c_str())) { - targets->insert(cmTargets::value_type( - this->GetPackageTargetName(), - this->CreateGlobalTarget(this->GetPackageTargetName(), - "Run CPack packaging tool...", - &cpackCommandLines, depends, workingDir.c_str(), - /*uses_terminal*/ true))); - } - // CPack source + targets.push_back(gti); + } +} + +void cmGlobalGenerator::AddGlobalTarget_PackageSource( + std::vector<GlobalTargetInfo>& targets) +{ + cmMakefile* mf = this->Makefiles[0]; const char* packageSourceTargetName = this->GetPackageSourceTargetName(); if (packageSourceTargetName) { - cpackCommandLines.erase(cpackCommandLines.begin(), - cpackCommandLines.end()); - singleLine.erase(singleLine.begin(), singleLine.end()); - depends.erase(depends.begin(), depends.end()); + GlobalTargetInfo gti; + gti.Name = packageSourceTargetName; + gti.Message = "Run CPack packaging tool for source..."; + gti.WorkingDir = mf->GetCurrentBinaryDirectory(); + gti.UsesTerminal = true; + cmCustomCommandLine singleLine; singleLine.push_back(cmSystemTools::GetCPackCommand()); singleLine.push_back("--config"); - configFile = mf->GetCurrentBinaryDirectory(); - ; + std::string configFile = mf->GetCurrentBinaryDirectory(); configFile += "/CPackSourceConfig.cmake"; - relConfigFile = "./CPackSourceConfig.cmake"; + std::string relConfigFile = "./CPackSourceConfig.cmake"; singleLine.push_back(relConfigFile); if (cmSystemTools::FileExists(configFile.c_str())) { singleLine.push_back(configFile); - cpackCommandLines.push_back(singleLine); - targets->insert(cmTargets::value_type( - packageSourceTargetName, - this->CreateGlobalTarget( - packageSourceTargetName, "Run CPack packaging tool for source...", - &cpackCommandLines, depends, workingDir.c_str(), - /*uses_terminal*/ true))); + gti.CommandLines.push_back(singleLine); + targets.push_back(gti); } } +} - // Test +void cmGlobalGenerator::AddGlobalTarget_Test( + std::vector<GlobalTargetInfo>& targets) +{ + cmMakefile* mf = this->Makefiles[0]; + const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir(); if (mf->IsOn("CMAKE_TESTING_ENABLED")) { - cpackCommandLines.erase(cpackCommandLines.begin(), - cpackCommandLines.end()); - singleLine.erase(singleLine.begin(), singleLine.end()); - depends.erase(depends.begin(), depends.end()); + GlobalTargetInfo gti; + gti.Name = this->GetTestTargetName(); + gti.Message = "Running tests..."; + gti.UsesTerminal = true; + cmCustomCommandLine singleLine; singleLine.push_back(cmSystemTools::GetCTestCommand()); singleLine.push_back("--force-new-ctest-process"); if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') { @@ -2151,21 +2164,19 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) { singleLine.push_back("$(ARGS)"); } - cpackCommandLines.push_back(singleLine); - targets->insert(cmTargets::value_type( - this->GetTestTargetName(), - this->CreateGlobalTarget(this->GetTestTargetName(), "Running tests...", - &cpackCommandLines, depends, CM_NULLPTR, - /*uses_terminal*/ true))); + gti.CommandLines.push_back(singleLine); + targets.push_back(gti); } +} - // Edit Cache +void cmGlobalGenerator::AddGlobalTarget_EditCache( + std::vector<GlobalTargetInfo>& targets) +{ const char* editCacheTargetName = this->GetEditCacheTargetName(); if (editCacheTargetName) { - cpackCommandLines.erase(cpackCommandLines.begin(), - cpackCommandLines.end()); - singleLine.erase(singleLine.begin(), singleLine.end()); - depends.erase(depends.begin(), depends.end()); + GlobalTargetInfo gti; + gti.Name = editCacheTargetName; + cmCustomCommandLine singleLine; // Use generator preference for the edit_cache rule if it is defined. std::string edit_cmd = this->GetEditCacheCommand(); @@ -2173,45 +2184,46 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) singleLine.push_back(edit_cmd); singleLine.push_back("-H$(CMAKE_SOURCE_DIR)"); singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); - cpackCommandLines.push_back(singleLine); - targets->insert(cmTargets::value_type( - editCacheTargetName, - this->CreateGlobalTarget( - editCacheTargetName, "Running CMake cache editor...", - &cpackCommandLines, depends, CM_NULLPTR, /*uses_terminal*/ true))); + gti.Message = "Running CMake cache editor..."; + gti.UsesTerminal = true; + gti.CommandLines.push_back(singleLine); } else { singleLine.push_back(cmSystemTools::GetCMakeCommand()); singleLine.push_back("-E"); singleLine.push_back("echo"); singleLine.push_back("No interactive CMake dialog available."); - cpackCommandLines.push_back(singleLine); - targets->insert(cmTargets::value_type( - editCacheTargetName, - this->CreateGlobalTarget( - editCacheTargetName, "No interactive CMake dialog available...", - &cpackCommandLines, depends, CM_NULLPTR, /*uses_terminal*/ false))); + gti.Message = "No interactive CMake dialog available..."; + gti.UsesTerminal = false; + gti.CommandLines.push_back(singleLine); } + + targets.push_back(gti); } +} - // Rebuild Cache +void cmGlobalGenerator::AddGlobalTarget_RebuildCache( + std::vector<GlobalTargetInfo>& targets) +{ const char* rebuildCacheTargetName = this->GetRebuildCacheTargetName(); if (rebuildCacheTargetName) { - cpackCommandLines.erase(cpackCommandLines.begin(), - cpackCommandLines.end()); - singleLine.erase(singleLine.begin(), singleLine.end()); - depends.erase(depends.begin(), depends.end()); + GlobalTargetInfo gti; + gti.Name = rebuildCacheTargetName; + gti.Message = "Running CMake to regenerate build system..."; + gti.UsesTerminal = true; + cmCustomCommandLine singleLine; singleLine.push_back(cmSystemTools::GetCMakeCommand()); singleLine.push_back("-H$(CMAKE_SOURCE_DIR)"); singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); - cpackCommandLines.push_back(singleLine); - targets->insert(cmTargets::value_type( - rebuildCacheTargetName, - this->CreateGlobalTarget( - rebuildCacheTargetName, "Running CMake to regenerate build system...", - &cpackCommandLines, depends, CM_NULLPTR, /*uses_terminal*/ true))); + gti.CommandLines.push_back(singleLine); + targets.push_back(gti); } +} - // Install +void cmGlobalGenerator::AddGlobalTarget_Install( + std::vector<GlobalTargetInfo>& targets) +{ + cmMakefile* mf = this->Makefiles[0]; + const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir(); bool skipInstallRules = mf->IsOn("CMAKE_SKIP_INSTALL_RULES"); if (this->InstallTargetEnabled && skipInstallRules) { this->CMakeInstance->IssueMessage( @@ -2221,9 +2233,6 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) } else if (this->InstallTargetEnabled && !skipInstallRules) { if (!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.') { std::set<std::string>* componentsSet = &this->InstallComponents; - cpackCommandLines.erase(cpackCommandLines.begin(), - cpackCommandLines.end()); - depends.erase(depends.begin(), depends.end()); std::ostringstream ostr; if (!componentsSet->empty()) { ostr << "Available install components are: "; @@ -2231,25 +2240,25 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) } else { ostr << "Only default component available"; } - singleLine.push_back(ostr.str()); - targets->insert(cmTargets::value_type( - "list_install_components", - this->CreateGlobalTarget("list_install_components", ostr.str().c_str(), - &cpackCommandLines, depends, CM_NULLPTR, - /*uses_terminal*/ false))); + GlobalTargetInfo gti; + gti.Name = "list_install_components"; + gti.Message = ostr.str(); + gti.UsesTerminal = false; + targets.push_back(gti); } std::string cmd = cmSystemTools::GetCMakeCommand(); - cpackCommandLines.erase(cpackCommandLines.begin(), - cpackCommandLines.end()); - singleLine.erase(singleLine.begin(), singleLine.end()); - depends.erase(depends.begin(), depends.end()); + GlobalTargetInfo gti; + gti.Name = this->GetInstallTargetName(); + gti.Message = "Install the project..."; + gti.UsesTerminal = true; + cmCustomCommandLine singleLine; if (this->GetPreinstallTargetName()) { - depends.push_back(this->GetPreinstallTargetName()); + gti.Depends.push_back(this->GetPreinstallTargetName()); } else { const char* noall = mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); if (!noall || cmSystemTools::IsOff(noall)) { - depends.push_back(this->GetAllTargetName()); + gti.Depends.push_back(this->GetAllTargetName()); } } if (mf->GetDefinition("CMake_BINARY_DIR") && @@ -2274,46 +2283,39 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) } singleLine.push_back("-P"); singleLine.push_back("cmake_install.cmake"); - cpackCommandLines.push_back(singleLine); - targets->insert(cmTargets::value_type( - this->GetInstallTargetName(), - this->CreateGlobalTarget(this->GetInstallTargetName(), - "Install the project...", &cpackCommandLines, - depends, CM_NULLPTR, /*uses_terminal*/ true))); + gti.CommandLines.push_back(singleLine); + targets.push_back(gti); // install_local if (const char* install_local = this->GetInstallLocalTargetName()) { + gti.Name = install_local; + gti.Message = "Installing only the local directory..."; + gti.UsesTerminal = true; + gti.CommandLines.clear(); + cmCustomCommandLine localCmdLine = singleLine; localCmdLine.insert(localCmdLine.begin() + 1, "-DCMAKE_INSTALL_LOCAL_ONLY=1"); - cpackCommandLines.erase(cpackCommandLines.begin(), - cpackCommandLines.end()); - cpackCommandLines.push_back(localCmdLine); - targets->insert(cmTargets::value_type( - install_local, - this->CreateGlobalTarget( - install_local, "Installing only the local directory...", - &cpackCommandLines, depends, CM_NULLPTR, /*uses_terminal*/ true))); + gti.CommandLines.push_back(localCmdLine); + targets.push_back(gti); } // install_strip const char* install_strip = this->GetInstallStripTargetName(); if ((install_strip != CM_NULLPTR) && (mf->IsSet("CMAKE_STRIP"))) { + gti.Name = install_strip; + gti.Message = "Installing the project stripped..."; + gti.UsesTerminal = true; + gti.CommandLines.clear(); + cmCustomCommandLine stripCmdLine = singleLine; stripCmdLine.insert(stripCmdLine.begin() + 1, "-DCMAKE_INSTALL_DO_STRIP=1"); - cpackCommandLines.erase(cpackCommandLines.begin(), - cpackCommandLines.end()); - cpackCommandLines.push_back(stripCmdLine); - - targets->insert(cmTargets::value_type( - install_strip, - this->CreateGlobalTarget( - install_strip, "Installing the project stripped...", - &cpackCommandLines, depends, CM_NULLPTR, /*uses_terminal*/ true))); + gti.CommandLines.push_back(stripCmdLine); + targets.push_back(gti); } } } @@ -2347,14 +2349,12 @@ bool cmGlobalGenerator::UseFolderProperty() return false; } -cmTarget cmGlobalGenerator::CreateGlobalTarget( - const std::string& name, const char* message, - const cmCustomCommandLines* commandLines, std::vector<std::string> depends, - const char* workingDirectory, bool uses_terminal) +cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti, + cmMakefile* mf) { // Package - cmTarget target(name, cmState::GLOBAL_TARGET, cmTarget::VisibilityNormal, - CM_NULLPTR); + cmTarget target(gti.Name, cmState::GLOBAL_TARGET, cmTarget::VisibilityNormal, + mf); target.SetProperty("EXCLUDE_FROM_ALL", "TRUE"); std::vector<std::string> no_outputs; @@ -2362,12 +2362,14 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( std::vector<std::string> no_depends; // Store the custom command in the target. cmCustomCommand cc(CM_NULLPTR, no_outputs, no_byproducts, no_depends, - *commandLines, CM_NULLPTR, workingDirectory); - cc.SetUsesTerminal(uses_terminal); + gti.CommandLines, CM_NULLPTR, gti.WorkingDir.c_str()); + cc.SetUsesTerminal(gti.UsesTerminal); target.AddPostBuildCommand(cc); - target.SetProperty("EchoString", message); - std::vector<std::string>::iterator dit; - for (dit = depends.begin(); dit != depends.end(); ++dit) { + if (!gti.Message.empty()) { + target.SetProperty("EchoString", gti.Message.c_str()); + } + for (std::vector<std::string>::const_iterator dit = gti.Depends.begin(); + dit != gti.Depends.end(); ++dit) { target.AddUtility(*dit); } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 1e1479a..f7b2e59 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -402,11 +402,30 @@ protected: bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; virtual void InitializeProgressMarks() {} - void CreateDefaultGlobalTargets(cmTargets* targets); - cmTarget CreateGlobalTarget(const std::string& name, const char* message, - const cmCustomCommandLines* commandLines, - std::vector<std::string> depends, - const char* workingDir, bool uses_terminal); + + struct GlobalTargetInfo + { + std::string Name; + std::string Message; + cmCustomCommandLines CommandLines; + std::vector<std::string> Depends; + std::string WorkingDir; + bool UsesTerminal; + GlobalTargetInfo() + : UsesTerminal(false) + { + } + }; + + void CreateDefaultGlobalTargets(std::vector<GlobalTargetInfo>& targets); + + void AddGlobalTarget_Package(std::vector<GlobalTargetInfo>& targets); + void AddGlobalTarget_PackageSource(std::vector<GlobalTargetInfo>& targets); + void AddGlobalTarget_Test(std::vector<GlobalTargetInfo>& targets); + void AddGlobalTarget_EditCache(std::vector<GlobalTargetInfo>& targets); + void AddGlobalTarget_RebuildCache(std::vector<GlobalTargetInfo>& targets); + void AddGlobalTarget_Install(std::vector<GlobalTargetInfo>& targets); + cmTarget CreateGlobalTarget(GlobalTargetInfo const& gti, cmMakefile* mf); std::string FindMakeProgramFile; std::string ConfiguredFilesPath; diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index 360ebeb..c90314e 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -15,7 +15,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1 || args.size() > 4) { + if (args.empty() || args.size() > 4) { this->SetError("called with wrong number of arguments. " "include() only takes one file."); return false; diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index cafdba7..904fcca 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -15,7 +15,7 @@ bool cmIncludeDirectoryCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { return true; } diff --git a/Source/cmIncludeRegularExpressionCommand.cxx b/Source/cmIncludeRegularExpressionCommand.cxx index 2473dff..bd26d93 100644 --- a/Source/cmIncludeRegularExpressionCommand.cxx +++ b/Source/cmIncludeRegularExpressionCommand.cxx @@ -15,7 +15,7 @@ bool cmIncludeRegularExpressionCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { - if ((args.size() < 1) || (args.size() > 2)) { + if ((args.empty()) || (args.size() > 2)) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx index a33b429..9b5d54a 100644 --- a/Source/cmLinkDirectoriesCommand.cxx +++ b/Source/cmLinkDirectoriesCommand.cxx @@ -15,7 +15,7 @@ bool cmLinkDirectoriesCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { return true; } diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx index 5d23d6a..bef234e 100644 --- a/Source/cmLinkLibrariesCommand.cxx +++ b/Source/cmLinkLibrariesCommand.cxx @@ -15,7 +15,7 @@ bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { return true; } // add libraries, nothe that there is an optional prefix diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index 466aaa7..025c0a3 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -167,10 +167,10 @@ public: iterator Truncate() { - assert(this->UpPositions.size() > 0); + assert(!this->UpPositions.empty()); this->UpPositions.erase(this->UpPositions.begin() + 1, this->UpPositions.end()); - assert(this->Data.size() > 0); + assert(!this->Data.empty()); this->Data.erase(this->Data.begin() + 1, this->Data.end()); return iterator(this, 1); } diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index 85188d1..6d9cf8e 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -18,7 +18,7 @@ bool cmLoadCacheCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with wrong number of arguments."); } diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index ddf6ce6..4d8a4e3 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -183,7 +183,7 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args, "The load_command command should not be called; see CMP0031.")) { return true; } - if (args.size() < 1) { + if (args.empty()) { return true; } diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index ee9dc8a..5231062 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -236,7 +236,7 @@ bool cmMacroFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, bool cmMacroCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx index 2fb6a75..6c979f6 100644 --- a/Source/cmMarkAsAdvancedCommand.cxx +++ b/Source/cmMarkAsAdvancedCommand.cxx @@ -15,7 +15,7 @@ bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmMathCommand.cxx b/Source/cmMathCommand.cxx index ca8b926..b812349 100644 --- a/Source/cmMathCommand.cxx +++ b/Source/cmMathCommand.cxx @@ -16,7 +16,7 @@ bool cmMathCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("must be called with at least one argument."); return false; } diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index c48910e..e884531 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -17,7 +17,7 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 139303b..6f98d94 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -15,7 +15,7 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("PROJECT called with incorrect number of arguments"); return false; } diff --git a/Source/cmRemoveCommand.cxx b/Source/cmRemoveCommand.cxx index 955f712..c695374 100644 --- a/Source/cmRemoveCommand.cxx +++ b/Source/cmRemoveCommand.cxx @@ -15,7 +15,7 @@ bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { return true; } diff --git a/Source/cmRemoveDefinitionsCommand.cxx b/Source/cmRemoveDefinitionsCommand.cxx index 638eda6..77de846 100644 --- a/Source/cmRemoveDefinitionsCommand.cxx +++ b/Source/cmRemoveDefinitionsCommand.cxx @@ -16,7 +16,7 @@ bool cmRemoveDefinitionsCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { // it is OK to have no arguments - if (args.size() < 1) { + if (args.empty()) { return true; } diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 8fb6aa0..6bdb28b 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -15,7 +15,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmSetDirectoryPropertiesCommand.cxx b/Source/cmSetDirectoryPropertiesCommand.cxx index ca758da..8584118 100644 --- a/Source/cmSetDirectoryPropertiesCommand.cxx +++ b/Source/cmSetDirectoryPropertiesCommand.cxx @@ -17,7 +17,7 @@ bool cmSetDirectoryPropertiesCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index 2fb137f..59d569d 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -18,7 +18,7 @@ bool cmSetTestsPropertiesCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 6db14c0..6f7ef6c 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -15,7 +15,7 @@ bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 3c913ee..addfed4 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -26,7 +26,7 @@ bool cmStringCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("must be called with at least one argument."); return false; } diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx index 401f588..4893978 100644 --- a/Source/cmSubdirCommand.cxx +++ b/Source/cmSubdirCommand.cxx @@ -15,7 +15,7 @@ bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d964f00..1b6c93e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -62,10 +62,10 @@ public: cmTarget::cmTarget(std::string const& name, cmState::TargetType type, Visibility vis, cmMakefile* mf) { - assert(mf || type == cmState::GLOBAL_TARGET); + assert(mf); this->Name = name; this->TargetTypeValue = type; - this->Makefile = CM_NULLPTR; + this->Makefile = mf; this->HaveInstallRule = false; this->DLLPlatform = false; this->IsAndroid = false; @@ -82,25 +82,6 @@ cmTarget::cmTarget(std::string const& name, cmState::TargetType type, this->RecordDependencies = false; } - if (mf) { - this->SetMakefile(mf); - } -} - -cmTarget cmTarget::CopyForDirectory(cmMakefile* mf) const -{ - assert(this->GetType() == cmState::GLOBAL_TARGET); - assert(this->GetMakefile() == CM_NULLPTR); - cmTarget result(*this); - result.SetMakefile(mf); - return result; -} - -void cmTarget::SetMakefile(cmMakefile* mf) -{ - // Set our makefile. - this->Makefile = mf; - // Check whether this is a DLL platform. this->DLLPlatform = (this->Makefile->IsOn("WIN32") || this->Makefile->IsOn("CYGWIN") || diff --git a/Source/cmTarget.h b/Source/cmTarget.h index ebc92f3..4b182bb 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -88,9 +88,6 @@ public: ///! Set/Get the name of the target const std::string& GetName() const { return this->Name; } - /** Get a copy of this target adapted for the given directory. */ - cmTarget CopyForDirectory(cmMakefile* mf) const; - /** Get the cmMakefile that owns this target. */ cmMakefile* GetMakefile() const { return this->Makefile; } @@ -283,8 +280,6 @@ public: }; private: - void SetMakefile(cmMakefile* mf); - bool HandleLocationPropertyPolicy(cmMakefile* context) const; const char* GetSuffixVariableInternal(bool implib) const; diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 1c4a9ce..b62e225 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -22,7 +22,7 @@ bool cmTargetLinkLibrariesCommand::InitialPass( std::vector<std::string> const& args, cmExecutionStatus&) { // must have one argument - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx index 05ba65a..5bf137c 100644 --- a/Source/cmUnsetCommand.cxx +++ b/Source/cmUnsetCommand.cxx @@ -15,7 +15,7 @@ bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1 || args.size() > 2) { + if (args.empty() || args.size() > 2) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx index f30ffe8..cf740db 100644 --- a/Source/cmVariableWatchCommand.cxx +++ b/Source/cmVariableWatchCommand.cxx @@ -104,7 +104,7 @@ cmVariableWatchCommand::~cmVariableWatchCommand() bool cmVariableWatchCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("must be called with at least one argument."); return false; } diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 93a6271..ad558fe 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -133,7 +133,7 @@ bool cmWhileFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, bool cmWhileCommand::InvokeInitialPass( const std::vector<cmListFileArgument>& args, cmExecutionStatus&) { - if (args.size() < 1) { + if (args.empty()) { this->SetError("called with incorrect number of arguments"); return false; } diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index 7ef3c03..405917a 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -11,6 +11,7 @@ set(CMakeLib_TESTS testUTF8 testXMLParser testXMLSafe + testFindPackageCommand ) set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/Tests/CMakeLib/testFindPackageCommand.cxx b/Tests/CMakeLib/testFindPackageCommand.cxx new file mode 100644 index 0000000..1cddb0e --- /dev/null +++ b/Tests/CMakeLib/testFindPackageCommand.cxx @@ -0,0 +1,76 @@ +/*============================================================================ + 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 "cmFindPackageCommand.h" + +#include <iostream> +#include <string> + +#define cmPassed(m) std::cout << "Passed: " << (m) << "\n" +#define cmFailed(m) \ + std::cout << "FAILED: " << (m) << "\n"; \ + failed = 1 + +int testFindPackageCommand(int /*unused*/, char* /*unused*/ []) +{ + int failed = 0; + + // ---------------------------------------------------------------------- + // Test cmFindPackage::Sort + std::vector<std::string> testString; + testString.push_back("lib-0.0"); + testString.push_back("lib-1.2"); + testString.push_back("lib-2.0"); + testString.push_back("lib-19.0.1"); + testString.push_back("lib-20.01.1"); + testString.push_back("lib-20.2.2a"); + + cmFindPackageCommand::Sort(testString.begin(), testString.end(), + cmFindPackageCommand::Natural, + cmFindPackageCommand::Asc); + if (!(testString[0] == "lib-0.0" && testString[1] == "lib-1.2" && + testString[2] == "lib-2.0" && testString[3] == "lib-19.0.1" && + testString[4] == "lib-20.01.1" && testString[5] == "lib-20.2.2a")) { + cmFailed("cmSystemTools::Sort fail with Natural ASC"); + } + + cmFindPackageCommand::Sort(testString.begin(), testString.end(), + cmFindPackageCommand::Natural, + cmFindPackageCommand::Dec); + if (!(testString[5] == "lib-0.0" && testString[4] == "lib-1.2" && + testString[3] == "lib-2.0" && testString[2] == "lib-19.0.1" && + testString[1] == "lib-20.01.1" && testString[0] == "lib-20.2.2a")) { + cmFailed("cmSystemTools::Sort fail with Natural ASC"); + } + + cmFindPackageCommand::Sort(testString.begin(), testString.end(), + cmFindPackageCommand::Name_order, + cmFindPackageCommand::Dec); + if (!(testString[5] == "lib-0.0" && testString[4] == "lib-1.2" && + testString[3] == "lib-19.0.1" && testString[2] == "lib-2.0" && + testString[1] == "lib-20.01.1" && testString[0] == "lib-20.2.2a")) { + cmFailed("cmSystemTools::Sort fail with Name DEC"); + } + + cmFindPackageCommand::Sort(testString.begin(), testString.end(), + cmFindPackageCommand::Name_order, + cmFindPackageCommand::Asc); + if (!(testString[0] == "lib-0.0" && testString[1] == "lib-1.2" && + testString[2] == "lib-19.0.1" && testString[3] == "lib-2.0" && + testString[4] == "lib-20.01.1" && testString[5] == "lib-20.2.2a")) { + cmFailed("cmSystemTools::Sort fail with Natural ASC"); + } + + if (!failed) { + cmPassed("cmSystemTools::Sort working"); + } + return failed; +} diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 04bbbc6..1a6f204 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -633,3 +633,33 @@ endif() if(PACKAGE_VERSION_UNSUITABLE) message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !") endif() + + +############################################################################ +##Test FIND_PACKAGE using sorting +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +SET(CMAKE_FIND_PACKAGE_SORT_ORDER NAME) +SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION ASC) + +set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) +FIND_PACKAGE(SortLib CONFIG) +IF (NOT "${SortLib_VERSION}" STREQUAL "3.1.1") + message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Name Asc! ${SortLib_VERSION}") +endif() +unset(SortLib_VERSION) + + +set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) +SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) +SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) +FIND_PACKAGE(SortLib CONFIG) +IF (NOT "${SortLib_VERSION}" STREQUAL "3.10.1") + message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Natural! Dec ${SortLib_VERSION}") +endif() +set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) +unset(SortLib_VERSION) + + +unset(CMAKE_FIND_PACKAGE_SORT_ORDER) +unset(CMAKE_FIND_PACKAGE_SORT_DIRECTION) +set(CMAKE_PREFIX_PATH ) diff --git a/Tests/FindPackageTest/SortLib-3.1.1/SortLibConfig.cmake b/Tests/FindPackageTest/SortLib-3.1.1/SortLibConfig.cmake new file mode 100644 index 0000000..c1f2088 --- /dev/null +++ b/Tests/FindPackageTest/SortLib-3.1.1/SortLibConfig.cmake @@ -0,0 +1,2 @@ +set(SORT_LIB_VERSION 3.1.1) +message("SortLib 3.1.1 config reached") diff --git a/Tests/FindPackageTest/SortLib-3.1.1/SortLibConfigVersion.cmake b/Tests/FindPackageTest/SortLib-3.1.1/SortLibConfigVersion.cmake new file mode 100644 index 0000000..fa927c7 --- /dev/null +++ b/Tests/FindPackageTest/SortLib-3.1.1/SortLibConfigVersion.cmake @@ -0,0 +1,9 @@ +set(PACKAGE_VERSION 3.1.1) +if(PACKAGE_FIND_VERSION_MAJOR EQUAL 3) + if(PACKAGE_FIND_VERSION_MINOR EQUAL 1) + set(PACKAGE_VERSION_COMPATIBLE 1) + if(PACKAGE_FIND_VERSION_PATCH EQUAL 1) + set(PACKAGE_VERSION_EXACT 1) + endif() + endif() +endif() diff --git a/Tests/FindPackageTest/SortLib-3.10.1/SortLibConfig.cmake b/Tests/FindPackageTest/SortLib-3.10.1/SortLibConfig.cmake new file mode 100644 index 0000000..3f3f659 --- /dev/null +++ b/Tests/FindPackageTest/SortLib-3.10.1/SortLibConfig.cmake @@ -0,0 +1,2 @@ +set(SORT_LIB_VERSION 3.10.1) +message("SortLib 3.10.1 config reached") diff --git a/Tests/FindPackageTest/SortLib-3.10.1/SortLibConfigVersion.cmake b/Tests/FindPackageTest/SortLib-3.10.1/SortLibConfigVersion.cmake new file mode 100644 index 0000000..6f44c2d --- /dev/null +++ b/Tests/FindPackageTest/SortLib-3.10.1/SortLibConfigVersion.cmake @@ -0,0 +1,9 @@ +set(PACKAGE_VERSION 3.10.1) +if(PACKAGE_FIND_VERSION_MAJOR EQUAL 3) + if(PACKAGE_FIND_VERSION_MINOR EQUAL 10) + set(PACKAGE_VERSION_COMPATIBLE 1) + if(PACKAGE_FIND_VERSION_PATCH EQUAL 1) + set(PACKAGE_VERSION_EXACT 1) + endif() + endif() +endif() diff --git a/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-result.txt b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-stderr.txt new file mode 100644 index 0000000..247923b --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at DOWNLOAD-httpheader-not-set.cmake:[0-9]+ \(file\): + file DOWNLOAD missing string for HTTPHEADER. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set.cmake b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set.cmake new file mode 100644 index 0000000..6efc958 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set.cmake @@ -0,0 +1 @@ +file(DOWNLOAD "" "" HTTPHEADER "Content-Type: application/x-compressed-tar" HTTPHEADER) diff --git a/Tests/RunCMake/file/LOCK-lowercase.cmake b/Tests/RunCMake/file/LOCK-lowercase.cmake new file mode 100644 index 0000000..373afda --- /dev/null +++ b/Tests/RunCMake/file/LOCK-lowercase.cmake @@ -0,0 +1,11 @@ +set(lock "${CMAKE_CURRENT_BINARY_DIR}/file-to-lock") + +if(WIN32) + string(TOLOWER ${lock} lock) +endif() + +file(LOCK ${lock} TIMEOUT 0) +file(LOCK ${lock} RELEASE) + +file(LOCK ${lock} TIMEOUT 0) +file(LOCK ${lock} RELEASE) diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index d8e9ce0..48fa757 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -2,8 +2,10 @@ include(RunCMake) run_cmake(DOWNLOAD-hash-mismatch) run_cmake(DOWNLOAD-unused-argument) +run_cmake(DOWNLOAD-httpheader-not-set) run_cmake(DOWNLOAD-pass-not-set) run_cmake(UPLOAD-unused-argument) +run_cmake(UPLOAD-httpheader-not-set) run_cmake(UPLOAD-pass-not-set) run_cmake(INSTALL-DIRECTORY) run_cmake(INSTALL-MESSAGE-bad) @@ -22,6 +24,7 @@ run_cmake(LOCK-error-no-result-variable) run_cmake(LOCK-error-no-timeout) run_cmake(LOCK-error-timeout) run_cmake(LOCK-error-unknown-option) +run_cmake(LOCK-lowercase) run_cmake(GLOB) run_cmake(GLOB_RECURSE) # test is valid both for GLOB and GLOB_RECURSE diff --git a/Tests/RunCMake/file/UPLOAD-httpheader-not-set-result.txt b/Tests/RunCMake/file/UPLOAD-httpheader-not-set-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-httpheader-not-set-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/UPLOAD-httpheader-not-set-stderr.txt b/Tests/RunCMake/file/UPLOAD-httpheader-not-set-stderr.txt new file mode 100644 index 0000000..341baf5 --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-httpheader-not-set-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at UPLOAD-httpheader-not-set.cmake:[0-9]+ \(file\): + file UPLOAD missing string for HTTPHEADER. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/UPLOAD-httpheader-not-set.cmake b/Tests/RunCMake/file/UPLOAD-httpheader-not-set.cmake new file mode 100644 index 0000000..18d43cc --- /dev/null +++ b/Tests/RunCMake/file/UPLOAD-httpheader-not-set.cmake @@ -0,0 +1 @@ +file(UPLOAD "" "" HTTPHEADER "Content-Type: application/x-compressed-tar" HTTPHEADER) diff --git a/Utilities/Doxygen/CMakeLists.txt b/Utilities/Doxygen/CMakeLists.txt index 6ebf2b4..add5326 100644 --- a/Utilities/Doxygen/CMakeLists.txt +++ b/Utilities/Doxygen/CMakeLists.txt @@ -12,7 +12,7 @@ if(NOT CMake_SOURCE_DIR) set(CMakeDeveloperReference_STANDALONE 1) - cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR) + cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR) get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH) get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH) include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake) diff --git a/Utilities/Release/linux64_release.cmake b/Utilities/Release/linux64_release.cmake index 168eb86..e7e154e 100644 --- a/Utilities/Release/linux64_release.cmake +++ b/Utilities/Release/linux64_release.cmake @@ -21,7 +21,7 @@ set(qt_xcb_libs set(INITIAL_CACHE " CMAKE_BUILD_TYPE:STRING=Release CMAKE_C_STANDARD:STRING=11 -CMAKE_CXX_STANDARD:STRING=11 +CMAKE_CXX_STANDARD:STRING=14 CMAKE_C_FLAGS:STRING=-D_POSIX_C_SOURCE=199506L -D_POSIX_SOURCE=1 -D_SVID_SOURCE=1 -D_BSD_SOURCE=1 CMAKE_EXE_LINKER_FLAGS:STRING=-static-libstdc++ -static-libgcc CURSES_LIBRARY:FILEPATH=/home/kitware/ncurses-5.9/lib/libncurses.a diff --git a/Utilities/Release/osx_release.cmake b/Utilities/Release/osx_release.cmake index e7e5ba4..12b12d7 100644 --- a/Utilities/Release/osx_release.cmake +++ b/Utilities/Release/osx_release.cmake @@ -14,7 +14,7 @@ set(CXXFLAGS "-stdlib=libc++") set(INITIAL_CACHE " CMAKE_BUILD_TYPE:STRING=Release CMAKE_C_STANDARD:STRING=11 -CMAKE_CXX_STANDARD:STRING=11 +CMAKE_CXX_STANDARD:STRING=14 CMAKE_OSX_ARCHITECTURES:STRING=x86_64 CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7 CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE diff --git a/Utilities/Release/win32_release.cmake b/Utilities/Release/win32_release.cmake index a27efda..f54a4ca 100644 --- a/Utilities/Release/win32_release.cmake +++ b/Utilities/Release/win32_release.cmake @@ -27,6 +27,6 @@ get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) set(GIT_EXTRA "git config core.autocrlf true") if(CMAKE_CREATE_VERSION STREQUAL "nightly") # Some tests fail spuriously too often. - set(EXTRA_CTEST_ARGS "-E Qt5Autogen") + set(EXTRA_CTEST_ARGS "-E 'Qt5Autogen|ConsoleBuf'") endif() include(${path}/release_cmake.cmake) diff --git a/Utilities/Release/win64_release.cmake b/Utilities/Release/win64_release.cmake index e39a610..bd2690f 100644 --- a/Utilities/Release/win64_release.cmake +++ b/Utilities/Release/win64_release.cmake @@ -28,6 +28,6 @@ get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) set(GIT_EXTRA "git config core.autocrlf true") if(CMAKE_CREATE_VERSION STREQUAL "nightly") # Some tests fail spuriously too often. - set(EXTRA_CTEST_ARGS "-E Qt5Autogen") + set(EXTRA_CTEST_ARGS "-E 'Qt5Autogen|ConsoleBuf'") endif() include(${path}/release_cmake.cmake) diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index 45f79dd..be4850e 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -11,7 +11,7 @@ #============================================================================= if(NOT CMake_SOURCE_DIR) set(CMakeHelp_STANDALONE 1) - cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR) + cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR) get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH) get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH) include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake) |