Files
fx/cmake/Platform.cmake

37 lines
979 B
CMake

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)