Browse Source

ARMClang: fix policy manipulation in the compiler module

Policies have their own scoping and cannot be set within a function
without affecting callers.
Ben Boeckel 6 years ago
parent
commit
32e4f236b7
1 changed files with 5 additions and 3 deletions
  1. 5 3
      Modules/Compiler/ARMClang.cmake

+ 5 - 3
Modules/Compiler/ARMClang.cmake

@@ -3,6 +3,9 @@ if(_ARMClang_CMAKE_LOADED)
 endif()
 set(_ARMClang_CMAKE_LOADED TRUE)
 
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
 get_filename_component(_CMAKE_C_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH)
 get_filename_component(_CMAKE_CXX_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH)
 
@@ -29,9 +32,6 @@ endfunction()
 # check processor is in list
 function(__armclang_check_processor processor list out_var)
   string(TOLOWER "${processor}" processor)
-  if(POLICY CMP0057)
-    cmake_policy(SET CMP0057 NEW)
-  endif()
   if(processor IN_LIST list)
     set(${out_var} TRUE PARENT_SCOPE)
   else()
@@ -67,3 +67,5 @@ macro(__compiler_armclang lang)
   set(CMAKE_${lang}_OUTPUT_EXTENSION ".o")
   set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1)
 endmacro()
+
+cmake_policy(POP)