forked from meta-pytorch/tokenizers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.cmake
More file actions
50 lines (45 loc) · 1.58 KB
/
Utils.cmake
File metadata and controls
50 lines (45 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
#
# Build tokenizers.
#
# ### Editing this file ###
#
# This file should be formatted with
# ~~~
# cmake-format -i CMakeLists.txt
# ~~~
# It should also be cmake-lint clean.
#
# This is the funtion to use -Wl, --whole-archive to link static library NB:
# target_link_options is broken for this case, it only append the interface link
# options of the first library.
function(kernel_link_options target_name)
# target_link_options(${target_name} INTERFACE
# "$<LINK_LIBRARY:WHOLE_ARCHIVE,target_name>")
target_link_options(
${target_name} INTERFACE "SHELL:LINKER:--whole-archive \
$<TARGET_FILE:${target_name}> \
LINKER:--no-whole-archive")
endfunction()
# Same as kernel_link_options but it's for MacOS linker
function(macos_kernel_link_options target_name)
target_link_options(${target_name} INTERFACE
"SHELL:LINKER:-force_load,$<TARGET_FILE:${target_name}>")
endfunction()
# Same as kernel_link_options but it's for MSVC linker
function(msvc_kernel_link_options target_name)
target_link_options(
${target_name} INTERFACE
"SHELL:LINKER:/WHOLEARCHIVE:$<TARGET_FILE:${target_name}>")
endfunction()
# Ensure that the load-time constructor functions run. By default, the linker
# would remove them since there are no other references to them.
function(target_link_options_shared_lib target_name)
if(APPLE)
macos_kernel_link_options(${target_name})
elseif(MSVC)
msvc_kernel_link_options(${target_name})
else()
kernel_link_options(${target_name})
endif()
endfunction()