At present, CMakeLists.txt interleaves configuration-option handling with dependency discovery. As a result, unnecessary checks may be performed. For example:
0$ cmake -B build --preset dev-mode -DBUILD_FOR_FUZZING=ON
1<snip>
2-- Found PkgConfig: /usr/bin/pkg-config (found version "2.3.0")
3-- Found ZeroMQ: /usr/lib64 (found suitable version "4.3.5", minimum required is "4.0.0")
4-- Performing Test HAVE_USDT_H
5-- Performing Test HAVE_USDT_H - Success
6-- Found USDT: /usr/include
7-- Found QRencode: /usr/lib64/libqrencode.so (found version "4.1.1")
8-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
9-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
10-- Found Threads: TRUE
11-- Performing Test HAVE_STDATOMIC
12-- Performing Test HAVE_STDATOMIC - Success
13-- Found WrapAtomic: TRUE
14-- Found OpenGL: /usr/lib64/libOpenGL.so
15-- Found WrapOpenGL: TRUE
16-- Found WrapVulkanHeaders: /usr/include
17-- Found Qt: /usr/lib64/cmake/Qt6 (found suitable version "6.10.1", minimum required is "6.2")
18CMake Warning at CMakeLists.txt:206 (message):
19 BUILD_FOR_FUZZING=ON will disable all other targets and force
20 BUILD_FUZZ_BINARY=ON.
21
22<snip>
This PR restructures the code to ensure that all dependencies are checked only after the final build option interaction.