diff --git a/recipes/arm-gnu-toolchain/all/conanfile.py b/recipes/arm-gnu-toolchain/all/conanfile.py index 9f6eae6ef88d1..eeba121256e8a 100644 --- a/recipes/arm-gnu-toolchain/all/conanfile.py +++ b/recipes/arm-gnu-toolchain/all/conanfile.py @@ -92,6 +92,7 @@ def validate(self): raise ConanInvalidConfiguration( "The compiler version must be one of the following: " f"{supported_compiler_versions}.") + major_version = str(self.version).split(".")[0] major_compiler_settings_version = compiler_version.split(".")[0] if major_version != major_compiler_settings_version: diff --git a/recipes/arm-gnu-toolchain/all/test_package/CMakeLists.txt b/recipes/arm-gnu-toolchain/all/test_package/CMakeLists.txt index a30567aa91ad9..4e10ff0505de5 100644 --- a/recipes/arm-gnu-toolchain/all/test_package/CMakeLists.txt +++ b/recipes/arm-gnu-toolchain/all/test_package/CMakeLists.txt @@ -1,18 +1,19 @@ cmake_minimum_required(VERSION 3.15) -# This is a workaround for Conan 1.x -set(CMAKE_TOOLCHAIN_FILE toolchain.cmake) - project(test_package LANGUAGES CXX) -set(test_package_compiler_flags -mcpu=cortex-m0plus +# Conan's adds host side flags to the conan_toolchain.cmake file which +# interferes with arm-none-eabi-g++. To fix this, we set CMAKE_CXX_FLAGS +# to an empty string, then provide target specific flags to the +# executable. +set(CMAKE_CXX_FLAGS "") + +set(compiler_flags + -mcpu=cortex-m0plus -mfloat-abi=soft --specs=nosys.specs --specs=nano.specs) -set(CMAKE_CXX_FLAGS "") -message(AUTHOR_WARNING "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}") - add_executable(${PROJECT_NAME} main.cpp) -target_compile_options(${PROJECT_NAME} PRIVATE ${test_package_compiler_flags}) -target_link_options(${PROJECT_NAME} PRIVATE ${test_package_compiler_flags}) +target_compile_options(${PROJECT_NAME} PRIVATE ${compiler_flags}) +target_link_options(${PROJECT_NAME} PRIVATE ${compiler_flags}) diff --git a/recipes/arm-gnu-toolchain/all/test_package/toolchain.cmake b/recipes/arm-gnu-toolchain/all/test_package/toolchain.cmake deleted file mode 100644 index c8ba5b9084150..0000000000000 --- a/recipes/arm-gnu-toolchain/all/test_package/toolchain.cmake +++ /dev/null @@ -1,34 +0,0 @@ -# Append current directory to CMAKE_MODULE_PATH for making device specific -# cmake modules visible -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) - -# Skip Working compiler test which tends to fail in CMake due to it using build -# target architecture flags and not host architecture flags. -set(CMAKE_CXX_COMPILER_WORKS TRUE) -set(CMAKE_C_COMPILER_WORKS TRUE) - -# Need to force system to Generic & ARM as leaving this to Conan will result in -# pollution from host profile settings -set(CMAKE_SYSTEM_NAME Generic) -set(CMAKE_SYSTEM_PROCESSOR arm) - -# Target definition -set(TOOLCHAIN arm-none-eabi) - -# Perform compiler test with static library -set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) - -# Set toolchain compilers -set(CMAKE_C_COMPILER ${TOOLCHAIN}-gcc${CMAKE_EXECUTABLE_SUFFIX}) -set(CMAKE_CXX_COMPILER ${TOOLCHAIN}-g++${CMAKE_EXECUTABLE_SUFFIX}) -set(CMAKE_ASM_COMPILER ${TOOLCHAIN}-gcc${CMAKE_EXECUTABLE_SUFFIX}) -set(CMAKE_AR ${TOOLCHAIN}-ar${CMAKE_EXECUTABLE_SUFFIX}) -set(CMAKE_SIZE_UTIL ${TOOLCHAIN}-size${CMAKE_EXECUTABLE_SUFFIX}) -set(CMAKE_OBJDUMP ${TOOLCHAIN}-objdump${CMAKE_EXECUTABLE_SUFFIX}) -set(CMAKE_OBJCOPY ${TOOLCHAIN}-objcopy${CMAKE_EXECUTABLE_SUFFIX}) -set(CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH} ${CMAKE_BINARY_DIR}) - -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)