pytorch/cmake
Alexander Grund a4b831a86a Replace if(NOT ${var}) by if(NOT var) (#41924)
Summary:
As explained in https://github.com/pytorch/pytorch/issues/41922 using `if(NOT ${var})" is usually wrong and can lead to issues like https://github.com/pytorch/pytorch/issues/41922 where the condition is wrongly evaluated to FALSE instead of TRUE. Instead the unevaluated variable name should be used in all cases, see the CMake docu for details.

This fixes the `NOT ${var}` cases by using a simple regexp replacement. It seems `pybind11_PREFER_third_party` is the only variable really prone to causing an issue as all others are set. However due to CMake evaluating unquoted strings in `if` conditions as variable names I recommend to never use unquoted `${var}` in an if condition. A similar regexp based replacement could be done on the whole codebase but as that does a lot of changes I didn't include this now. Also `if(${var})` will likely lead to a parser error if `var` is unset instead of a wrong result

Fixes https://github.com/pytorch/pytorch/issues/41922

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

Reviewed By: seemethere

Differential Revision: D22700229

Pulled By: mrshenli

fbshipit-source-id: e2b3466039e4312887543c2e988270547a91c439
2020-07-23 15:49:20 -07:00
..
External Update pthreadpool to pthreadpool:029c88620802e1361ccf41d1970bd5b07fd6b7bb. (#40524) 2020-07-09 10:00:36 -07:00
Modules Fix NCCL version check when nccl.h in non-standard location. (#40982) 2020-07-17 13:54:17 -07:00
Modules_CUDA_fix Replace if(NOT ${var}) by if(NOT var) (#41924) 2020-07-23 15:49:20 -07:00
public Replace if(NOT ${var}) by if(NOT var) (#41924) 2020-07-23 15:49:20 -07:00
BuildVariables.cmake Remove Caffe2_MAIN_LIBS (#38408) 2020-05-15 12:27:15 -07:00
Caffe2Config.cmake.in Formatting cmake (to lowercase without space for if/elseif/else/endif) (#35521) 2020-03-27 14:25:17 -07:00
Caffe2ConfigVersion.cmake.in Formatting cmake (to lowercase without space for if/elseif/else/endif) (#35521) 2020-03-27 14:25:17 -07:00
cmake_uninstall.cmake.in Formatting cmake (to lowercase without space for if/elseif/else/endif) (#35521) 2020-03-27 14:25:17 -07:00
Codegen.cmake [cmake] Use PROJECT_SOURCE_DIR instead of CMAKE_* (#41387) 2020-07-15 11:09:05 -07:00
Dependencies.cmake Replace if(NOT ${var}) by if(NOT var) (#41924) 2020-07-23 15:49:20 -07:00
GoogleTestPatch.cmake Fix conda build for Windows (#19824) 2019-04-27 23:10:46 -07:00
iOS.cmake Fix/relax CMake linter rules (#35574) 2020-03-27 16:52:33 -07:00
MiscCheck.cmake Fix AVX detection with clang-cl (#35653) 2020-03-30 07:53:37 -07:00
ProtoBuf.cmake Replace if(NOT ${var}) by if(NOT var) (#41924) 2020-07-23 15:49:20 -07:00
ProtoBufPatch.cmake Formatting cmake (to lowercase without space for if/elseif/else/endif) (#35521) 2020-03-27 14:25:17 -07:00
Summary.cmake add clang code coverage compile flags (#41103) 2020-07-09 14:14:18 -07:00
TorchConfig.cmake.in Re-apply PyTorch pthreadpool changes 2020-06-23 19:26:21 -07:00
TorchConfigVersion.cmake.in Formatting cmake (to lowercase without space for if/elseif/else/endif) (#35521) 2020-03-27 14:25:17 -07:00
Utils.cmake Replace if(NOT ${var}) by if(NOT var) (#41924) 2020-07-23 15:49:20 -07:00
VulkanCodegen.cmake [Mobile GPU][Integration] Vulkan backend integration (#36491) 2020-05-26 08:30:13 -07:00
VulkanDependencies.cmake [vulkan] jni build support USE_VULKAN (#39188) 2020-05-28 15:39:02 -07:00
Whitelist.cmake Fix/relax CMake linter rules (#35574) 2020-03-27 16:52:33 -07:00