Skip to content

Commit

Permalink
Clear CXX flags to make test_package work
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Khalil Estell committed Oct 17, 2023
1 parent c6bc92c commit e7ae67e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 43 deletions.
1 change: 1 addition & 0 deletions recipes/arm-gnu-toolchain/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 10 additions & 9 deletions recipes/arm-gnu-toolchain/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
34 changes: 0 additions & 34 deletions recipes/arm-gnu-toolchain/all/test_package/toolchain.cmake

This file was deleted.

0 comments on commit e7ae67e

Please sign in to comment.