Skip to content

Commit 66f65c0

Browse files
committed
CMake: Fix third party toolchain file suppport
Compile defintions are always included. However, functions that set compile options are only called if a third party toolchain file is not used
1 parent 0bf4683 commit 66f65c0

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

CMakeLists.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ endif()
1212

1313
include(${MBED_CONFIG_PATH}/mbed_config.cmake)
1414
include(${MBED_PATH}/tools/cmake/core.cmake)
15-
include(${MBED_PATH}/tools/cmake/profile.cmake)
1615

1716
add_library(mbed-core INTERFACE)
1817

1918
add_library(mbed-os INTERFACE)
2019

2120
target_link_libraries(mbed-os
22-
INTERFACE
23-
mbed-rtos
24-
mbed-core
21+
INTERFACE
22+
mbed-rtos
23+
mbed-core
2524
)
2625

2726
add_library(mbed-baremetal INTERFACE)
@@ -59,14 +58,18 @@ if(NOT ${MBED_PRINTF_LIB} IN_LIST MBED_PRINTF_LIB_TYPES)
5958
)
6059
endif()
6160

62-
mbed_set_cpu_core_options(mbed-core ${MBED_TOOLCHAIN})
63-
mbed_set_toolchain_options(mbed-core)
64-
mbed_set_c_lib(mbed-core ${MBED_C_LIB})
65-
mbed_set_printf_lib(mbed-core ${MBED_PRINTF_LIB})
66-
mbed_set_profile_options(mbed-core ${MBED_TOOLCHAIN})
61+
mbed_set_cpu_core_definitions(mbed-core)
62+
if(${MBED_TOOLCHAIN_FILE_USED})
63+
mbed_set_cpu_core_options(mbed-core ${MBED_TOOLCHAIN})
64+
mbed_set_toolchain_options(mbed-core)
65+
mbed_set_profile_options(mbed-core ${MBED_TOOLCHAIN})
66+
mbed_set_c_lib(mbed-core ${MBED_C_LIB})
67+
mbed_set_printf_lib(mbed-core ${MBED_PRINTF_LIB})
68+
endif()
69+
6770

6871
set(MBED_TARGET_LABELS
69-
${MBED_TARGET_LABELS} CACHE INTERNAL ""
72+
${MBED_TARGET_LABELS} CACHE INTERNAL ""
7073
)
7174

7275
target_compile_definitions(mbed-core

tools/cmake/app.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,19 @@ endif()
99

1010
include(${MBED_CONFIG_PATH}/mbed_config.cmake)
1111

12+
set(MBED_TOOLCHAIN_FILE_USED FALSE)
13+
1214
# Set default toolchain file
1315
if(NOT CMAKE_TOOLCHAIN_FILE)
16+
set(MBED_TOOLCHAIN_FILE_USED TRUE)
17+
1418
set(CMAKE_TOOLCHAIN_FILE "${MBED_PATH}/tools/cmake/toolchain.cmake" CACHE INTERNAL "")
19+
20+
# Specify locations for toolchains and generic options
21+
include(${MBED_PATH}/tools/cmake/toolchains/${MBED_TOOLCHAIN}.cmake)
22+
23+
# Specify available build profiles and add options for the selected build profile
24+
include(${MBED_PATH}/tools/cmake/profile.cmake)
1525
endif()
1626

17-
# Toolchain setup
18-
include(${MBED_PATH}/tools/cmake/toolchains/${MBED_TOOLCHAIN}.cmake)
1927
enable_language(C CXX ASM)

0 commit comments

Comments
 (0)