Commit 7d210cef16 for aom

commit 7d210cef16e828b2400e7baadc2687f30dc3f745
Author: Wan-Teh Chang <wtc@google.com>
Date:   Fri Jul 31 11:24:30 2026 -0700

    Introduce ENABLE_APPS build option

    With this change:
    - ENABLE_APPS: Controls build of the main apps: aomenc and aomdec
    - ENABLE_EXAMPLES: Controls build of the binaries in examples/ folder
    - ENABLE_TOOLS: Controls build of binaries in the tools/ folder (no
      change)

    aomdec and aomenc are no longer added to the
    AOM_DECODER_EXAMPLE_TARGETS, AOM_ENCODER_EXAMPLE_TARGETS, and
    AOM_EXAMPLE_TARGETS variables in CMakeLists.txt.

    Inspired by https://github.com/AOMediaCodec/avm/pull/5062 but written
    from scratch and then compared with it.

    Bug: 540998250
    Change-Id: Ibd6a8d5ed4b14b487333c53d7a98fe2cdce0d07a

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5dfd628eb4..3ffc6b9086 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -309,7 +309,8 @@ if(CONFIG_HIGHWAY)
   set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_hwy)
 endif()

-if(ENABLE_EXAMPLES)
+if(ENABLE_APPS)
+  # Only used by aomenc.
   add_library(aom_encoder_stats OBJECT ${AOM_ENCODER_STATS_SOURCES})
   set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_encoder_stats)
 endif()
