diff options
author | JinWang An <jinwang.an@samsung.com> | 2022-12-27 17:20:17 +0900 |
---|---|---|
committer | JinWang An <jinwang.an@samsung.com> | 2022-12-27 17:20:17 +0900 |
commit | a15be45cafea5ce2b2791b7aaa8acfcaf2ec2e2f (patch) | |
tree | 130fd8721662ea77eeda82d4b89c193e5844338e | |
parent | 47713772c95f12ee5f3a63340b5830ef98c5b0f2 (diff) | |
download | cmake-a15be45cafea5ce2b2791b7aaa8acfcaf2ec2e2f.tar.gz cmake-a15be45cafea5ce2b2791b7aaa8acfcaf2ec2e2f.tar.bz2 cmake-a15be45cafea5ce2b2791b7aaa8acfcaf2ec2e2f.zip |
Imported Upstream version 3.23.4upstream/3.23.4
-rw-r--r-- | Help/release/3.23.rst | 6 | ||||
-rw-r--r-- | Modules/FindCUDAToolkit.cmake | 37 | ||||
-rw-r--r-- | Modules/FindGTest.cmake | 2 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 4 | ||||
-rw-r--r-- | Source/cmFileCommand.cxx | 10 | ||||
-rw-r--r-- | Source/cmStringAlgorithms.cxx | 32 | ||||
-rw-r--r-- | Source/cmStringAlgorithms.h | 10 | ||||
-rw-r--r-- | Tests/CMakeLib/testStringAlgorithms.cxx | 35 |
8 files changed, 111 insertions, 25 deletions
diff --git a/Help/release/3.23.rst b/Help/release/3.23.rst index 18fd83bd3..594bb0bc6 100644 --- a/Help/release/3.23.rst +++ b/Help/release/3.23.rst @@ -310,9 +310,9 @@ Changes made since CMake 3.23.0 include the following. The old ``CPACK_PACKAGEMAKER_CHOICES`` variable is now also set to the same content as it was before, but it is formally deprecated. -3.23.3 ------- +3.23.3, 3.23.4 +-------------- -* This version made no changes to documented features or interfaces. +* These versions made no changes to documented features or interfaces. Some implementation updates were made to support ecosystem changes and/or fix regressions. diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake index afdd4c44a..f6dfc4f2f 100644 --- a/Modules/FindCUDAToolkit.cmake +++ b/Modules/FindCUDAToolkit.cmake @@ -924,7 +924,7 @@ if(CUDAToolkit_FOUND) endif() _CUDAToolkit_find_and_add_import_lib(culibos) # it's a static library - foreach (cuda_lib cublasLt cublas cufft curand cusparse nppc nvjpeg) + foreach (cuda_lib cublasLt cufft curand cusparse nppc nvjpeg) _CUDAToolkit_find_and_add_import_lib(${cuda_lib}) _CUDAToolkit_find_and_add_import_lib(${cuda_lib}_static DEPS culibos) endforeach() @@ -932,8 +932,11 @@ if(CUDAToolkit_FOUND) if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.0.0) # cublas depends on cublasLt # https://docs.nvidia.com/cuda/archive/11.0/cublas/index.html#static-library - _CUDAToolkit_find_and_add_import_lib(cublas DEPS cublasLt) - _CUDAToolkit_find_and_add_import_lib(cublas_static DEPS cublasLt_static) + _CUDAToolkit_find_and_add_import_lib(cublas DEPS cublasLt culibos) + _CUDAToolkit_find_and_add_import_lib(cublas_static DEPS cublasLt_static culibos) + else() + _CUDAToolkit_find_and_add_import_lib(cublas DEPS culibos) + _CUDAToolkit_find_and_add_import_lib(cublas_static DEPS culibos) endif() # cuFFTW depends on cuFFT @@ -944,25 +947,25 @@ if(CUDAToolkit_FOUND) endif() # cuSOLVER depends on cuBLAS, and cuSPARSE - _CUDAToolkit_find_and_add_import_lib(cusolver DEPS cublas cusparse) - _CUDAToolkit_find_and_add_import_lib(cusolver_static DEPS cublas_static cusparse_static culibos) - - - if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 10.1.2) - # cusolver depends on liblapack_static.a starting with CUDA 10.1 update 2, - # https://docs.nvidia.com/cuda/archive/11.5.0/cusolver/index.html#static-link-lapack - _CUDAToolkit_find_and_add_import_lib(cusolver_lapack_static ALT lapack_static) # implementation detail static lib - _CUDAToolkit_find_and_add_import_lib(cusolver_static DEPS cusolver_lapack_static) - endif() - + set(cusolver_deps cublas cusparse) + set(cusolver_static_deps cublas_static cusparse_static culibos) if(CUDAToolkit_VERSION VERSION_GREATER 11.2.1) # cusolver depends on libcusolver_metis and cublasLt # https://docs.nvidia.com/cuda/archive/11.2.2/cusolver/index.html#link-dependency - _CUDAToolkit_find_and_add_import_lib(cusolver DEPS cublasLt) - + list(APPEND cusolver_deps cublasLt) _CUDAToolkit_find_and_add_import_lib(cusolver_metis_static ALT metis_static) # implementation detail static lib - _CUDAToolkit_find_and_add_import_lib(cusolver_static DEPS cusolver_metis_static cublasLt_static) + list(APPEND cusolver_static_deps cusolver_metis_static cublasLt_static) + endif() + if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 10.1.2) + # cusolver depends on liblapack_static.a starting with CUDA 10.1 update 2, + # https://docs.nvidia.com/cuda/archive/11.5.0/cusolver/index.html#static-link-lapack + _CUDAToolkit_find_and_add_import_lib(cusolver_lapack_static ALT lapack_static) # implementation detail static lib + list(APPEND cusolver_static_deps cusolver_lapack_static) endif() + _CUDAToolkit_find_and_add_import_lib(cusolver DEPS ${cusolver_deps}) + _CUDAToolkit_find_and_add_import_lib(cusolver_static DEPS ${cusolver_static_deps}) + unset(cusolver_deps) + unset(cusolver_static_deps) # nvGRAPH depends on cuRAND, and cuSOLVER. _CUDAToolkit_find_and_add_import_lib(nvgraph DEPS curand cusolver) diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index 60bb40103..92334e44e 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -314,7 +314,7 @@ if(GTest_FOUND) __gtest_define_backwards_compatible_library_targets() endif() -if(GMock_FOUND) +if(GMock_FOUND AND GTest_FOUND) if(NOT TARGET GTest::gmock) __gtest_determine_library_type(GMOCK_LIBRARY) add_library(GTest::gmock ${GMOCK_LIBRARY_TYPE} IMPORTED) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f6786592f..bdc1b7dcf 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 23) -set(CMake_VERSION_PATCH 3) +set(CMake_VERSION_PATCH 4) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) @@ -21,7 +21,7 @@ endif() if(NOT CMake_VERSION_NO_GIT) # If this source was exported by 'git archive', use its commit info. - set(git_info [==[d566bd962d CMake 3.23.3]==]) + set(git_info [==[34a6da34b8 CMake 3.23.4]==]) # Otherwise, try to identify the current development source version. if(NOT git_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]?[0-9a-f]?)[0-9a-f]* " diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index da2f15fdf..fb15a1b92 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -199,13 +199,19 @@ bool HandleReadCommand(std::vector<std::string> const& args, // is there a limit? std::string::size_type sizeLimit = std::string::npos; if (!arguments.Limit.empty()) { - std::istringstream(arguments.Limit) >> sizeLimit; + unsigned long long limit; + if (cmStrToULongLong(arguments.Limit, &limit)) { + sizeLimit = static_cast<std::string::size_type>(limit); + } } // is there an offset? cmsys::ifstream::off_type offset = 0; if (!arguments.Offset.empty()) { - std::istringstream(arguments.Offset) >> offset; + long long off; + if (cmStrToLongLong(arguments.Offset, &off)) { + offset = static_cast<cmsys::ifstream::off_type>(off); + } } file.seekg(offset, std::ios::beg); // explicit ios::beg for IBM VisualAge 6 diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx index 1bb680819..f73c85413 100644 --- a/Source/cmStringAlgorithms.cxx +++ b/Source/cmStringAlgorithms.cxx @@ -250,6 +250,38 @@ bool cmStrToULong(std::string const& str, unsigned long* value) return cmStrToULong(str.c_str(), value); } +bool cmStrToLongLong(const char* str, long long* value) +{ + errno = 0; + char* endp; + *value = strtoll(str, &endp, 10); + return (*endp == '\0') && (endp != str) && (errno == 0); +} + +bool cmStrToLongLong(std::string const& str, long long* value) +{ + return cmStrToLongLong(str.c_str(), value); +} + +bool cmStrToULongLong(const char* str, unsigned long long* value) +{ + errno = 0; + char* endp; + while (cmIsSpace(*str)) { + ++str; + } + if (*str == '-') { + return false; + } + *value = strtoull(str, &endp, 10); + return (*endp == '\0') && (endp != str) && (errno == 0); +} + +bool cmStrToULongLong(std::string const& str, unsigned long long* value) +{ + return cmStrToULongLong(str.c_str(), value); +} + template <typename Range> std::size_t getJoinedLength(Range const& rng, cm::string_view separator) { diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 492e588bb..83938bc24 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -303,3 +303,13 @@ bool cmStrToLong(std::string const& str, long* value); * integer */ bool cmStrToULong(const char* str, unsigned long* value); bool cmStrToULong(std::string const& str, unsigned long* value); + +/** Converts a string to long long. Expects that the whole string + * is an integer */ +bool cmStrToLongLong(const char* str, long long* value); +bool cmStrToLongLong(std::string const& str, long long* value); + +/** Converts a string to unsigned long long. Expects that the whole string + * is an integer */ +bool cmStrToULongLong(const char* str, unsigned long long* value); +bool cmStrToULongLong(std::string const& str, unsigned long long* value); diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx index c2706c1f9..1e6b6118e 100644 --- a/Tests/CMakeLib/testStringAlgorithms.cxx +++ b/Tests/CMakeLib/testStringAlgorithms.cxx @@ -227,6 +227,41 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ []) } // ---------------------------------------------------------------------- + // Test cmStrToLongLong + { + long long value; + assert_ok(cmStrToLongLong("1", &value) && value == 1, + "cmStrToLongLong parses a positive decimal integer."); + assert_ok(cmStrToLongLong(" 1", &value) && value == 1, + "cmStrToLongLong parses a decimal integer after whitespace."); + + assert_ok(cmStrToLongLong("-1", &value) && value == -1, + "cmStrToLongLong parses a negative decimal integer."); + assert_ok( + cmStrToLongLong(" -1", &value) && value == -1, + "cmStrToLongLong parses a negative decimal integer after whitespace."); + + assert_ok(!cmStrToLongLong("1x", &value), + "cmStrToLongLong rejects trailing content."); + } + + // ---------------------------------------------------------------------- + // Test cmStrToULongLong + { + unsigned long long value; + assert_ok(cmStrToULongLong("1", &value) && value == 1, + "cmStrToULongLong parses a decimal integer."); + assert_ok(cmStrToULongLong(" 1", &value) && value == 1, + "cmStrToULongLong parses a decimal integer after whitespace."); + assert_ok(!cmStrToULongLong("-1", &value), + "cmStrToULongLong rejects a negative number."); + assert_ok(!cmStrToULongLong(" -1", &value), + "cmStrToULongLong rejects a negative number after whitespace."); + assert_ok(!cmStrToULongLong("1x", &value), + "cmStrToULongLong rejects trailing content."); + } + + // ---------------------------------------------------------------------- // Test cmStrLen { constexpr auto len = cmStrLen("Hello world!"); |