ms2.cmake: use macro, not function to avoid messing up with options

parent a84a7de5
......@@ -24,37 +24,39 @@
# This function can be used to add an option. Give it option name and description,
# default value and optionally dependent predicate and value
function (ms2_add_option NAME DESCRIPTION DEFAULT_VALUE)
macro (ms2_add_dependent_option NAME DESCRIPTION DEFAULT_VALUE CONDITION CONDITION_VALUE)
string(TOUPPER ${NAME} UPPERCASE_NAME)
string(REGEX REPLACE " " "_" UPPERCASE_NAME ${UPPERCASE_NAME})
string(REGEX REPLACE "\\+" "P" UPPERCASE_NAME ${UPPERCASE_NAME})
if (ARGC EQUAL 5)
cmake_dependent_option(ENABLE_${UPPERCASE_NAME} "${DESCRIPTION}" "${DEFAULT_VALUE}" "${ARGV3}" "${ARGV4}")
elseif (ARGC EQUAL 3)
option(ENABLE_${UPPERCASE_NAME} "Enable ${NAME}: ${DESCRIPTION}" "${DEFAULT_VALUE}")
else()
message(FATAL_ERROR "Invalid arguments count: ${ARGC}. Expected 3 or 5")
endif()
add_feature_info(${NAME} ENABLE_${UPPERCASE_NAME} ${DESCRIPTION})
endfunction()
cmake_dependent_option(ENABLE_${UPPERCASE_NAME} "${DESCRIPTION}" "${DEFAULT_VALUE}" "${CONDITION}" "${CONDITION_VALUE}")
add_feature_info("${NAME}" "ENABLE_${UPPERCASE_NAME}" "${DESCRIPTION}")
endmacro()
macro (ms2_add_option NAME DESCRIPTION DEFAULT_VALUE)
string(TOUPPER ${NAME} UPPERCASE_NAME)
string(REGEX REPLACE " " "_" UPPERCASE_NAME ${UPPERCASE_NAME})
string(REGEX REPLACE "\\+" "P" UPPERCASE_NAME ${UPPERCASE_NAME})
option(ENABLE_${UPPERCASE_NAME} "Enable ${NAME}: ${DESCRIPTION}" "${DEFAULT_VALUE}")
add_feature_info("${NAME}" "ENABLE_${UPPERCASE_NAME}" "${DESCRIPTION}")
endmacro()
ms2_add_option("GPL third parties" "Usage of GPL third-party code (FFmpeg and x264)." ${DEFAULT_VALUE_ENABLE_GPL_THIRD_PARTIES})
ms2_add_option("Non free codecs" "Allow inclusion of non-free codecs in the build." OFF)
#security options
ms2_add_option("SRTP" "SRTP media encryption support." ${DEFAULT_VALUE_ENABLE_SRTP})
ms2_add_option("ZRTP" "ZRTP media encryption support." ${DEFAULT_VALUE_ENABLE_ZRTP} "ENABLE_SRTP" OFF)
ms2_add_option("DTLS" "DTLS media encryption support." ${DEFAULT_VALUE_ENABLE_DTLS} "ENABLE_SRTP" OFF)
ms2_add_dependent_option("ZRTP" "ZRTP media encryption support." ${DEFAULT_VALUE_ENABLE_ZRTP} "ENABLE_SRTP" OFF)
ms2_add_dependent_option("DTLS" "DTLS media encryption support." ${DEFAULT_VALUE_ENABLE_DTLS} "ENABLE_SRTP" OFF)
#audio options and codecs
ms2_add_option("WebRTC AEC" "WebRTC echo canceller support." ${DEFAULT_VALUE_ENABLE_WEBRTC_AEC})
ms2_add_option("WASAPI" "Windows Audio Session API (WASAPI) sound card support." ${DEFAULT_VALUE_ENABLE_WASAPI} "MSVC" OFF)
ms2_add_option("AMRNB" "AMR narrow-band audio encoding/decoding support (require license)." OFF "ENABLE_NON_FREE_CODECS" OFF)
ms2_add_option("AMRWB" "AMR wide-band audio encoding/decoding support (require license)." OFF "ENABLE_NON_FREE_CODECS" OFF)
ms2_add_dependent_option("WASAPI" "Windows Audio Session API (WASAPI) sound card support." ${DEFAULT_VALUE_ENABLE_WASAPI} "MSVC" OFF)
ms2_add_dependent_option("AMRNB" "AMR narrow-band audio encoding/decoding support (require license)." OFF "ENABLE_NON_FREE_CODECS" OFF)
ms2_add_dependent_option("AMRWB" "AMR wide-band audio encoding/decoding support (require license)." OFF "ENABLE_NON_FREE_CODECS" OFF)
if(ENABLE_AMRNB OR ENABLE_AMRWB)
set(ENABLE_AMR ON CACHE BOOL "" FORCE)
endif()
ms2_add_option("G729" "G.729 audio encoding/decoding support (require license)." OFF "ENABLE_NON_FREE_CODECS" OFF)
ms2_add_dependent_option("G729" "G.729 audio encoding/decoding support (require license)." OFF "ENABLE_NON_FREE_CODECS" OFF)
ms2_add_option("GSM" "GSM audio encoding/decoding support." ${DEFAULT_VALUE_ENABLE_GSM})
ms2_add_option("iLBC" "iLBC audio encoding/decoding support." ${DEFAULT_VALUE_ENABLE_ILBC})
ms2_add_option("ISAC" "ISAC audio encoding/decoding support." ${DEFAULT_VALUE_ENABLE_ISAC})
......@@ -69,12 +71,12 @@ set(FFMPEG_DEPENDENT_PRED "ENABLE_VIDEO")
if (IOS)
set(FFMPEG_DEPENDENT_PRED "${FFMPEG_DEPENDENT_PRED};ENABLE_GPL_THIRD_PARTIES")
endif()
ms2_add_option("FFmpeg" "Some video processing features via FFmpeg: JPEG encoding/decoding, video scaling, H264 decoding..." ${DEFAULT_VALUE_ENABLE_FFMPEG} "${FFMPEG_DEPENDENT_PRED}" OFF)
ms2_add_option("H263" "H263 video encoding/decoding support (require license)." OFF "ENABLE_FFMPEG;ENABLE_NON_FREE_CODECS" OFF)
ms2_add_option("H263+" "H263+ video encoding/decoding support (require license)." OFF "ENABLE_FFMPEG;ENABLE_NON_FREE_CODECS" OFF)
ms2_add_dependent_option("FFmpeg" "Some video processing features via FFmpeg: JPEG encoding/decoding, video scaling, H264 decoding..." ${DEFAULT_VALUE_ENABLE_FFMPEG} "${FFMPEG_DEPENDENT_PRED}" OFF)
ms2_add_dependent_option("H263" "H263 video encoding/decoding support (require license)." OFF "ENABLE_FFMPEG;ENABLE_NON_FREE_CODECS" OFF)
ms2_add_dependent_option("H263+" "H263+ video encoding/decoding support (require license)." OFF "ENABLE_FFMPEG;ENABLE_NON_FREE_CODECS" OFF)
ms2_add_option("MKV" "MKV playing and recording support." ${DEFAULT_VALUE_ENABLE_MKV})
ms2_add_option("MPEG4" "MPEG4 video encoding/decoding support (require license)." OFF "ENABLE_FFMPEG;ENABLE_NON_FREE_CODECS" OFF)
ms2_add_option("OpenH264" "H.264 video encoding/decoding support with the openh264 library (require license)." OFF "ENABLE_VIDEO;ENABLE_NON_FREE_CODECS" OFF)
ms2_add_option("V4L" "V4L camera driver." ON "ENABLE_VIDEO; UNIX; NOT APPLE" OFF)
ms2_add_option("VPX" "VPX (VP8) video encoding/decoding support." ${DEFAULT_VALUE_ENABLE_VPX} "ENABLE_VIDEO" OFF)
ms2_add_option("X264" "H.264 video encoding support with the x264 library (require license)." OFF "ENABLE_VIDEO;ENABLE_NON_FREE_CODECS" OFF)
ms2_add_dependent_option("MPEG4" "MPEG4 video encoding/decoding support (require license)." OFF "ENABLE_FFMPEG;ENABLE_NON_FREE_CODECS" OFF)
ms2_add_dependent_option("OpenH264" "H.264 video encoding/decoding support with the openh264 library (require license)." OFF "ENABLE_VIDEO;ENABLE_NON_FREE_CODECS" OFF)
ms2_add_dependent_option("V4L" "V4L camera driver." ON "ENABLE_VIDEO; UNIX; NOT APPLE" OFF)
ms2_add_dependent_option("VPX" "VPX (VP8) video encoding/decoding support." ${DEFAULT_VALUE_ENABLE_VPX} "ENABLE_VIDEO" OFF)
ms2_add_dependent_option("X264" "H.264 video encoding support with the x264 library (require license)." OFF "ENABLE_VIDEO;ENABLE_NON_FREE_CODECS" OFF)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment