| 1 |
# Copyright (c) 2017-2022, Intel Corporation |
| 2 |
# |
| 3 |
# Permission is hereby granted, free of charge, to any person obtaining a |
| 4 |
# copy of this software and associated documentation files (the "Software"), |
| 5 |
# to deal in the Software without restriction, including without limitation |
| 6 |
# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 7 |
# and/or sell copies of the Software, and to permit persons to whom the |
| 8 |
# Software is furnished to do so, subject to the following conditions: |
| 9 |
# |
| 10 |
# The above copyright notice and this permission notice shall be included |
| 11 |
# in all copies or substantial portions of the Software. |
| 12 |
# |
| 13 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 14 |
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 16 |
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 17 |
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 18 |
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 19 |
# OTHER DEALINGS IN THE SOFTWARE. |
| 20 |
|
| 21 |
cmake_minimum_required(VERSION 3.5) |
| 22 |
project(IntelMediaDriver) |
| 23 |
set(MEDIA_VERSION "26.1.6${MEDIA_VERSION_EXTRA}" CACHE STRING "" FORCE) |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
include(os_release_info.cmake) |
| 31 |
|
| 32 |
get_os_release_info(os_name os_version) |
| 33 |
|
| 34 |
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX STREQUAL "") |
| 35 |
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "..." FORCE) |
| 36 |
endif() |
| 37 |
message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}") |
| 38 |
|
| 39 |
if("${os_name}" STREQUAL "clear-linux-os") |
| 40 |
# clear-linux-os distribution avoids /etc for distribution defaults. |
| 41 |
# Set this variable explicitly before including GNUInstallDirs. |
| 42 |
set(CMAKE_INSTALL_SYSCONFDIR "usr/share/defaults/etc") |
| 43 |
endif() |
| 44 |
|
| 45 |
include(CMakeDependentOption) |
| 46 |
|
| 47 |
option (ENABLE_KERNELS "Build driver with shaders (kernels) support" ON) |
| 48 |
# ENABLE_NONFREE_KERNELS option permits to enable closed source EU shaders (kernels) |
| 49 |
# additionally to open source EU shaders and fixed function hardware. |
| 50 |
cmake_dependent_option( ENABLE_NONFREE_KERNELS |
| 51 |
"Use closed source pre-built binary shaders (kernels)" ON |
| 52 |
"ENABLE_KERNELS" OFF) |
| 53 |
cmake_dependent_option( BUILD_KERNELS |
| 54 |
"Rebuild shaders (kernels) from sources" OFF |
| 55 |
"ENABLE_KERNELS;NOT ENABLE_NONFREE_KERNELS" OFF) |
| 56 |
option (BUILD_CMRTLIB "Build and Install cmrtlib together with media driver" ON) |
| 57 |
|
| 58 |
option (ENABLE_PRODUCTION_KMD "Enable Production KMD header files" OFF) |
| 59 |
|
| 60 |
include(GNUInstallDirs) |
| 61 |
|
| 62 |
if (BUILD_CMRTLIB AND NOT CMAKE_WDDM_LINUX) |
| 63 |
add_subdirectory(cmrtlib) |
| 64 |
endif() |
| 65 |
|
| 66 |
if (BUILD_KERNELS) |
| 67 |
find_program(IGA iga64) |
| 68 |
if (NOT IGA) |
| 69 |
message(FATAL_ERROR "Failed to find IGA") |
| 70 |
endif() |
| 71 |
|
| 72 |
find_program(CMC cmc) |
| 73 |
if (NOT CMC) |
| 74 |
message(FATAL_ERROR "Failed to find CMC") |
| 75 |
endif() |
| 76 |
|
| 77 |
find_program(PYTHON python) |
| 78 |
if (NOT PYTHON) |
| 79 |
message(FATAL_ERROR "Failed to find PYTHON") |
| 80 |
endif() |
| 81 |
|
| 82 |
add_subdirectory(Tools/MediaDriverTools) |
| 83 |
endif() |
| 84 |
|
| 85 |
add_subdirectory(media_driver) |
| 86 |
|
| 87 |
if("${LIBVA_DRIVERS_PATH}" STREQUAL "") |
| 88 |
set(LIBVA_DRIVERS_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/dri/") |
| 89 |
endif() |
| 90 |
message(STATUS "LIBVA_DRIVERS_PATH = ${LIBVA_DRIVERS_PATH}") |
| 91 |
|
| 92 |
install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/media_driver/iHD_drv_video.so DESTINATION ${LIBVA_DRIVERS_PATH} COMPONENT media) |
| 93 |
|
| 94 |
option (INSTALL_DRIVER_SYSCONF "Install driver system configuration file" OFF) |
| 95 |
if (INSTALL_DRIVER_SYSCONF) |
| 96 |
configure_file ( |
| 97 |
${CMAKE_CURRENT_SOURCE_DIR}/media_driver/cmake/linux/intel-media.sh.in |
| 98 |
${CMAKE_CURRENT_BINARY_DIR}/media_driver/cmake/linux/intel-media.sh) |
| 99 |
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/media_driver/cmake/linux/intel-media.sh |
| 100 |
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/profile.d/ COMPONENT media) |
| 101 |
endif() |
| 102 |
|
| 103 |
include(${CMAKE_CURRENT_LIST_DIR}/pack_ext.cmake OPTIONAL) |
| 104 |
|
| 105 |
if (NOT MEDIA_PACKING) |
| 106 |
set(CPACK_GENERATOR "DEB" "RPM") |
| 107 |
else() |
| 108 |
set(CPACK_GENERATOR ${MEDIA_PACKAGING}) |
| 109 |
endif() |
| 110 |
set(CPACK_PACKAGE_NAME "intel-media") |
| 111 |
set(CPACK_PACKAGE_VENDOR "Intel") |
| 112 |
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "intel-media Open Source Driver") |
| 113 |
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") |
| 114 |
set(CPACK_RPM_PACKAGE_GROUP "System Environment/Libraries") |
| 115 |
set(CPACK_RPM_PACKAGE_LICENSE "Intel") |
| 116 |
|
| 117 |
set(CPACK_PACKAGE_VERSION ${MEDIA_VERSION}) |
| 118 |
|
| 119 |
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel") |
| 120 |
|
| 121 |
# Create Distro OS initial based on 1st-2nd letter of string |
| 122 |
# or label "generic" for unsupported/unknown distros for CPACK_PACKAGE_FILE_NAME |
| 123 |
if("${os_name}" STREQUAL "ubuntu") |
| 124 |
set(DISTRO_INFO "u${os_version}") |
| 125 |
elseif("${os_name}" STREQUAL "fedora") |
| 126 |
set(DISTRO_INFO "f${os_version}") |
| 127 |
elseif("${os_name}" STREQUAL "clear-linux-os") |
| 128 |
set(DISTRO_INFO "cl${os_version}") |
| 129 |
elseif("${os_name}" STREQUAL "centos") |
| 130 |
set(DISTRO_INFO "ce${os_version}") |
| 131 |
else() |
| 132 |
set(DISTRO_INFO "generic") |
| 133 |
endif() |
| 134 |
|
| 135 |
# Format Package Version and Build Type Strings for CPACK_PACKAGE_FILE_NAME |
| 136 |
string(TOLOWER "${BUILD_TYPE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}" PACKAGE_TYPE) |
| 137 |
|
| 138 |
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${DISTRO_INFO}-${PACKAGE_TYPE}") |
| 139 |
|
| 140 |
include(CPack) |
| 141 |
|