Files
cmake/Tests/RunCMake/Diagnostics/NonTargetDirectives.cmake
Matthew Woehlke 00959286b9 Diagnostics: Warn about non-target directives
Introduce `CMD_STRICT` to act as a parent for warnings about allowed but
disrecommended usage. Introduce a warning that discourages use of
non-target directives (which modify the build environment for the entire
[sub]tree). Add notes to the official documentation recommending use of
target-specific alternatives. This has been accepted wisdom for quite
some time, but only some of the affected commands made any mention of
this in the documentation.
2026-07-28 11:38:20 -04:00

20 lines
506 B
CMake

cmake_minimum_required(VERSION 4.4)
project(NonTargetDirectives)
# Test diagnostics for non-target directives. Note that, because we don't
# need to actually compile anything, it doesn't matter if we use options,
# directories, or libraries that don't exist.
add_definitions(-DFOO)
add_compile_definitions(BAR)
add_compile_options(-fPIC)
add_link_options(-Wl,--no-undefined)
include_directories(${CMAKE_SOURCE_DIR}/include)
link_directories(${CMAKE_SOURCE_DIR}/lib)
link_libraries(/usr/lib/libm.so)