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}