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() 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 871fdf329c2..49fd267f183 100644 --- a/setup.py +++ b/setup.py @@ -709,6 +709,9 @@ def run(self): "-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