cmake: auto-detect KF5/KF6, fall back to KF5 if KF6 not found

This commit is contained in:
Levi Neely 2026-08-07 17:41:54 +02:00
parent 2d6e0ed787
commit 60c273e94a
1 changed files with 9 additions and 0 deletions

View File

@ -3,6 +3,15 @@ project(kde-ollie VERSION 0.1.0 LANGUAGES CXX)
option(OLLIE_KF5 "Build against KF5/Qt5 (Plasma 5.27)" OFF) option(OLLIE_KF5 "Build against KF5/Qt5 (Plasma 5.27)" OFF)
# Auto-detect: if OLLIE_KF5 not explicitly set, try KF6 first, fall back to KF5
if(NOT DEFINED OLLIE_KF5 OR NOT OLLIE_KF5)
find_package(KF6 QUIET COMPONENTS Runner CoreAddons)
if(NOT KF6_FOUND)
message(STATUS "KF6 not found, falling back to KF5")
set(OLLIE_KF5 ON)
endif()
endif()
# Suppress CMP0160 warnings from KF5 cmake files (read-only IMPORTED property) # Suppress CMP0160 warnings from KF5 cmake files (read-only IMPORTED property)
if(OLLIE_KF5) if(OLLIE_KF5)
cmake_policy(SET CMP0160 OLD) cmake_policy(SET CMP0160 OLD)