forked from dotnet/coreclr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuretools.cmake
79 lines (73 loc) · 2.51 KB
/
configuretools.cmake
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Get the version of the compiler that is in the file name for tool location.
set (CLR_CMAKE_COMPILER_FILE_NAME_VERSION "")
if (CMAKE_C_COMPILER MATCHES "-?[0-9]+\.?[0-9]+$")
set(CLR_CMAKE_COMPILER_FILE_NAME_VERSION "${CMAKE_MATCH_0}")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(APPLE)
set(LLVM_PREFIX "")
else()
set(LLVM_PREFIX "llvm-")
endif()
function(locate_llvm_exec exec var)
find_program(EXEC_LOCATION_${exec}
NAMES
"${LLVM_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}"
"${LLVM_PREFIX}${exec}")
if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND")
message(FATAL_ERROR "Unable to find llvm tool for: ${exec}.")
endif()
set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE)
endfunction()
locate_llvm_exec(ar CMAKE_AR)
locate_llvm_exec(link CMAKE_LINKER)
locate_llvm_exec(nm CMAKE_NM)
if(NOT APPLE)
locate_llvm_exec(objdump CMAKE_OBJDUMP)
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if(CMAKE_CROSSCOMPILING)
set(GCC_PREFIX "${CMAKE_CXX_COMPILER_TARGET}-")
else()
set(GCC_PREFIX "")
endif()
function(locate_gcc_exec exec var)
string(TOUPPER ${exec} EXEC_UPPERCASE)
if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "")
set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE)
return()
endif()
find_program(EXEC_LOCATION_${exec}
NAMES
"${GCC_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}"
"${GCC_PREFIX}${exec}")
if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND")
message(FATAL_ERROR "Unable to find gcc tool for: ${exec}.")
endif()
set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE)
endfunction()
locate_gcc_exec(ar CMAKE_AR)
locate_gcc_exec(link CMAKE_LINKER)
locate_gcc_exec(nm CMAKE_NM)
if(NOT APPLE)
locate_gcc_exec(objdump CMAKE_OBJDUMP)
endif()
locate_gcc_exec(objcopy CMAKE_OBJCOPY)
locate_gcc_exec(ranlib CMAKE_RANLIB)
endif()
if (NOT WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
if (CMAKE_CROSSCOMPILING AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD)
if (CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
find_program(OBJCOPY ${TOOLCHAIN}-objcopy)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
find_program(OBJCOPY objcopy)
else()
clr_unknown_arch()
endif()
else()
find_program(OBJCOPY objcopy)
endif()
if (OBJCOPY STREQUAL "OBJCOPY-NOTFOUND")
message(FATAL_ERROR "objcopy not found")
endif()
endif()