FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
plibsys/cmake/PlatformDetect.cmake at master · sigdev2/plibsys · GitHub
sigdev2
/
plibsys
Public
forked from
saprykin/plibsys
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
plibsys
/
cmake
/
PlatformDetect.cmake
Copy path
More file actions
More file actions
Latest commit
History
History
History
169 lines (143 loc) · 6.14 KB
Breadcrumbs
plibsys
/
cmake
/
PlatformDetect.cmake
Copy path
File metadata and controls
169 lines (143 loc) · 6.14 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#
The MIT License
#
#
Copyright (C) 2018-2023 Alexander Saprykin <saprykin.spb@gmail.com>
#
#
Permission is hereby granted, free of charge, to any person obtaining
#
a copy of this software and associated documentation files (the
#
'Software'), to deal in the Software without restriction, including
#
without limitation the rights to use, copy, modify, merge, publish,
#
distribute, sublicense, and/or sell copies of the Software, and to
#
permit persons to whom the Software is furnished to do so, subject to
#
the following conditions:
#
#
The above copyright notice and this permission notice shall be
#
included in all copies or substantial portions of the Software.
#
#
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
#
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
#
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
#
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
#
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
#
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
#
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
function
(
plibsys_detect_c_compiler
result
)
#
Get target system OS
string
(
TOLOWER
${
CMAKE_SYSTEM_NAME
}
PLIBSYS_TARGET_OS)
#
Detect C compiler by it's ID
if
(
CMAKE_C_COMPILER_ID
STREQUAL
GNU)
set
(PLIBSYS_C_COMPILER gcc)
elseif
(
CMAKE_C_COMPILER_ID
STREQUAL
MSVC
)
set
(PLIBSYS_C_COMPILER
msvc
)
else
()
string
(
TOLOWER
${
CMAKE_C_COMPILER_ID
}
PLIBSYS_C_COMPILER)
endif
()
#
Fix gcc -> qcc naming on QNX 6
if
((PLIBSYS_TARGET_OS
STREQUAL
qnx)
AND
(PLIBSYS_C_COMPILER
STREQUAL
gcc))
set
(PLIBSYS_C_COMPILER qcc)
endif
()
#
Rename intel -> icc
if
(PLIBSYS_C_COMPILER
STREQUAL
intel)
set
(PLIBSYS_C_COMPILER icc)
endif
()
#
Rename intelllvm -> icc
if
(PLIBSYS_C_COMPILER
STREQUAL
intelllvm)
set
(PLIBSYS_C_COMPILER icc)
endif
()
#
Rename openwatcom -> watcom
if
(PLIBSYS_C_COMPILER
STREQUAL
openwatcom)
set
(PLIBSYS_C_COMPILER watcom)
endif
()
#
Rename xl -> xlc
if
(PLIBSYS_C_COMPILER
STREQUAL
xl)
set
(PLIBSYS_C_COMPILER xlc)
endif
()
#
Rename xlclang -> xlc
if
(PLIBSYS_C_COMPILER
STREQUAL
xlclang)
set
(PLIBSYS_C_COMPILER xlc)
endif
()
#
Rename ibmclang -> clang
if
(PLIBSYS_C_COMPILER
STREQUAL
ibmclang)
set
(PLIBSYS_C_COMPILER clang)
endif
()
#
Rename appleclang -> clang
if
(PLIBSYS_C_COMPILER
STREQUAL
appleclang)
set
(PLIBSYS_C_COMPILER clang)
endif
()
#
Rename nvhpc -> pgi
if
(PLIBSYS_C_COMPILER
STREQUAL
nvhpc)
set
(PLIBSYS_C_COMPILER pgi)
endif
()
#
Assign result
set
(
${result}
${PLIBSYS_C_COMPILER}
PARENT_SCOPE
)
endfunction
(
plibsys_detect_c_compiler
)
function
(
plibsys_detect_os_bits
result
)
if
(PLIBSYS_SIZEOF_VOID_P
EQUAL
8)
set
(PLIBSYS_ARCH_BITS 64)
elseif
(PLIBSYS_SIZEOF_VOID_P
EQUAL
4)
set
(PLIBSYS_ARCH_BITS 32)
elseif
(PLIBSYS_SIZEOF_VOID_P
EQUAL
0)
set
(PLIBSYS_ARCH_BITS
"universal"
)
else
()
set
(PLIBSYS_ARCH_BITS
"unknown"
)
endif
()
set
(
${result}
${PLIBSYS_ARCH_BITS}
PARENT_SCOPE
)
endfunction
(
plibsys_detect_os_bits
)
function
(
plibsys_detect_cpu_arch
result
)
if
(
CMAKE_SYSTEM_PROCESSOR
MATCHES
"(i[1-9]86)|(x86_64)"
)
if
(
CMAKE_CROSSCOMPILING
)
if
(
CMAKE_SYSTEM_PROCESSOR
MATCHES
"i[1-9]86"
)
set
(PLIBSYS_PROCESSOR_ARCH
"x86"
)
else
()
set
(PLIBSYS_PROCESSOR_ARCH
"x64"
)
endif
()
else
()
plibsys_detect_os_bits
(
PLIBSYS_OS_BITS
)
if
(PLIBSYS_OS_BITS
STREQUAL
"32"
)
set
(PLIBSYS_PROCESSOR_ARCH
"x86"
)
elseif
(PLIBSYS_OS_BITS
STREQUAL
"64"
)
set
(PLIBSYS_PROCESSOR_ARCH
"x64"
)
else
()
set
(PLIBSYS_PROCESSOR_ARCH
"x
${PLIBSYS_OS_BITS}
"
)
endif
()
endif
()
else
()
set
(PLIBSYS_PROCESSOR_ARCH
${
CMAKE_SYSTEM_PROCESSOR
}
)
endif
()
set
(
${result}
${PLIBSYS_PROCESSOR_ARCH}
PARENT_SCOPE
)
endfunction
(
plibsys_detect_cpu_arch
)
function
(
plibsys_detect_target_os
result
)
string
(
TOLOWER
${
CMAKE_SYSTEM_NAME
}
PLIBSYS_TARGET_OS)
#
Rename mingw -> windows
if
(PLIBSYS_TARGET_OS
MATCHES
"(mingw.*)"
)
set
(PLIBSYS_TARGET_OS windows)
endif
()
#
Rename hp-ux -> hpux
if
(PLIBSYS_TARGET_OS
STREQUAL
hp-ux)
set
(PLIBSYS_TARGET_OS hpux)
endif
()
#
Rename sco_sv -> scosv
if
(PLIBSYS_TARGET_OS
STREQUAL
sco_sv)
set
(PLIBSYS_TARGET_OS scosv)
endif
()
#
Rename osf1 -> tru64
if
(PLIBSYS_TARGET_OS
STREQUAL
osf1)
set
(PLIBSYS_TARGET_OS tru64)
endif
()
#
Rename craylinuxenvironment -> linux
if
(PLIBSYS_TARGET_OS
STREQUAL
craylinuxenvironment)
set
(PLIBSYS_TARGET_OS
linux
)
endif
()
set
(
${result}
${PLIBSYS_TARGET_OS}
PARENT_SCOPE
)
endfunction
(
plibsys_detect_target_os
)
function
(
plibsys_detect_target_platform
result
)
plibsys_detect_target_os
(
PLIBSYS_TARGET_OS
)
plibsys_detect_os_bits
(
PLIBSYS_OS_BITS
)
plibsys_detect_c_compiler
(
PLIBSYS_C_COMPILER
)
if
(PLIBSYS_TARGET_OS
STREQUAL
windows)
set
(PLIBSYS_TARGET_PLATFORM win
${PLIBSYS_OS_BITS}
)
else
()
set
(PLIBSYS_TARGET_PLATFORM
${PLIBSYS_TARGET_OS}
)
endif
()
set
(PLIBSYS_TARGET_PLATFORM
${PLIBSYS_TARGET_PLATFORM}
-
${PLIBSYS_C_COMPILER}
)
set
(
${result}
${PLIBSYS_TARGET_PLATFORM}
PARENT_SCOPE
)
endfunction
(
plibsys_detect_target_platform
)
Back
|
FazBrowse Home
|
New Git URL