@@ -440,7 +441,7 @@ file(WRITE "${AOM_GEN_SRC_DIR}/usage_exit.c"
 #
 # Application and application support targets.
 #
-if(ENABLE_EXAMPLES OR ENABLE_TESTS OR ENABLE_TOOLS)
+if(ENABLE_APPS OR ENABLE_EXAMPLES OR ENABLE_TESTS OR ENABLE_TOOLS)
   add_library(aom_common_app_util OBJECT ${AOM_COMMON_APP_UTIL_SOURCES})
   set_property(TARGET aom_common_app_util PROPERTY FOLDER examples)
   add_library(aom_usage_exit OBJECT "${AOM_GEN_SRC_DIR}/usage_exit.c")
@@ -457,10 +458,14 @@ if(ENABLE_EXAMPLES OR ENABLE_TESTS OR ENABLE_TOOLS)
   endif()
 endif()

-if(CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
+if(CONFIG_AV1_DECODER AND ENABLE_APPS)
   add_executable(aomdec "${AOM_ROOT}/apps/aomdec.c"
                         $<TARGET_OBJECTS:aom_common_app_util>
                         $<TARGET_OBJECTS:aom_decoder_app_util>)
+  list(APPEND AOM_APP_TARGETS aomdec)
+endif()
+
+if(CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
   add_executable(decode_to_md5 "${AOM_ROOT}/examples/decode_to_md5.c"
                                $<TARGET_OBJECTS:aom_common_app_util>
                                $<TARGET_OBJECTS:aom_decoder_app_util>)
@@ -513,7 +518,7 @@ if(CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
   endif()

   # Maintain a list of decoder example targets.
-  list(APPEND AOM_DECODER_EXAMPLE_TARGETS aomdec decode_to_md5 decode_with_drops
+  list(APPEND AOM_DECODER_EXAMPLE_TARGETS decode_to_md5 decode_with_drops
               scalable_decoder simple_decoder)

   # Add decoder examples to the app targets list.
@@ -540,11 +545,15 @@ if(CONFIG_LIBYUV OR CONFIG_TUNE_BUTTERAUGLI)
 endif()

 if(CONFIG_AV1_ENCODER)
-  if(ENABLE_EXAMPLES)
+  if(ENABLE_APPS)
     add_executable(aomenc "${AOM_ROOT}/apps/aomenc.c"
                           $<TARGET_OBJECTS:aom_common_app_util>
                           $<TARGET_OBJECTS:aom_encoder_app_util>
                           $<TARGET_OBJECTS:aom_encoder_stats>)
+    list(APPEND AOM_APP_TARGETS aomenc)
+  endif()
+
+  if(ENABLE_EXAMPLES)
     add_executable(lossless_encoder "${AOM_ROOT}/examples/lossless_encoder.c"
                                     $<TARGET_OBJECTS:aom_common_app_util>
                                     $<TARGET_OBJECTS:aom_encoder_app_util>)
@@ -575,7 +584,7 @@ if(CONFIG_AV1_ENCODER)
     target_link_libraries(svc_encoder_rtc ${AOM_LIB_LINK_TYPE} aom_av1_rc)

     # Maintain a list of encoder example targets.
-    list(APPEND AOM_ENCODER_EXAMPLE_TARGETS aomenc lossless_encoder set_maps
+    list(APPEND AOM_ENCODER_EXAMPLE_TARGETS lossless_encoder set_maps
                 simple_encoder scalable_encoder svc_encoder_rtc twopass_encoder)
     if(NOT BUILD_SHARED_LIBS AND NOT CONFIG_REALTIME_ONLY)
       list(APPEND AOM_ENCODER_EXAMPLE_TARGETS noise_model photon_noise_table)
@@ -816,7 +825,7 @@ foreach(aom_app ${AOM_APP_TARGETS})
   target_link_libraries(${aom_app} ${AOM_LIB_LINK_TYPE} aom)
 endforeach()

-if(ENABLE_EXAMPLES OR ENABLE_TESTS OR ENABLE_TOOLS)
+if(ENABLE_APPS OR ENABLE_EXAMPLES OR ENABLE_TESTS OR ENABLE_TOOLS)
   if(CONFIG_LIBYUV)
     # Add to existing targets.
     foreach(aom_app ${AOM_APP_TARGETS})
@@ -895,11 +904,9 @@ if(ENABLE_EXAMPLES AND "${CMAKE_GENERATOR}" MATCHES "Makefiles$")
   file(MAKE_DIRECTORY "${AOM_CONFIG_DIR}/examples")

   foreach(target ${AOM_EXAMPLE_TARGETS})
-    if(NOT "${target}" MATCHES "aomdec\|aomenc")
-      set_target_properties(${target}
-                            PROPERTIES RUNTIME_OUTPUT_DIRECTORY
-                                       "${AOM_CONFIG_DIR}/examples")
-    endif()
+    set_target_properties(${target}
+                          PROPERTIES RUNTIME_OUTPUT_DIRECTORY
+                                     "${AOM_CONFIG_DIR}/examples")
   endforeach()

   if(ENABLE_TOOLS AND AOM_TOOL_TARGETS)
@@ -984,10 +991,10 @@ if(ENABLE_DOCS)
 endif()

 # Aomedia dist rule.
-if(CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
+if(CONFIG_AV1_DECODER AND ENABLE_APPS)
   list(APPEND AOM_DIST_APPS $<TARGET_FILE:aomdec>)
 endif()
-if(CONFIG_AV1_ENCODER AND ENABLE_EXAMPLES)
+if(CONFIG_AV1_ENCODER AND ENABLE_APPS)
   list(APPEND AOM_DIST_APPS $<TARGET_FILE:aomenc>)
 endif()

diff --git a/cmake/aom_config_defaults.cmake b/cmake/aom_config_defaults.cmake
index 875bf5abaa..4590ed4f8f 100644
--- a/cmake/aom_config_defaults.cmake
+++ b/cmake/aom_config_defaults.cmake
@@ -187,6 +187,8 @@ set_aom_config_var(CONFIG_HIGHWAY 0 "Use Highway for SIMD.")
 #
 # Variables in this section control optional features of the build system.
 #
+set_aom_option_var(ENABLE_APPS
+                   "Enables build of main applications (aomenc/aomdec)." ON)
 set_aom_option_var(ENABLE_CCACHE "Enable ccache support." OFF)
 set_aom_option_var(ENABLE_DECODE_PERF_TESTS "Enables decoder performance tests"
                    OFF)
diff --git a/cmake/aom_install.cmake b/cmake/aom_install.cmake
index a8f6d64361..bad2f30d38 100644
--- a/cmake/aom_install.cmake
+++ b/cmake/aom_install.cmake
@@ -69,13 +69,13 @@ macro(setup_aom_install_targets)
     add_dependencies(aom_pc aom_version)

     if(CONFIG_AV1_DECODER)
-      if(ENABLE_EXAMPLES)
+      if(ENABLE_APPS)
         list(APPEND AOM_INSTALL_BINS aomdec)
       endif()
     endif()

     if(CONFIG_AV1_ENCODER)
-      if(ENABLE_EXAMPLES)
+      if(ENABLE_APPS)
         list(APPEND AOM_INSTALL_BINS aomenc)
       endif()
     endif()
diff --git a/cmake/dist.cmake b/cmake/dist.cmake
index 511f34a2e6..822b4ebe58 100644
--- a/cmake/dist.cmake
+++ b/cmake/dist.cmake
@@ -33,9 +33,7 @@ endif()
 if(AOM_DIST_EXAMPLES)
   listify_string("${AOM_DIST_EXAMPLES}" "AOM_DIST_EXAMPLES")
   foreach(example ${AOM_DIST_EXAMPLES})
-    if(NOT "${example}" MATCHES "aomdec\|aomenc")
-      file(INSTALL "${example}" DESTINATION "${AOM_DIST_DIR}/bin/examples")
-    endif()
+    file(INSTALL "${example}" DESTINATION "${AOM_DIST_DIR}/bin/examples")
   endforeach()
 endif()

diff --git a/examples/build_av1_dec_fuzzer.sh b/examples/build_av1_dec_fuzzer.sh
index d1dfd23f01..1a798a17aa 100755
--- a/examples/build_av1_dec_fuzzer.sh
+++ b/examples/build_av1_dec_fuzzer.sh
@@ -50,8 +50,8 @@ BUILD_DIR=$2
 EXTRA_C_FLAGS='-UNDEBUG -DDO_RANGE_CHECK_CLAMP=1 -DAOM_MAX_ALLOCABLE_MEMORY=1073741824'
 cd "${BUILD_DIR}"
 cmake "${AOM_DIR}" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONFIG_PIC=1 \
-  -DFORCE_HIGHBITDEPTH_DECODING=0 \
-  -DCONFIG_AV1_ENCODER=0 -DENABLE_EXAMPLES=0 -DENABLE_DOCS=0 -DENABLE_TESTS=0 \
+  -DFORCE_HIGHBITDEPTH_DECODING=0 -DCONFIG_AV1_ENCODER=0 \
+  -DENABLE_APPS=0 -DENABLE_EXAMPLES=0 -DENABLE_DOCS=0 -DENABLE_TESTS=0 \
   -DCONFIG_SIZE_LIMIT=1 -DDECODE_HEIGHT_LIMIT=12288 -DDECODE_WIDTH_LIMIT=12288 \
   -DAOM_EXTRA_C_FLAGS="${EXTRA_C_FLAGS}" \
   -DAOM_EXTRA_CXX_FLAGS="${EXTRA_C_FLAGS}" -DSANITIZE=fuzzer-no-link,address