Browse Source

IAR: Tolerate variables named for languages

If a project or user sets a variable or cache entry named `C` or `CXX`,
we were previously comparing those language names to the value of that
variable, rather than the name itself.  Double-quote the string to take
advantage of policy `CMP0054`, but also add "x" prefixes to support
projects that do not set the policy.

This extends a similar fix from commit c8eb357738 (CompilerId: Tolerate
variables named for languages, 2021-06-17, v3.21.0-rc1~9^2).
Joakim Lönnberg 2 years ago
parent
commit
3b365c461f
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Modules/Compiler/IAR.cmake

+ 1 - 1
Modules/Compiler/IAR.cmake

@@ -9,7 +9,7 @@
 include_guard()
 
 macro(__compiler_iar_common lang)
-  if (${lang} MATCHES "^(C|CXX)$")
+  if ("x${lang}" MATCHES "^x(C|CXX)$")
     set(CMAKE_${lang}_COMPILE_OBJECT             "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
     set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>")
     set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE     "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")