Require CMake 3.13 when building with Ninja (#68731)

Summary:
There is a bug in CMake's Ninja generator where files considered inputs to the cmake command couldn't be generated by another build step. The fix was included in CMake 3.13, but 3.10.3 is still sufficient for other cmake generators e.g. makefiles.
For reference, the bug is here https://gitlab.kitware.com/cmake/cmake/-/issues/18584

This is necessary for https://github.com/pytorch/pytorch/issues/68246 but I'm isolating the change here to make testing easier.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/68731

Reviewed By: jbschlosser

Differential Revision: D32604545

Pulled By: malfet

fbshipit-source-id: 9bc0bd8641ba415dd63ce21a05c177e2f1dd9866
This commit is contained in:
Peter Bell 2021-11-23 09:30:25 -08:00 committed by Facebook GitHub Bot
parent 3282386aa4
commit e7e1b76106
2 changed files with 6 additions and 2 deletions

View File

@ -141,7 +141,7 @@ case "$image" in
pytorch-linux-xenial-py3-clang5-asan)
ANACONDA_PYTHON_VERSION=3.6
CLANG_VERSION=5.0
CMAKE_VERSION=3.10.3
CMAKE_VERSION=3.13.5
PROTOBUF=yes
DB=yes
VISION=yes
@ -165,7 +165,7 @@ case "$image" in
pytorch-linux-xenial-py3-clang5-android-ndk-r19c)
ANACONDA_PYTHON_VERSION=3.6
CLANG_VERSION=5.0
CMAKE_VERSION=3.10.3
CMAKE_VERSION=3.13.5
LLVMDEV=yes
PROTOBUF=yes
ANDROID=yes

View File

@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
#cmake_policy(SET CMP0022 NEW)
#cmake_policy(SET CMP0023 NEW)
if(CMAKE_GENERATOR STREQUAL "Ninja" AND CMAKE_VERSION VERSION_LESS 3.13)
message(FATAL_ERROR "Using the Ninja generator requires CMake version 3.13 or greater")
endif()
# Use compiler ID "AppleClang" instead of "Clang" for XCode.
# Not setting this sometimes makes XCode C compiler gets detected as "Clang",
# even when the C++ one is detected as "AppleClang".