Skip to content

Commit

Permalink
If a feature is explicitly requested via the cmake command line, erro…
Browse files Browse the repository at this point in the history
…r out if necessary libraries are missing and do not silently disable the requested feature.
  • Loading branch information
JoachimFalk committed Dec 21, 2024
1 parent 95f7b1c commit f319a6b
Showing 1 changed file with 44 additions and 9 deletions.
53 changes: 44 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ find_package(ZLIB REQUIRED)
find_package(Pixman REQUIRED)

# Check for gettext
if(DEFINED ENABLE_NLS)
option(ENABLE_NLS "Enable translation of program messages" ON)
if(ENABLE_NLS)
endif()
if(ENABLE_NLS OR NOT DEFINED ENABLE_NLS)
# Tools
find_package(Gettext)

Expand Down Expand Up @@ -176,18 +178,26 @@ if(ENABLE_NLS)
endif()

if(NOT GETTEXT_FOUND OR NOT ICONV_FOUND)
message(WARNING "Gettext NOT found. Native Language Support disabled.")
set(ENABLE_NLS 0)
if(NOT DEFINED ENABLE_NLS)
message(WARNING "Gettext NOT found. Native Language Support disabled.")
else()
message(FATAL_ERROR "Native Language Support requested, but gettext NOT found!")
endif()
set(ENABLE_NLS OFF)
else()
set(ENABLE_NLS ON)
endif()
endif()

if(DEFINED ENABLE_H264)
option(ENABLE_H264 "Enable H.264 RFB encoding" ON)
if(ENABLE_H264)
endif()
if(ENABLE_H264 OR NOT DEFINED ENABLE_H264)
if(WIN32)
add_definitions("-DHAVE_H264")
set(H264_LIBS "WIN") # may be LIBAV in the future
set(H264_LIBRARIES ole32 mfplat mfuuid wmcodecdspuuid)

set(ENABLE_H264 ON)
set(CMAKE_REQUIRED_LIBRARIES ${H264_LIBRARIES})
check_variable_exists(CLSID_VideoProcessorMFT HAVE_VIDEO_PROCESSOR_MFT)
set(CMAKE_REQUIRED_LIBRARIES)
Expand All @@ -203,9 +213,15 @@ if(ENABLE_H264)
add_definitions("-D__STDC_CONSTANT_MACROS")
add_definitions("-DHAVE_H264")
set(H264_LIBS "LIBAV")
set(ENABLE_H264 ON)
else()
set(H264_LIBS "NONE")
message(WARNING "FFMPEG support can't be found")
if(NOT DEFINED ENABLE_H264)
set(H264_LIBS "NONE")
message(WARNING "FFMPEG support can't be found. No H.264 RFB encoding support.")
else()
message(FATAL_ERROR "H.264 RFB encoding support requested, but FFMPEG support can't be found!")
endif()
set(ENABLE_H264 OFF)
endif()
endif()
add_definitions("-DH264_${H264_LIBS}")
Expand Down Expand Up @@ -283,19 +299,38 @@ if(BUILD_VIEWER)
endif()

# Check for GNUTLS library
if(DEFINED ENABLE_GNUTLS)
option(ENABLE_GNUTLS "Enable protocol encryption and advanced authentication" ON)
if(ENABLE_GNUTLS)
endif()
if(ENABLE_GNUTLS OR NOT DEFINED ENABLE_GNUTLS)
find_package(GnuTLS)
if (GNUTLS_FOUND)
add_definitions("-DHAVE_GNUTLS")
set(ENABLE_GNUTLS ON)
else()
if(NOT DEFINED ENABLE_GNUTLS)
message(WARNING "GnuTLS NOT found. SSL support disabled.")
else()
message(FATAL_ERROR "GnuTLS support requested, but library could not be found!")
endif()
endif()
endif()

if(DEFINED ENABLE_NETTLE)
option(ENABLE_NETTLE "Enable RSA-AES security types" ON)
if (ENABLE_NETTLE)
endif()
if(ENABLE_NETTLE OR NOT DEFINED ENABLE_NETTLE)
find_package(Nettle)
if (NETTLE_FOUND)
add_definitions("-DHAVE_NETTLE")
set(ENABLE_NETTLE ON)
else()
if(NOT DEFINED ENABLE_NETTLE)
message(WARNING "Nettle library NOT found. RSA-AES security types disabled.")
else()
message(FATAL_ERROR "RSA-AES security types requested, but Nettle library could not be found!")
endif()
set(ENABLE_NETTLE OFF)
endif()
endif()

Expand Down

0 comments on commit f319a6b

Please sign in to comment.