From 96392060548295ca4d839220807f8e6ac6336c86 Mon Sep 17 00:00:00 2001 From: Mengwei Liu Date: Thu, 27 Mar 2025 20:06:50 -0700 Subject: [PATCH 1/3] Unbreak CI job failures caused by cmake upgrade Summary: CMake is upgraded to 4.0.0 and it's imcompatible with `cmake_minimum_required(VERSION 3.0.2)` from `third-party/gflags/CMakeLists.txt:73` Test Plan: Reviewers: Subscribers: Tasks: Tags: --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 871fdf329c2..64d78263345 100644 --- a/setup.py +++ b/setup.py @@ -703,6 +703,8 @@ def run(self): # like `TorchConfig.cmake` that are provided by pip packages. f"-DCMAKE_PREFIX_PATH={cmake_prefix_path}", f"-DCMAKE_BUILD_TYPE={cfg}", + # A temporary flag for overriding exception caused by CMake 4.0.0+ + "-DCMAKE_POLICY_VERSION_MINIMUM=3.5", # Enable logging even when in release mode. We are building for # desktop, where saving a few kB is less important than showing # useful error information to users. From 79423d0e4526026af095c5fef46bb68bb6ffb3f9 Mon Sep 17 00:00:00 2001 From: Mengwei Liu Date: Thu, 27 Mar 2025 20:20:06 -0700 Subject: [PATCH 2/3] Update Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- install_requirements.py | 3 +++ setup.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/install_requirements.py b/install_requirements.py index 4b3de68b8db..0a950e91f31 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -123,6 +123,9 @@ def install_requirements(use_pytorch_nightly): # This is usually not recommended. new_env = os.environ.copy() new_env["USE_CPP"] = "1" # install torchao kernels + # Set a flag to override the compatiblity error caused by CMake 4.0.0+ dropping support for + # things like `cmake_minimum_required (VERSION 3.0.2 FATAL_ERROR)` + new_env["CMAKE_POLICY_VERSION_MINIMUM"] = "3.5" subprocess.run( [ sys.executable, diff --git a/setup.py b/setup.py index 64d78263345..49fd267f183 100644 --- a/setup.py +++ b/setup.py @@ -703,14 +703,15 @@ def run(self): # like `TorchConfig.cmake` that are provided by pip packages. f"-DCMAKE_PREFIX_PATH={cmake_prefix_path}", f"-DCMAKE_BUILD_TYPE={cfg}", - # A temporary flag for overriding exception caused by CMake 4.0.0+ - "-DCMAKE_POLICY_VERSION_MINIMUM=3.5", # Enable logging even when in release mode. We are building for # desktop, where saving a few kB is less important than showing # useful error information to users. "-DEXECUTORCH_ENABLE_LOGGING=ON", "-DEXECUTORCH_LOG_LEVEL=Info", "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15", + # Set a flag to override the compatiblity error caused by CMake 4.0.0+ dropping support for + # things like `cmake_minimum_required (VERSION 3.0.2 FATAL_ERROR)` + "-DCMAKE_POLICY_VERSION_MINIMUM=3.5", # The separate host project is only required when cross-compiling, # and it can cause build race conditions (libflatcc.a errors) when # enabled. TODO(dbort): Remove this override once this option is From 4aea3d8f19a97d2c00d6c33abda6d7b2e36dfe95 Mon Sep 17 00:00:00 2001 From: Mengwei Liu Date: Thu, 27 Mar 2025 20:37:27 -0700 Subject: [PATCH 3/3] CMakeLists.txt Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6509d4adeef..8f9c8ad7418 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,9 @@ include(tools/cmake/Utils.cmake) include(CMakeDependentOption) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - +# Set a flag to override the compatiblity error caused by CMake 4.0.0+ dropping support for +# things like `cmake_minimum_required (VERSION 3.0.2 FATAL_ERROR)` +set(CMAKE_POLICY_VERSION_MINIMUM 3.5) if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 17) endif()