CMAKE_SKIP_INSTALL_RULES has very noisy warning behavior
Consider the following CMakeLists.txt:
cmake_minimum_required(VERSION 3.21)
project(test NONE)
install(FILES "foo.txt" DESTINATION "share")
If I run cmake -S . -B build -DCMAKE_SKIP_INSTALL_RULES=YES
, I get a warning... why?
$ cmake -S . -B build -DCMAKE_SKIP_INSTALL_RULES=YES
CMake Warning in CMakeLists.txt:
CMAKE_SKIP_INSTALL_RULES was enabled even though installation rules have
been specified
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/test/build
This looks to me like the warning reports simply that the feature works as intended. Are we all really supposed to guard our install rules with a check for this variable?
if (NOT CMAKE_SKIP_INSTALL_RULES)
install(...)
endif ()
I would think the variable should simply disable the install()
command (as if it were not written in the first place)... after all, that's what the documentation suggests.
Whether to disable generation of installation rules.
If
TRUE
, CMake will neither generate installation rules nor will it generatecmake_install.cmake
files. This variable isFALSE
by default.
As reported in #17694, this also misleads readers into thinking that it could work on a per-directory basis. But given the warning, I am confused by the feature as a global flag. If I'm expected to manually guard my install()
rules, then what is the point?