find_program finds objcopy and objdump before finding arm-none-eabi-objcopy and arm-none-eabi-objdump
From Mark Betters:
if (NOT TRIPLET)
set(TRIPLET "arm-none-eabi")
endif()
if (NOT TOOLCHAIN_ROOT)
set(TOOLCHAIN_ROOT "/usr")
endif()
set(TOOLCHAIN_BIN_PATH "${TOOLCHAIN_ROOT}/bin")
find_program(CMAKE_OBJCOPY
NAMES ${TRIPLET}-objcopy
PATHS ${TOOLCHAIN_BIN_PATH}
NO_DEFAULT_PATH
NO_PACKAGE_ROOT_PATH
NO_CMAKE_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
NO_CMAKE_FIND_ROOT_PATH
)
find_program(CMAKE_OBJDUMP
NAMES ${TRIPLET}-objdump
PATHS ${TOOLCHAIN_BIN_PATH}
NO_DEFAULT_PATH
NO_PACKAGE_ROOT_PATH
NO_CMAKE_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
NO_CMAKE_FIND_ROOT_PATH
)
... finds /usr/bin/objcopy and /usr/bin/objdump, which wasn't what I wanted. I had to add these lines before the find_program(...) calls to successfully find /usr/bin/arm-none-eabi-objcopy and /usr/bin/arm-none-eabi-objdump:
unset(CMAKE_OBJCOPY CACHE)
unset(CMAKE_OBJDUMP CACHE)
CMake version: 3.16.3