Help needed with simple CMake project using GNU Arm Embedded Toolchain

Hi, I am using the GNU Arm Embedded Toolchain on Windows. I’m taking a simple gnu make project and converting it to CMake, but CMake fails at the ‘Check for working CXX compiler’ stage.

The tools directory is:

>dir "C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin\"
 Volume in drive C has no label.
 Volume Serial Number is 4E8C-D075

 Directory of C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin

15/11/2021  15:46    <DIR>          .
15/11/2021  15:46    <DIR>          ..
18/10/2021  03:16           805,704 arm-none-eabi-addr2line.exe
18/10/2021  03:16           829,768 arm-none-eabi-ar.exe
18/10/2021  03:16         1,403,208 arm-none-eabi-as.exe
18/10/2021  03:16         2,129,736 arm-none-eabi-c++.exe
18/10/2021  03:16           803,656 arm-none-eabi-c++filt.exe
18/10/2021  03:16         2,128,200 arm-none-eabi-cpp.exe
18/10/2021  03:16            48,456 arm-none-eabi-elfedit.exe
18/10/2021  03:16         2,129,736 arm-none-eabi-g++.exe
18/10/2021  03:16         2,126,664 arm-none-eabi-gcc-10.3.1.exe
18/10/2021  03:16            69,448 arm-none-eabi-gcc-ar.exe
18/10/2021  03:16            69,448 arm-none-eabi-gcc-nm.exe
18/10/2021  03:16            69,448 arm-none-eabi-gcc-ranlib.exe
18/10/2021  03:16         2,126,664 arm-none-eabi-gcc.exe
18/10/2021  03:16         1,403,720 arm-none-eabi-gcov-dump.exe
18/10/2021  03:16         1,453,896 arm-none-eabi-gcov-tool.exe
18/10/2021  03:16         1,574,728 arm-none-eabi-gcov.exe
18/10/2021  03:16             4,045 arm-none-eabi-gdb-add-index
18/10/2021  03:16             4,045 arm-none-eabi-gdb-add-index-py
18/10/2021  03:16         7,500,104 arm-none-eabi-gdb-py.exe
18/10/2021  03:16         7,200,584 arm-none-eabi-gdb.exe
18/10/2021  03:16           863,048 arm-none-eabi-gprof.exe
18/10/2021  03:16         1,410,376 arm-none-eabi-ld.bfd.exe
18/10/2021  03:16         1,410,376 arm-none-eabi-ld.exe
18/10/2021  03:16        21,784,904 arm-none-eabi-lto-dump.exe
18/10/2021  03:16           816,456 arm-none-eabi-nm.exe
18/10/2021  03:16           926,024 arm-none-eabi-objcopy.exe
18/10/2021  03:16         1,421,640 arm-none-eabi-objdump.exe
18/10/2021  03:16           829,768 arm-none-eabi-ranlib.exe
18/10/2021  03:16           875,336 arm-none-eabi-readelf.exe
18/10/2021  03:16           806,216 arm-none-eabi-size.exe
18/10/2021  03:16           806,216 arm-none-eabi-strings.exe
18/10/2021  03:16           926,024 arm-none-eabi-strip.exe
18/10/2021  03:16               142 gccvar.bat
              33 File(s)     66,757,784 bytes
               2 Dir(s)  63,214,821,376 bytes free

My CMakeLists.txt file is:

cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR)

set(TOOLCHAIN_PATH "C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10")
find_program(ARM_CC NAMES arm-none-eabi-gcc PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_CXX NAMES arm-none-eabi-g++ PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_ASM NAMES arm-none-eabi-as PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_AR NAMES arm-none-eabi-ar PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_LINK NAMES arm-none-eabi-ld PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)
find_program(ARM_FROMELF NAMES arm-none-eabi-readelf PATHS ${TOOLCHAIN_PATH}/bin REQUIRED NO_DEFAULT_PATH)

set(CMAKE_C_COMPILER ${ARM_CC} CACHE STRING "")
set(CMAKE_CXX_COMPILER ${ARM_CXX} CACHE STRING "")
set(CMAKE_ASM_COMPILER ${ARM_ASM} CACHE STRING "")
set(CMAKE_LINKER ${ARM_LINK} CACHE STRING "")

# Set a default build type of Release (this can be overridden by the user via the
# command line) (https://discourse.cmake.org/t/how-to-deal-with-ninja-setting-cmake-build-type-to-debug/281/3).
# Note: this must be done before the project command.
if (NOT CMAKE_BUILD_TYPE)
  set (CMAKE_BUILD_TYPE "Release" CACHE
       STRING "Choose the type of build.")
endif()       
message(STATUS "Build type is '${CMAKE_BUILD_TYPE}'")

project(wdt_interrupt_gnu LANGUAGES CXX C)

# Require C++14 tooling (minimum) for all targets in this project
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Specify additional compiler options
#   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")

# Specify compiler warning / optimisation options

# lots of warnings
add_compile_options(-Wall -pedantic)
    
# Specify the hw_interface executable.
add_executable(wdt_interrupt_gnu 
               main.c
               )

# Enable generation of map file
target_link_options(wdt_interrupt_gnu PRIVATE
  LINKER:--print-memory-usage
  LINKER:-Map,${CMAKE_CURRENT_BINARY_DIR}/hw_interface.map
)

The output is:

>cmake -G Ninja ..
-- Build type is 'Release'
-- The CXX compiler identification is GNU 10.3.1
-- The C compiler identification is GNU 10.3.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin/arm-none-eabi-g++.exe
-- Check for working CXX compiler: C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin/arm-none-eabi-g++.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/CMakeTestCXXCompiler.cmake:59 (message):
  The C++ compiler

    "C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin/arm-none-eabi-g++.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/SVNProj/Elysion/trunk/software/prototypes/wdt_interrupt_gnu/build/CMakeFiles/CMakeTmp

    Run Build Command(s):C:/bin/ninja-win/ninja.exe cmTC_3316e && [1/2] Building CXX object CMakeFiles/cmTC_3316e.dir/testCXXCompiler.cxx.obj
    [2/2] Linking CXX executable cmTC_3316e.exe
    FAILED: cmTC_3316e.exe
    cmd.exe /C "cd . && C:\PROGRA~2\GNUARM~1\102021~1.10\bin\AR10B2~1.EXE   CMakeFiles/cmTC_3316e.dir/testCXXCompiler.cxx.obj -o cmTC_3316e.exe -Wl,--out-implib,libcmTC_3316e.dll.a -Wl,--major-image-version,0,--minor-image-version,0   && cd ."
    c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: unrecognized option '--major-image-version'
    c:/progra~2/gnuarm~1/102021~1.10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: use the --help option for usage information
    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:29 (project)

-- Configuring incomplete, errors occurred!

Can anyone help me please?

Did you read the documentation which describe how to define a toolchain file?