Skip to content

CMake: remove need for APP_TARGET #14265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ if(${MBED_TOOLCHAIN_FILE_USED})
mbed_set_profile_options(mbed-core ${MBED_TOOLCHAIN})
mbed_set_c_lib(mbed-core ${MBED_C_LIB})
mbed_set_printf_lib(mbed-core ${MBED_PRINTF_LIB})

target_compile_features(mbed-core
INTERFACE
c_std_11
cxx_std_14
)

endif()

target_compile_definitions(mbed-core
Expand Down Expand Up @@ -87,15 +94,6 @@ target_include_directories(mbed-core
${CMAKE_CURRENT_SOURCE_DIR}
)

# We need to generate a "response file" to pass to the C preprocessor because of path length
# limitations on Windows. We set the response file and bind the path to a global property here.
# We query this global property when we set the linker script for the MBED_TARGET being built.
#
# TODO: Remove this and find a more idiomatic way of passing compile definitions to CPP without
# using global properties.
mbed_generate_options_for_linker(${APP_TARGET} LINKER_PREPROCESS_DEFINITIONS)
set_property(GLOBAL PROPERTY COMPILE_DEFS_RESPONSE_FILE ${LINKER_PREPROCESS_DEFINITIONS})

# These targets are made visible here so their source files which
# are spread in different directories can be referenced and can be linked against
# by libraries that depend on them.
Expand Down Expand Up @@ -138,14 +136,27 @@ endif()

#
# Configures the application
# Note, this function will be removed in the next revisions
#
function(mbed_configure_app_target target)
# Set the language standard to use per target
target_compile_features(${target}
PUBLIC
c_std_11
cxx_std_14
)
# We need to generate a "response file" to pass to the C preprocessor because of path length
# limitations on Windows. We set the response file and bind the path to a global property here.
# We query this global property when we set the linker script for the MBED_TARGET being built.
#
# TODO: Remove this and find a more idiomatic way of passing compile definitions to CPP without
# using global properties.
mbed_generate_options_for_linker(${target} LINKER_PREPROCESS_DEFINITIONS)
set_property(GLOBAL PROPERTY COMPILE_DEFS_RESPONSE_FILE ${LINKER_PREPROCESS_DEFINITIONS})

# Gcc Arm requires memap to be set with app name, equally to ARMClang
# TODO: move this to toolchain and set properly
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
message(${target})
target_link_options(mbed-core
INTERFACE
"-Wl,-Map=${CMAKE_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map"
)
endif()
endfunction()

#
Expand Down
3 changes: 1 addition & 2 deletions tools/cmake/set_linker_script.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ function(mbed_set_linker_script input_target raw_linker_script_path)
add_dependencies(${input_target} ${LinkerScriptTarget})
target_link_options(${input_target}
INTERFACE
"-T" "${LINKER_SCRIPT_PATH}"
"-Wl,-Map=${CMAKE_BINARY_DIR}/${APP_TARGET}${CMAKE_EXECUTABLE_SUFFIX}.map"
"-T" "${LINKER_SCRIPT_PATH}"
)
elseif(MBED_TOOLCHAIN STREQUAL "ARM")
target_link_options(${input_target}
Expand Down