From 8aa4a85b3531712e0224ffe1360ea168adfbcaa8 Mon Sep 17 00:00:00 2001 From: Martin Kojtal Date: Tue, 25 Aug 2020 12:40:20 +0100 Subject: [PATCH] CMake: use CMAKE_TOOLCHAIN_FILE We should define CMAKE_TOOLCHAIN_FILE (as we are providing Mbed OS toolchain file). This fixes also the issue we had with Unix makefiles where application would be without response files. For more details, see https://gitlab.kitware.com/cmake/cmake/-/issues/21104 As the Mbed OS toolchain file is included by CMake, we need to have enabling language in the main CMake (can be executed only once). --- CMakeLists.txt | 24 +++++++++++++++--------- cmake/toolchain.cmake | 7 ------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da0734694c..a7b5e2149d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,23 +10,29 @@ if(POLICY CMP0076) cmake_policy(SET CMP0076 NEW) endif() +include(${MBED_CONFIG_PATH}/mbed_config.cmake) + +# Set default toolchain file +if(NOT CMAKE_TOOLCHAIN_FILE) + set(CMAKE_TOOLCHAIN_FILE "${MBED_ROOT}/cmake/toolchain.cmake" CACHE INTERNAL "") +endif() + +# Toolchain setup +include(${MBED_ROOT}/cmake/toolchains/${MBED_TOOLCHAIN}.cmake) +enable_language(C CXX ASM) + +include(${MBED_ROOT}/cmake/core.cmake) +include(${MBED_ROOT}/cmake/util.cmake) +include(${MBED_ROOT}/cmake/profile.cmake) + # Create Mbed OS library add_library(mbed-os OBJECT) -include(${MBED_CONFIG_PATH}/mbed_config.cmake) - -include(${MBED_ROOT}/cmake/core.cmake) mbed_set_cpu_core_options(mbed-os ${MBED_TOOLCHAIN}) - -include(${MBED_ROOT}/cmake/toolchain.cmake) mbed_set_toolchain_options(mbed-os) mbed_set_language_standard(mbed-os) - -include(${MBED_ROOT}/cmake/profile.cmake) mbed_set_profile_options(mbed-os ${MBED_TOOLCHAIN}) -include(${MBED_ROOT}/cmake/util.cmake) - set_target_properties(mbed-os PROPERTIES MBED_TARGET_LABELS "${MBED_TARGET_LABELS}" diff --git a/cmake/toolchain.cmake b/cmake/toolchain.cmake index a69343c66c..38e138c936 100644 --- a/cmake/toolchain.cmake +++ b/cmake/toolchain.cmake @@ -40,19 +40,12 @@ elseif (MBED_CPU_CORE STREQUAL Cortex-M7FD) set(CMAKE_SYSTEM_PROCESSOR cortex-m7) endif() - - -include(${MBED_ROOT}/cmake/toolchains/${MBED_TOOLCHAIN}.cmake) - # Compiler setup set(CMAKE_SYSTEM_NAME Generic) set(CMAKE_CROSSCOMPILING TRUE) set(CMAKE_C_COMPILER_WORKS TRUE) set(CMAKE_CXX_COMPILER_WORKS TRUE) -# Project setup -enable_language(C CXX ASM) - # Set the language standard to use per target function(mbed_set_language_standard target) set_target_properties(${target}