armclang: warn on non-Ninja generator for CMake 3.20.

When using ARMClang linker and scatter files (armlink) then all
libraries are linked as object libraries using `$<TARGET_OBJECTS:lib>`.

CMake version 3.20 only has limited support for such linking:
> Referencing $<TARGET_OBJECTS> in target_link_libraries calls worked
> in versions of CMake prior to 3.21 for some cases, but was not fully
> supported.

One of those cases that do not work is Unix Makefiles generators.

As only Ninja is currently verified to work, this commit will check the
CMake version in use and the generator, and if CMake version <=3.21 is
used with non-Ninja generator then an error is raised informing user
to either use Ninja generator or update CMake.

As the Ninja generator has been confirmed to work as expected, then that
generator is accepted with CMake 3.20 and older.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2021-08-13 23:24:11 +02:00 committed by Anas Nashif
commit 93f0d0d528

View file

@ -4,6 +4,15 @@ set_ifndef(ARMCLANG_TOOLCHAIN_PATH "$ENV{ARMCLANG_TOOLCHAIN_PATH}")
set(ARMCLANG_TOOLCHAIN_PATH ${ARMCLANG_TOOLCHAIN_PATH} CACHE PATH "armclang tools install directory")
assert(ARMCLANG_TOOLCHAIN_PATH "ARMCLANG_TOOLCHAIN_PATH is not set")
if(${CMAKE_VERSION} VERSION_LESS 3.21
AND NOT ${CMAKE_GENERATOR} STREQUAL Ninja
)
message(FATAL_ERROR "ARMClang Toolchain and '${CMAKE_GENERATOR}' generator "
"doesn't work properly for target object files on CMake version: "
"${CMAKE_VERSION}. Use the 'Ninja' generator or update to CMake >= 3.21."
)
endif()
if(NOT EXISTS ${ARMCLANG_TOOLCHAIN_PATH})
message(FATAL_ERROR "Nothing found at ARMCLANG_TOOLCHAIN_PATH: '${ARMCLANG_TOOLCHAIN_PATH}'")
endif()