xref: /aosp_15_r20/external/libgav1/cmake/libgav1_options.cmake (revision 095378508e87ed692bf8dfeb34008b65b3735891)
1*09537850SAkhilesh Sanikop# Copyright 2019 The libgav1 Authors
2*09537850SAkhilesh Sanikop#
3*09537850SAkhilesh Sanikop# Licensed under the Apache License, Version 2.0 (the "License");
4*09537850SAkhilesh Sanikop# you may not use this file except in compliance with the License.
5*09537850SAkhilesh Sanikop# You may obtain a copy of the License at
6*09537850SAkhilesh Sanikop#
7*09537850SAkhilesh Sanikop#      http://www.apache.org/licenses/LICENSE-2.0
8*09537850SAkhilesh Sanikop#
9*09537850SAkhilesh Sanikop# Unless required by applicable law or agreed to in writing, software
10*09537850SAkhilesh Sanikop# distributed under the License is distributed on an "AS IS" BASIS,
11*09537850SAkhilesh Sanikop# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*09537850SAkhilesh Sanikop# See the License for the specific language governing permissions and
13*09537850SAkhilesh Sanikop# limitations under the License.
14*09537850SAkhilesh Sanikop
15*09537850SAkhilesh Sanikopif(LIBGAV1_CMAKE_LIBGAV1_OPTIONS_CMAKE_)
16*09537850SAkhilesh Sanikop  return()
17*09537850SAkhilesh Sanikopendif() # LIBGAV1_CMAKE_LIBGAV1_OPTIONS_CMAKE_
18*09537850SAkhilesh Sanikopset(LIBGAV1_CMAKE_LIBGAV1_OPTIONS_CMAKE_)
19*09537850SAkhilesh Sanikop
20*09537850SAkhilesh Sanikop# Simple wrapper for CMake's builtin option command that tracks libgav1's build
21*09537850SAkhilesh Sanikop# options in the list variable $libgav1_options.
22*09537850SAkhilesh Sanikopmacro(libgav1_option)
23*09537850SAkhilesh Sanikop  unset(option_NAME)
24*09537850SAkhilesh Sanikop  unset(option_HELPSTRING)
25*09537850SAkhilesh Sanikop  unset(option_VALUE)
26*09537850SAkhilesh Sanikop  unset(optional_args)
27*09537850SAkhilesh Sanikop  unset(multi_value_args)
28*09537850SAkhilesh Sanikop  set(single_value_args NAME HELPSTRING VALUE)
29*09537850SAkhilesh Sanikop  cmake_parse_arguments(option "${optional_args}" "${single_value_args}"
30*09537850SAkhilesh Sanikop                        "${multi_value_args}" ${ARGN})
31*09537850SAkhilesh Sanikop
32*09537850SAkhilesh Sanikop  if(NOT (option_NAME AND option_HELPSTRING AND DEFINED option_VALUE))
33*09537850SAkhilesh Sanikop    message(FATAL_ERROR "libgav1_option: NAME HELPSTRING and VALUE required.")
34*09537850SAkhilesh Sanikop  endif()
35*09537850SAkhilesh Sanikop
36*09537850SAkhilesh Sanikop  option(${option_NAME} ${option_HELPSTRING} ${option_VALUE})
37*09537850SAkhilesh Sanikop
38*09537850SAkhilesh Sanikop  if(LIBGAV1_VERBOSE GREATER 2)
39*09537850SAkhilesh Sanikop    message("--------- libgav1_option ---------\n"
40*09537850SAkhilesh Sanikop            "option_NAME=${option_NAME}\n"
41*09537850SAkhilesh Sanikop            "option_HELPSTRING=${option_HELPSTRING}\n"
42*09537850SAkhilesh Sanikop            "option_VALUE=${option_VALUE}\n"
43*09537850SAkhilesh Sanikop            "------------------------------------------\n")
44*09537850SAkhilesh Sanikop  endif()
45*09537850SAkhilesh Sanikop
46*09537850SAkhilesh Sanikop  list(APPEND libgav1_options ${option_NAME})
47*09537850SAkhilesh Sanikop  list(REMOVE_DUPLICATES libgav1_options)
48*09537850SAkhilesh Sanikopendmacro()
49*09537850SAkhilesh Sanikop
50*09537850SAkhilesh Sanikop# Dumps the $libgav1_options list via CMake message command.
51*09537850SAkhilesh Sanikopmacro(libgav1_dump_options)
52*09537850SAkhilesh Sanikop  foreach(option_name ${libgav1_options})
53*09537850SAkhilesh Sanikop    message("${option_name}: ${${option_name}}")
54*09537850SAkhilesh Sanikop  endforeach()
55*09537850SAkhilesh Sanikopendmacro()
56