From d3ab5eb53d4ef4c187524c2804aa6e0a6406da89 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Fri, 8 Oct 2021 09:13:27 +0900 Subject: Imported Upstream version 3.12.2 --- Help/variable/CMAKE_ANDROID_STL_TYPE.rst | 3 ++- Help/variable/CMAKE_LANG_CLANG_TIDY.rst | 2 +- Modules/CMakeCUDAInformation.cmake | 2 +- Modules/CheckIPOSupported.cmake | 15 +++++++++++---- Modules/FindBoost.cmake | 6 +++++- Modules/FindCUDA.cmake | 3 ++- Modules/FindMatlab.cmake | 15 --------------- Modules/Platform/Android-Common.cmake | 4 +++- Modules/Platform/Android/Determine-Compiler-NDK.cmake | 13 ++++++++++++- Modules/Platform/Windows-NVIDIA-CUDA.cmake | 2 +- Source/CMakeVersion.cmake | 2 +- Source/cmExportFileGenerator.cxx | 5 +++++ Source/cmGlobVerificationManager.cxx | 7 +++++++ Source/cmGlobVerificationManager.h | 3 +++ Source/cmState.cxx | 1 + Source/cmVisualStudio10TargetGenerator.cxx | 6 +++++- Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu | 6 ++++++ Tests/RunCMake/Android/RunCMakeTest.cmake | 11 ++++++++--- Tests/RunCMake/Android/common.cmake | 7 ++++--- Tests/RunCMake/export/ExportPropertiesUndefined.cmake | 11 +++++++++++ Tests/RunCMake/export/RunCMakeTest.cmake | 1 + 21 files changed, 90 insertions(+), 35 deletions(-) create mode 100644 Tests/RunCMake/export/ExportPropertiesUndefined.cmake diff --git a/Help/variable/CMAKE_ANDROID_STL_TYPE.rst b/Help/variable/CMAKE_ANDROID_STL_TYPE.rst index cfb76aa04..d174575c8 100644 --- a/Help/variable/CMAKE_ANDROID_STL_TYPE.rst +++ b/Help/variable/CMAKE_ANDROID_STL_TYPE.rst @@ -30,7 +30,8 @@ set to specify the STL variant to be used. The value may be one of: ``stlport_shared`` STLport Shared -The default value is ``gnustl_static``. Note that this default differs from +The default value is ``gnustl_static`` on NDK versions that provide it +and otherwise ``c++_static``. Note that this default differs from the native NDK build system because CMake may be used to build projects for Android that are not natively implemented for it and use the C++ standard library. diff --git a/Help/variable/CMAKE_LANG_CLANG_TIDY.rst b/Help/variable/CMAKE_LANG_CLANG_TIDY.rst index d1fccbb4d..bd49de369 100644 --- a/Help/variable/CMAKE_LANG_CLANG_TIDY.rst +++ b/Help/variable/CMAKE_LANG_CLANG_TIDY.rst @@ -9,5 +9,5 @@ created. For example: .. code-block:: cmake - set(CMAKE_CXX_CLANG_TIDY clang-tidy checks=-*,readability-*) + set(CMAKE_CXX_CLANG_TIDY clang-tidy -checks=-*,readability-*) add_executable(foo foo.cxx) diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake index 8e62941c1..43ae989e0 100644 --- a/Modules/CMakeCUDAInformation.cmake +++ b/Modules/CMakeCUDAInformation.cmake @@ -185,7 +185,7 @@ if(__IMPLICT_DLINK_DIRS) endif() set(__IMPLICT_DLINK_FLAGS ) foreach(dir ${__IMPLICT_DLINK_DIRS}) - if(EXISTS "${dir}/libcublas_device.a") + if(EXISTS "${dir}/libcurand_static.a") string(APPEND __IMPLICT_DLINK_FLAGS " -L\"${dir}\"") endif() endforeach() diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake index d8297d91c..3344834cd 100644 --- a/Modules/CheckIPOSupported.cmake +++ b/Modules/CheckIPOSupported.cmake @@ -56,13 +56,14 @@ include(CMakeParseArguments) # cmake_parse_arguments # X_RESULT - name of the final result variable # X_OUTPUT - name of the variable with information about error macro(_ipo_not_supported output) - string(COMPARE EQUAL "${X_RESULT}" "" is_empty) - if(is_empty) + if(NOT X_RESULT) message(FATAL_ERROR "IPO is not supported (${output}).") endif() set("${X_RESULT}" NO PARENT_SCOPE) - set("${X_OUTPUT}" "${output}" PARENT_SCOPE) + if(X_OUTPUT) + set("${X_OUTPUT}" "${output}" PARENT_SCOPE) + endif() endmacro() # Run IPO/LTO test @@ -125,7 +126,13 @@ macro(_ipo_run_language_check language) ) if(NOT result) - _ipo_not_supported("${output}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "${language} compiler IPO check failed with the following output:\n" + "${output}\n") + _ipo_not_supported("check failed to compile") + if(X_OUTPUT) + set("${X_OUTPUT}" "${output}" PARENT_SCOPE) + endif() return() endif() endmacro() diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 4e5c45db5..d5e701170 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -881,7 +881,11 @@ function(_Boost_COMPONENT_HEADERS component _hdrs) set(_Boost_CHRONO_HEADERS "boost/chrono.hpp") set(_Boost_CONTAINER_HEADERS "boost/container/container_fwd.hpp") set(_Boost_CONTRACT_HEADERS "boost/contract.hpp") - set(_Boost_CONTEXT_HEADERS "boost/context/detail/fcontext.hpp") + if(Boost_VERSION VERSION_LESS 106100) + set(_Boost_CONTEXT_HEADERS "boost/context/all.hpp") + else() + set(_Boost_CONTEXT_HEADERS "boost/context/detail/fcontext.hpp") + endif() set(_Boost_COROUTINE_HEADERS "boost/coroutine/all.hpp") set(_Boost_DATE_TIME_HEADERS "boost/date_time/date.hpp") set(_Boost_EXCEPTION_HEADERS "boost/exception/exception.hpp") diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 21cace37f..1650e55a7 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -971,7 +971,8 @@ if(NOT CUDA_VERSION VERSION_LESS "3.2") find_cuda_helper_libs(nvcuvid) endif() endif() -if(CUDA_VERSION VERSION_GREATER "5.0") +if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2") + # In CUDA 9.2 cublas_device was deprecated find_cuda_helper_libs(cublas_device) endif() diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 54e62db74..2d04b84dd 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -1216,21 +1216,6 @@ function(_Matlab_find_instances_win32 matlab_roots) extract_matlab_versions_from_registry_brute_force(_matlab_versions_from_registry) endif() - # filtering the results with the registry keys - matlab_get_all_valid_matlab_roots_from_registry("${_matlab_versions_from_registry}" _matlab_possible_roots) - unset(_matlab_versions_from_registry) - - set(_matlab_versions_from_registry) - matlab_extract_all_installed_versions_from_registry(CMAKE_CL_64 _matlab_versions_from_registry) - - # the returned list is empty, doing the search on all known versions - if(NOT _matlab_versions_from_registry) - if(MATLAB_FIND_DEBUG) - message(STATUS "[MATLAB] Search for Matlab from the registry unsuccessful, testing all supported versions") - endif() - extract_matlab_versions_from_registry_brute_force(_matlab_versions_from_registry) - endif() - # filtering the results with the registry keys matlab_get_all_valid_matlab_roots_from_registry("${_matlab_versions_from_registry}" _matlab_possible_roots) set(${matlab_roots} ${_matlab_possible_roots} PARENT_SCOPE) diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake index 80a8f410d..f8b934693 100644 --- a/Modules/Platform/Android-Common.cmake +++ b/Modules/Platform/Android-Common.cmake @@ -32,8 +32,10 @@ if(CMAKE_ANDROID_NDK) ) endif() unset(_ANDROID_STL_TYPE_FOUND) - else() + elseif(IS_DIRECTORY ${CMAKE_ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++) set(CMAKE_ANDROID_STL_TYPE "gnustl_static") + else() + set(CMAKE_ANDROID_STL_TYPE "c++_static") endif() unset(_ANDROID_STL_TYPES) diff --git a/Modules/Platform/Android/Determine-Compiler-NDK.cmake b/Modules/Platform/Android/Determine-Compiler-NDK.cmake index 064992514..5f2cc524e 100644 --- a/Modules/Platform/Android/Determine-Compiler-NDK.cmake +++ b/Modules/Platform/Android/Determine-Compiler-NDK.cmake @@ -35,7 +35,18 @@ elseif(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION) endif() set(_ANDROID_TOOL_PATTERNS "*-${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}") else() - set(_ANDROID_TOOL_PATTERNS "*-[0-9].[0-9]") + # If we can find any gcc toolchains then use one by default. + # Otherwise we look for clang toolchains (e.g. NDK r18+). + file(GLOB _ANDROID_CONFIG_MKS_FOR_GCC + "${CMAKE_ANDROID_NDK}/build/core/toolchains/*-[0-9].[0-9]/config.mk" + "${CMAKE_ANDROID_NDK}/toolchains/*-[0-9].[0-9]/config.mk" + ) + if(_ANDROID_CONFIG_MKS_FOR_GCC) + set(_ANDROID_TOOL_PATTERNS "*-[0-9].[0-9]") + else() + set(_ANDROID_TOOL_PATTERNS "*-clang") + endif() + unset(_ANDROID_CONFIG_MKS_FOR_GCC) endif() set(_ANDROID_CONFIG_MK_PATTERNS) foreach(base "build/core/toolchains" "toolchains") diff --git a/Modules/Platform/Windows-NVIDIA-CUDA.cmake b/Modules/Platform/Windows-NVIDIA-CUDA.cmake index f1c1f2df1..ba1638f87 100644 --- a/Modules/Platform/Windows-NVIDIA-CUDA.cmake +++ b/Modules/Platform/Windows-NVIDIA-CUDA.cmake @@ -44,7 +44,7 @@ if(__IMPLICT_DLINK_DIRS) endif() set(__IMPLICT_DLINK_FLAGS ) foreach(dir ${__IMPLICT_DLINK_DIRS}) - if(EXISTS "${dir}/cublas_device.lib") + if(EXISTS "${dir}/curand_static.lib") string(APPEND __IMPLICT_DLINK_FLAGS " -L\"${dir}\"") endif() endforeach() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a1343ae19..e236d3135 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 12) -set(CMake_VERSION_PATCH 1) +set(CMake_VERSION_PATCH 2) #set(CMake_VERSION_RC 0) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 5f615714b..9e6560fa9 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -1143,6 +1143,11 @@ bool cmExportFileGenerator::PopulateExportProperties( return false; } auto propertyValue = targetProperties.GetPropertyValue(prop); + if (propertyValue == nullptr) { + // Asked to export a property that isn't defined on the target. Do not + // consider this an error, there's just nothing to export. + continue; + } std::string evaluatedValue = cmGeneratorExpression::Preprocess( propertyValue, cmGeneratorExpression::StripAllGeneratorExpressions); if (evaluatedValue != propertyValue) { diff --git a/Source/cmGlobVerificationManager.cxx b/Source/cmGlobVerificationManager.cxx index e23b6eaea..189b517a0 100644 --- a/Source/cmGlobVerificationManager.cxx +++ b/Source/cmGlobVerificationManager.cxx @@ -170,3 +170,10 @@ void cmGlobVerificationManager::AddCacheEntry( value.Backtraces.emplace_back(variable, backtrace); } } + +void cmGlobVerificationManager::Reset() +{ + this->Cache.clear(); + this->VerifyScript.clear(); + this->VerifyStamp.clear(); +} diff --git a/Source/cmGlobVerificationManager.h b/Source/cmGlobVerificationManager.h index 4508602fe..cf04c97c7 100644 --- a/Source/cmGlobVerificationManager.h +++ b/Source/cmGlobVerificationManager.h @@ -37,6 +37,9 @@ protected: const std::string& variable, const cmListFileBacktrace& bt); + ///! Clear the glob cache for state reset. + void Reset(); + ///! Check targets should be written in generated build system. bool DoWriteVerifyTarget() const; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index a57be4db6..b2f609172 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -267,6 +267,7 @@ cmStateSnapshot cmState::Reset() { this->GlobalProperties.clear(); this->PropertyDefinitions.clear(); + this->GlobVerificationManager->Reset(); cmStateDetail::PositionType pos = this->SnapshotData.Truncate(); this->ExecutionListFiles.Truncate(); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index eff915b47..f472d8a42 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1207,7 +1207,11 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommands(Elem& e0) this->GeneratorTarget->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) { if (cmSourceFile const* sf = this->LocalGenerator->CreateVCProjBuildRule()) { - this->WriteCustomCommand(e0, sf); + // Write directly rather than through WriteCustomCommand because + // we do not want the de-duplication and it has no dependencies. + if (cmCustomCommand const* command = sf->GetCustomCommand()) { + this->WriteCustomRule(e0, sf, *command); + } } } } diff --git a/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu b/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu index 7eecec114..2c7c3887b 100644 --- a/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu +++ b/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu @@ -3,6 +3,9 @@ #include #include +// this test only makes sense for versions of CUDA that ships +// static libraries that have separable compilation device symbols +#if __CUDACC_VER_MAJOR__ <= 9 __global__ void deviceCublasSgemm(int n, float alpha, float beta, const float* d_A, const float* d_B, float* d_C) @@ -22,6 +25,7 @@ __global__ void deviceCublasSgemm(int n, float alpha, float beta, cublasDestroy(cnpHandle); } +#endif int choose_cuda_device() { @@ -63,6 +67,7 @@ int main(int argc, char** argv) return 0; } +#if __CUDACC_VER_MAJOR__ <= 9 // initial values that will make sure that the cublasSgemm won't actually // do any work int n = 0; @@ -72,6 +77,7 @@ int main(int argc, char** argv) float* d_B = nullptr; float* d_C = nullptr; deviceCublasSgemm<<<1, 1>>>(n, alpha, beta, d_A, d_B, d_C); +#endif return 0; } diff --git a/Tests/RunCMake/Android/RunCMakeTest.cmake b/Tests/RunCMake/Android/RunCMakeTest.cmake index 2027c4f91..45798ce59 100644 --- a/Tests/RunCMake/Android/RunCMakeTest.cmake +++ b/Tests/RunCMake/Android/RunCMakeTest.cmake @@ -61,8 +61,12 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) list(APPEND _abis_${_version} ${_abis}) endif() endforeach() - set(_abis_ ${_abis_${_latest_gcc}}) set(_abis_clang ${_abis_${_latest_clang}}) + if(_latest_gcc) + set(_abis_ ${_abis_${_latest_gcc}}) + else() + set(_abis_ ${_abis_clang}) + endif() if(_versions MATCHES "clang") set(_versions "clang" ${_versions}) endif() @@ -132,10 +136,11 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK) set(stl_types none system - gnustl_static - gnustl_shared ) + if(IS_DIRECTORY "${ndk}/sources/cxx-stl/gnu-libstdc++") + list(APPEND stl_types gnustl_static gnustl_shared) + endif() if(IS_DIRECTORY "${ndk}/sources/cxx-stl/gabi++/libs") list(APPEND stl_types gabi++_static gabi++_shared) endif() diff --git a/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake index f931be1f8..aaa7c8919 100644 --- a/Tests/RunCMake/Android/common.cmake +++ b/Tests/RunCMake/Android/common.cmake @@ -8,7 +8,6 @@ endif() foreach(f "${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX}" "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}g++${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" - "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}cpp${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ar${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ld${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}" ) @@ -61,10 +60,12 @@ execute_process( if(NOT _res EQUAL 0) message(SEND_ERROR "Failed to run 'gcc -dumpmachine':\n ${_res}") endif() -if(NOT _out STREQUAL "${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}") +string(REPLACE "--" "-" _out_check "${_out}") +if(NOT _out_check STREQUAL "${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}" + AND NOT (_out STREQUAL "arm--linux-android" AND CMAKE_C_ANDROID_TOOLCHAIN_MACHINE STREQUAL "arm-linux-androideabi")) message(SEND_ERROR "'gcc -dumpmachine' produced:\n" " ${_out}\n" - "which is not equal to CMAKE_C_ANDROID_TOOLCHAIN_MACHINE:\n" + "which does not match CMAKE_C_ANDROID_TOOLCHAIN_MACHINE:\n" " ${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}" ) endif() diff --git a/Tests/RunCMake/export/ExportPropertiesUndefined.cmake b/Tests/RunCMake/export/ExportPropertiesUndefined.cmake new file mode 100644 index 000000000..aa529f29a --- /dev/null +++ b/Tests/RunCMake/export/ExportPropertiesUndefined.cmake @@ -0,0 +1,11 @@ +enable_language(CXX) +add_library(foo empty.cpp) +set_target_properties(foo PROPERTIES + EXPORT_PROPERTIES "NotDefinedProp" +) +export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake") +install(TARGETS foo EXPORT fooExport + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake index 10ced9006..46bb1fca3 100644 --- a/Tests/RunCMake/export/RunCMakeTest.cmake +++ b/Tests/RunCMake/export/RunCMakeTest.cmake @@ -8,3 +8,4 @@ run_cmake(NoExportSet) run_cmake(ForbiddenToExportInterfaceProperties) run_cmake(ForbiddenToExportImportedProperties) run_cmake(ForbiddenToExportPropertyWithGenExp) +run_cmake(ExportPropertiesUndefined) -- cgit v1.2.3