Skip to content

Commit 33c06fb

Browse files
authored
Merge pull request #14265 from 0xc0170/cmake-fix-app-target
CMake: remove need for APP_TARGET
2 parents 64892c9 + 207dcbb commit 33c06fb

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

CMakeLists.txt

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ if(${MBED_TOOLCHAIN_FILE_USED})
5757
mbed_set_profile_options(mbed-core ${MBED_TOOLCHAIN})
5858
mbed_set_c_lib(mbed-core ${MBED_C_LIB})
5959
mbed_set_printf_lib(mbed-core ${MBED_PRINTF_LIB})
60+
61+
target_compile_features(mbed-core
62+
INTERFACE
63+
c_std_11
64+
cxx_std_14
65+
)
66+
6067
endif()
6168

6269
target_compile_definitions(mbed-core
@@ -87,15 +94,6 @@ target_include_directories(mbed-core
8794
${CMAKE_CURRENT_SOURCE_DIR}
8895
)
8996

90-
# We need to generate a "response file" to pass to the C preprocessor because of path length
91-
# limitations on Windows. We set the response file and bind the path to a global property here.
92-
# We query this global property when we set the linker script for the MBED_TARGET being built.
93-
#
94-
# TODO: Remove this and find a more idiomatic way of passing compile definitions to CPP without
95-
# using global properties.
96-
mbed_generate_options_for_linker(${APP_TARGET} LINKER_PREPROCESS_DEFINITIONS)
97-
set_property(GLOBAL PROPERTY COMPILE_DEFS_RESPONSE_FILE ${LINKER_PREPROCESS_DEFINITIONS})
98-
9997
# These targets are made visible here so their source files which
10098
# are spread in different directories can be referenced and can be linked against
10199
# by libraries that depend on them.
@@ -143,14 +141,27 @@ endif()
143141

144142
#
145143
# Configures the application
144+
# Note, this function will be removed in the next revisions
146145
#
147146
function(mbed_configure_app_target target)
148-
# Set the language standard to use per target
149-
target_compile_features(${target}
150-
PUBLIC
151-
c_std_11
152-
cxx_std_14
153-
)
147+
# We need to generate a "response file" to pass to the C preprocessor because of path length
148+
# limitations on Windows. We set the response file and bind the path to a global property here.
149+
# We query this global property when we set the linker script for the MBED_TARGET being built.
150+
#
151+
# TODO: Remove this and find a more idiomatic way of passing compile definitions to CPP without
152+
# using global properties.
153+
mbed_generate_options_for_linker(${target} LINKER_PREPROCESS_DEFINITIONS)
154+
set_property(GLOBAL PROPERTY COMPILE_DEFS_RESPONSE_FILE ${LINKER_PREPROCESS_DEFINITIONS})
155+
156+
# Gcc Arm requires memap to be set with app name, equally to ARMClang
157+
# TODO: move this to toolchain and set properly
158+
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
159+
message(${target})
160+
target_link_options(mbed-core
161+
INTERFACE
162+
"-Wl,-Map=${CMAKE_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map"
163+
)
164+
endif()
154165
endfunction()
155166

156167
#

tools/cmake/set_linker_script.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ function(mbed_set_linker_script input_target raw_linker_script_path)
3737
add_dependencies(${input_target} ${LinkerScriptTarget})
3838
target_link_options(${input_target}
3939
INTERFACE
40-
"-T" "${LINKER_SCRIPT_PATH}"
41-
"-Wl,-Map=${CMAKE_BINARY_DIR}/${APP_TARGET}${CMAKE_EXECUTABLE_SUFFIX}.map"
40+
"-T" "${LINKER_SCRIPT_PATH}"
4241
)
4342
elseif(MBED_TOOLCHAIN STREQUAL "ARM")
4443
target_link_options(${input_target}

0 commit comments

Comments
 (0)