Insufficient dependency definitions in cmake config
For the dependency definitions in CMakeLists.txt, required dependencies are defined in two different ways:
- by using
find_package(XCB 1.10 REQUIRED COMPONENTS ...
, CMake would fail at this line if dependency not found - by using
find_package(KDecoration2 ${PROJECT_VERSION} CONFIG) set_package_properties(KDecoration2 PROPERTIES TYPE REQUIRED PURPOSE "Required for server side decoration support" )
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
at the end.
The second method is fine if there is no other CMake code before that line depending on those required dependencies. In this Kdecoration2 example, at https://invent.kde.org/plasma/kwin/-/blob/master/src/plugins/kdecorations/aurorae/src/config/CMakeLists.txt?ref_type=heads#L1 the variable ${KDECORATION_KCM_PLUGIN_DIR}
is required but it's only defined by CMake code within KDecoration2. Since missing KDecoration2 will not cause FATAL_ON_MISSING_REQUIRED_PACKAGES until the feature summary stage, if KDecoration2 is not available we are seeing error:
Must specify INSTALL_NAMESPACE for kcm_auroraedecoration
Without mentioning the actual error is missing KDecoration2 dependency.
To solve these kind of issues, we can either move all required dependency definitions to the first method, or move all the add_package
and feature_summary
calls before any add_subdirectory
call, since CMake files in a subdirectory may have CMake config time dependency on a specific required dependency.