cmake: Fix warnings and normalize variables/errors

As of 3.17 using find_package_handle_standard_args checks that the name
of the FindXXX file and the first argument are the same case.

Some modules used non-standard variables or the old singular variables
instead of plurals. This normalizes variable usage to the new-style.

Some CMakeLists.txt did custom error checking instead of propagating
find_package errors. These were changes to call find_package with
REQUIRED or without QUIET where needed and shortens the custom status
messages. This helps users who want to enable that functionality see
what precisely wasnt found.
This commit is contained in:
Kurt Kartaltepe
2020-04-03 20:56:48 -07:00
parent e822b47427
commit d928bfd1ea
12 changed files with 63 additions and 83 deletions

View File

@@ -5,23 +5,28 @@ if(DISABLE_V4L2)
return()
endif()
find_package(Libv4l2)
find_package(LibUDev QUIET)
if(NOT LIBV4L2_FOUND AND ENABLE_V4L2)
message(FATAL_ERROR "libv4l2 not found bit plugin set as enabled")
elseif(NOT LIBV4L2_FOUND)
message(STATUS "libv4l2 not found, disabling v4l2 plugin")
return()
if(ENABLE_V4L2)
find_package(Libv4l2 REQUIRED)
else()
find_package(Libv4l2)
if(NOT LIBV4L2_FOUND)
message(STATUS "libv4l2 not found, disabling v4l2 plugin")
return()
endif()
endif()
if(NOT UDEV_FOUND OR DISABLE_UDEV)
message(STATUS "udev disabled for v4l2 plugin")
else()
set(linux-v4l2-udev_SOURCES
v4l2-udev.c
)
if(DISABLE_UDEV)
add_definitions(-DHAVE_UDEV)
else()
find_package(UDev)
if(NOT UDEV_FOUND)
message(STATUS "udev disabled for v4l2 plugin")
else()
set(linux-v4l2-udev_SOURCES
v4l2-udev.c
)
endif()
endif()
include_directories(

View File

@@ -5,22 +5,21 @@ set_property(CACHE WITH_RTMPS PROPERTY STRINGS AUTO ON OFF)
option(STATIC_MBEDTLS "Statically link mbedTLS into binary" OFF)
if (WITH_RTMPS OR (WITH_RTMPS STREQUAL "AUTO"))
find_package(MbedTLS QUIET)
find_package(ZLIB QUIET)
if (WITH_RTMPS STREQUAL "AUTO")
find_package(MbedTLS)
find_package(ZLIB)
if (NOT MBEDTLS_FOUND OR NOT ZLIB_FOUND)
set(WITH_RTMPS "OFF")
message(WARNING "mbedTLS or zlib was not found, RTMPS will be auto-disabled")
endif()
endif()
if (LIBMBEDTLS_FOUND AND ZLIB_FOUND)
if (WITH_RTMPS)
find_package(MbedTLS REQUIRED)
find_package(ZLIB REQUIRED)
add_definitions(-DCRYPTO -DUSE_MBEDTLS)
include_directories(${LIBMBEDTLS_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
include_directories(${MBEDTLS_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
else()
if(WITH_RTMPS STREQUAL "AUTO")
message(WARNING "mbedTLS was not found, RTMPS will be auto-disabled")
elseif (WITH_RTMPS)
message(FATAL_ERROR "RTMPS enabled by user, but mbedTLS was not found")
endif()
unset(LIBMBEDTLS_LIBRARIES)
unset(ZLIB_LIBRARIES)
add_definitions(-DNO_CRYPTO)
endif()
@@ -172,7 +171,7 @@ add_library(obs-outputs MODULE
${obs-outputs_librtmp_HEADERS})
target_link_libraries(obs-outputs
libobs
${LIBMBEDTLS_LIBRARIES}
${MBEDTLS_LIBRARIES}
${ZLIB_LIBRARIES}
${ftl_IMPORTS}
${obs-outputs_PLATFORM_DEPS})

View File

@@ -5,13 +5,14 @@ if(DISABLE_VLC)
return()
endif()
find_package(LibVLC QUIET)
if(NOT LIBVLC_INCLUDES_FOUND AND ENABLE_VLC)
message(FATAL_ERROR "LibVLC includes not found but set as enabled")
elseif(NOT LIBVLC_INCLUDES_FOUND)
message(STATUS "LibVLC includes not found, VLC video plugin disabled")
return()
if(ENABLE_VLC)
find_package(LibVLC REQUIRED)
else()
find_package(LibVLC)
if(NOT LibVLC_FOUND)
message(STATUS "VLC video plugin disabled")
return()
endif()
endif()
include_directories(${LIBVLC_INCLUDE_DIRS})
@@ -41,6 +42,7 @@ endif()
add_library(vlc-video MODULE
${vlc-video_SOURCES}
${vlc-video_HEADERS})
# instead of linking vlc we load at runtime.
target_link_libraries(vlc-video
libobs
${vlc-video_PLATFORM_DEPS})