diff --git a/.ci/manywheel/build_common.sh b/.ci/manywheel/build_common.sh index ec822b0cd4af..f70b8df4149c 100644 --- a/.ci/manywheel/build_common.sh +++ b/.ci/manywheel/build_common.sh @@ -31,7 +31,6 @@ elif [[ "$OS_NAME" == *"Ubuntu"* ]]; then # Comment out nvidia repositories to prevent them from getting apt-get updated, see https://github.com/pytorch/pytorch/issues/74968 # shellcheck disable=SC2046 sed -i 's/.*nvidia.*/# &/' $(find /etc/apt/ -type f -name "*.list") - retry apt-get update retry apt-get -y install zip openssl else @@ -98,6 +97,7 @@ if [[ -z "$PYTORCH_ROOT" ]]; then exit 1 fi pushd "$PYTORCH_ROOT" +retry pip install -q cmake python setup.py clean retry pip install -qr requirements.txt case ${DESIRED_PYTHON} in diff --git a/.ci/manywheel/build_libtorch.sh b/.ci/manywheel/build_libtorch.sh index 8f70210dd5b6..e9ab620475d1 100644 --- a/.ci/manywheel/build_libtorch.sh +++ b/.ci/manywheel/build_libtorch.sh @@ -92,6 +92,7 @@ if [[ -z "$PYTORCH_ROOT" ]]; then exit 1 fi pushd "$PYTORCH_ROOT" +retry pip install -q cmake python setup.py clean retry pip install -qr requirements.txt retry pip install -q numpy==2.0.1 diff --git a/.github/requirements/pip-requirements-macOS.txt b/.github/requirements/pip-requirements-macOS.txt index 399e5805d732..e8464f0a55ff 100644 --- a/.github/requirements/pip-requirements-macOS.txt +++ b/.github/requirements/pip-requirements-macOS.txt @@ -1,5 +1,5 @@ boto3==1.35.42 -cmake==3.25.* +cmake==3.27.* expecttest==0.3.0 fbscribelogger==0.1.7 filelock==3.6.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index c968af00ed6d..2e2ffee058a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.18 FATAL_ERROR) +cmake_minimum_required(VERSION 3.27 FATAL_ERROR) # cmake_policy(SET CMP0022 NEW) cmake_policy(SET CMP0023 NEW) # Use compiler ID "AppleClang" instead of "Clang" for XCode. Not setting this @@ -6,6 +6,7 @@ cmake_minimum_required(VERSION 3.18 FATAL_ERROR) # one is detected as "AppleClang". cmake_policy(SET CMP0010 NEW) cmake_policy(SET CMP0025 NEW) +cmake_policy(SET CMP0126 OLD) # Enables CMake to set LTO on compilers other than Intel. cmake_policy(SET CMP0069 NEW) @@ -16,6 +17,8 @@ cmake_policy(SET CMP0069 NEW) # we do this (and we don't if cmake is old), but it's nice when it's possible, # and it's possible on our Windows configs. cmake_policy(SET CMP0092 NEW) +# Don't remove the FindCUDA module +cmake_policy(SET CMP0146 OLD) # Prohibit in-source builds if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) @@ -559,6 +562,10 @@ if(MSVC) set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler /Zc:__cplusplus") set(CMAKE_NINJA_CMCLDEPS_RC OFF) + if(MSVC_Z7_OVERRIDE) + # CMake set debug flags to use /Z7 + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded) + endif() foreach( flag_var CMAKE_C_FLAGS @@ -571,12 +578,6 @@ if(MSVC) CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - # Replace /Zi and /ZI with /Z7 - if(MSVC_Z7_OVERRIDE) - if(${flag_var} MATCHES "/Z[iI]") - string(REGEX REPLACE "/Z[iI]" "/Z7" ${flag_var} "${${flag_var}}") - endif(${flag_var} MATCHES "/Z[iI]") - endif(MSVC_Z7_OVERRIDE) if(${CAFFE2_USE_MSVC_STATIC_RUNTIME}) if(${flag_var} MATCHES "/MD") diff --git a/aten/src/ATen/CMakeLists.txt b/aten/src/ATen/CMakeLists.txt index 5256879ab26f..01b601848c6a 100644 --- a/aten/src/ATen/CMakeLists.txt +++ b/aten/src/ATen/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.18 FATAL_ERROR) +cmake_minimum_required(VERSION 3.27 FATAL_ERROR) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) if(NOT MSVC) diff --git a/aten/src/ATen/native/cpu/BlasKernel.cpp b/aten/src/ATen/native/cpu/BlasKernel.cpp index 6d6976e6ccff..ab3b16c395a3 100644 --- a/aten/src/ATen/native/cpu/BlasKernel.cpp +++ b/aten/src/ATen/native/cpu/BlasKernel.cpp @@ -100,6 +100,7 @@ auto sum(int64_t N, Func f) { } template +__ubsan_ignore_signed_int_overflow__ std::enable_if_t, void> gemm_notrans_( int64_t m, diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/deps/clog/CMakeLists.txt b/aten/src/ATen/native/quantized/cpu/qnnpack/deps/clog/CMakeLists.txt index af31056c4430..979af29f723d 100644 --- a/aten/src/ATen/native/quantized/cpu/qnnpack/deps/clog/CMakeLists.txt +++ b/aten/src/ATen/native/quantized/cpu/qnnpack/deps/clog/CMakeLists.txt @@ -4,7 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -cmake_minimum_required(VERSION 3.18 FATAL_ERROR) +cmake_minimum_required(VERSION 3.27 FATAL_ERROR) include(GNUInstallDirs) diff --git a/c10/CMakeLists.txt b/c10/CMakeLists.txt index f00c662e70e0..8e9d267352dd 100644 --- a/c10/CMakeLists.txt +++ b/c10/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.18 FATAL_ERROR) +cmake_minimum_required(VERSION 3.27 FATAL_ERROR) project(c10 CXX) set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard whose features are requested to build this target.") diff --git a/cmake/ProtoBuf.cmake b/cmake/ProtoBuf.cmake index 4c436dcd6451..fe3113205df1 100644 --- a/cmake/ProtoBuf.cmake +++ b/cmake/ProtoBuf.cmake @@ -33,25 +33,6 @@ macro(custom_protobuf_find) set(__caffe2_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE}) set(CMAKE_POSITION_INDEPENDENT_CODE ON) - if(MSVC) - foreach(flag_var - CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL) - if(${flag_var} MATCHES "/Z[iI7]") - string(REGEX REPLACE "/Z[iI7]" "" ${flag_var} "${${flag_var}}") - endif() - endforeach(flag_var) - if(MSVC_Z7_OVERRIDE) - foreach(flag_var - CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELWITHDEBINFO - CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if(${flag_var} MATCHES "/Z[iI]") - string(REGEX REPLACE "/Z[iI]" "/Z7" ${flag_var} "${${flag_var}}") - endif() - endforeach(flag_var) - endif(MSVC_Z7_OVERRIDE) - endif(MSVC) - if(CMAKE_VERSION VERSION_GREATER_EQUAL "4.0.0") message(WARNING "Ancient protobuf forces CMake compatibility") set(CMAKE_POLICY_VERSION_MINIMUM 3.5) diff --git a/tools/setup_helpers/cmake.py b/tools/setup_helpers/cmake.py index 1fd7377cb07d..678ba7ab207c 100644 --- a/tools/setup_helpers/cmake.py +++ b/tools/setup_helpers/cmake.py @@ -60,12 +60,15 @@ class CMake: cmake3_version = CMake._get_version(which("cmake3")) cmake_version = CMake._get_version(which("cmake")) - _cmake_min_version = LooseVersion("3.18.0") + _cmake_min_version = LooseVersion("3.27.0") if all( ver is None or ver < _cmake_min_version for ver in [cmake_version, cmake3_version] ): - raise RuntimeError("no cmake or cmake3 with version >= 3.18.0 found") + raise RuntimeError( + "no cmake or cmake3 with version >= 3.27.0 found:" + + str([cmake_version, cmake3_version]) + ) if cmake3_version is None: cmake_command = "cmake" diff --git a/torch/CMakeLists.txt b/torch/CMakeLists.txt index ebbf93e59a37..55bd03122eee 100644 --- a/torch/CMakeLists.txt +++ b/torch/CMakeLists.txt @@ -2,7 +2,7 @@ # Now it only builds the Torch python bindings. if(NOT CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO) - cmake_minimum_required(VERSION 3.18 FATAL_ERROR) + cmake_minimum_required(VERSION 3.27 FATAL_ERROR) project(torch CXX C) find_package(torch REQUIRED) option(USE_CUDA "Use CUDA" ON) diff --git a/torch/_inductor/cpp_builder.py b/torch/_inductor/cpp_builder.py index db2654a54bf0..a27292d9c6f6 100644 --- a/torch/_inductor/cpp_builder.py +++ b/torch/_inductor/cpp_builder.py @@ -1731,7 +1731,7 @@ class CppBuilder: definitions = " ".join(self._build_option.get_definitions()) contents = textwrap.dedent( f""" - cmake_minimum_required(VERSION 3.18 FATAL_ERROR) + cmake_minimum_required(VERSION 3.27 FATAL_ERROR) project(aoti_model LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) diff --git a/torch/lib/libshm/CMakeLists.txt b/torch/lib/libshm/CMakeLists.txt index 8a7329ddab77..c3cd26fea7bf 100644 --- a/torch/lib/libshm/CMakeLists.txt +++ b/torch/lib/libshm/CMakeLists.txt @@ -1,5 +1,5 @@ project(libshm C CXX) -cmake_minimum_required(VERSION 3.18 FATAL_ERROR) +cmake_minimum_required(VERSION 3.27 FATAL_ERROR) set(TORCH_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../)