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
|
#
# Copyright (c) 2018-2023, Intel Corporation
#
# SPDX-License-Identifier: BSD-3-Clause
#
# ispc ADDISPCTest.cmake
#
include_guard(DIRECTORY)
if (UNIX)
if(NOT ISPC_ARCH)
execute_process( COMMAND sh "-c" "uname -m | sed -e s/x86_64/x86/ -e s/amd64/x86/ -e s/i686/x86/ -e s/arm64/aarch64/ -e s/arm.*/arm/ -e s/sa110/arm/" OUTPUT_VARIABLE ARCH)
string(STRIP ${ARCH} ARCH)
execute_process( COMMAND getconf LONG_BIT OUTPUT_VARIABLE ARCH_BIT)
string(STRIP ${ARCH_BIT} arch_bit)
if ("${ARCH}" STREQUAL "x86")
if (${arch_bit} EQUAL 32)
set(ispc_arch "x86")
else()
set(ispc_arch "x86-64")
endif()
elseif ("${ARCH}" STREQUAL "arm")
set(ispc_arch "arm")
elseif ("${ARCH}" STREQUAL "aarch64")
set(ispc_arch "aarch64")
endif()
endif()
set(ISPC_ARCH "${ispc_arch}" CACHE STRING "ISPC CPU ARCH")
set(ISPC_ARCH_BIT "${arch_bit}" CACHE STRING "ISPC CPU BIT")
else()
if(NOT ISPC_ARCH)
set(ispc_arch "x86")
if (CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(ispc_arch "x86-64")
endif()
endif()
set(ISPC_ARCH "${ispc_arch}" CACHE STRING "ISPC CPU ARCH")
set(ISPC_ARCH_BIT "${arch_bit}" CACHE STRING "ISPC CPU BIT")
endif()
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19.2 AND
(("${CMAKE_GENERATOR}" MATCHES "Make") OR ("${CMAKE_GENERATOR}" MATCHES "Ninja")) )
enable_language(ISPC)
include(${CMAKE_CURRENT_LIST_DIR}/AddISPCExampleModern.cmake)
else()
include(${CMAKE_CURRENT_LIST_DIR}/AddISPCExampleLegacy.cmake)
endif()
|