blob: 717b1ae7c26be02d7ac88f0e536169a78de0ed48 [file] [log] [blame]
Julian Hall07679f22020-11-23 17:45:16 +01001#-------------------------------------------------------------------------------
2# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8#[===[.rst:
9.. cmake:command:: env_set_link_options
10
11 .. code-block:: cmake
12
13 env_set_link_options(TGT foo)
14
15 Set default compile options for the arm-linux environment.
16
17 Inputs:
18
19 ``TGT``
20 Name of target to compile generated source files.
21
22#]===]
23function(env_set_link_options)
24 set(_options )
25 set(_oneValueArgs TGT)
26 set(_multiValueArgs )
27
28 cmake_parse_arguments(PARAMS "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
29
30 #Verify mandatory parameters
31 if (NOT DEFINED PARAMS_TGT)
32 message(FATAL_ERROR "env_set_link_options(): mandatory parameter TGT missing.")
33 endif()
34
35 if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
36 # Options for GCC that control linking
37 target_link_options(${PARAMS_TGT} PRIVATE
38 -fno-lto
39 -pie
40 -zmax-page-size=4096
41 )
42 # Options directly for LD, these are not understood by GCC
43 target_link_options(${PARAMS_TGT} PRIVATE
44 -Wl,--as-needed
45 -Wl,--sort-section=alignment
46 # -Wl,--dynamic-list ${CMAKE_CURRENT_LIST_DIR}/dyn_list
47 )
48 endif()
49
50endfunction()