IAR/CXX: Fix compatibility with CMP0057 OLD

Commit a9073db7 (IAR: update language specification detection, 2021-09-23)
added usage of the if() IN_LIST operation and forgot to account for it not
being available in CMP0057 OLD mode.
Push and temporarily enable the policy. Also avoid the unnecessary temporary
variable for the list.

Fixes #23147.
This commit is contained in:
Raul Tambre
2022-01-29 22:48:25 +02:00
parent b1325f5912
commit cc4da8d13a

View File

@@ -16,14 +16,17 @@ endif()
# Whenever needed, override this default behavior using CMAKE_IAR_CXX_FLAG in your toolchain file.
if(NOT CMAKE_IAR_CXX_FLAG)
set(_CMAKE_IAR_MODERNCXX_LIST 14 17)
if(${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} IN_LIST _CMAKE_IAR_MODERNCXX_LIST OR
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW) # if IN_LIST
if(${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} IN_LIST "14;17" OR
("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM" AND ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} EQUAL 98))
string(PREPEND CMAKE_CXX_FLAGS "--c++ ")
else()
string(PREPEND CMAKE_CXX_FLAGS "--eec++ ")
endif()
unset(_CMAKE_IAR_MODERNCXX_LIST)
cmake_policy(POP)
endif()
set(CMAKE_CXX_STANDARD_COMPILE_OPTION "")