build: add module to handle querying platform details
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
function(get_platform_details)
|
||||
set(options)
|
||||
set(one_value_args SYSTEM PROCESSOR)
|
||||
set(multi_value_args
|
||||
NAMESPACES
|
||||
DEPENDENCIES
|
||||
LIBS)
|
||||
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||
"${options}"
|
||||
"${one_value_args}"
|
||||
"${multi_value_args}")
|
||||
|
||||
set(system_name "")
|
||||
|
||||
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
set(system_name "linux")
|
||||
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||
set(system_name "apple")
|
||||
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
||||
set(system_name "win32")
|
||||
else ()
|
||||
message(FATAL_ERROR "Unsupported platform: ${CMAKE_SYSTEM_NAME}")
|
||||
endif ()
|
||||
|
||||
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
|
||||
set(system_arch "amd64")
|
||||
elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
|
||||
set(system_arch "aarch64")
|
||||
else ()
|
||||
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif ()
|
||||
|
||||
set(${arg_SYSTEM} ${system_name} PARENT_SCOPE)
|
||||
set(${arg_PROCESSOR} ${system_arch} PARENT_SCOPE)
|
||||
endfunction (get_platform_details)
|
||||
|
||||
Reference in New Issue
Block a user