Use of non-target directives, such as add_compile_definitions(), include_directories() or add_compile_options(), is not recommended. As of CMake 4.5.0, it triggers -Wnon-target-directive warnings.
For example:
$ cmake -B build -Wnon-target-directive
-- The C compiler identification is GNU 16.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Warning (non-target-directive) at CMakeLists.txt:66 (add_compile_definitions):
Use of non-target directives is not recommended. Consider
target_compile_definitions instead.
This warning is for project developers. Use -Wno-author or
-Wno-non-target-directive to suppress it.
CMake Warning (non-target-directive) at CMakeLists.txt:78 (add_compile_definitions):
Use of non-target directives is not recommended. Consider
target_compile_definitions instead.
This warning is for project developers. Use -Wno-author or
-Wno-non-target-directive to suppress it.
CMake Warning (non-target-directive) at CMakeLists.txt:79 (add_compile_definitions):
Use of non-target directives is not recommended. Consider
target_compile_definitions instead.
This warning is for project developers. Use -Wno-author or
-Wno-non-target-directive to suppress it.
...
This issue affects downstream projects. For example, Bitcoin Core sets "errors": {"dev": true} in its "dev-mode" preset, which makes the configuration step fail.
This PR introduces a project-wide interface library, following the approach used in Bitcoin Core.