43 lines
1.3 KiB
CMake
43 lines
1.3 KiB
CMake
function(GenerateTriplet OUTPUT_VARIABLE)
|
|
# Determine system architecture
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
set(ARCH "x64")
|
|
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
set(ARCH "x86")
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|aarch)64$")
|
|
set(ARCH "arm64")
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|aarch).*")
|
|
set(ARCH "arm")
|
|
else()
|
|
message(FATAL_ERROR "Unsupported architecture")
|
|
return()
|
|
endif()
|
|
|
|
# Determine OS and create vcpkg-compatible triplet
|
|
if(WIN32)
|
|
# Windows triplets: x64-windows, x64-windows-static, x64-windows-dynamic
|
|
if(BUILD_SHARED_LIBS)
|
|
set(TRIPLET "${ARCH}-windows-dynamic")
|
|
else()
|
|
set(TRIPLET "${ARCH}-windows-static")
|
|
endif()
|
|
elseif(APPLE)
|
|
if (IOS)
|
|
set(TRIPLET "${ARCH}-ios")
|
|
else ()
|
|
# macOS triplets: x64-osx, arm64-osx
|
|
set(TRIPLET "${ARCH}-osx")
|
|
endif ()
|
|
elseif(UNIX)
|
|
# Linux triplets: x64-linux, arm64-linux
|
|
set(TRIPLET "${ARCH}-linux")
|
|
else()
|
|
message(FATAL_ERROR "Unsupported operating system")
|
|
return()
|
|
endif()
|
|
|
|
message(STATUS "Generated vcpkg-compatible triplet: ${TRIPLET}")
|
|
|
|
# Set the output variable in the parent scope
|
|
set(${OUTPUT_VARIABLE} ${TRIPLET} PARENT_SCOPE)
|
|
endfunction() |