Debian Codegraph @

CMakeLists.txt

raw ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
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
15 # libgav1 requires modern CMake.
16 cmake_minimum_required(VERSION 3.7.1 FATAL_ERROR)
17
18 # libgav1 requires C++11.
19 set(CMAKE_CXX_STANDARD 11)
20 set(ABSL_CXX_STANDARD 11)
21 # libgav1 requires C99.
22 set(CMAKE_C_STANDARD 99)
23
24 project(libgav1 CXX C)
25
26 set(libgav1_root "${CMAKE_CURRENT_SOURCE_DIR}")
27 set(libgav1_build "${CMAKE_BINARY_DIR}")
28
29 if("${libgav1_root}" STREQUAL "${libgav1_build}")
30 message(
31 FATAL_ERROR
32 "Building from within the libgav1 source tree is not supported.\n"
33 "Hint: Run these commands\n" "$ rm -rf CMakeCache.txt CMakeFiles\n"
34 "$ mkdir -p ../libgav1_build\n" "$ cd ../libgav1_build\n"
35 "And re-run CMake from the libgav1_build directory.")
36 endif()
37
38 set(libgav1_examples "${libgav1_root}/examples")
39 set(libgav1_source "${libgav1_root}/src")
40
41 include("${libgav1_root}/cmake/libgav1_options.cmake")
42
43 libgav1_option(NAME LIBGAV1_ENABLE_OPTIMIZATIONS HELPSTRING
44 "Enables optimized code." VALUE ON)
45 libgav1_option(NAME LIBGAV1_ENABLE_AVX2 HELPSTRING "Enables avx2 optimizations."
46 VALUE ON)
47 libgav1_option(NAME LIBGAV1_ENABLE_NEON HELPSTRING "Enables neon optimizations."
48 VALUE ON)
49 libgav1_option(NAME LIBGAV1_ENABLE_SSE4_1 HELPSTRING
50 "Enables sse4.1 optimizations." VALUE ON)
51 libgav1_option(NAME LIBGAV1_ENABLE_EXAMPLES HELPSTRING "Enables examples." VALUE
52 ON)
53 libgav1_option(NAME LIBGAV1_ENABLE_TESTS HELPSTRING "Enables tests." VALUE ON)
54 libgav1_option(
55 NAME LIBGAV1_VERBOSE HELPSTRING
56 "Enables verbose build system output. Higher numbers are more verbose." VALUE
57 OFF)
58
59 if(NOT CMAKE_BUILD_TYPE)
60 set(CMAKE_BUILD_TYPE Release)
61 endif()
62
63 # Enable generators like Xcode and Visual Studio to place projects in folders.
64 get_property(use_folders_is_set GLOBAL PROPERTY USE_FOLDERS SET)
65 if(NOT use_folders_is_set)
66 set_property(GLOBAL PROPERTY USE_FOLDERS TRUE)
67 endif()
68
69 include(FindThreads)
70
71 include("${libgav1_examples}/libgav1_examples.cmake")
72 include("${libgav1_root}/cmake/libgav1_build_definitions.cmake")
73 include("${libgav1_root}/cmake/libgav1_cpu_detection.cmake")
74 include("${libgav1_root}/cmake/libgav1_flags.cmake")
75 include("${libgav1_root}/cmake/libgav1_helpers.cmake")
76 include("${libgav1_root}/cmake/libgav1_install.cmake")
77 include("${libgav1_root}/cmake/libgav1_intrinsics.cmake")
78 include("${libgav1_root}/cmake/libgav1_sanitizer.cmake")
79 include("${libgav1_root}/cmake/libgav1_targets.cmake")
80 include("${libgav1_root}/cmake/libgav1_variables.cmake")
81 include("${libgav1_root}/tests/libgav1_tests.cmake")
82 include("${libgav1_source}/dsp/libgav1_dsp.cmake")
83 include("${libgav1_source}/libgav1_decoder.cmake")
84 include("${libgav1_source}/utils/libgav1_utils.cmake")
85
86 libgav1_optimization_detect()
87 libgav1_set_build_definitions()
88 libgav1_set_cxx_flags()
89 libgav1_configure_sanitizer()
90
91 # Supported bit depth.
92 libgav1_track_configuration_variable(LIBGAV1_MAX_BITDEPTH)
93
94 # C++ and linker flags.
95 libgav1_track_configuration_variable(LIBGAV1_CXX_FLAGS)
96 libgav1_track_configuration_variable(LIBGAV1_EXE_LINKER_FLAGS)
97
98 # Sanitizer integration.
99 libgav1_track_configuration_variable(LIBGAV1_SANITIZE)
100
101 # Generated source file directory.
102 libgav1_track_configuration_variable(LIBGAV1_GENERATED_SOURCES_DIRECTORY)
103
104 # Controls use of std::mutex and absl::Mutex in ThreadPool.
105 libgav1_track_configuration_variable(LIBGAV1_THREADPOOL_USE_STD_MUTEX)
106 if((DEFINED
107 LIBGAV1_THREADPOOL_USE_STD_MUTEX
108 AND NOT LIBGAV1_THREADPOOL_USE_STD_MUTEX)
109 OR NOT (DEFINED LIBGAV1_THREADPOOL_USE_STD_MUTEX OR ANDROID OR IOS))
110 set(use_absl_threading TRUE)
111 endif()
112
113 if(LIBGAV1_VERBOSE)
114 libgav1_dump_cmake_flag_variables()
115 libgav1_dump_tracked_configuration_variables()
116 libgav1_dump_options()
117 endif()
118
119 set(libgav1_abseil_build "${libgav1_build}/abseil")
120 set(libgav1_gtest_build "${libgav1_build}/gtest")
121
122 # Compiler/linker flags must be lists, but come in from the environment as
123 # strings. Break them up:
124 if(NOT "${LIBGAV1_CXX_FLAGS}" STREQUAL "")
125 separate_arguments(LIBGAV1_CXX_FLAGS)
126 endif()
127 if(NOT "${LIBGAV1_EXE_LINKER_FLAGS}" STREQUAL "")
128 separate_arguments(LIBGAV1_EXE_LINKER_FLAGS)
129 endif()
130
131 # Set test-only flags based on LIBGAV1_CXX_FLAGS.
132 libgav1_set_test_flags()
133
134 set(libgav1_abseil "${libgav1_root}/third_party/abseil-cpp")
135 if(EXISTS "${libgav1_abseil}")
136 set(ABSL_PROPAGATE_CXX_STD ON)
137 add_subdirectory("${libgav1_abseil}" "${libgav1_abseil_build}"
138 EXCLUDE_FROM_ALL)
139 else()
140 if(use_absl_threading OR LIBGAV1_ENABLE_EXAMPLES OR LIBGAV1_ENABLE_TESTS)
141 message(
142 FATAL_ERROR
143 "Abseil not found. This dependency is required by the"
144 " examples & tests and libgav1 when LIBGAV1_THREADPOOL_USE_STD_MUTEX is"
145 " not defined. To continue, download the Abseil repository to"
146 " third_party/abseil-cpp:\n git \\\n -C ${libgav1_root} \\\n"
147 " clone -b 20220623.0 --depth 1 \\\n"
148 " https://github.com/abseil/abseil-cpp.git third_party/abseil-cpp")
149 endif()
150 endif()
151
152 libgav1_reset_target_lists()
153 libgav1_add_dsp_targets()
154 libgav1_add_decoder_targets()
155 libgav1_add_examples_targets()
156 libgav1_add_tests_targets()
157 libgav1_add_utils_targets()
158 libgav1_setup_install_target()
159
160 if(LIBGAV1_ENABLE_TESTS)
161 # include(CTest) or -DBUILD_TESTING=1 aren't used to avoid enabling abseil
162 # tests.
163 enable_testing()
164 endif()
165
166 if(LIBGAV1_VERBOSE)
167 libgav1_dump_cmake_flag_variables()
168 libgav1_dump_tracked_configuration_variables()
169 libgav1_dump_options()
170 endif()