cmake: use tri-state AUTO/ON/OFF for encoders
This commit is contained in:
+34
-7
@@ -14,6 +14,7 @@ set(CMAKE_CXX_STANDARD 20)
|
||||
include("cmake/CPM.cmake")
|
||||
include(FetchContent)
|
||||
include(ExternalProject)
|
||||
include("cmake/AutoOption.cmake")
|
||||
|
||||
option(WIVRN_USE_SYSTEM_FREETYPE "Use system FreeType" ON)
|
||||
option(WIVRN_USE_SYSTEMD "Use systemd" ON)
|
||||
@@ -21,9 +22,9 @@ option(WIVRN_USE_ANDROID_VALIDATION_LAYER "Download the android version of the V
|
||||
option(WIVRN_BUILD_CLIENT "Build WiVRn client" ON)
|
||||
option(WIVRN_BUILD_SERVER "Build WiVRn server" ON)
|
||||
|
||||
option(WIVRN_USE_NVENC "Enable nvenc (Nvidia) hardware encoder" OFF)
|
||||
option(WIVRN_USE_VAAPI "Enable vaapi (AMD/Intel) hardware encoder" OFF)
|
||||
option(WIVRN_USE_X264 "Enable x264 software encoder" OFF)
|
||||
auto_option(WIVRN_USE_NVENC "Enable nvenc (Nvidia) hardware encoder" AUTO)
|
||||
auto_option(WIVRN_USE_VAAPI "Enable vaapi (AMD/Intel) hardware encoder" AUTO)
|
||||
auto_option(WIVRN_USE_X264 "Enable x264 software encoder" AUTO)
|
||||
|
||||
option(ENABLE_COLOURED_OUTPUT "Always produce ANSI-coloured output (GNU/Clang only)." ON)
|
||||
|
||||
@@ -43,16 +44,37 @@ if (WIVRN_BUILD_SERVER)
|
||||
message(FATAL_ERROR "No encoder selected, use at least one of WIVRN_USE_NVENC, WIVRN_USE_VAAPI or WIVRN_USE_X264")
|
||||
endif()
|
||||
|
||||
if (WIVRN_USE_NVENC)
|
||||
if (WIVRN_USE_NVENC STREQUAL "AUTO")
|
||||
find_package(CUDAToolkit)
|
||||
if (CUDAToolkit_FOUND)
|
||||
set(WIVRN_USE_NVENC ON)
|
||||
else()
|
||||
set(WIVRN_USE_NVENC OFF)
|
||||
endif()
|
||||
elseif(WIVRN_USE_NVENC)
|
||||
find_package(CUDAToolkit REQUIRED)
|
||||
endif()
|
||||
|
||||
if (WIVRN_USE_VAAPI)
|
||||
if (WIVRN_USE_VAAPI STREQUAL "AUTO")
|
||||
pkg_check_modules(LIBAV IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
|
||||
if (LIBAV_FOUND)
|
||||
set(WIVRN_USE_VAAPI ON)
|
||||
else()
|
||||
set(WIVRN_USE_VAAPI OFF)
|
||||
endif()
|
||||
elseif (WIVRN_USE_VAAPI)
|
||||
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
|
||||
endif()
|
||||
|
||||
if (WIVRN_USE_X264)
|
||||
pkg_check_modules(X264 IMPORTED_TARGET x264)
|
||||
if (WIVRN_USE_X264 STREQUAL "AUTO")
|
||||
pkg_check_modules(X264 IMPORTED_TARGET x264)
|
||||
if (X264_FOUND)
|
||||
set(WIVRN_USE_X264 ON)
|
||||
else()
|
||||
set(WIVRN_USE_X264 OFF)
|
||||
endif()
|
||||
elseif (WIVRN_USE_X264)
|
||||
pkg_check_modules(X264 REQUIRED IMPORTED_TARGET x264)
|
||||
endif()
|
||||
|
||||
if (WIVRN_USE_SYSTEMD)
|
||||
@@ -97,4 +119,9 @@ endif()
|
||||
|
||||
if (WIVRN_BUILD_SERVER)
|
||||
add_subdirectory(server)
|
||||
|
||||
message("Selected encoders:")
|
||||
message("\tNVENC: ${WIVRN_USE_NVENC}")
|
||||
message("\tVAAPI: ${WIVRN_USE_VAAPI}")
|
||||
message("\tx264: ${WIVRN_USE_X264}")
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
function(auto_option name description default)
|
||||
set(${name} ${default} CACHE STRING "${description}")
|
||||
set_property(CACHE ${name} PROPERTY STRINGS AUTO ON OFF)
|
||||
endfunction()
|
||||
Reference in New Issue
Block a user