* Generate map files in build * Add .map file artifact publishing * Add Xlinker to spelling exceptions * Remove PublishMapFiles from clang builds * Generate the map file artifact name * CXX_COMPILER_ID and some logging for Clang which might be linking using the GNU linker by default * More logging * Move logging out of conditional * Logging up high, use OS to determine which link flags to set * Use linker options specific to AppleClang's context, publish map files for all platforms
22 lines
949 B
CMake
22 lines
949 B
CMake
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# Instructs linker to generate map files and optimize build for minimal size
|
|
# Requires CMake version >= 3.13 to use add_link_options
|
|
|
|
function(create_map_file TARGET_NAME MAP_FILE_NAME)
|
|
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13")
|
|
if(MSVC)
|
|
target_link_options(${TARGET_NAME} PRIVATE /MAP)
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
|
|
target_link_options(${TARGET_NAME} PRIVATE LINKER:SHELL:-Wl,-map,${MAP_FILE_NAME})
|
|
target_link_options(${TARGET_NAME} PRIVATE -Os)
|
|
else()
|
|
target_link_options(${TARGET_NAME} PRIVATE -Xlinker -Map=${MAP_FILE_NAME})
|
|
target_link_options(${TARGET_NAME} PRIVATE -Os)
|
|
endif()
|
|
else()
|
|
message("Skipping map file generation because CMake version does not support target_link_options")
|
|
endif()
|
|
endfunction()
|