From ed609f57c43284c80dc27505a8b42e3006bd53b1 Mon Sep 17 00:00:00 2001 From: Martin Kojtal Date: Thu, 8 Apr 2021 13:45:03 +0100 Subject: [PATCH] CMake app: add our cmake folder to CMAKE_MODULE_PATH All files within tools/cmake can now include within tools/cmake. We do not expose internal folders like core/profiles/toolchains. They should be included via toolchain file (mbed_toolchain in our case). --- tools/cmake/app.cmake | 9 ++++++--- tools/cmake/profile.cmake | 2 +- tools/cmake/toolchain.cmake | 5 +++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/cmake/app.cmake b/tools/cmake/app.cmake index 49a0a1953d..0542feffa9 100644 --- a/tools/cmake/app.cmake +++ b/tools/cmake/app.cmake @@ -1,6 +1,9 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# Add our CMake list files to CMake default module path +set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_LIST_DIR}") + find_program(CCACHE "ccache") if(CCACHE) set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE}) @@ -12,11 +15,11 @@ include(${MBED_CONFIG_PATH}/mbed_config.cmake) # Load toolchain file if(NOT CMAKE_TOOLCHAIN_FILE OR MBED_TOOLCHAIN_FILE_USED) set(MBED_TOOLCHAIN_FILE_USED TRUE CACHE INTERNAL "") - include(${mbed-os_SOURCE_DIR}/tools/cmake/toolchain.cmake) + include(toolchain) endif() # Specify available build profiles and add options for the selected build profile -include(${mbed-os_SOURCE_DIR}/tools/cmake/profile.cmake) +include(profile) enable_language(C CXX ASM) @@ -26,7 +29,7 @@ set(CMAKE_EXECUTABLE_SUFFIX .elf) # Find Python find_package(Python3 COMPONENTS Interpreter) -include(${CMAKE_CURRENT_LIST_DIR}/CheckPythonPackage.cmake) +include(CheckPythonPackage) # Check python packages from requirements.txt file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/requirements.txt PYTHON_REQUIREMENTS) diff --git a/tools/cmake/profile.cmake b/tools/cmake/profile.cmake index def3255ee5..ca5b05231a 100644 --- a/tools/cmake/profile.cmake +++ b/tools/cmake/profile.cmake @@ -29,4 +29,4 @@ else() endif() endif() -include(${CMAKE_CURRENT_LIST_DIR}/profiles/${LOWERCASE_CMAKE_BUILD_TYPE}.cmake) +include(profiles/${LOWERCASE_CMAKE_BUILD_TYPE}) diff --git a/tools/cmake/toolchain.cmake b/tools/cmake/toolchain.cmake index 03149891cb..7a61a0dd0c 100644 --- a/tools/cmake/toolchain.cmake +++ b/tools/cmake/toolchain.cmake @@ -100,8 +100,9 @@ set(link_options "") set(common_options "") set(c_cxx_compile_options "") # compile options only for C/CXX set(asm_compile_options "") # compile options only for ASM -include(${CMAKE_CURRENT_LIST_DIR}/toolchains/${MBED_TOOLCHAIN}.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/cores/${MBED_CPU_CORE}.cmake) + +include(toolchains/${MBED_TOOLCHAIN}) +include(cores/${MBED_CPU_CORE}) #converts a list into a string with each of its elements seperated by a space macro(list_to_space_separated OUTPUT_VAR)# 2nd arg: LIST...