Update CMakeLists to follow KDE pattern

This commit is contained in:
Χγφτ Kompanion 2025-10-16 01:20:30 +02:00
parent 122df11433
commit 220be1744d
1 changed files with 17 additions and 42 deletions

View File

@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.22)
project(Kompanion LANGUAGES CXX)
set(PROJECT_VERSION "0.0.1")
set(QT_MIN_VERSION "6.8.0")
set(KF6_MIN_VERSION "6.8.0")
set(QT_MIN_VERSION "6.0.0")
set(KF6_MIN_VERSION "6.0.0")
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
set(CMAKE_CXX_STANDARD 20)
@ -37,18 +37,9 @@ if (KOMPANION_USE_GUI)
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Gui)
endif()
set(KOMPANION_KCONFIG_TARGET "")
find_package(KF6Config ${KF6_MIN_VERSION} QUIET)
if (KF6Config_FOUND)
set(KOMPANION_KCONFIG_TARGET KF6::ConfigCore)
else()
find_package(KF5Config QUIET)
if (KF5Config_FOUND)
set(KOMPANION_KCONFIG_TARGET KF5::ConfigCore)
endif()
endif()
add_feature_info("KConfig" NOT (KOMPANION_KCONFIG_TARGET STREQUAL "") "Persist settings via KConfig if available.")
find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS
Config
)
find_package(Qt6Test ${QT_MIN_VERSION} CONFIG QUIET)
set_package_properties(Qt6Test PROPERTIES
PURPOSE "Required for tests"
@ -60,19 +51,13 @@ add_feature_info("Qt6Test" Qt6Test_FOUND "Required for building tests")
set(KOMPANION_DB_INIT_INSTALL_DIR "${KDE_INSTALL_FULL_DATADIR}/kompanion/db/init")
install(DIRECTORY db/init/ DESTINATION ${KDE_INSTALL_DATADIR}/kompanion/db/init FILES_MATCHING PATTERN "*.sql")
option(BUILD_KOMPANION_CLI "Build Kompanion Qt command-line client" ON)
add_subdirectory(src/dal)
add_executable(kom_mcp
src/main.cpp
)
target_include_directories(kom_mcp PRIVATE src)
target_link_libraries(kom_mcp PRIVATE kom_dal)
if (NOT KOMPANION_KCONFIG_TARGET STREQUAL "")
target_link_libraries(kom_mcp PRIVATE ${KOMPANION_KCONFIG_TARGET})
target_compile_definitions(kom_mcp PRIVATE HAVE_KCONFIG)
endif()
target_link_libraries(kom_mcp PRIVATE kom_dal KF6::ConfigCore)
target_compile_options(kom_mcp PRIVATE -fexceptions)
target_compile_definitions(kom_mcp PRIVATE
PROJECT_SOURCE_DIR="${CMAKE_SOURCE_DIR}"
@ -83,7 +68,6 @@ install(TARGETS kom_mcp RUNTIME DESTINATION bin)
option(BUILD_TESTS "Build tests" ON)
if (BUILD_KOMPANION_CLI)
add_executable(kompanion
src/cli/KompanionApp.cpp
)
@ -91,19 +75,10 @@ if (BUILD_KOMPANION_CLI)
target_link_libraries(kompanion PRIVATE
Qt6::Core
Qt6::Sql
KF6::ConfigCore
kom_dal
)
target_compile_definitions(kompanion PRIVATE
PROJECT_SOURCE_DIR="${CMAKE_SOURCE_DIR}"
KOMPANION_DB_INIT_INSTALL_DIR="${KOMPANION_DB_INIT_INSTALL_DIR}"
)
if (NOT KOMPANION_KCONFIG_TARGET STREQUAL "")
target_link_libraries(kompanion PRIVATE ${KOMPANION_KCONFIG_TARGET})
target_compile_definitions(kompanion PRIVATE HAVE_KCONFIG)
endif()
target_compile_options(kompanion PRIVATE -fexceptions -Wno-unused-function)
install(TARGETS kompanion RUNTIME DESTINATION bin)
endif()
install(TARGETS kompanion RUNTIME ${KF_INSTALL_TARGETS_DEFAULT_ARGS})
if (BUILD_TESTS)
enable_testing()