In build/configuration files (e.g., CMakeLists), keep statements organized so that they are (1) scoped to the conditions that actually enable the associated sources/targets, and (2) ordered deterministically (e.g., alphabetical for registration lists).

Apply scope correctly

Keep registrations sorted

Example (CMake)

macro(ncnn_add_layer class)
  foreach(name IN LISTS ${class})
    if(WITH_LAYER_${name})
      if(WITH_LAYER_${name}_${arch})
        # sources only for enabled arch
        source_group("sources\\layers" FILES
          "${CMAKE_CURRENT_SOURCE_DIR}/layer/${name}.cpp")
        source_group("sources\\layers\\${arch}" FILES
          "${CMAKE_CURRENT_SOURCE_DIR}/layer/${arch}/${name}_${arch}.cpp")

        if(WITH_LAYER_${name}_vulkan)
          # sources only for enabled Vulkan
          source_group("sources\\layers\\vulkan" FILES
            "${CMAKE_CURRENT_SOURCE_DIR}/layer/vulkan/${name}_vulkan.cpp")
        endif()
      endif()
    endif()
  endforeach()
endmacro()

# Tests: keep calls alphabetically
ncnn_add_layer_test(AbsVal)
ncnn_add_layer_test(ReLU)

This improves readability (future editors can see what is guarded by what) and produces cleaner, more predictable diffs.