• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 The libgav1 Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15if(LIBGAV1_CMAKE_LIBGAV1_VARIABLES_CMAKE_)
16  return()
17endif() # LIBGAV1_CMAKE_LIBGAV1_VARIABLES_CMAKE_
18set(LIBGAV1_CMAKE_LIBGAV1_VARIABLES_CMAKE_ 1)
19
20# Halts generation when $variable_name does not refer to a directory that
21# exists.
22macro(libgav1_variable_must_be_directory variable_name)
23  if("${variable_name}" STREQUAL "")
24    message(
25      FATAL_ERROR
26        "Empty variable_name passed to libgav1_variable_must_be_directory.")
27  endif()
28
29  if("${${variable_name}}" STREQUAL "")
30    message(
31      FATAL_ERROR
32        "Empty variable ${variable_name} is required to build libgav1.")
33  endif()
34
35  if(NOT IS_DIRECTORY "${${variable_name}}")
36    message(
37      FATAL_ERROR
38        "${variable_name}, which is ${${variable_name}}, does not refer to a\n"
39        "directory.")
40  endif()
41endmacro()
42
43# Adds $var_name to the tracked variables list.
44macro(libgav1_track_configuration_variable var_name)
45  if(LIBGAV1_VERBOSE GREATER 2)
46    message("---- libgav1_track_configuration_variable ----\n"
47            "var_name=${var_name}\n"
48            "----------------------------------------------\n")
49  endif()
50
51  list(APPEND libgav1_configuration_variables ${var_name})
52  list(REMOVE_DUPLICATES libgav1_configuration_variables)
53endmacro()
54
55# Logs current C++ and executable linker flags via CMake's message command.
56macro(libgav1_dump_cmake_flag_variables)
57  unset(flag_variables)
58  list(APPEND flag_variables "CMAKE_CXX_FLAGS_INIT" "CMAKE_CXX_FLAGS"
59              "CMAKE_EXE_LINKER_FLAGS_INIT" "CMAKE_EXE_LINKER_FLAGS")
60  if(CMAKE_BUILD_TYPE)
61    list(APPEND flag_variables "CMAKE_BUILD_TYPE"
62                "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}_INIT"
63                "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}"
64                "CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE}_INIT"
65                "CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE}")
66  endif()
67  foreach(flag_variable ${flag_variables})
68    message("${flag_variable}:${${flag_variable}}")
69  endforeach()
70endmacro()
71
72# Dumps the variables tracked in $libgav1_configuration_variables via CMake's
73# message command.
74macro(libgav1_dump_tracked_configuration_variables)
75  foreach(config_variable ${libgav1_configuration_variables})
76    message("${config_variable}:${${config_variable}}")
77  endforeach()
78endmacro()
79