blob: c555931ded5a29370d4e16562bbd9d63f59a0f33 [file] [log] [blame]
Michael J. Spencer626916f2010-12-10 19:47:54 +00001# Define functions to get the host and target triple.
2
3function(get_host_triple out out_arch out_vendor out_os)
4 # Get the architecture.
5 set(arch ${CMAKE_HOST_SYSTEM_PROCESSOR})
6 if (arch STREQUAL "x86")
7 set(arch "i686")
8 endif()
9 # Get the vendor.
10 if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
11 set(vendor "apple")
12 else()
13 set(vendor "pc")
14 endif()
15 # Get os.
16 if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
17 set(os "win32")
18 else()
19 string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} os)
20 endif()
21 set(triple "${arch}-${vendor}-${os}")
22 set(${out} ${triple} PARENT_SCOPE)
23 set(${out_arch} ${arch} PARENT_SCOPE)
24 set(${out_vendor} ${vendor} PARENT_SCOPE)
25 set(${out_os} ${os} PARENT_SCOPE)
26 message(STATUS "Host triple: ${triple}")
27endfunction()
28
29function(get_target_triple out out_arch out_vendor out_os)
30 # Get the architecture.
31 set(arch ${CMAKE_SYSTEM_PROCESSOR})
32 if (arch STREQUAL "x86")
33 set(arch "i686")
34 endif()
35 # Get the vendor.
36 if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
37 set(vendor "apple")
38 else()
39 set(vendor "pc")
40 endif()
41 # Get os.
42 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
43 set(os "win32")
44 else()
45 string(TOLOWER ${CMAKE_SYSTEM_NAME} os)
46 endif()
47 set(triple "${arch}-${vendor}-${os}")
48 set(${out} ${triple} PARENT_SCOPE)
49 set(${out_arch} ${arch} PARENT_SCOPE)
50 set(${out_vendor} ${vendor} PARENT_SCOPE)
51 set(${out_os} ${os} PARENT_SCOPE)
52 message(STATUS "Target triple: ${triple}")
53endfunction()