Warning, /network/smb4k/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 # SPDX-License-Identifier: BSD-2-Clause
0002 # SPDX-FileCopyrightText: 2019 Pino Toscano <pino@kde.org>
0003 # SPDX-FileCopyrightText: 2009-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0004 
0005 #
0006 # Minimum required CMake version
0007 #
0008 cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
0009 
0010 #
0011 # Version
0012 #
0013 set(VERSION_MAJOR 3)
0014 set(VERSION_MINOR 2)
0015 set(VERSION_PATCH 70)
0016 
0017 set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
0018 
0019 #
0020 # Project
0021 #
0022 project(smb4k)
0023 
0024 #
0025 # CMake policies
0026 #
0027 cmake_policy(SET CMP0037 NEW)
0028 
0029 if (POLICY CMP0071)
0030   cmake_policy(SET CMP0071 NEW)
0031 endif()
0032 
0033 #
0034 # Minimum required versions of Qt and Frameworks
0035 #
0036 set(QT_MIN_VERSION "5.15.8")
0037 set(KF5_MIN_VERSION "5.103.0")
0038 
0039 #
0040 # Options for building Smb4K
0041 #
0042 # Install plasmoid
0043 option(SMB4K_INSTALL_PLASMOID "Install the plasmoid" ON)
0044 
0045 # Build with KDSoap WS Discovery client
0046 option(SMB4K_WITH_WS_DISCOVERY "Build with WS-Discovery support for browsing" OFF)
0047 
0048 # Compile definitions
0049 # Error out when deprecated functions (in Qt <= 6.0.0) are encountered
0050 add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x060000)
0051 
0052 #
0053 # Required packages and includes
0054 #
0055 find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
0056 set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/)
0057 
0058 include(KDEInstallDirs)
0059 include(KDECompilerSettings NO_POLICY_SCOPE)
0060 include(KDECMakeSettings)
0061 include(FeatureSummary)
0062 include(ECMInstallIcons)
0063 include(ECMSetupVersion)
0064 include(CheckSymbolExists)
0065 include(KDEClangFormat)
0066 
0067 #
0068 # Version
0069 # 
0070 ecm_setup_version(${VERSION} VARIABLE_PREFIX SMB4K VERSION_HEADER smb4k_version.h)
0071 
0072 #
0073 # Source code formatting
0074 # 
0075 file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
0076 kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
0077 
0078 # Qt modules
0079 find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} NO_MODULE REQUIRED COMPONENTS
0080   Core
0081   Gui
0082   Network
0083   PrintSupport
0084   Qml
0085   Widgets
0086 )
0087 
0088 # Frameworks modules
0089 find_package(KF${QT_MAJOR_VERSION} ${KF5_MIN_VERSION} REQUIRED COMPONENTS
0090   Auth
0091   Completion
0092   Config
0093   ConfigWidgets
0094   CoreAddons
0095   Crash
0096   DBusAddons
0097   DNSSD
0098   DocTools
0099   I18n
0100   IconThemes
0101   JobWidgets
0102   KIO
0103   Notifications
0104   Solid
0105   Wallet
0106   WidgetsAddons
0107   WindowSystem
0108   XmlGui
0109 )
0110 
0111 if (QT_MAJOR_VERSION STREQUAL "6")
0112     find_package(KF6StatusNotifierItem ${KF_MIN_VERSION} REQUIRED)
0113 endif()
0114 
0115 # Install the plasmoid if desired
0116 if (SMB4K_INSTALL_PLASMOID)
0117   if (QT_MAJOR_VERSION STREQUAL "6")
0118     find_package(Plasma)
0119     set_package_properties(Plasma PROPERTIES TYPE RUNTIME)
0120   else()
0121     find_package(KF5 COMPONENTS Plasma)
0122     set_package_properties(KF5Plasma PROPERTIES TYPE RUNTIME)
0123   endif()
0124 endif()
0125 
0126 # Find libsmbclient.h
0127 find_package(Libsmbclient REQUIRED MODULE)
0128 
0129 # Check that the required smbc_* functions are provided
0130 set(CMAKE_REQUIRED_LIBRARIES ${LIBSMBCLIENT_LIBRARIES})
0131 set(CMAKE_REQUIRED_INCLUDES ${LIBSMBCLIENT_INCLUDE_DIRS})
0132 check_symbol_exists(smbc_setOptionProtocols libsmbclient.h HAVE_SMBC_PROTOCOL)
0133 
0134 if (NOT HAVE_SMBC_PROTOCOL)
0135   message(FATAL_ERROR "The function smbc_setOptionProtocols() is missing in Samba's client library's header file.")
0136 endif()
0137 
0138 # Find KDSoap client
0139 if (SMB4K_WITH_WS_DISCOVERY)
0140     if (QT_MAJOR_VERSION EQUAL "6")
0141       set(KDSOAP_PACKAGE KDSoap-qt6)
0142       set(KDSOAP_VERSION 2.0.0)
0143     else ()
0144       set(KDSOAP_PACKAGE KDSoap)
0145       set(KDSOAP_VERSION 1.9.0)
0146     endif ()
0147     message(STATUS "Building with WS-Discovery support (-DSMB4K_WITH_WS_DISCOVERY=OFF to disable)")
0148     find_package(${KDSOAP_PACKAGE} ${KDSOAP_VERSION} REQUIRED)
0149     find_package(KDSoapWSDiscoveryClient 0.2 REQUIRED)
0150 elseif(NOT SMB4K_WITH_WS_DISCOVERY)
0151     message(STATUS "Not building with WS-Discovery support (-DSMB4K_WITH_WS_DISCOVERY=ON to enable)")
0152 endif(SMB4K_WITH_WS_DISCOVERY)
0153 
0154 #
0155 # Make sure that Smb4K builds when several custom targets
0156 # with the same name exist (happens in the po directory).
0157 #
0158 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/po")
0159   set_property(GLOBAL PROPERTY ALLOW_DUPLICATE_CUSTOM_TARGETS ON)
0160 endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/po")
0161 
0162 add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055000)
0163 
0164 #
0165 # Add subdirectories
0166 #
0167 add_subdirectory(core)
0168 add_subdirectory(helpers)
0169 add_subdirectory(smb4k)
0170 add_subdirectory(doc)
0171 
0172 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/po")
0173   ki18n_install(po)
0174   if(KF5DocTools_FOUND)
0175     kdoctools_install(po)
0176   endif(KF5DocTools_FOUND)
0177 endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/po")
0178 
0179 #
0180 # Make adjustments according to the options set by the user
0181 #
0182 # Plasmoid: Notify the user and add the subdirectory if desired
0183 if (SMB4K_INSTALL_PLASMOID)
0184   message(STATUS "Installing plasmoid (-DSMB4K_INSTALL_PLASMOID=OFF to disable)")
0185   add_subdirectory(plasmoid)
0186 elseif(NOT SMB4K_INSTALL_PLASMOID)
0187   message(STATUS "Not installing plasmoid (-DSMB4K_INSTALL_PLASMOID=ON to enable)")
0188 endif(SMB4K_INSTALL_PLASMOID)
0189 
0190 ########### install files ###############
0191 
0192 feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)