kde/kf6-extra-cmake-modules: rebase to 6.28.0 (ECM) + teach version parser set(VERSION)
kf6-kcoreaddons 6.28.0 requires ECM >= 6.28.0 but the vendored ECM source/ was still 6.10.0: the sync engine skipped it because ECM's version marker is a bare set(VERSION "X.Y.Z") that the parser didn't recognize (only KF_VERSION / PROJECT_VERSION / RELEASE_SERVICE_VERSION). Re-lay ECM from its 6.28.0 source.tar (pure cmake modules, no Redox port) and teach both the sync engine and the validator to read set(VERSION) so this class is caught, not silently skipped.
This commit is contained in:
@@ -5,14 +5,13 @@ include:
|
||||
- project: sysadmin/ci-utilities
|
||||
file:
|
||||
- /gitlab-templates/linux.yml
|
||||
- /gitlab-templates/linux-static.yml
|
||||
- /gitlab-templates/freebsd.yml
|
||||
- /gitlab-templates/android-qt6.yml
|
||||
- /gitlab-templates/linux-qt6.yml
|
||||
- /gitlab-templates/linux-qt6-next.yml
|
||||
- /gitlab-templates/linux-qt6-static.yml
|
||||
- /gitlab-templates/windows.yml
|
||||
- /gitlab-templates/windows-static.yml
|
||||
- /gitlab-templates/freebsd-qt6.yml
|
||||
- /gitlab-templates/windows-qt6.yml
|
||||
- /gitlab-templates/alpine-qt6.yml
|
||||
|
||||
- /gitlab-templates/xml-lint.yml
|
||||
- /gitlab-templates/yaml-lint.yml
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
Options:
|
||||
per-test-timeout: 120
|
||||
require-passing-tests-on: [ 'Linux', 'FreeBSD', 'Windows' ]
|
||||
require-passing-tests-on: ['Linux', 'FreeBSD', 'Windows']
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
6.28.0
|
||||
@@ -5,13 +5,13 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#=============================================================================
|
||||
|
||||
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.29)
|
||||
|
||||
#
|
||||
# Preliminary setup
|
||||
#
|
||||
|
||||
set(VERSION "6.10.0") # handled by release scripts
|
||||
set(VERSION "6.28.0") # handled by release scripts
|
||||
|
||||
project(ECM
|
||||
VERSION "${VERSION}"
|
||||
@@ -40,7 +40,7 @@ set(SHARE_INSTALL_DIR share
|
||||
set(CMAKECONFIG_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/cmake/)
|
||||
|
||||
set(FIND_MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/find-modules/)
|
||||
set(KDE_MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/kde-modules/)
|
||||
set(KDE_MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/kde-modules)
|
||||
set(MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/modules/)
|
||||
set(TOOLCHAIN_MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/toolchain/)
|
||||
|
||||
|
||||
@@ -41,11 +41,6 @@ QtHelpBuilder.build_keywords = new_build_keywords
|
||||
|
||||
from docutils.parsers.rst import Directive, directives
|
||||
from docutils.transforms import Transform
|
||||
try:
|
||||
from docutils.utils.error_reporting import SafeString, ErrorString
|
||||
except ImportError:
|
||||
# error_reporting was not in utils before version 0.11:
|
||||
from docutils.error_reporting import SafeString, ErrorString
|
||||
|
||||
from docutils import io, nodes
|
||||
|
||||
@@ -80,13 +75,13 @@ class ECMModule(Directive):
|
||||
f = io.FileInput(source_path=path, encoding=encoding,
|
||||
error_handler=e_handler)
|
||||
except UnicodeEncodeError:
|
||||
raise self.severe('Problems with "%s" directive path:\n'
|
||||
'Cannot encode input file path "%s" '
|
||||
'(wrong locale?).' %
|
||||
(self.name, SafeString(path)))
|
||||
msg = ('Problems with "%s" directive path:\n'
|
||||
'Cannot encode input file path "%s" '
|
||||
'(wrong locale?).' % (self.name, path))
|
||||
raise self.severe(msg)
|
||||
except IOError as error:
|
||||
raise self.severe('Problems with "%s" directive path:\n%s.' %
|
||||
(self.name, ErrorString(error)))
|
||||
msg = 'Problems with "%s" directive path:\n%s.' % (self.name, error)
|
||||
raise self.severe(msg)
|
||||
raw_lines = f.read().splitlines()
|
||||
f.close()
|
||||
rst = None
|
||||
|
||||
@@ -32,6 +32,8 @@ target:
|
||||
Since 5.113.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
if(WIN32)
|
||||
find_program(7Zip_EXECUTABLE NAMES 7z 7za)
|
||||
else()
|
||||
|
||||
@@ -34,6 +34,8 @@ Deprecated: since 5.113, use :find-module:`Find7Zip`.
|
||||
Since 5.85.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_program(7z_EXECUTABLE NAMES 7z.exe 7za.exe)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
@@ -33,6 +33,8 @@ exported library, it must be made available by the package config file.
|
||||
Since 5.56.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_Canberra QUIET IMPORTED_TARGET libcanberra)
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ exported library, it must be made available by the package config file.
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CMakePushCheckState)
|
||||
@@ -57,13 +59,15 @@ find_path(EGL_INCLUDE_DIR
|
||||
HINTS
|
||||
${PKG_EGL_INCLUDE_DIRS}
|
||||
)
|
||||
find_library(EGL_LIBRARY
|
||||
NAMES
|
||||
EGL
|
||||
libEGL
|
||||
HINTS
|
||||
${PKG_EGL_LIBRARY_DIRS}
|
||||
)
|
||||
if(NOT EMSCRIPTEN)
|
||||
find_library(EGL_LIBRARY
|
||||
NAMES
|
||||
EGL
|
||||
libEGL
|
||||
HINTS
|
||||
${PKG_EGL_LIBRARY_DIRS}
|
||||
)
|
||||
endif()
|
||||
|
||||
# NB: We do *not* use the version information from pkg-config, as that
|
||||
# is the implementation version (eg: the Mesa version)
|
||||
@@ -95,7 +99,9 @@ if(EGL_INCLUDE_DIR)
|
||||
endif()
|
||||
|
||||
cmake_push_check_state(RESET)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}")
|
||||
if(NOT EMSCRIPTEN)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}")
|
||||
endif()
|
||||
list(APPEND CMAKE_REQUIRED_INCLUDES "${EGL_INCLUDE_DIR}")
|
||||
|
||||
check_cxx_source_compiles("
|
||||
|
||||
@@ -18,7 +18,7 @@ The following components are available::
|
||||
AVUTIL SWRESAMPLE SWSCALE POSTPROCESS
|
||||
|
||||
If no components are specified in the find_module call, the following ones
|
||||
will be choosen as default::
|
||||
will be chosen as default::
|
||||
|
||||
AVFORMAT AVUTIL AVCODEC
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ imported target:
|
||||
Since 5.41.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_GLIB2 QUIET glib-2.0)
|
||||
|
||||
@@ -81,7 +83,7 @@ find_library(GLIB2_GIO_LIBRARIES
|
||||
)
|
||||
|
||||
# search the glibconfig.h include dir under the same root where the library is found
|
||||
get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH)
|
||||
get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" DIRECTORY)
|
||||
|
||||
find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h
|
||||
PATH_SUFFIXES glib-2.0/include
|
||||
|
||||
@@ -52,6 +52,8 @@ A simple invocation would be:
|
||||
Since 5.35.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
|
||||
ecm_find_package_version_check(Gperf)
|
||||
|
||||
@@ -27,6 +27,8 @@ Installs a Android AAR library that has been created with ``gradle_add_aar``.
|
||||
Since 5.76.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../modules/QtVersionOption.cmake)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ target:
|
||||
Since 5.49.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
ecm_find_package_version_check(IcoTool)
|
||||
find_program(IcoTool_EXECUTABLE NAMES icotool)
|
||||
|
||||
@@ -9,7 +9,7 @@ FindInotify
|
||||
|
||||
Try to find inotify on this system. This finds:
|
||||
- libinotify on Unix like systems, or
|
||||
- the kernel's inotify on Linux systems.
|
||||
- the kernel's inotify.
|
||||
|
||||
This will define the following variables:
|
||||
|
||||
@@ -20,39 +20,63 @@ This will define the following variables:
|
||||
``Inotify_INCLUDE_DIRS``
|
||||
This has to be passed to target_include_directories()
|
||||
|
||||
On Linux and SunOS, the libraries and include directories are empty,
|
||||
even though ``Inotify_FOUND`` may be set to TRUE. This is because
|
||||
On some platforms like Linux and SunOS, the libraries and include directories
|
||||
are empty, even though ``Inotify_FOUND`` may be set to TRUE. This is because
|
||||
no special includes or libraries are needed. On other systems
|
||||
these may be needed to use inotify.
|
||||
|
||||
Since 5.32.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
# Reset the cache var before searching for sys/inotify.h
|
||||
# This is required, because on systems with native inotify we reset Inotify_INCLUDE_DIRS
|
||||
# to an empty string. Rerunning CMake in this case will reuse the empty variable
|
||||
# and we will not get into if(Inotify_INCLUDE_DIRS) the second time
|
||||
unset(Inotify_INCLUDE_DIRS CACHE)
|
||||
find_path(Inotify_INCLUDE_DIRS sys/inotify.h PATHS /usr/include NO_DEFAULT_PATH)
|
||||
find_path(Inotify_INCLUDE_DIRS sys/inotify.h)
|
||||
|
||||
if(Inotify_INCLUDE_DIRS)
|
||||
# On Linux and SunOS, there is no library to link against, on the BSDs there is.
|
||||
# On the BSD's, inotify is implemented through a library, libinotify.
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "SunOS")
|
||||
# On OSes with a kernel implementation, there is no library to link against.
|
||||
# On some others inotify is implemented through a library, libinotify.
|
||||
# If we found a header, but not a library, assume a kernel implementation
|
||||
find_library(Inotify_LIBRARIES NAMES inotify)
|
||||
if(NOT Inotify_LIBRARIES)
|
||||
set(Inotify_FOUND TRUE)
|
||||
set(Inotify_LIBRARIES "")
|
||||
set(Inotify_INCLUDE_DIRS "")
|
||||
set(Inotify_LIBRARIES "" CACHE STRING "" FORCE)
|
||||
set(Inotify_INCLUDE_DIRS "" CACHE STRING "" FORCE)
|
||||
else()
|
||||
find_library(Inotify_LIBRARIES NAMES inotify)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Inotify
|
||||
FOUND_VAR
|
||||
Inotify_FOUND
|
||||
REQUIRED_VARS
|
||||
Inotify_LIBRARIES
|
||||
Inotify_INCLUDE_DIRS
|
||||
)
|
||||
mark_as_advanced(Inotify_LIBRARIES Inotify_INCLUDE_DIRS)
|
||||
include(FeatureSummary)
|
||||
set_package_properties(Inotify PROPERTIES
|
||||
URL "https://github.com/libinotify-kqueue/"
|
||||
DESCRIPTION "inotify API on the *BSD family of operating systems."
|
||||
)
|
||||
# On FreeBSD 15+ we may end up with both in-kernel and libinotify
|
||||
# implementation. To discern between them, compare prefixes of
|
||||
# ${Inotify_INCLUDE_DIRS} and ${Inotify_LIBRARIES}: if we get
|
||||
# /usr/include and /usr/local/lib/libinotify.so then assume that the
|
||||
# kernel implementation is available and user wants it, instead of libinotify
|
||||
cmake_path(GET Inotify_INCLUDE_DIRS PARENT_PATH includes_prefix)
|
||||
cmake_path(GET Inotify_LIBRARIES PARENT_PATH lib_prefix)
|
||||
cmake_path(GET lib_prefix PARENT_PATH lib_prefix)
|
||||
cmake_path(COMPARE ${includes_prefix} EQUAL ${lib_prefix} prefixes_match)
|
||||
|
||||
if(NOT prefixes_match)
|
||||
set(Inotify_FOUND TRUE)
|
||||
set(Inotify_LIBRARIES "" CACHE STRING "" FORCE)
|
||||
set(Inotify_INCLUDE_DIRS "" CACHE STRING "" FORCE)
|
||||
else()
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Inotify
|
||||
FOUND_VAR
|
||||
Inotify_FOUND
|
||||
REQUIRED_VARS
|
||||
Inotify_LIBRARIES
|
||||
Inotify_INCLUDE_DIRS
|
||||
)
|
||||
include(FeatureSummary)
|
||||
set_package_properties(Inotify PROPERTIES
|
||||
URL "https://github.com/libinotify-kqueue/"
|
||||
DESCRIPTION "inotify API on the *BSD family of operating systems."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT TARGET Inotify::Inotify)
|
||||
add_library(Inotify::Inotify INTERFACE IMPORTED)
|
||||
|
||||
@@ -20,6 +20,8 @@ Once done this will define:
|
||||
Since 5.80.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PKG_iso_codes QUIET iso-codes)
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ will be set to true. Otherwise, it will be set to false.
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
|
||||
ecm_find_package_version_check(KF5)
|
||||
|
||||
@@ -25,6 +25,8 @@ will be set to true. Otherwise, it will be set to false.
|
||||
Since 6.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
|
||||
ecm_find_package_version_check(KF6)
|
||||
|
||||
@@ -39,6 +39,8 @@ exported library, it must be made available by the package config file.
|
||||
Since 5.53.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_EXIV2 QUIET exiv2)
|
||||
|
||||
@@ -86,6 +88,12 @@ if(LibExiv2_FOUND AND NOT TARGET LibExiv2::LibExiv2)
|
||||
IMPORTED_LOCATION "${LibExiv2_LIBRARIES}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LibExiv2_INCLUDE_DIRS}"
|
||||
)
|
||||
|
||||
if("${LibExiv2_LIBRARIES}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
|
||||
set_target_properties(LibExiv2::LibExiv2 PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${PC_EXIV2_LINK_LIBRARIES}"
|
||||
)
|
||||
endif()
|
||||
if (LibExiv2_VERSION VERSION_LESS 0.28.0)
|
||||
# exiv2 0.27 or older still uses std::auto_ptr, which is no longer available
|
||||
# by default when using newer C++ versions
|
||||
|
||||
@@ -39,6 +39,8 @@ exported library, it must be made available by the package config file.
|
||||
Since 1.3.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
|
||||
ecm_find_package_version_check(LibGit2)
|
||||
|
||||
@@ -29,6 +29,8 @@ If ``LibMount_FOUND`` is TRUE, it will also define the following imported target
|
||||
Since 5.83.0
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_LIBMOUNT QUIET IMPORTED_TARGET mount)
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ In addition, the following targets are defined:
|
||||
Since 5.80.0
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_program(SETCAP_EXECUTABLE NAMES setcap DOC "The setcap executable")
|
||||
|
||||
find_library(Libcap_LIBRARIES NAMES cap DOC "The cap (capabilities) library")
|
||||
|
||||
@@ -32,6 +32,8 @@ exported library, it must be made available by the package config file.
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
|
||||
ecm_find_package_version_check(OpenEXR)
|
||||
|
||||
@@ -32,6 +32,8 @@ will be defined.
|
||||
Since 5.54.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(ECMFindModuleHelpersStub)
|
||||
|
||||
ecm_find_package_version_check(PhoneNumber)
|
||||
|
||||
@@ -52,6 +52,8 @@ package config file.
|
||||
Since 5.19
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
|
||||
ecm_find_package_version_check(Poppler)
|
||||
|
||||
@@ -36,6 +36,8 @@ imported target:
|
||||
Since 5.41.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
# Support PulseAudio_MINIMUM_VERSION for compatibility:
|
||||
if(NOT PulseAudio_FIND_VERSION)
|
||||
set(PulseAudio_FIND_VERSION "${PulseAudio_MINIMUM_VERSION}")
|
||||
|
||||
@@ -12,6 +12,8 @@ Finds the Qt5 QHelpGenerator
|
||||
QHelpGenerator_EXECUTABLE - Path to executable
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../modules/QtVersionOption.cmake)
|
||||
find_package(Qt${QT_MAJOR_VERSION}Help QUIET)
|
||||
if (TARGET Qt5::qhelpgenerator)
|
||||
|
||||
+2
@@ -83,6 +83,8 @@ WaylandScanner is required and will be searched for.
|
||||
Since 1.4.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
include("${ECM_MODULE_DIR}/ECMQueryQt.cmake")
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ Finds the REUSE Tool by FSFE: https://github.com/fsfe/reuse-tool
|
||||
REUSETOOL_EXECUTABLE - Path to executable
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_program(REUSETOOL_EXECUTABLE NAMES reuse)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
@@ -34,6 +34,8 @@ will be available:
|
||||
Since 5.41.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
# NOTE: libsasl2.pc doesn't export the include dir.
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_Sasl2 libsasl2)
|
||||
|
||||
@@ -27,6 +27,8 @@ imported target:
|
||||
Since 5.44.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PKG_Libseccomp QUIET libseccomp)
|
||||
|
||||
|
||||
+3
-1
@@ -32,6 +32,8 @@ perform this task).
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
|
||||
ecm_find_package_version_check(SharedMimeInfo)
|
||||
@@ -69,7 +71,7 @@ mark_as_advanced(UPDATE_MIME_DATABASE_EXECUTABLE)
|
||||
function(UPDATE_XDG_MIMETYPES _path)
|
||||
get_filename_component(_xdgmimeDir "${_path}" NAME)
|
||||
if("${_xdgmimeDir}" STREQUAL packages )
|
||||
get_filename_component(_xdgmimeDir "${_path}" PATH)
|
||||
get_filename_component(_xdgmimeDir "${_path}" DIRECTORY)
|
||||
else()
|
||||
set(_xdgmimeDir "${_path}")
|
||||
endif()
|
||||
|
||||
@@ -31,6 +31,8 @@ target:
|
||||
Since 5.72.0
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
|
||||
pkg_check_modules(PC_TAGLIB QUIET taglib)
|
||||
|
||||
@@ -32,6 +32,8 @@ target:
|
||||
Since 5.57.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_UDEV QUIET libudev)
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ package config file.
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
|
||||
ecm_find_package_version_check(Wayland)
|
||||
|
||||
+2
@@ -18,6 +18,8 @@ This will define the following variables:
|
||||
The wayland protocols data directory
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PKG_wayland_protocols QUIET wayland-protocols)
|
||||
|
||||
|
||||
@@ -75,6 +75,8 @@ export this code.
|
||||
Since 1.4.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
|
||||
ecm_find_package_version_check(WaylandScanner)
|
||||
|
||||
@@ -41,6 +41,8 @@ exported library, it must be made available by the package config file.
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
|
||||
ecm_find_package_version_check(X11_XCB)
|
||||
|
||||
@@ -62,6 +62,8 @@ package config file.
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake)
|
||||
|
||||
ecm_find_package_version_check(XCB)
|
||||
|
||||
@@ -37,6 +37,8 @@ Bear in mind, however, that if the target is in the link interface of an
|
||||
exported library, it must be made available by the package config file.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PKG_epoxy QUIET epoxy)
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ target:
|
||||
Since 5.85.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_program(gzip_EXECUTABLE NAMES gzip)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
+20
-3
@@ -90,6 +90,10 @@ Since 5.17.0
|
||||
- ``APPLE_SUPPRESS_X11_WARNING`` option since 5.14.0
|
||||
- ``CMAKE_AUTORCC`` enabled by default when supported by CMake (>= 3.0) since 5.62.0
|
||||
|
||||
Since 6.25.0
|
||||
|
||||
Disable ``CMAKE_CXX_SCAN_FOR_MODULES`` by default.
|
||||
|
||||
Translations (deprecated)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
A fetch-translations target will be set up that will download translations
|
||||
@@ -112,6 +116,13 @@ All ``KDE_L10N_*`` options have been deprecated since 5.102.0, as translations
|
||||
are meanwhile present inside the source code repositories.
|
||||
#]=======================================================================]
|
||||
|
||||
# Explicitly pushing current policies on the stack, because this module
|
||||
# by its very purpose one day might also want to set policies to the caller scope
|
||||
# and consumers be asked to include using NO_POLICY_SCOPE.
|
||||
cmake_policy(PUSH)
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
################# RPATH handling ##################################
|
||||
|
||||
if(NOT KDE_SKIP_RPATH_SETTINGS)
|
||||
@@ -160,8 +171,6 @@ endif()
|
||||
|
||||
find_program(APPSTREAMCLI appstreamcli)
|
||||
function(appstreamtest)
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0064 NEW) # enable TEST operator
|
||||
if(TEST appstreamtest)
|
||||
# already configured
|
||||
elseif(APPSTREAMCLI)
|
||||
@@ -169,7 +178,6 @@ function(appstreamtest)
|
||||
else()
|
||||
message(STATUS "Could not set up the appstream test. appstreamcli is missing.")
|
||||
endif()
|
||||
cmake_policy(POP)
|
||||
endfunction()
|
||||
|
||||
if(NOT KDE_SKIP_TEST_SETTINGS)
|
||||
@@ -240,6 +248,12 @@ if(NOT KDE_SKIP_BUILD_SETTINGS)
|
||||
# and in KDE plugins don't have a prefix.
|
||||
set(CMAKE_SHARED_MODULE_PREFIX "")
|
||||
|
||||
# We use private Qt modules in various places, disable the warning about it
|
||||
set(QT_NO_PRIVATE_MODULE_WARNING ON)
|
||||
|
||||
# KDE code doesn't use modules, disable module scanning to avoid unnecessary work
|
||||
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
|
||||
|
||||
unset(EXECUTABLE_OUTPUT_PATH)
|
||||
unset(LIBRARY_OUTPUT_PATH)
|
||||
unset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
|
||||
@@ -388,3 +402,6 @@ if(NOT EXISTS ${CMAKE_SOURCE_DIR}/po AND NOT TARGET fetch-translations)
|
||||
execute_process(${fetch_commands})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# see begin
|
||||
cmake_policy(POP)
|
||||
|
||||
@@ -49,6 +49,8 @@ file in the directory with the following contents:
|
||||
Since 5.64
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
# try to find clang-format in path
|
||||
find_program(KDE_CLANG_FORMAT_EXECUTABLE clang-format)
|
||||
|
||||
@@ -59,7 +61,7 @@ if(KDE_CLANG_FORMAT_EXECUTABLE)
|
||||
file(READ ${CLANG_FORMAT_FILE} CLANG_FORMAT_CONTENTS LIMIT 1000)
|
||||
string(FIND "${CLANG_FORMAT_CONTENTS}" "This file got automatically created by ECM, do not edit" matchres)
|
||||
if(${matchres} EQUAL -1)
|
||||
message(WARNING "The .clang-format file already exists. Please remove it in order to use the file provided by ECM")
|
||||
message(DEBUG "Using existing .clang-format file provided by project.")
|
||||
else()
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/clang-format.cmake ${CLANG_FORMAT_FILE} @ONLY)
|
||||
endif()
|
||||
@@ -108,6 +110,7 @@ function(KDE_CLANG_FORMAT)
|
||||
else()
|
||||
add_custom_command(TARGET clang-format
|
||||
COMMAND
|
||||
POST_BUILD
|
||||
${CMAKE_COMMAND} -E echo "Could not set up the clang-format target as the clang-format executable is missing."
|
||||
)
|
||||
endif()
|
||||
|
||||
+29
-1
@@ -53,6 +53,12 @@ none of the above variables will be modified.
|
||||
|
||||
The following CMake C++ standard default variables are set:
|
||||
|
||||
For ``KDE_COMPILERSETTINGS_LEVEL`` >= 6.13:
|
||||
|
||||
- ``CMAKE_CXX_STANDARD``: ``20``
|
||||
- ``CMAKE_CXX_STANDARD_REQUIRED``: ``TRUE``
|
||||
- ``CMAKE_CXX_EXTENSIONS``: ``OFF``
|
||||
|
||||
For ``KDE_COMPILERSETTINGS_LEVEL`` >= 5.85:
|
||||
|
||||
- ``CMAKE_CXX_STANDARD``: ``17``
|
||||
@@ -156,6 +162,11 @@ Inclusion of this module defines the following variables:
|
||||
|
||||
Since 5.85
|
||||
|
||||
``ECM_FORCE_ASSERTS``
|
||||
Enable Q_ASSERT regardless of ``CMAKE_BUILD_TYPE``. Off by default.
|
||||
|
||||
Since 6.24
|
||||
|
||||
Example usages:
|
||||
|
||||
.. code-block:: cmake
|
||||
@@ -207,6 +218,10 @@ Example usages:
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
# Not setting cmake_policy, given this module is supposed to be in the same
|
||||
# policy scope as the includer (see also recommendation to use NO_POLICY_SCOPE)
|
||||
# So code here needs to be kept compatible with each new cmake version and new policies.
|
||||
|
||||
############################################################
|
||||
# Select and check KDE_COMPILERSETTINGS_LEVEL
|
||||
# For a specified version of KDE_COMPILERSETTINGS_LEVEL always the same set
|
||||
@@ -386,7 +401,10 @@ if (NOT CMAKE_C_STANDARD)
|
||||
endif()
|
||||
endif()
|
||||
if (NOT CMAKE_CXX_STANDARD)
|
||||
if (KDE_INTERNAL_COMPILERSETTINGS_LEVEL VERSION_GREATER_EQUAL 5.85.0)
|
||||
if (KDE_INTERNAL_COMPILERSETTINGS_LEVEL VERSION_GREATER_EQUAL 6.13.0)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
elseif (KDE_INTERNAL_COMPILERSETTINGS_LEVEL VERSION_GREATER_EQUAL 5.85.0)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
else()
|
||||
@@ -635,6 +653,11 @@ if (MSVC)
|
||||
# C4661: 'identifier' : no suitable definition provided for explicit
|
||||
# template instantiation request
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4661")
|
||||
# Enable warnings:
|
||||
# C5249: 'bitfield' of type 'enumeration_name' has named enumerators
|
||||
# with values that cannot be represented in the given bit field width
|
||||
# of 'bitfield_width'.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w35249")
|
||||
|
||||
if (CMAKE_CXX_STANDARD GREATER_EQUAL 11)
|
||||
# Ensure __cplusplus is correct, otherwise it defaults to 199711L which isn't true
|
||||
@@ -783,6 +806,11 @@ if (CMAKE_GENERATOR STREQUAL "Ninja" AND
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
|
||||
endif()
|
||||
|
||||
option(ECM_FORCE_ASSERTS "Enable Q_ASSERT regardless of build type" OFF)
|
||||
if (ECM_FORCE_ASSERTS)
|
||||
add_definitions(-DQT_FORCE_ASSERTS)
|
||||
endif()
|
||||
|
||||
include("${ECM_MODULE_DIR}/ECMEnableSanitizers.cmake")
|
||||
include("${ECM_MODULE_DIR}/ECMCoverageOption.cmake")
|
||||
|
||||
|
||||
+4
@@ -15,6 +15,10 @@ module to get more strict settings.
|
||||
Kept as is, to be removed on next backward-compatibility-breakage occasion.
|
||||
#]=======================================================================]
|
||||
|
||||
# Not setting cmake_policy, given this module is supposed to be in the same
|
||||
# policy scope as the includer (see also recommendation to use NO_POLICY_SCOPE)
|
||||
# So code here needs to be kept compatible with each new cmake version and new policies.
|
||||
|
||||
if (NOT CMAKE_CXX_STANDARD)
|
||||
if (ECM_GLOBAL_FIND_VERSION VERSION_GREATER_EQUAL 5.84.0)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
+4
-3
@@ -30,6 +30,10 @@ Qt-defined keywords like signals and slots will not be defined.
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
# Not setting cmake_policy, given this module is supposed to be in the same
|
||||
# policy scope as the includer (see also recommendation to use NO_POLICY_SCOPE)
|
||||
# So code here needs to be kept compatible with each new cmake version and new policies.
|
||||
|
||||
# No-one else should be using this module, at least by the time when requiring
|
||||
# ECM 5.85 as minimum, where also settings levels had been introduced for
|
||||
# KDECompilerSettings to satisfy the needs for stricter out-of-the-box
|
||||
@@ -50,9 +54,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/../modules/QtVersionOption.cmake)
|
||||
if (QT_MAJOR_VERSION EQUAL "6")
|
||||
find_package(Qt6Core)
|
||||
set(ENABLE_BSYMBOLICFUNCTIONS ${QT_FEATURE_reduce_relocations})
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||
else ()
|
||||
set(ENABLE_BSYMBOLICFUNCTIONS ON)
|
||||
endif()
|
||||
|
||||
+8
-3
@@ -24,18 +24,21 @@ This function will create a pre-commit hook which contains all the given checks.
|
||||
In addition to that, you can pass in paths to custom scripts that will be run as the pre-commit hook.
|
||||
If a custom hooks directory is set via ``core.hooksPath``, a warning is issued.
|
||||
|
||||
The created pre-commit script will also execute any custom user-provided
|
||||
scripts located in .git/hooks/pre-commit.d directory.
|
||||
|
||||
Checks:
|
||||
|
||||
- ``CLANG_FORMAT`` With this check enabled the ``git clang-format`` tool will be used to make sure that
|
||||
the changed parts are properly formatted. In case the changes are not properly formatted an error
|
||||
message with the command to preview the formatting changes and to format the files in place
|
||||
will be displayed. This tool will reuse the exsting ``.clang-format`` file, in case you
|
||||
will be displayed. This tool will reuse the existing ``.clang-format`` file, in case you
|
||||
want to use the one provided by ECM you can include ``include(KDEClangFormat)`` which will copy
|
||||
the file to the source dir. It is also recommended to reformat the entire project before enforcing
|
||||
the formatting using this commit hook.
|
||||
- ``JSON_SCHEMA`` Since 5.110, uses the check-jsonschema CLI tool to ensure that all files are valid JSON and
|
||||
- ``JSON_SCHEMA`` Since 5.110, uses the check-jsonschema CLI tool to ensure that all files are valid JSON and
|
||||
match the KPluginMetaData spec. This only applied if the JSON file has a "KPlugin" object in its root.
|
||||
To ignore invalid files, for example for testing error handling, given files can be exlcuded in the .kde-ci.yml file
|
||||
To ignore invalid files, for example for testing error handling, given files can be excluded in the .kde-ci.yml file
|
||||
Define Options.json-validate-ignore with an array of the files you want to ignore
|
||||
|
||||
Example usage:
|
||||
@@ -48,6 +51,8 @@ Example usage:
|
||||
Since 5.79
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
# try to find clang-format in path
|
||||
find_program(KDE_CLANG_FORMAT_EXECUTABLE clang-format)
|
||||
find_program(KDE_CHECK_JSONSCHEMA_EXECUTABLE check-jsonschema)
|
||||
|
||||
@@ -11,5 +11,7 @@ Compatibility wrapper around :kde-module:`KDEInstallDirs5`.
|
||||
Since 5.82.0, prior to that equivalent to :kde-module:`KDEInstallDirs5`.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../modules/QtVersionOption.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/KDEInstallDirs${QT_MAJOR_VERSION}.cmake)
|
||||
|
||||
@@ -186,11 +186,21 @@ deprecated counterparts) may be passed to the ``DESTINATION`` options of
|
||||
``install()`` commands for the corresponding file type. They are set in the
|
||||
CMake cache, and so the defaults above can be overridden by users.
|
||||
|
||||
Note that the ``KDE_INSTALL_<dir>``, ``CMAKE_INSTALL_<dir>`` or deprecated
|
||||
form of the variable can be changed using CMake command line variable
|
||||
definitions; in either case, all forms of the variable will be affected. The
|
||||
effect of passing multiple forms of the same variable on the command line
|
||||
(such as ``KDE_INSTALL_BINDIR`` and ``CMAKE_INSTALL_BINDIR`` is undefined.
|
||||
Note that if the ``KDE_INSTALL_<dir>``, ``CMAKE_INSTALL_<dir>`` or deprecated
|
||||
form of the variable are set before ``include(KDEInstallDirs)``, they won't be
|
||||
overwritten by ``KDEInstallDirs``. This is useful if you eg. want to use CMake
|
||||
command line variable definitions to set custom values. There are however some
|
||||
other implications you need to be aware of: ``GNUInstallDirs`` defines
|
||||
``CMAKE_INSTALL_<dir>`` variables, before hence ``KDEInstallDirs`` will not
|
||||
overwrite them if it is included later. In most cases this is unintended and
|
||||
if you need to include ``GNUInstallDirs`` you should always do that after after
|
||||
you included ``KDEInstallDirs``.
|
||||
|
||||
If you set custom values to ``KDE_INSTALL_<dir>`` or ``CMAKE_INSTALL_<dir>``
|
||||
as described above always both forms of the variable will be affected.
|
||||
The effect of passing multiple forms of the same variable eg. on the command
|
||||
line (such as ``KDE_INSTALL_BINDIR`` and ``CMAKE_INSTALL_BINDIR``) is undefined
|
||||
and should be avoided.
|
||||
|
||||
The variable ``KDE_INSTALL_TARGETS_DEFAULT_ARGS`` is also defined (along with
|
||||
the deprecated form ``INSTALL_TARGETS_DEFAULT_ARGS``). This should be used
|
||||
@@ -227,6 +237,8 @@ for the prefix into a process.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/KDEInstallDirsCommon.cmake)
|
||||
|
||||
if(WIN32)
|
||||
|
||||
@@ -100,6 +100,8 @@ where ``<dir>`` is one of (default values in parentheses):
|
||||
documentation bundles in QCH format for Qt-extending libraries (``DATAROOTDIR/doc/qch`` or qtpaths's ``QT_INSTALL_DOCS``)
|
||||
``QCHDIR``
|
||||
documentation bundles in QCH format (``DATAROOTDIR/doc/qch``)
|
||||
``QTMETATYPESDIR``
|
||||
Qt metatypes files (``metatypes`` or qtpaths's ``QT_INSTALL_ARCHDATA/metatypes``). Since 6.27.
|
||||
``MANDIR``
|
||||
man documentation (``DATAROOTDIR/man``)
|
||||
``INFODIR``
|
||||
@@ -149,11 +151,22 @@ The ``KDE_INSTALL_<dir>`` variables may be passed to the ``DESTINATION`` options
|
||||
``install()`` commands for the corresponding file type. They are set in the
|
||||
CMake cache, and so the defaults above can be overridden by users.
|
||||
|
||||
Note that the ``KDE_INSTALL_<dir>`` or ``CMAKE_INSTALL_<dir>`` variables
|
||||
can be changed using CMake command line variable definitions; in either case,
|
||||
both forms of the variable will be affected. The effect of passing multiple
|
||||
forms of the same variable on the command line
|
||||
(such as ``KDE_INSTALL_BINDIR`` and ``CMAKE_INSTALL_BINDIR`` is undefined.
|
||||
Note that if the ``KDE_INSTALL_<dir>`` or ``CMAKE_INSTALL_<dir>`` variables are set
|
||||
before ``include(KDEInstallDirs)``, they won't be overwritten by ``KDEInstallDirs``.
|
||||
This is useful if you eg. want to use CMake command line variable definitions to
|
||||
set custom values. There are however some other implications you need to be aware of:
|
||||
``GNUInstallDirs`` defines ``CMAKE_INSTALL_<dir>`` variables, before hence
|
||||
``KDEInstallDirs`` will not overwrite them if it is included later. In most cases
|
||||
this is unintended and if you need to include ``GNUInstallDirs`` you should always do
|
||||
that after after you included ``KDEInstallDirs``. Be aware that Qt uses
|
||||
``GNUInstallDirs`` since Qt6 and hence ``find_package(Qt6 ...)`` is equivalent to
|
||||
``include(GNUInstallDirs)`` in this case.
|
||||
|
||||
If you set custom values to ``KDE_INSTALL_<dir>`` or ``CMAKE_INSTALL_<dir>``
|
||||
as described above always both forms of the variable will be affected.
|
||||
The effect of passing multiple forms of the same variable eg. on the command
|
||||
line (such as ``KDE_INSTALL_BINDIR`` and ``CMAKE_INSTALL_BINDIR``) is undefined
|
||||
and should be avoided.
|
||||
|
||||
The variable ``KDE_INSTALL_TARGETS_DEFAULT_ARGS`` is also defined.
|
||||
This should be used when libraries or user-executable applications are installed,
|
||||
@@ -183,6 +196,8 @@ file that allows to easily incorporate the necessary environment variables
|
||||
for the prefix into a process.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
set(KDE_INSTALL_DIRS_NO_DEPRECATED TRUE)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/KDEInstallDirsCommon.cmake)
|
||||
@@ -227,6 +242,18 @@ if(KDE_INSTALL_USE_QT_SYS_PATHS)
|
||||
file(RELATIVE_PATH qt_qml_dir ${qt_install_prefix_dir} ${qt_qml_dir})
|
||||
endif()
|
||||
_define_absolute(QMLDIR ${qt_qml_dir} "QtQuick2 imports")
|
||||
|
||||
ecm_query_qt(qt_archdata_dir QT_INSTALL_ARCHDATA)
|
||||
|
||||
if(_qt_prefix_is_cmake_install_prefix)
|
||||
file(RELATIVE_PATH qt_archdata_dir ${qt_install_prefix_dir} ${qt_archdata_dir})
|
||||
endif()
|
||||
|
||||
if (qt_archdata_dir)
|
||||
_define_absolute(QTMETATYPESDIR "${qt_archdata_dir}/metatypes" "Qt metatypes files")
|
||||
else()
|
||||
_define_non_cache(QTMETATYPESDIR "metatypes")
|
||||
endif()
|
||||
else()
|
||||
set(_pluginsDirParent LIBDIR)
|
||||
if (ANDROID)
|
||||
@@ -238,6 +265,8 @@ else()
|
||||
|
||||
_define_relative(QMLDIR LIBDIR "qml"
|
||||
"QtQuick2 imports")
|
||||
|
||||
_define_non_cache(QTMETATYPESDIR "metatypes")
|
||||
endif()
|
||||
|
||||
_define_relative(PLUGINDIR QTPLUGINDIR ""
|
||||
|
||||
+49
-25
@@ -54,6 +54,7 @@ set(_gnu_install_dirs_vars
|
||||
SYSCONFDIR
|
||||
SHAREDSTATEDIR
|
||||
LOCALSTATEDIR
|
||||
RUNSTATEDIR
|
||||
LIBDIR
|
||||
INCLUDEDIR
|
||||
OLDINCLUDEDIR
|
||||
@@ -88,15 +89,14 @@ macro(_define_relative varname parent subdir docstring)
|
||||
if(${ARGC} GREATER 5)
|
||||
set(_aliasname "${ARGV5}")
|
||||
endif()
|
||||
|
||||
set(_cmakename)
|
||||
if(NOT KDE_INSTALL_DIRS_NO_CMAKE_VARIABLES)
|
||||
list(FIND _gnu_install_dirs_vars "${varname}" _list_offset)
|
||||
set(_cmakename_is_deprecated FALSE)
|
||||
if(NOT KDE_INSTALL_DIRS_NO_DEPRECATED OR NOT _list_offset EQUAL -1)
|
||||
# The CMake name (CMAKE_INSTALL_<something>) is only supported for those variables
|
||||
# defined by the GNUInstallDirs. Also in older ECM versions we supported CMAKE_INSTALL_<something>
|
||||
# for all variables and if deprecated behaviour is enabled we still do
|
||||
if((${varname} IN_LIST _gnu_install_dirs_vars) OR NOT KDE_INSTALL_DIRS_NO_DEPRECATED)
|
||||
set(_cmakename CMAKE_INSTALL_${varname})
|
||||
if(_list_offset EQUAL -1)
|
||||
set(_cmakename_is_deprecated TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -121,7 +121,9 @@ macro(_define_relative varname parent subdir docstring)
|
||||
endif()
|
||||
|
||||
if(KDE_INSTALL_${varname})
|
||||
# The name was given (eg. on the command line or in the projects CMakeLists.txt)
|
||||
# make sure the cache documentation is set correctly
|
||||
|
||||
get_property(_iscached CACHE KDE_INSTALL_${varname} PROPERTY VALUE SET)
|
||||
if (_iscached)
|
||||
# make sure the docs are still set if it was passed on the command line
|
||||
@@ -132,33 +134,51 @@ macro(_define_relative varname parent subdir docstring)
|
||||
PROPERTY TYPE PATH)
|
||||
endif()
|
||||
elseif(${_oldstylename})
|
||||
message(DEPRECATION "${_oldstylename} is deprecated, use KDE_INSTALL_${varname} instead.")
|
||||
# The old name was given (probably on the command line): move
|
||||
# it to the new name
|
||||
# If KDE_INSTALL_DIRS_NO_DEPRECATED is true, _oldstylename will be empty due to
|
||||
# the logic on top of this macro, hence you will never end up here in this case
|
||||
message(DEPRECATION "${_oldstylename} is deprecated, use KDE_INSTALL_${varname} instead.")
|
||||
# The old name was given (probably on the command line): move it to the new name
|
||||
set(KDE_INSTALL_${varname} "${${_oldstylename}}"
|
||||
CACHE PATH
|
||||
"${docstring} (${_docpath})"
|
||||
FORCE)
|
||||
elseif(${_aliasname})
|
||||
# The alias variable was given (probably on the command line): move
|
||||
# it to the new name
|
||||
# The alias variable was given (probably on the command line): move it to the new name
|
||||
set(KDE_INSTALL_${varname} "${${_aliasname}}"
|
||||
CACHE PATH
|
||||
"${docstring} (${_docpath})"
|
||||
FORCE)
|
||||
elseif(${_cmakename})
|
||||
if(_cmakename_is_deprecated)
|
||||
message(DEPRECATION "${_cmakename} is deprecated, use KDE_INSTALL_${varname} instead.")
|
||||
# CMake name was given (eg. on the command line)
|
||||
if(NOT ${varname} IN_LIST _gnu_install_dirs_vars)
|
||||
# CMake name is NOT one of those defined by GNUInstallDirs. This is deprecated.
|
||||
if(NOT KDE_INSTALL_DIRS_NO_DEPRECATED)
|
||||
# Deprecated behavior is enabled, so allow this anyways
|
||||
message(DEPRECATION "${_cmakename} is deprecated, use KDE_INSTALL_${varname} instead.")
|
||||
|
||||
set(KDE_INSTALL_${varname} "${${_cmakename}}"
|
||||
CACHE PATH
|
||||
"${docstring} (${_docpath})"
|
||||
FORCE)
|
||||
endif()
|
||||
else()
|
||||
# CMake name is one of those defined by GNUInstallDirs.
|
||||
# Note: If KDE_INSTALL_DIRS_NO_CMAKE_VARIABLES is true, _cmakename will be empty due to
|
||||
# the logic on top of this macro, hence you will never end up here in this case
|
||||
|
||||
message(WARNING "KDE_INSTALL_${varname} got its value from ${_cmakename}. In most cases this is unintended, check if you included GNUInstallDirs before KDEInstallDirs. Some third party modules include GNUInstallDirs too so eg. find_package(Qt6 ...) is equivalent to include(GNUInstallDirs). If you set ${_cmakename} deliberately before including KDEInstallDirs its recommended to use KDE_INSTALL_${varname} instead to suppress this message.")
|
||||
|
||||
# The CMAKE_ name was given (probably on the command line): move it to the new name
|
||||
set(KDE_INSTALL_${varname} "${${_cmakename}}"
|
||||
CACHE PATH
|
||||
"${docstring} (${_docpath})"
|
||||
FORCE)
|
||||
endif()
|
||||
# The CMAKE_ name was given (probably on the command line): move
|
||||
# it to the new name
|
||||
set(KDE_INSTALL_${varname} "${${_cmakename}}"
|
||||
CACHE PATH
|
||||
"${docstring} (${_docpath})"
|
||||
FORCE)
|
||||
else()
|
||||
# insert an empty value into the cache, indicating the default
|
||||
# should be used (including compatibility vars above)
|
||||
endif()
|
||||
|
||||
if(NOT KDE_INSTALL_${varname})
|
||||
# KDE_INSTALL_${varname} has not been set yet elsewhere so insert an empty value
|
||||
# into the cache, indicating the default should be used (including compatibility vars above)
|
||||
set(KDE_INSTALL_${varname} ""
|
||||
CACHE PATH "${docstring} (${_docpath})")
|
||||
set(KDE_INSTALL_${varname} "${_realpath}")
|
||||
@@ -210,8 +230,7 @@ macro(_define_non_cache varname value)
|
||||
endif()
|
||||
|
||||
if(NOT KDE_INSTALL_DIRS_NO_CMAKE_VARIABLES)
|
||||
list(FIND _gnu_install_dirs_vars "${varname}" _list_offset)
|
||||
if(NOT KDE_INSTALL_DIRS_NO_DEPRECATED OR NOT _list_offset EQUAL -1)
|
||||
if(NOT KDE_INSTALL_DIRS_NO_DEPRECATED OR (${varname} IN_LIST _gnu_install_dirs_vars))
|
||||
set(CMAKE_INSTALL_${varname} "${KDE_INSTALL_${varname}}")
|
||||
set(CMAKE_INSTALL_FULL_${varname} "${KDE_INSTALL_FULL_${varname}}")
|
||||
endif()
|
||||
@@ -261,7 +280,12 @@ _define_absolute(INCLUDEDIR "include"
|
||||
"C and C++ header files"
|
||||
INCLUDE_INSTALL_DIR)
|
||||
|
||||
_define_absolute(LOCALSTATEDIR "var"
|
||||
set(_default_localstate_dir "var")
|
||||
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
|
||||
set(_default_localstate_dir "/var")
|
||||
endif()
|
||||
|
||||
_define_absolute(LOCALSTATEDIR ${_default_localstate_dir}
|
||||
"modifiable single-machine data")
|
||||
|
||||
_define_absolute(SHAREDSTATEDIR "com"
|
||||
|
||||
+3
-1
@@ -18,6 +18,8 @@ The check can be ignored by setting ``KF_IGNORE_PLATFORM_CHECK`` to ``ON``.
|
||||
Since 5.93
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
option(KF_IGNORE_PLATFORM_CHECK "Ignore the supported platform check against metainfo.yaml" OFF)
|
||||
if ("$ENV{KF_IGNORE_PLATFORM_CHECK}" STREQUAL "ON")
|
||||
message(WARNING "KF_IGNORE_PLATFORM_CHECK set to ON from the environment")
|
||||
@@ -74,6 +76,6 @@ if (NOT "${KF_IGNORE_PLATFORM_CHECK}")
|
||||
endforeach()
|
||||
|
||||
if (NOT _MetainfoFoundSupportedPlatform)
|
||||
message(FATAL_ERROR "Your current platform '${CMAKE_SYSTEM_NAME}' is not supported. The list of supported platorms is '${_MetainfoSupportedPlatforms}'.If you think this is a mistake or you are working on enabling the platform please build with the KF_IGNORE_PLATFORM_CHECK variable set to true")
|
||||
message(FATAL_ERROR "Your current platform '${CMAKE_SYSTEM_NAME}' is not supported. The list of supported platforms is '${_MetainfoSupportedPlatforms}'.If you think this is a mistake or you are working on enabling the platform please build with the KF_IGNORE_PLATFORM_CHECK variable set to true")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
+17
-3
@@ -64,14 +64,26 @@ Deprecated:
|
||||
|
||||
Multiple templates can be passed at once.
|
||||
|
||||
This function does nothing when cross-compiling.
|
||||
Unless setting KDE_INSTALL_APP_TEMPLATES, this function is skipped when cross-compiling.
|
||||
|
||||
|
||||
Since 5.18
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(KDEInstallDirs)
|
||||
|
||||
if(NOT CMAKE_CROSSCOMPILING)
|
||||
set(default_kde_install_app_templates ON)
|
||||
else()
|
||||
set(default_kde_install_app_templates OFF)
|
||||
endif()
|
||||
|
||||
option(KDE_INSTALL_APP_TEMPLATES "Skip installation of KAppTemplate/KDevelop compatible application templates" ${default_kde_install_app_templates})
|
||||
|
||||
function(kde_package_app_templates)
|
||||
if (CMAKE_CROSSCOMPILING)
|
||||
if (NOT KDE_INSTALL_APP_TEMPLATES)
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -110,7 +122,7 @@ function(kde_package_app_templates)
|
||||
foreach(_templateName ${ARG_TEMPLATES})
|
||||
get_filename_component(_tmp_file ${_templateName} ABSOLUTE)
|
||||
get_filename_component(_baseName ${_tmp_file} NAME_WE)
|
||||
set(_template ${CMAKE_CURRENT_BINARY_DIR}/${_baseName}.tar.bz2)
|
||||
set(_template ${CMAKE_BINARY_DIR}/${KDE_INSTALL_KAPPTEMPLATESDIR}/${_baseName}.tar.bz2)
|
||||
|
||||
# also enlist directories as deps to catch file removals
|
||||
file(GLOB_RECURSE _subdirs_entries LIST_DIRECTORIES true CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${_templateName}/*")
|
||||
@@ -130,6 +142,7 @@ function(kde_package_app_templates)
|
||||
|
||||
# Make tar archive reproducible, the arguments are only available with GNU tar
|
||||
add_custom_command(OUTPUT ${_template}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${KDE_INSTALL_KAPPTEMPLATESDIR}
|
||||
COMMAND ${_tar_executable} ARGS
|
||||
--exclude .kdev_ignore --exclude .svn
|
||||
--sort=name
|
||||
@@ -143,6 +156,7 @@ function(kde_package_app_templates)
|
||||
)
|
||||
else()
|
||||
add_custom_command(OUTPUT ${_template}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${KDE_INSTALL_KAPPTEMPLATESDIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E tar "cvfj" ${_template} .
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_templateName}
|
||||
DEPENDS ${_subdirs_entries}
|
||||
|
||||
+9
@@ -15,6 +15,15 @@ if (CMAKE_CROSSCOMPILING)
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_package(Python3 COMPONENTS Interpreter)
|
||||
if (Python3_EXECUTABLE)
|
||||
execute_process(COMMAND ${Python3_EXECUTABLE} -Esc "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase': '${CMAKE_INSTALL_PREFIX}', 'base': '${CMAKE_INSTALL_PREFIX}'}))" OUTPUT_VARIABLE sysconfig_output)
|
||||
string(STRIP ${sysconfig_output} PYTHON_INSTALL_DIR)
|
||||
|
||||
set(SH_EXPORT_PYTHONPATH "export PYTHONPATH=\"${PYTHON_INSTALL_DIR}\":$PYTHONPATH")
|
||||
set(FISH_EXPORT_PYTHONPATH "set -x --path PYTHONPATH \"${PYTHON_INSTALL_DIR}\" $PYTHONPATH")
|
||||
endif()
|
||||
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/prefix.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/prefix.sh @ONLY)
|
||||
|
||||
find_program(FISH_EXECUTABLE fish)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
file(GLOB install_done "${INSTALL_FILES}")
|
||||
if (install_done)
|
||||
file(READ "${INSTALL_FILES}" out)
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
Language: JavaScript
|
||||
DisableFormat: true
|
||||
---
|
||||
Language: Json
|
||||
DisableFormat: false
|
||||
IndentWidth: 4
|
||||
---
|
||||
|
||||
# Style for C++
|
||||
Language: Cpp
|
||||
|
||||
+22
@@ -1,3 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
${PRE_COMMIT_SCRIPTS}
|
||||
|
||||
RESULT=$?
|
||||
if [ $RESULT != 0 ]; then
|
||||
exit $RESULT
|
||||
fi
|
||||
|
||||
# If the user has custom commit hooks defined in pre-commit.d directory,
|
||||
# execute them
|
||||
PRE_COMMIT_D_DIR="$(dirname "$0")/pre-commit.d/"
|
||||
|
||||
if [ -d "$PRE_COMMIT_D_DIR" ]; then
|
||||
for PRE_COMMIT_D_HOOK in "$PRE_COMMIT_D_DIR"/*; do
|
||||
./"$PRE_COMMIT_D_HOOK"
|
||||
RESULT=$?
|
||||
if [ $RESULT != 0 ]; then
|
||||
echo "$PRE_COMMIT_D_HOOK returned non-zero: $RESULT, commit aborted"
|
||||
exit $RESULT
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -14,3 +14,5 @@ export QT_QUICK_CONTROLS_STYLE_PATH=@KDE_INSTALL_FULL_QMLDIR@/QtQuick/Controls.2
|
||||
export MANPATH=@KDE_INSTALL_FULL_DATADIR@/man:${MANPATH:-/usr/local/share/man:/usr/share/man}
|
||||
|
||||
export SASL_PATH=@KDE_INSTALL_FULL_LIBDIR@/sasl2:${SASL_PATH:-/usr/@CMAKE_INSTALL_LIBDIR@/sasl2}
|
||||
|
||||
@SH_EXPORT_PYTHONPATH@
|
||||
|
||||
@@ -20,3 +20,5 @@ set -x --path QT_PLUGIN_PATH "@KDE_INSTALL_FULL_QTPLUGINDIR@" $QT_PLUGIN_PATH
|
||||
set -x --path QML2_IMPORT_PATH "@KDE_INSTALL_FULL_QMLDIR@" $QML2_IMPORT_PATH
|
||||
|
||||
set -x --path QT_QUICK_CONTROLS_STYLE_PATH "@KDE_INSTALL_FULL_QMLDIR@/QtQuick/Controls.2/" $QT_QUICK_CONTROLS_STYLE_PATH
|
||||
|
||||
@FISH_EXPORT_PYTHONPATH@
|
||||
|
||||
@@ -14,6 +14,8 @@ std:atomic.
|
||||
Since 5.75.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CheckLibraryExists)
|
||||
|
||||
|
||||
@@ -47,8 +47,32 @@ The following variables impact the behavior:
|
||||
This allows to separate e.g. development files from what ends up in the APK.
|
||||
|
||||
Since 6.0.0
|
||||
|
||||
For automatically deriving APK versions from CMake this creates a ``ecm-version.gradle``
|
||||
file which defines the following variables:
|
||||
``ecmVersionName``: Set to ``PROJECT_VERSION``
|
||||
``ecmVersionCode``: Derived from the current time in local builds, and from ``CI_PIPELINE_CREATED_AT``
|
||||
in builds from Gitlab pipelines. This ensures a strictly increasing version code as well as
|
||||
synchronized version codes for APKs of multiple architectures when build in a Gitlab pipeline.
|
||||
|
||||
This can be included by calling ``apply from: '../ecm-version.gradle'`` in the project's ``build.gradle``
|
||||
file and is typically used in manifest placeholders:
|
||||
|
||||
```
|
||||
defaultConfig {
|
||||
versionName ecmVersionName
|
||||
versionCode ecmVersionCode
|
||||
manifestPlaceholders = [versionName: ecmVersionName, versionCode: ecmVersionCode]
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Since 6.12.0
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
# make ExecuteCoreModules test pass on Qt5
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../modules/QtVersionOption.cmake)
|
||||
if (QT_MAJOR_VERSION EQUAL 5)
|
||||
@@ -69,12 +93,22 @@ function (ecm_add_android_apk TARGET)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# F-Droid assumes that APKs of different versions have different filenames;
|
||||
# therefore, on CI we add the CI_PIPELINE_CREATED_AT timestamp to the APK filename
|
||||
set(APK_NAME_TIMESTAMP "")
|
||||
if (DEFINED ENV{CI_PIPELINE_CREATED_AT})
|
||||
# remove all non-digits from an ISO 8601 formatted timestamp like 2025-05-21T16:00:54Z
|
||||
string(REGEX REPLACE "^([0-9]+)-([0-9]+)-([0-9]+)T([0-9]+):([0-9]+):([0-9]+).*$" "-\\1\\2\\3\\4\\5\\6" APK_NAME_TIMESTAMP "$ENV{CI_PIPELINE_CREATED_AT}")
|
||||
endif()
|
||||
|
||||
configure_file(${_ECM_TOOLCHAIN_DIR}/ecm-version.gradle.in ${CMAKE_BINARY_DIR}/ecm-version.gradle)
|
||||
|
||||
set(APK_NAME "${TARGET}")
|
||||
if (ARGS_PACKAGE_NAME)
|
||||
set(APK_NAME "${ARGS_PACKAGE_NAME}")
|
||||
endif()
|
||||
|
||||
set(APK_OUTPUT_DIR "${CMAKE_BINARY_DIR}/${TARGET}_build_apk/")
|
||||
set(APK_OUTPUT_DIR "${CMAKE_BINARY_DIR}/${APK_NAME}_build_apk/")
|
||||
set(APK_EXECUTABLE_PATH "${APK_OUTPUT_DIR}/libs/${CMAKE_ANDROID_ARCH_ABI}/lib${APK_NAME}_${CMAKE_ANDROID_ARCH_ABI}.so")
|
||||
|
||||
set(QML_IMPORT_PATHS "")
|
||||
@@ -151,7 +185,7 @@ function (ecm_add_android_apk TARGET)
|
||||
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/ranlib "${CMAKE_RANLIB}")
|
||||
set(CREATEAPK_TARGET_NAME "create-apk-${APK_NAME}")
|
||||
set(APK_NAME_FULL "${APK_NAME}-${CMAKE_ANDROID_ARCH_ABI}.apk")
|
||||
set(APK_NAME_FULL "${APK_NAME}${APK_NAME_TIMESTAMP}-${CMAKE_ANDROID_ARCH_ABI}.apk")
|
||||
add_custom_target(${CREATEAPK_TARGET_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Generating ${APK_NAME_FULL} with $<TARGET_FILE:Qt6::androiddeployqt>"
|
||||
|
||||
@@ -83,6 +83,8 @@ macOS notes
|
||||
Since 1.7.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
function(ecm_add_app_icon appsources_or_target)
|
||||
set(options)
|
||||
set(oneValueArgs OUTFILE_BASENAME)
|
||||
@@ -368,7 +370,7 @@ macro(_ecm_add_app_icon_categorize_icons icons type known_sizes)
|
||||
|
||||
if (offset GREATER -1)
|
||||
list(APPEND ${type}_at_${size}px "${icon_full}")
|
||||
elseif()
|
||||
else()
|
||||
message(STATUS "not found ${type}_at_${size}px ${icon_full}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -256,6 +256,8 @@ Example usage:
|
||||
Since 5.36.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../modules/QtVersionOption.cmake)
|
||||
include(ECMQueryQt)
|
||||
|
||||
|
||||
@@ -178,6 +178,8 @@ Example usage:
|
||||
Since 5.62.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(FeatureSummary)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/QtVersionOption.cmake)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# SPDX-FileCopyrightText: 2013 Alexander Richardson <arichardson.kde@gmail.com>
|
||||
# SPDX-FileCopyrightText: 2015 Alex Merry <alex.merry@kde.org>
|
||||
# SPDX-FileCopyrightText: 2025 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
@@ -12,8 +13,10 @@ Convenience functions for adding tests.
|
||||
::
|
||||
|
||||
ecm_add_tests(<sources>
|
||||
[COMPILE_DEFINITIONS <definition> [<definition> [...]]] # Since 6.13.0
|
||||
[ENVIRONMENT <list>] # Since 6.13.0
|
||||
LINK_LIBRARIES <library> [<library> [...]]
|
||||
[NAME_PREFIX <prefix>]
|
||||
[NAME_PREFIX <prefix> (| NO_NAME_PREFIX] # Since 6.22.0)
|
||||
[GUI]
|
||||
[TARGET_NAMES_VAR <target_names_var>]
|
||||
[TEST_NAMES_VAR <test_names_var>]
|
||||
@@ -21,15 +24,20 @@ Convenience functions for adding tests.
|
||||
)
|
||||
|
||||
A convenience function for adding multiple tests, each consisting of a
|
||||
single source file. For each file in <sources>, an executable target will be
|
||||
created (the name of which will be the basename of the source file). This
|
||||
will be linked against the libraries given with ``LINK_LIBRARIES``. Each
|
||||
executable will be added as a test with the same name.
|
||||
single source file. For each file in <sources>, an executable target is
|
||||
created (whose name is the base name of the source file) with the compiler
|
||||
definitions passed with ``COMPILE_DEFINITIONS``. This will be linked
|
||||
against the libraries given with ``LINK_LIBRARIES``. Each executable will
|
||||
be added as a test with the same name and can have an environment provided
|
||||
by ``ENVIRONMENT``.
|
||||
|
||||
If ``NAME_PREFIX`` is given, this prefix will be prepended to the test names, but
|
||||
not the target names. As a result, it will not prevent clashes between tests
|
||||
with the same name in different parts of the project, but it can be used to
|
||||
give an indication of where to look for a failing test.
|
||||
If ``NAME_PREFIX`` is not set, it will default to a value depending on the
|
||||
strategy as controlled by the variable ``ECM_TEST_NAME_PREFIX_STRATEGY``, if
|
||||
set in the current scope and ``NO_NAME_PREFIX`` is not set (since 6.22).
|
||||
|
||||
If the flag ``GUI`` is passed the test binaries will be GUI executables, otherwise
|
||||
the resulting binaries will be console applications (regardless of the value
|
||||
@@ -58,17 +66,31 @@ generator expressions. Since 5.111.
|
||||
|
||||
ecm_add_test(
|
||||
<sources>
|
||||
[COMPILE_DEFINITIONS <definition> [<definition> [...]]] # Since 6.13.0
|
||||
[ENVIRONMENT <list>] # Since 6.13.0
|
||||
LINK_LIBRARIES <library> [<library> [...]]
|
||||
[TEST_NAME <name>]
|
||||
[NAME_PREFIX <prefix>]
|
||||
[NAME_PREFIX <prefix> (| NO_NAME_PREFIX] # Since 6.22.0)
|
||||
[GUI]
|
||||
[TARGET_NAME_VAR <target_name_var>]
|
||||
[TEST_NAME_VAR <test_name_var>]
|
||||
[WORKING_DIRECTORY <dir>] # Since 5.111
|
||||
)
|
||||
|
||||
This is a single-test form of ``ecm_add_tests`` that allows multiple source files
|
||||
to be used for a single test. If using multiple source files, ``TEST_NAME`` must
|
||||
be given; this will be used for both the target and test names (and, as with
|
||||
``ecm_add_tests()``, the ``NAME_PREFIX`` argument will be prepended to the test name).
|
||||
be given; this will be used for both the target and test names.
|
||||
|
||||
As with ``ecm_add_tests()``, the ``NAME_PREFIX`` argument will be prepended to
|
||||
the test name.
|
||||
If ``NAME_PREFIX`` is not set, it will default to a value depending on the
|
||||
strategy as controlled by the variable ``ECM_TEST_NAME_PREFIX_STRATEGY``, if
|
||||
set in the current scope and ``NO_NAME_PREFIX`` is not set (since 6.22).
|
||||
|
||||
The ``TARGET_NAME_VAR`` and ``TEST_NAME_VAR`` arguments, if given, should specify a
|
||||
variable name to receive the generated target and test name,
|
||||
respectively. This makes it convenient to apply properties to them as a
|
||||
whole, for example, using ``set_target_properties()`` or ``set_tests_properties()``.
|
||||
|
||||
``WORKING_DIRECTORY`` sets the test property `WORKING_DIRECTORY
|
||||
<https://cmake.org/cmake/help/latest/prop_test/WORKING_DIRECTORY.html>`_
|
||||
@@ -76,18 +98,259 @@ in which to execute the test. By default the test will be run in
|
||||
``${CMAKE_CURRENT_BINARY_DIR}``. The working directory can be specified using
|
||||
generator expressions. Since 5.111.
|
||||
|
||||
::
|
||||
|
||||
ecm_test_set_dir_properties( # Since 6.22.0
|
||||
[DIR <dir>]
|
||||
[PREFIX_NAME <name>]
|
||||
[PREFIX_NAME_IGNORE | PREFIX_NAME_NOT_IGNORE]
|
||||
[FIRST_PREFIX_NAME]
|
||||
[LAST_PREFIX_NAME]
|
||||
)
|
||||
|
||||
|
||||
The function can be used to set properties to individual directories to
|
||||
influence the behaviour of the test functions. The properties will be set to
|
||||
the current source directory. For source directories which themselves do not
|
||||
have a CMakeLists.txt file and thus are not added by any `add_subdirectory()
|
||||
<https://cmake.org/cmake/help/latest/command/add_subdirectory.html>`_ calls,
|
||||
the ``DIR`` argument can be used to instead set the property to any such
|
||||
subdirectory ``<dir>``.
|
||||
|
||||
``PREFIX_NAME`` can be used to override by ``<name>`` the name derived from
|
||||
the given directory.
|
||||
|
||||
``PREFIX_NAME_IGNORE`` or ``PREFIX_NAME_NOT_IGNORE`` can be used to override
|
||||
the filtering done by ``ECM_TEST_NAME_PREFIX_IGNORE_DIRS`` for the name of the
|
||||
given directory.
|
||||
|
||||
``FIRST_PREFIX_NAME`` and ``LAST_PREFIX_NAME`` can be used to limit the range
|
||||
of directories in the path used for deriving the prefix name.
|
||||
|
||||
::
|
||||
|
||||
ecm_test_get_name_prefix( # Since 6.22.0
|
||||
<name_prefix_var>
|
||||
)
|
||||
|
||||
The ``name_prefix_var`` argument should specify a variable name to receive the
|
||||
default test prefix name for the current scope, based on
|
||||
the value of ``ECM_TEST_NAME_PREFIX_STRATEGY`` and the respective further setup.
|
||||
|
||||
::
|
||||
|
||||
ECM_TEST_NAME_PREFIX_STRATEGY # Since 6.22.0
|
||||
|
||||
This variable is specifying the strategy to use when estimating the default
|
||||
test name prefix to use by the macros ``ecm_add_tests()`` and ``ecm_add_test()``
|
||||
when no explicit ``NAME_PREFIX`` argument is passed. The supported values are:
|
||||
|
||||
* ``VARIABLE``: The default name prefix is taken from the value of the variable
|
||||
``ECM_TEST_NAME_PREFIX`` in the scope where the macros are called.
|
||||
|
||||
* ``PATH``: The default name prefix is derived from the relative path of the
|
||||
current source directory where the macros are called, by replacing the
|
||||
dir separators with "-".
|
||||
See also ``ECM_TEST_NAME_PREFIX_IGNORE_DIRS`` for skipping some directory names.
|
||||
|
||||
When unset, the ``VARIABLE`` strategy is used.
|
||||
|
||||
::
|
||||
|
||||
ECM_TEST_NAME_PREFIX # Since 6.22.0
|
||||
|
||||
When ``ECM_TEST_NAME_PREFIX_STRATEGY`` is set to ``VARIABLE``,
|
||||
the current value of the variable is used as default for the test name prefix.
|
||||
|
||||
::
|
||||
|
||||
ECM_TEST_NAME_PREFIX_IGNORE_DIRS # Since 6.22.0
|
||||
|
||||
When ``ECM_TEST_NAME_PREFIX_STRATEGY`` is set to ``PATH``, this variable is used
|
||||
to filter out directory names in the relative path of the current source directory
|
||||
when deriving the name prefix. By default the variable is set to
|
||||
"src", "test", "tests", "autotest", "autotests" when including the ``ECMAddTest`` module,
|
||||
if not already defined.
|
||||
|
||||
|
||||
Example usage:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
set(ECM_TEST_NAME_PREFIX_STRATEGY "PATH")
|
||||
list(APPEND ECM_TEST_NAME_PREFIX_IGNORE_DIRS "plugins")
|
||||
|
||||
# Being in subdir "src/plugins/foo" this test will get
|
||||
# the test name prefix set to "foo-", next to base name "mytest":
|
||||
ecm_add_test(
|
||||
mytest.cpp
|
||||
LINK_LIBRARIES mylib
|
||||
)
|
||||
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(ECMMarkAsTest)
|
||||
include(ECMMarkNonGuiExecutable)
|
||||
|
||||
# set variable on the include scope, as consumers are supposed to have access to it
|
||||
if(NOT DEFINED ECM_TEST_NAME_PREFIX_IGNORE_DIRS)
|
||||
set(ECM_TEST_NAME_PREFIX_IGNORE_DIRS "src" "test" "tests" "autotest" "autotests")
|
||||
endif()
|
||||
|
||||
function(_ecm_test_name_prefix_from_project_path _name_prefix_varname)
|
||||
# estimate names of chain of dirs of current source dir to main dir
|
||||
file(RELATIVE_PATH _project_path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(_project_path MATCHES "^\\.\\./")
|
||||
message(FATAL_ERROR "The PATH strategy can not be used with directories outside the root source dir.")
|
||||
endif()
|
||||
|
||||
string(REPLACE "/" ";" _dirs ${_project_path})
|
||||
|
||||
# derive prefix names
|
||||
set(_names)
|
||||
set(_subpath ${CMAKE_SOURCE_DIR})
|
||||
set(_lastcmakesubpath ${_subpath}) # path of current including CMakeLists.txt
|
||||
set(_relativelastcmakesubpath)
|
||||
get_directory_property(_cmakesubdirs DIRECTORY ${_lastcmakesubpath} "SUBDIRECTORIES")
|
||||
foreach(_dir ${_dirs})
|
||||
string(APPEND _subpath "/${_dir}")
|
||||
|
||||
# subdir with CMakeLists.txt?
|
||||
if(_subpath IN_LIST _cmakesubdirs)
|
||||
set(_lastcmakesubpath ${_subpath})
|
||||
set(_relativelastcmakesubpath)
|
||||
set(_property_name_suffix)
|
||||
# prepare nexs subdir
|
||||
get_directory_property(_cmakesubdirs DIRECTORY ${_lastcmakesubpath} "SUBDIRECTORIES")
|
||||
else()
|
||||
string(APPEND _relativelastcmakesubpath "/${_dir}")
|
||||
# keep in sync with writing the properties in ecm_test_set_dir_properties
|
||||
string(SHA1 _relativelastcmakesubpath_hash ${_relativelastcmakesubpath})
|
||||
set(_property_name_suffix ":${_relativelastcmakesubpath_hash}")
|
||||
endif()
|
||||
|
||||
get_directory_property(_substitute_name DIRECTORY ${_lastcmakesubpath} "ECM_TEST_NAME_PREFIX_DIR_NAME${_property_name_suffix}")
|
||||
|
||||
get_directory_property(_first_name DIRECTORY ${_lastcmakesubpath} "ECM_TEST_NAME_PREFIX_DIR_FIRST${_property_name_suffix}")
|
||||
|
||||
if(_first_name)
|
||||
# drop any current names
|
||||
set(_names)
|
||||
endif()
|
||||
|
||||
if (_substitute_name)
|
||||
list(APPEND _names ${_substitute_name})
|
||||
else()
|
||||
get_directory_property(_ignore_dir DIRECTORY ${_lastcmakesubpath} "ECM_TEST_NAME_PREFIX_DIR_IGNORE${_property_name_suffix}")
|
||||
if (_ignore_dir STREQUAL "")
|
||||
if(_dir IN_LIST ECM_TEST_NAME_PREFIX_IGNORE_DIRS)
|
||||
set(_ignore_dir TRUE)
|
||||
else()
|
||||
set(_ignore_dir FALSE)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT _ignore_dir)
|
||||
list(APPEND _names ${_dir})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
get_directory_property(_last_name DIRECTORY ${_lastcmakesubpath} "ECM_TEST_NAME_PREFIX_DIR_LAST${_property_name_suffix}")
|
||||
if(_last_name)
|
||||
# finish estimating prefix names
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# create final prefix name
|
||||
string(JOIN "-" _name_prefix ${_names})
|
||||
if (_name_prefix)
|
||||
string(APPEND _name_prefix "-")
|
||||
endif()
|
||||
|
||||
set(${_name_prefix_varname} ${_name_prefix} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(ecm_test_set_dir_properties)
|
||||
set(options PREFIX_NAME_IGNORE PREFIX_NAME_NOT_IGNORE FIRST_PREFIX_NAME LAST_PREFIX_NAME)
|
||||
set(oneValueArgs PREFIX_NAME DIR)
|
||||
set(multiValueArgs)
|
||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(ARG_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "Unknown keywords given to ECM_TEST_SET_DIR_PROPERTIES(): \"${ARG_UNPARSED_ARGUMENTS}\"")
|
||||
endif()
|
||||
if(ARG_PREFIX_NAME_IGNORE AND ARG_PREFIX_NAME_NOT_IGNORE)
|
||||
message(FATAL_ERROR "Pass either PREFIX_NAME_IGNORE or PREFIX_NAME_NOT_IGNORE to ECM_TEST_SET_DIR_PROPERTIES.")
|
||||
endif()
|
||||
set(_subdir)
|
||||
if(ARG_DIR)
|
||||
get_filename_component(_subdir ${ARG_DIR} REALPATH)
|
||||
if(NOT IS_DIRECTORY "${_subdir}")
|
||||
message(FATAL_ERROR "DIR argument passed to ECM_TEST_SET_DIR_PROPERTIES is not a directory: \"${ARG_DIR}\"")
|
||||
endif()
|
||||
if (_subdir STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(_subdir)
|
||||
else()
|
||||
file(RELATIVE_PATH _subdir ${CMAKE_CURRENT_SOURCE_DIR} ${_subdir})
|
||||
if(_subdir MATCHES "^\\.\\./")
|
||||
message(FATAL_ERROR "DIR argument passed to ECM_TEST_SET_DIR_PROPERTIES is not a subdirectory: \"${ARG_DIR}\"")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(_subdir)
|
||||
# map to a hash, as cmake does not specify allowed property characters
|
||||
# keep in sync with reading the properties in _ecm_test_name_prefix_from_project_path
|
||||
string(SHA1 _subdir_hash "/${_subdir}")
|
||||
set(_property_name_suffix ":${_subdir_hash}")
|
||||
else()
|
||||
set(_property_name_suffix)
|
||||
endif()
|
||||
|
||||
if (ARG_PREFIX_NAME)
|
||||
set_directory_properties(PROPERTIES "ECM_TEST_NAME_PREFIX_DIR_NAME${_property_name_suffix}" "${ARG_PREFIX_NAME}")
|
||||
endif()
|
||||
if (ARG_PREFIX_NAME_IGNORE)
|
||||
set_directory_properties(PROPERTIES "ECM_TEST_NAME_PREFIX_DIR_IGNORE${_property_name_suffix}" "TRUE")
|
||||
endif()
|
||||
if (ARG_PREFIX_NAME_NOT_IGNORE)
|
||||
set_directory_properties(PROPERTIES "ECM_TEST_NAME_PREFIX_DIR_IGNORE${_property_name_suffix}" "FALSE")
|
||||
endif()
|
||||
if (ARG_FIRST_PREFIX_NAME)
|
||||
set_directory_properties(PROPERTIES "ECM_TEST_NAME_PREFIX_DIR_FIRST${_property_name_suffix}" "TRUE")
|
||||
endif()
|
||||
if (ARG_LAST_PREFIX_NAME)
|
||||
set_directory_properties(PROPERTIES "ECM_TEST_NAME_PREFIX_DIR_LAST${_property_name_suffix}" "TRUE")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(ecm_test_get_name_prefix _name_prefix_varname)
|
||||
if(NOT ECM_TEST_NAME_PREFIX_STRATEGY)
|
||||
set(_strategy "VARIABLE")
|
||||
else()
|
||||
set(_strategies "VARIABLE" "PATH")
|
||||
if (NOT ECM_TEST_NAME_PREFIX_STRATEGY IN_LIST _strategies)
|
||||
message(FATAL_ERROR "ECM_TEST_NAME_PREFIX_STRATEGY set to unknown value ${ECM_TEST_NAME_PREFIX_STRATEGY}")
|
||||
endif()
|
||||
set(_strategy ${ECM_TEST_NAME_PREFIX_STRATEGY})
|
||||
endif()
|
||||
|
||||
if (${_strategy} STREQUAL "PATH")
|
||||
_ecm_test_name_prefix_from_project_path(_name_prefix)
|
||||
else()
|
||||
set(_name_prefix ${ECM_TEST_NAME_PREFIX})
|
||||
endif()
|
||||
set(${_name_prefix_varname} ${_name_prefix} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(ecm_add_test)
|
||||
set(options GUI)
|
||||
# TARGET_NAME_VAR and TEST_NAME_VAR are undocumented args used by
|
||||
# ecm_add_tests
|
||||
set(options GUI NO_NAME_PREFIX)
|
||||
set(oneValueArgs TEST_NAME NAME_PREFIX TARGET_NAME_VAR TEST_NAME_VAR WORKING_DIRECTORY)
|
||||
set(multiValueArgs LINK_LIBRARIES)
|
||||
set(multiValueArgs COMPILE_DEFINITIONS ENVIRONMENT LINK_LIBRARIES)
|
||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
set(_sources ${ARG_UNPARSED_ARGUMENTS})
|
||||
list(LENGTH _sources _sourceCount)
|
||||
@@ -101,6 +364,15 @@ function(ecm_add_test)
|
||||
message(FATAL_ERROR "ecm_add_test() called with multiple source files but without setting \"TEST_NAME\"")
|
||||
endif()
|
||||
|
||||
if (NOT ARG_NAME_PREFIX)
|
||||
if(NOT ARG_NO_NAME_PREFIX)
|
||||
ecm_test_get_name_prefix(ARG_NAME_PREFIX)
|
||||
endif()
|
||||
else()
|
||||
if(ARG_NO_NAME_PREFIX)
|
||||
message(FATAL_ERROR "ecm_add_test() called with both \"NO_NAME_PREFIX\" and \"NAME_PREFIX\"")
|
||||
endif()
|
||||
endif()
|
||||
set(_testname ${ARG_NAME_PREFIX}${_targetname})
|
||||
set(gui_args)
|
||||
if(ARG_GUI)
|
||||
@@ -116,7 +388,7 @@ function(ecm_add_test)
|
||||
endif()
|
||||
add_test(NAME ${_testname} COMMAND ${_targetname} ${test_args})
|
||||
target_link_libraries(${_targetname} ${ARG_LINK_LIBRARIES})
|
||||
target_compile_definitions(${_targetname} PRIVATE -DQT_FORCE_ASSERTS)
|
||||
target_compile_definitions(${_targetname} PRIVATE -DQT_FORCE_ASSERTS ${ARG_COMPILE_DEFINITIONS})
|
||||
ecm_mark_as_test(${_targetname})
|
||||
if (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
||||
set(_plugin_path ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
@@ -129,7 +401,11 @@ function(ecm_add_test)
|
||||
endif()
|
||||
set(_plugin_path "${_plugin_path}${PATHSEP}$ENV{QT_PLUGIN_PATH}")
|
||||
endif()
|
||||
set_property(TEST ${_testname} PROPERTY ENVIRONMENT "QT_PLUGIN_PATH=${_plugin_path}")
|
||||
list(APPEND ARG_ENVIRONMENT "QT_PLUGIN_PATH=${_plugin_path}")
|
||||
endif()
|
||||
if (ARG_ENVIRONMENT)
|
||||
list(JOIN ARG_ENVIRONMENT ";" env)
|
||||
set_property(TEST ${_testname} PROPERTY ENVIRONMENT "${env}")
|
||||
endif()
|
||||
if (ARG_TARGET_NAME_VAR)
|
||||
set(${ARG_TARGET_NAME_VAR} "${_targetname}" PARENT_SCOPE)
|
||||
@@ -140,10 +416,20 @@ function(ecm_add_test)
|
||||
endfunction()
|
||||
|
||||
function(ecm_add_tests)
|
||||
set(options GUI)
|
||||
set(options GUI NO_NAME_PREFIX)
|
||||
set(oneValueArgs NAME_PREFIX TARGET_NAMES_VAR TEST_NAMES_VAR WORKING_DIRECTORY)
|
||||
set(multiValueArgs LINK_LIBRARIES)
|
||||
set(multiValueArgs COMPILE_DEFINITIONS ENVIRONMENT LINK_LIBRARIES)
|
||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
set(_name_prefix "")
|
||||
if(ARG_NO_NAME_PREFIX)
|
||||
if(ARG_NAME_PREFIX)
|
||||
message(FATAL_ERROR "ecm_add_tests() called with both \"NO_NAME_PREFIX\" and \"NAME_PREFIX\"")
|
||||
endif()
|
||||
elseif(ARG_NAME_PREFIX)
|
||||
set(_name_prefix "NAME_PREFIX" "${ARG_NAME_PREFIX}")
|
||||
endif()
|
||||
|
||||
if(ARG_GUI)
|
||||
set(_exe_type GUI)
|
||||
else()
|
||||
@@ -157,7 +443,9 @@ function(ecm_add_tests)
|
||||
set(target_names)
|
||||
foreach(_test_source ${ARG_UNPARSED_ARGUMENTS})
|
||||
ecm_add_test(${_test_source}
|
||||
NAME_PREFIX ${ARG_NAME_PREFIX}
|
||||
${_name_prefix}
|
||||
COMPILE_DEFINITIONS ${ARG_COMPILE_DEFINITIONS}
|
||||
ENVIRONMENT ${ARG_ENVIRONMENT}
|
||||
LINK_LIBRARIES ${ARG_LINK_LIBRARIES}
|
||||
TARGET_NAME_VAR target_name
|
||||
TEST_NAME_VAR test_name
|
||||
|
||||
@@ -65,6 +65,8 @@ the CMake ``GLOB`` argument of the ``FILE`` function.
|
||||
Since 5.75.0
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(FeatureSummary)
|
||||
|
||||
option(SKIP_LICENSE_TESTS "Skip outbound license tests" OFF)
|
||||
|
||||
@@ -31,6 +31,8 @@ This will install the file as foo.txt with any cmake variable replacements made
|
||||
Since 5.73.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
function(ecm_install_configured_files)
|
||||
set(options COPYONLY ESCAPE_QUOTES @ONLY)
|
||||
set(oneValueArgs DESTINATION COMPONENT)
|
||||
|
||||
@@ -22,6 +22,8 @@ links against ``libgcov``.
|
||||
Since 1.3.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
option(BUILD_COVERAGE "Build the project with gcov support" OFF)
|
||||
|
||||
if(BUILD_COVERAGE)
|
||||
|
||||
+4
-2
@@ -76,6 +76,8 @@ been installed by ecm_create_qm_from_po_files(), and compiles it into ``mylib``.
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
message(AUTHOR_WARNING "ECMCreateQmFromPoFiles is deprecated and will be removed before the release of Extra CMake Modules 1.0. Use ECMPoQmTools instead.")
|
||||
|
||||
# Stolen from FindGettext.cmake
|
||||
@@ -107,7 +109,7 @@ function(_ECM_QM_CREATE_TARGET install_destination catalog_name)
|
||||
else()
|
||||
# Qt < 5.3.1 does not define Qt5::lconvert
|
||||
get_target_property(lrelease_location Qt5::lrelease LOCATION)
|
||||
get_filename_component(lrelease_path ${lrelease_location} PATH)
|
||||
get_filename_component(lrelease_path ${lrelease_location} DIRECTORY)
|
||||
find_program(lconvert_executable
|
||||
NAMES lconvert-qt5 lconvert
|
||||
PATHS ${lrelease_path}
|
||||
@@ -204,7 +206,7 @@ endfunction()
|
||||
#
|
||||
# This is a macro so that the value written in ${ARGS_CREATE_LOADER} is
|
||||
# correctly propagated to ECM_CREATE_QM_FROM_PO_FILES parent scope. If it were
|
||||
# not a macro, ECM_CREATE_QM_FROM_PO_FILES would have to ckeck if
|
||||
# not a macro, ECM_CREATE_QM_FROM_PO_FILES would have to check if
|
||||
# CREATE_LOADER is in the arguments and propagate the value itself.
|
||||
macro(_ECM_CREATE_QM_FROM_PO_FILES_LEGACY)
|
||||
set(options)
|
||||
|
||||
@@ -48,6 +48,8 @@ Example usage:
|
||||
Since 5.91
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
function (ecm_set_disabled_deprecation_versions)
|
||||
cmake_parse_arguments(ARGS "SHOW_DEPRECATIONS;DISABLE_NEWER_WARNINGS" "" "" ${ARGN})
|
||||
|
||||
@@ -104,6 +106,10 @@ function (ecm_set_disabled_deprecation_versions)
|
||||
# Add 1 to the major version and store it as a hex value
|
||||
math(EXPR next_major_version "(${CMAKE_MATCH_1} + 1) * 65536 " OUTPUT_FORMAT HEXADECIMAL)
|
||||
add_definitions(-D${DEPRECATION_NAME}_DEPRECATED_WARNINGS_SINCE=${next_major_version})
|
||||
elseif(IS_QT_DEPRECATION)
|
||||
# For KF, this is implicitly the version we disable depreactions. Qt6 needs this explicitly
|
||||
# Qt6 has a new define called QT_WARN_DEPRECATED_UP_TO, but the old one works fine for now and we don't need to make assumptions about the Qt version
|
||||
add_definitions(-D${DEPRECATION_NAME}_DEPRECATED_WARNINGS_SINCE=${DEPRECATION_HEX_VERSION})
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
|
||||
@@ -15,6 +15,7 @@ The following sanitizers are supported:
|
||||
- Thread Sanitizer
|
||||
- Leak Sanitizer
|
||||
- Undefined Behaviour Sanitizer
|
||||
- Realtime Sanitizer
|
||||
|
||||
All of them are implemented in Clang, depending on your version, and
|
||||
there is an work in progress in GCC, where some of them are currently
|
||||
@@ -45,9 +46,10 @@ The options are:
|
||||
- leak
|
||||
- undefined
|
||||
- fuzzer
|
||||
- realtime
|
||||
|
||||
The sanitizers "address", "memory" and "thread" are mutually exclusive. You
|
||||
cannot enable two of them in the same build.
|
||||
The sanitizers "address", "memory", "thread" and "realtime" are mutually
|
||||
exclusive. You cannot enable two of them in the same build.
|
||||
|
||||
"leak" requires the "address" sanitizer.
|
||||
|
||||
@@ -74,6 +76,8 @@ This is an example of usage::
|
||||
Since 1.3.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
# MACRO check_compiler_version
|
||||
#-----------------------------
|
||||
macro (check_compiler_version gcc_required_version clang_required_version msvc_required_version)
|
||||
@@ -117,6 +121,16 @@ macro (enable_sanitizer_flags sanitize_option)
|
||||
set(XSAN_COMPILE_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
|
||||
set(XSAN_LINKER_FLAGS "asan")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
# fixes "note: variable tracking size limit exceeded with
|
||||
# -fvar-tracking-assignments, retrying without" (which is
|
||||
# another way of saying "I'll go ahead and compile this
|
||||
# thing _twice_") by making it unlimited
|
||||
# Reference:
|
||||
# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
|
||||
# -> max-vartrack-size
|
||||
string(APPEND XSAN_COMPILE_FLAGS " --param=max-vartrack-size=0")
|
||||
endif ()
|
||||
elseif (${sanitize_option} MATCHES "thread")
|
||||
check_compiler_version("4.8" "3.1" "99.99")
|
||||
set(XSAN_COMPILE_FLAGS "-fsanitize=thread")
|
||||
@@ -134,6 +148,9 @@ macro (enable_sanitizer_flags sanitize_option)
|
||||
elseif (${sanitize_option} MATCHES "fuzzer")
|
||||
check_compiler_version("99.99" "6.0" "99.99")
|
||||
set(XSAN_COMPILE_FLAGS "-fsanitize=fuzzer")
|
||||
elseif (${sanitize_option} MATCHES "realtime")
|
||||
check_compiler_version("99.99" "20.0" "99.99")
|
||||
set(XSAN_COMPILE_FLAGS "-fsanitize=realtime")
|
||||
else ()
|
||||
message(FATAL_ERROR "Compiler sanitizer option \"${sanitize_option}\" not supported.")
|
||||
endif ()
|
||||
|
||||
@@ -28,6 +28,8 @@ Example:
|
||||
Since 5.247
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(FeatureSummary)
|
||||
function(ecm_feature_summary)
|
||||
|
||||
|
||||
@@ -103,6 +103,8 @@ The following variables will be set:
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
macro(ecm_find_package_version_check module_name)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.16.0)
|
||||
message(FATAL_ERROR "CMake 3.16.0 is required by Find${module_name}.cmake")
|
||||
@@ -257,6 +259,11 @@ macro(ecm_find_package_handle_library_components module_name)
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${${module_name}_${ecm_fpwc_comp}_INCLUDE_DIR}"
|
||||
INTERFACE_LINK_LIBRARIES "${ecm_fpwc_dep_targets}"
|
||||
)
|
||||
if("${${module_name}_${ecm_fpwc_comp}_LIBRARY}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")
|
||||
set_target_properties(${module_name}::${ecm_fpwc_comp} PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${PKG_${module_name}_${ecm_fpwc_comp}_LINK_LIBRARIES}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
list(APPEND ${module_name}_TARGETS
|
||||
"${module_name}::${ecm_fpwc_comp}")
|
||||
|
||||
@@ -7,11 +7,15 @@
|
||||
ECMFindQmlModule
|
||||
----------------
|
||||
|
||||
Find QML import modules through a ``find_qmlmodule()`` call.
|
||||
It looks for the qmldir and uses the qmlplugindump if needed application to find the plugins and sets them up as
|
||||
runtime dependencies.
|
||||
This is useful so that when we configure a project we are notified when some
|
||||
QML imports are not present in the system.
|
||||
Finds QML import modules to set them as dependencies.
|
||||
|
||||
Because QML modules are not hard compile time requirements, they can be easy to miss
|
||||
by packagers and developers, causing suboptimal build results or runtime issues.
|
||||
Use this CMake module to ensure a QML module is installed at compile time
|
||||
during CMake configuration.
|
||||
|
||||
Internally, this CMake module looks for the qmldir and, if needed, uses
|
||||
qmlplugindump to find the plugins and set them up as dependencies.
|
||||
|
||||
::
|
||||
|
||||
@@ -32,6 +36,8 @@ Usage example:
|
||||
Since 5.38.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
set(MODULES_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
function(ecm_find_qmlmodule MODULE_NAME)
|
||||
@@ -40,7 +46,7 @@ function(ecm_find_qmlmodule MODULE_NAME)
|
||||
if (ARG_UNPARSED_ARGUMENTS)
|
||||
list(GET ARG_UNPARSED_ARGUMENTS 0 VERSION) # If we have any unparsed args, that should be the version
|
||||
endif()
|
||||
set(ARGN "") # The find_package call below should not recieve arguments in KF6
|
||||
set(ARGN "") # The find_package call below should not receive arguments in KF6
|
||||
else()
|
||||
list(GET ARGN 0 VERSION)
|
||||
list(REMOVE_AT ARGN 0)
|
||||
@@ -54,11 +60,9 @@ function(ecm_find_qmlmodule MODULE_NAME)
|
||||
if(COMMAND set_package_properties)
|
||||
if (ARG_REQUIRED)
|
||||
set(TYPE_STRING TYPE REQUIRED)
|
||||
else()
|
||||
set(TYPE_STRING TYPE RUNTIME)
|
||||
endif()
|
||||
set_package_properties(${GENMODULE} PROPERTIES
|
||||
DESCRIPTION "QML module '${MODULE_NAME}' is a runtime dependency."
|
||||
DESCRIPTION "QML module '${MODULE_NAME}' is a dependency."
|
||||
${TYPE_STRING})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#=============================================================================
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
include("${ECM_MODULE_DIR}/QtVersionOption.cmake")
|
||||
include("${ECM_MODULE_DIR}/ECMQueryQt.cmake")
|
||||
|
||||
+2
@@ -56,6 +56,8 @@ Example usage:
|
||||
Since 5.73.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
function(ecm_generate_dbus_service_file)
|
||||
set(options)
|
||||
set(oneValueArgs EXECUTABLE NAME SYSTEMD_SERVICE DESTINATION RENAME)
|
||||
|
||||
+78
-22
@@ -31,6 +31,7 @@ For preparing some values useful in the context it also provides a function
|
||||
[DEPRECATED_BASE_VERSION <deprecated_base_version>]
|
||||
[DEPRECATION_VERSIONS <deprecation_version> [<deprecation_version2> [...]]]
|
||||
[EXCLUDE_DEPRECATED_BEFORE_AND_AT <exclude_deprecated_before_and_at_version>]
|
||||
[DEPRECATED_ATTRIBUTE_TYPE <attribute_type>] # Since 6.28
|
||||
[NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE]
|
||||
[NO_DEFINITION_EXPORT_TO_BUILD_INTERFACE]
|
||||
[USE_VERSION_HEADER [<version_file_name>]] # Since 5.106
|
||||
@@ -68,6 +69,24 @@ deprecated before and at should be excluded from the build completely.
|
||||
Possible values are "0" (default), "CURRENT" (which resolves to <version>)
|
||||
and a version string in the format "<major>.<minor>.<patchlevel>".
|
||||
|
||||
``DEPRECATED_ATTRIBUTE_TYPE`` specifies the type of attribute to use in the
|
||||
generated macros. Options are "STANDARD" (default when the minimum required
|
||||
version of ECM is 6.28 or newer) or "COMPILER" (default otherwise, legacy).
|
||||
"STANDARD" will result in the use of the C++ standard attribute
|
||||
``[[deprecated("text")]]``, where-as "COMPILER" will use the pre-C++14
|
||||
compiler-specific annotations like ``__attribute__ ((__deprecated__("text")))``
|
||||
or ``__declspec(deprecated("text"))``, if available.
|
||||
Since 6.28.
|
||||
|
||||
.. warning::
|
||||
The compiler-specific annotation attributes can be placed more freely in
|
||||
the signatures of declarations, the C++ standard ``[[deprecated("text")]]``
|
||||
ones are restrained to the standard locations for attributes. So when
|
||||
switching from "COMPILER" to "STANDARD" it needs to be ensured all used
|
||||
deprecation macros are only at locations where attributes are possible.
|
||||
Also note that with "STANDARD" the special enumerator macros (see below)
|
||||
will not be available, as usually the normal deprecation macro can be used.
|
||||
|
||||
``NO_BUILD_SET_DEPRECATED_WARNINGS_SINCE`` specifies that the definition
|
||||
``<prefix_name><uppercase_base_name>_DEPRECATED_WARNINGS_SINCE`` will
|
||||
not be set for the library inside its own build, and thus will be defined
|
||||
@@ -110,7 +129,7 @@ would only append the string passed as argument value.
|
||||
|
||||
The function ``ecm_generate_export_header`` defines C++ preprocessor macros
|
||||
in the generated export header, some for use in the sources of the library
|
||||
the header is generated for, other for use by projects linking agsinst the
|
||||
the header is generated for, other for use by projects linking against the
|
||||
library.
|
||||
|
||||
The macros for use in the library C++ sources are these, next to those also
|
||||
@@ -139,6 +158,8 @@ defined by `GenerateExportHeader
|
||||
on the warnings macro flags set (see below). In builds using C++14 standard or earlier,
|
||||
where enumerator attributes are not yet supported, the macro will always yield an empty string.
|
||||
With MSVC it is also always an empty string for now.
|
||||
Not available with ``DEPRECATED_ATTRIBUTE_TYPE`` set to "STANDARD", there the normal macro can
|
||||
be usually used.
|
||||
Since 5.82.
|
||||
|
||||
``<prefix_name><uppercase_base_name>_ENUMERATOR_DEPRECATED_VERSION_BELATED(major, minor, textmajor, textminor, text)``
|
||||
@@ -151,6 +172,8 @@ defined by `GenerateExportHeader
|
||||
Useful for retroactive tagging of API for the compiler without injecting the
|
||||
API into the compiler warning conditions of already released versions.
|
||||
With MSVC it is also always an empty string for now.
|
||||
Not available with ``DEPRECATED_ATTRIBUTE_TYPE`` set to "STANDARD", there the normal macro can
|
||||
be usually used.
|
||||
Since 5.82.
|
||||
|
||||
``<prefix_name><uppercase_base_name>_ENABLE_DEPRECATED_SINCE(major, minor)``
|
||||
@@ -405,10 +428,9 @@ To get the hex number style value the helper macro
|
||||
Since 5.64.0.
|
||||
#]=======================================================================]
|
||||
|
||||
include(GenerateExportHeader)
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0057 NEW) # if IN_LIST
|
||||
include(GenerateExportHeader)
|
||||
|
||||
# helper method
|
||||
function(_ecm_geh_generate_hex_number _var_name _version)
|
||||
@@ -475,6 +497,7 @@ function(ecm_generate_export_header target)
|
||||
VERSION_BASE_NAME
|
||||
VERSION_MACRO_NAME
|
||||
EXCLUDE_DEPRECATED_BEFORE_AND_AT
|
||||
DEPRECATED_ATTRIBUTE_TYPE
|
||||
EXPORT_MACRO_NAME
|
||||
DEPRECATED_MACRO_NAME
|
||||
NO_EXPORT_MACRO_NAME
|
||||
@@ -579,6 +602,19 @@ function(ecm_generate_export_header target)
|
||||
else()
|
||||
set(_deprecated_macro_name "${_macro_base_name}_DEPRECATED")
|
||||
endif()
|
||||
if (ARGS_DEPRECATED_ATTRIBUTE_TYPE STREQUAL "STANDARD")
|
||||
set(_use_std_attribute TRUE)
|
||||
elseif (ARGS_DEPRECATED_ATTRIBUTE_TYPE STREQUAL "COMPILER")
|
||||
set(_use_std_attribute FALSE)
|
||||
elseif (ARGS_DEPRECATED_ATTRIBUTE_TYPE)
|
||||
message(FATAL_ERROR "DEPRECATED_ATTRIBUTE_TYPE has to be one of STANDARD and COMPILER, was \"${ARGS_DEPRECATED_ATTRIBUTE_TYPE}\".")
|
||||
else()
|
||||
if (ECM_GLOBAL_FIND_VERSION VERSION_LESS 6.28)
|
||||
set(_use_std_attribute FALSE)
|
||||
else()
|
||||
set(_use_std_attribute TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT IS_ABSOLUTE ${ARGS_EXPORT_FILE_NAME})
|
||||
set(ARGS_EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${ARGS_EXPORT_FILE_NAME}")
|
||||
@@ -601,8 +637,9 @@ function(ecm_generate_export_header target)
|
||||
endif()
|
||||
|
||||
# for the set of compiler versions supported by ECM/KF we can assume those attributes supported
|
||||
# KF6: with C++17 as minimum standard planned, switch to always use [[deprecated(text)]]
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
if (_use_std_attribute)
|
||||
set(_decl_deprecated_text_definition "[[deprecated(text)]]")
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
set(_decl_deprecated_text_definition "__attribute__ ((__deprecated__(text)))")
|
||||
elseif(MSVC)
|
||||
set(_decl_deprecated_text_definition "__declspec(deprecated(text))")
|
||||
@@ -618,6 +655,24 @@ function(ecm_generate_export_header target)
|
||||
string(APPEND _output "#include <${_version_header}>\n")
|
||||
endif()
|
||||
endif()
|
||||
if (_use_std_attribute)
|
||||
# generate_export_header() has no option to disable generation of macros
|
||||
# for deprecation attributes or to use the standard attribute.
|
||||
# For now just add code to redefine the respective macros.
|
||||
# TODO: consider stop using generate_export_header(), only deployed actually to
|
||||
# get the export/visibility macros definitions, simple logic could be copied over
|
||||
string(APPEND _output "
|
||||
#undef ${_macro_base_name}_DECL_DEPRECATED
|
||||
#define ${_macro_base_name}_DECL_DEPRECATED [[deprecated]]
|
||||
|
||||
#undef ${_macro_base_name}_DECL_DEPRECATED_EXPORT
|
||||
#define ${_macro_base_name}_DECL_DEPRECATED_EXPORT ${_macro_base_name}_EXPORT ${_macro_base_name}_DECL_DEPRECATED
|
||||
|
||||
#undef ${_macro_base_name}_DECL_DEPRECATED_NO_EXPORT
|
||||
#define ${_macro_base_name}_DECL_DEPRECATED_NO_EXPORT ${_macro_base_name}_NO_EXPORT ${_macro_base_name}_DECL_DEPRECATED
|
||||
"
|
||||
)
|
||||
endif()
|
||||
string(APPEND _output "
|
||||
#define ${_macro_base_name}_DECL_DEPRECATED_TEXT(text) ${_decl_deprecated_text_definition}
|
||||
"
|
||||
@@ -764,16 +819,18 @@ function(ecm_generate_export_header target)
|
||||
"#define ${_macro_base_name}_DEPRECATED_VERSION_BELATED(major, minor, textmajor, textminor, text) ${_macro_base_name}_DEPRECATED_VERSION_##major(minor, \"Since \"#textmajor\".\"#textminor\". \" text)
|
||||
"
|
||||
)
|
||||
# reusing the existing version-controlled deprecation macros for enumerator deprecation macros
|
||||
# to avoid having to repeat all the explicit version variants
|
||||
# TODO: MSVC seems to have issues with __declspec(deprecated) being used as enumerator attribute
|
||||
# and deals only with standard [[deprecated(text)]].
|
||||
# But for now we have to keep the deprecation macros using the compiler-specific attributes,
|
||||
# because CMake's GenerateExportHeader uses the latter for the export macros and
|
||||
# at least GCC does not support both being used mixed e.g. on the same class or method.
|
||||
# Possibly needs to be solved by forking GenerateExportHeader to get complete control.
|
||||
if(NOT MSVC)
|
||||
string(APPEND _output
|
||||
# only add special macros for enums for compiler-specific attribute backward-support
|
||||
if(NOT _use_std_attribute)
|
||||
# reusing the existing version-controlled deprecation macros for enumerator deprecation macros
|
||||
# to avoid having to repeat all the explicit version variants
|
||||
# TODO: MSVC seems to have issues with __declspec(deprecated) being used as enumerator attribute
|
||||
# and deals only with standard [[deprecated(text)]].
|
||||
# But for now we have to keep the deprecation macros using the compiler-specific attributes,
|
||||
# because CMake's GenerateExportHeader uses the latter for the export macros and
|
||||
# at least GCC does not support both being used mixed e.g. on the same class or method.
|
||||
# Possibly needs to be solved by forking GenerateExportHeader to get complete control.
|
||||
if(NOT MSVC)
|
||||
string(APPEND _output
|
||||
"#if defined(__cpp_enumerator_attributes) && __cpp_enumerator_attributes >= 201411
|
||||
# define ${_macro_base_name}_ENUMERATOR_DEPRECATED_VERSION(major, minor, text) ${_macro_base_name}_DEPRECATED_VERSION(major, minor, text)
|
||||
# define ${_macro_base_name}_ENUMERATOR_DEPRECATED_VERSION_BELATED(major, minor, textmajor, textminor, text) ${_macro_base_name}_DEPRECATED_VERSION_BELATED(major, minor, textmajor, textminor, text)
|
||||
@@ -782,14 +839,15 @@ function(ecm_generate_export_header target)
|
||||
# define ${_macro_base_name}_ENUMERATOR_DEPRECATED_VERSION_BELATED(major, minor, textmajor, textminor, text)
|
||||
#endif
|
||||
"
|
||||
)
|
||||
else()
|
||||
string(APPEND _output
|
||||
)
|
||||
else()
|
||||
string(APPEND _output
|
||||
"// Not yet implemented for MSVC
|
||||
#define ${_macro_base_name}_ENUMERATOR_DEPRECATED_VERSION(major, minor, text)
|
||||
#define ${_macro_base_name}_ENUMERATOR_DEPRECATED_VERSION_BELATED(major, minor, textmajor, textminor, text)
|
||||
"
|
||||
)
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if (ARGS_CUSTOM_CONTENT_FROM_VARIABLE)
|
||||
@@ -834,5 +892,3 @@ function(ecm_generate_export_header target)
|
||||
CUSTOM_CONTENT_FROM_VARIABLE _output
|
||||
)
|
||||
endfunction()
|
||||
|
||||
cmake_policy(POP)
|
||||
|
||||
@@ -18,6 +18,7 @@ Generate C/C++ CamelCase forwarding headers.
|
||||
[HEADER_EXTENSION <header_extension>]
|
||||
[OUTPUT_DIR <output_dir>]
|
||||
[PREFIX <prefix>]
|
||||
[SHARED_PREFIX <prefix>] # since 6.19
|
||||
[REQUIRED_HEADERS <variable>]
|
||||
[COMMON_HEADER <HeaderName>]
|
||||
[RELATIVE <relative_path>])
|
||||
@@ -47,6 +48,14 @@ forwarding headers based on the original names (e.g. ``kparts/part.h``). This
|
||||
allows includes like ``"#include <kparts/part.h>"`` to be used before
|
||||
installation, as long as the include_directories are set appropriately.
|
||||
|
||||
``SHARED_PREFIX`` works similar to ``PREFIX``. It though assumes the original
|
||||
headers will be installed in the same subdirectory as the forwarding headers.
|
||||
So the generated files will include the original ones locally without any prefix.
|
||||
And the above mentioned pre-installation convenience forwarding headers based on
|
||||
the original names will be placed in the same subdirectory
|
||||
(e.g. ``KParts/part.h``), to allow includes like ``"#include <KParts/Part>"`` to
|
||||
be used before installation and working properly. Since 6.19.0.
|
||||
|
||||
``OUTPUT_DIR`` specifies where the files will be generated; this should be within
|
||||
the build directory. By default, ``${CMAKE_CURRENT_BINARY_DIR}`` will be used.
|
||||
This option can be used to avoid file conflicts.
|
||||
@@ -65,18 +74,21 @@ The ``RELATIVE`` argument indicates where the original headers can be found
|
||||
relative to ``CMAKE_CURRENT_SOURCE_DIR``. It does not affect the generated
|
||||
CamelCase forwarding files, but ``ecm_generate_headers()`` uses it when checking
|
||||
that the original header exists, and to generate originally named forwarding
|
||||
headers when ``PREFIX`` is set.
|
||||
headers when ``PREFIX`` or ``SHARED_PREFIX`` is set.
|
||||
|
||||
To allow other parts of the source distribution (eg: tests) to use the
|
||||
generated headers before installation, it may be desirable to set the
|
||||
``INCLUDE_DIRECTORIES`` property for the library target to output_dir. For
|
||||
example, if ``OUTPUT_DIR`` is ``CMAKE_CURRENT_BINARY_DIR`` (the default), you could do
|
||||
generated headers before installation, it may be desirable to add to the
|
||||
``INCLUDE_DIRECTORIES`` property of the library target the output_dir.
|
||||
If ``OUTPUT_DIR`` is ``CMAKE_CURRENT_BINARY_DIR`` (the default) and
|
||||
``CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE`` is ``ON`` (as set by
|
||||
:kde-module:`KDECMakeSettings`), this is automatically done.
|
||||
Otherwise you could do (adapt if ``OUTPUT_DIR`` is something else)
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
target_include_directories(MyLib PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
|
||||
|
||||
Example usage (without ``PREFIX``):
|
||||
Example usage (without ``PREFIX`` pr ``SHARED_PREFIX``):
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
@@ -115,12 +127,33 @@ Example usage (with ``PREFIX``):
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/mylib
|
||||
COMPONENT Devel)
|
||||
|
||||
Example usage (with ``SHARED_PREFIX``):
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
ecm_generate_headers(
|
||||
MyLib_FORWARDING_HEADERS
|
||||
HEADERS
|
||||
Foo
|
||||
# several classes are contained in bar.h, so generate
|
||||
# additional files
|
||||
Bar,BarList
|
||||
# etc
|
||||
SHARED_PREFIX MyLib
|
||||
REQUIRED_HEADERS MyLib_HEADERS
|
||||
)
|
||||
install(FILES ${MyLib_FORWARDING_HEADERS} ${MyLib_HEADERS}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MyLib
|
||||
COMPONENT Devel)
|
||||
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var)
|
||||
set(options)
|
||||
set(oneValueArgs ORIGINAL HEADER_EXTENSION OUTPUT_DIR PREFIX REQUIRED_HEADERS COMMON_HEADER RELATIVE)
|
||||
set(oneValueArgs ORIGINAL HEADER_EXTENSION OUTPUT_DIR PREFIX SHARED_PREFIX REQUIRED_HEADERS COMMON_HEADER RELATIVE)
|
||||
set(multiValueArgs HEADER_NAMES)
|
||||
cmake_parse_arguments(EGH "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
@@ -128,6 +161,10 @@ function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var)
|
||||
message(FATAL_ERROR "Unexpected arguments to ECM_GENERATE_HEADERS: ${EGH_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
if(EGH_PREFIX AND EGH_SHARED_PREFIX)
|
||||
message(FATAL_ERROR "Cannot pass both PREFIX and SHARED_PREFIX arguments to ECM_GENERATE_HEADERS")
|
||||
endif()
|
||||
|
||||
if(NOT EGH_HEADER_NAMES)
|
||||
message(FATAL_ERROR "Missing header_names argument to ECM_GENERATE_HEADERS")
|
||||
endif()
|
||||
@@ -153,16 +190,27 @@ function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var)
|
||||
set(EGH_RELATIVE "${EGH_RELATIVE}/")
|
||||
endif()
|
||||
|
||||
set(originalprefix)
|
||||
if (EGH_PREFIX)
|
||||
if (NOT "${EGH_PREFIX}" MATCHES "^.*/$")
|
||||
set(EGH_PREFIX "${EGH_PREFIX}/")
|
||||
endif()
|
||||
set(prefix)
|
||||
if (EGH_SHARED_PREFIX)
|
||||
set(prefix "${EGH_SHARED_PREFIX}")
|
||||
elseif (EGH_PREFIX)
|
||||
set(prefix "${EGH_PREFIX}")
|
||||
endif()
|
||||
if (prefix AND NOT "${prefix}" MATCHES "^.*/$")
|
||||
string(APPEND prefix "/")
|
||||
endif()
|
||||
|
||||
set(originalprefix) # prefix used in the include by the forwarding header
|
||||
set(buildoriginalprefix) # prefix used in the build to place the convenience forwarding headers
|
||||
if (EGH_SHARED_PREFIX)
|
||||
set(buildoriginalprefix "${prefix}")
|
||||
elseif (EGH_PREFIX)
|
||||
if (EGH_ORIGINAL STREQUAL "CAMELCASE")
|
||||
set(originalprefix "${EGH_PREFIX}")
|
||||
set(originalprefix "${prefix}")
|
||||
else()
|
||||
string(TOLOWER "${EGH_PREFIX}" originalprefix)
|
||||
string(TOLOWER "${prefix}" originalprefix)
|
||||
endif()
|
||||
set(buildoriginalprefix "${originalprefix}")
|
||||
endif()
|
||||
|
||||
foreach(_classnameentry ${EGH_HEADER_NAMES})
|
||||
@@ -182,21 +230,41 @@ function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var)
|
||||
endif()
|
||||
|
||||
foreach(_CLASSNAME ${_classnames})
|
||||
set(FANCY_HEADER_FILE "${EGH_OUTPUT_DIR}/${EGH_PREFIX}${_CLASSNAME}")
|
||||
set(FANCY_HEADER_FILE "${EGH_OUTPUT_DIR}/${prefix}${_CLASSNAME}")
|
||||
if (NOT EXISTS ${FANCY_HEADER_FILE})
|
||||
file(WRITE ${FANCY_HEADER_FILE} "#include \"${originalprefix}${originalbasename}.${EGH_HEADER_EXTENSION}\" // IWYU pragma: export\n")
|
||||
set(_content "#include \"${originalprefix}${originalbasename}.${EGH_HEADER_EXTENSION}\" // IWYU pragma: export\n")
|
||||
if (prefix AND "${originalprefix}" STREQUAL "")
|
||||
# Here a relative include is created, without the namespace prefix.
|
||||
# This results in some potentially non-unique file content, when other relative forwarding
|
||||
# headers exist for the same base name (e.g. Prison/Barcode vs. KPkPass/Barcode, which both
|
||||
# would simply include "barcode.h").
|
||||
# Some filesystems automatically hardlink files which are identical by the content checksum
|
||||
# (e.g. for RPM-provided files under /usr, to save storage space).
|
||||
# This collides with Clang seemingly doing optimization by looking at the inodes of the
|
||||
# to-be included files, and reusing content from the inode as found with any first path.
|
||||
# So for a compilation unit which includes multiple forwarding headers with different
|
||||
# namespaces but same basename, so having same inode with those systems, the latter ones will
|
||||
# not result in the actual relative original headers being included.
|
||||
# See https://github.com/llvm/llvm-project/issues/26953
|
||||
# As counter-measure some unique content is added below, serving some double purpose by giving
|
||||
# instructions how to use the file, in case someone looks at it.
|
||||
string(PREPEND _content "// Forwarding header, use by: #include <${prefix}${_CLASSNAME}>\n")
|
||||
endif()
|
||||
file(WRITE ${FANCY_HEADER_FILE} "${_content}")
|
||||
endif()
|
||||
list(APPEND ${camelcase_forwarding_headers_var} "${FANCY_HEADER_FILE}")
|
||||
if (EGH_PREFIX)
|
||||
# Local forwarding header, for namespaced headers, e.g. kparts/part.h
|
||||
if (prefix)
|
||||
# Build-local convenience forwarding header, for namespaced headers, e.g. kparts/part.h
|
||||
# Ensures either the prefixed forwarding include works ("kparts/part.h"), or the unnamespaced
|
||||
# local relative ("part.h") will pick up the correct header, not some consumer one.
|
||||
if(EGH_ORIGINAL STREQUAL "CAMELCASE")
|
||||
set(originalclassname "${_CLASSNAME}")
|
||||
else()
|
||||
string(TOLOWER "${_CLASSNAME}" originalclassname)
|
||||
endif()
|
||||
set(REGULAR_HEADER_NAME ${EGH_OUTPUT_DIR}/${originalprefix}${originalclassname}.${EGH_HEADER_EXTENSION})
|
||||
set(REGULAR_HEADER_NAME ${EGH_OUTPUT_DIR}/${buildoriginalprefix}${originalclassname}.${EGH_HEADER_EXTENSION})
|
||||
if (NOT EXISTS ${REGULAR_HEADER_NAME})
|
||||
file(RELATIVE_PATH _actualheader_relative "${EGH_OUTPUT_DIR}/${originalprefix}" "${_actualheader}")
|
||||
file(RELATIVE_PATH _actualheader_relative "${EGH_OUTPUT_DIR}/${buildoriginalprefix}" "${_actualheader}")
|
||||
file(WRITE ${REGULAR_HEADER_NAME} "#include \"${_actualheader_relative}\" // IWYU pragma: export\n")
|
||||
endif()
|
||||
endif()
|
||||
@@ -207,7 +275,7 @@ function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var)
|
||||
|
||||
if(EGH_COMMON_HEADER)
|
||||
#combine required headers into 1 big convenience header
|
||||
set(COMMON_HEADER ${EGH_OUTPUT_DIR}/${EGH_PREFIX}${EGH_COMMON_HEADER})
|
||||
set(COMMON_HEADER ${EGH_OUTPUT_DIR}/${prefix}${EGH_COMMON_HEADER})
|
||||
file(WRITE ${COMMON_HEADER} "// convenience header\n")
|
||||
foreach(_header ${_REQUIRED_HEADERS})
|
||||
get_filename_component(_base ${_header} NAME)
|
||||
|
||||
+4
-1
@@ -74,7 +74,8 @@ cache variable is set to something different.
|
||||
|
||||
To properly use this macro a version needs to be set. To retrieve it,
|
||||
``ECM_PKGCONFIG_INSTALL_DIR`` uses ``PROJECT_VERSION``. To set it, use the
|
||||
``project()`` command or the ``ecm_setup_version()`` macro
|
||||
``project()`` command (or if you still set CMP0048 to OLD and don't have
|
||||
CMake >= 4 the ``ecm_setup_version()`` macro)
|
||||
|
||||
Example usage:
|
||||
|
||||
@@ -90,6 +91,8 @@ Example usage:
|
||||
Since 1.3.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
function(ECM_GENERATE_PKGCONFIG_FILE)
|
||||
set(options INSTALL)
|
||||
set(oneValueArgs BASE_NAME LIB_NAME FILENAME_VAR INCLUDE_INSTALL_DIR LIB_INSTALL_DIR DESCRIPTION URL)
|
||||
|
||||
@@ -87,6 +87,8 @@ in their ``.pro`` file.
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
# Replicate the logic from KDEInstallDirs.cmake as we can't depend on it
|
||||
# Ask qmake if we're using the same prefix as Qt
|
||||
set(_should_query_qt OFF)
|
||||
|
||||
+50
-4
@@ -19,6 +19,7 @@ Generate Python bindings using Shiboken.
|
||||
VERSION <version>
|
||||
WRAPPED_HEADER <filename>
|
||||
TYPESYSTEM <filename>
|
||||
[EXPORT_TYPESYSTEM]
|
||||
GENERATED_SOURCES <filename> [<filename> [...]]
|
||||
DEPENDENCIES <target> [<target> [...]]
|
||||
QT_VERSION <version>
|
||||
@@ -36,6 +37,9 @@ for the library.
|
||||
|
||||
``TYPESYSTEM`` is the XML file where the bindings are defined.
|
||||
|
||||
``EXPORT_TYPESYSTEM`` specifies that the typesystem XML file and the
|
||||
generated header are exported and can be used by other typesystem XML files.
|
||||
|
||||
``GENERATED_SOURCES`` is the list of generated C++ source files by Shiboken
|
||||
that will be used to build the shared library.
|
||||
|
||||
@@ -43,9 +47,9 @@ that will be used to build the shared library.
|
||||
|
||||
``DEPENDENCIES`` is the list of dependencies that the bindings uses.
|
||||
|
||||
``HOMEPAGE_URL`` is a URL to the proyect homepage.
|
||||
``HOMEPAGE_URL`` is a URL to the project homepage.
|
||||
|
||||
``ISSUES_URL` is a URL where users can report bugs and feature requests.
|
||||
``ISSUES_URL`` is a URL where users can report bugs and feature requests.
|
||||
|
||||
``AUTHOR`` is a string with the author of the library.
|
||||
|
||||
@@ -54,18 +58,36 @@ description on the Python Package Index.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
set(MODULES_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
function(ecm_generate_python_bindings)
|
||||
set(options )
|
||||
set(options EXPORT_TYPESYSTEM)
|
||||
set(oneValueArgs PACKAGE_NAME WRAPPED_HEADER TYPESYSTEM VERSION QT_VERSION HOMEPAGE_URL ISSUES_URL AUTHOR README)
|
||||
set(multiValueArgs GENERATED_SOURCES DEPENDENCIES)
|
||||
|
||||
cmake_parse_arguments(PB "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (NOT Python3_EXECUTABLE)
|
||||
message(FATAL_ERROR "Python3_EXECUTABLE not set. Make sure find_package(Python3) is called before including ECMGeneratePythonBindings")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${Python3_EXECUTABLE} -Esc "import build" RESULT_VARIABLE PYTHON_BUILD_CHECK_EXIT_CODE OUTPUT_QUIET ERROR_QUIET)
|
||||
|
||||
if (PYTHON_BUILD_CHECK_EXIT_CODE)
|
||||
message(FATAL_ERROR "The 'build' Python module is needed for ECMGeneratePythonBindings")
|
||||
endif()
|
||||
|
||||
# Ugly hacks because PySide6::pyside6 only includes /usr/includes/PySide6 and none of the sub directory
|
||||
# Qt bugreport: PYSIDE-2882
|
||||
get_property(PYSIDE_INCLUDE_DIRS TARGET "PySide6::pyside6" PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(NOT PYSIDE_INCLUDE_DIR)
|
||||
set(PYSIDE_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include/PySide${QT_MAJOR_VERSION}")
|
||||
endif()
|
||||
if(NOT PYSIDE_INCLUDE_DIR IN_LIST PYSIDE_INCLUDE_DIRS)
|
||||
list(APPEND PYSIDE_INCLUDE_DIRS "${PYSIDE_INCLUDE_DIR}")
|
||||
endif()
|
||||
foreach(PYSIDE_INCLUDE_DIR ${PYSIDE_INCLUDE_DIRS})
|
||||
file(GLOB PYSIDE_SUBDIRS LIST_DIRECTORIES true "${PYSIDE_INCLUDE_DIR}/*")
|
||||
foreach (PYSIDE_SUBDIR ${PYSIDE_SUBDIRS})
|
||||
@@ -108,6 +130,7 @@ function(ecm_generate_python_bindings)
|
||||
${INCLUDES}
|
||||
--include-paths=${CMAKE_SOURCE_DIR}
|
||||
--typesystem-paths=${CMAKE_SOURCE_DIR}
|
||||
--typesystem-paths="${CMAKE_INSTALL_PREFIX}/share/PySide${QT_MAJOR_VERSION}/typesystems"
|
||||
--typesystem-paths=${PYSIDE_TYPESYSTEMS}
|
||||
--output-directory=${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@@ -132,6 +155,12 @@ function(ecm_generate_python_bindings)
|
||||
get_property(_defs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
|
||||
list(FILTER _defs EXCLUDE REGEX [[^QT_DISABLE_DEPRECATED_BEFORE=]])
|
||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS ${_defs})
|
||||
get_property(_defs DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
|
||||
list(FILTER _defs EXCLUDE REGEX [[^QT_DISABLE_DEPRECATED_UP_TO=]])
|
||||
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS ${_defs})
|
||||
get_property(_defs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
|
||||
list(FILTER _defs EXCLUDE REGEX [[^QT_DISABLE_DEPRECATED_UP_TO=]])
|
||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS ${_defs})
|
||||
|
||||
# Define and build the bindings library.
|
||||
add_library(${PB_PACKAGE_NAME} SHARED ${${PB_PACKAGE_NAME}_sources})
|
||||
@@ -151,7 +180,16 @@ function(ecm_generate_python_bindings)
|
||||
)
|
||||
|
||||
# Hide noisy warnings
|
||||
target_compile_options(${PB_PACKAGE_NAME} PRIVATE -Wno-cast-function-type -Wno-missing-include-dirs)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
target_compile_options(${PB_PACKAGE_NAME} PRIVATE
|
||||
-Wno-cast-function-type
|
||||
-Wno-keyword-macro
|
||||
-Wno-missing-include-dirs
|
||||
-Wno-overloaded-virtual
|
||||
-Wno-shadow
|
||||
-Wno-zero-as-null-pointer-constant
|
||||
)
|
||||
endif()
|
||||
|
||||
# Adjust the name of generated module.
|
||||
set_property(TARGET ${PB_PACKAGE_NAME} PROPERTY PREFIX "")
|
||||
@@ -171,4 +209,12 @@ function(ecm_generate_python_bindings)
|
||||
COMMENT "Building Python Wheel"
|
||||
)
|
||||
|
||||
# Export the header and the typesystem XML file
|
||||
if (PB_EXPORT_TYPESYSTEM)
|
||||
string(TOLOWER ${PB_PACKAGE_NAME} lower_package_name)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PB_PACKAGE_NAME}/${lower_package_name}_python.h
|
||||
DESTINATION "${PYSIDE_INCLUDE_DIR}/${PB_PACKAGE_NAME}/")
|
||||
install(FILES "${PB_TYPESYSTEM}" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/PySide${QT_MAJOR_VERSION}/typesystems/")
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
+2
-1
@@ -6,7 +6,7 @@ authors = [
|
||||
]
|
||||
description = "Python bindings for ${PB_PACKAGE_NAME}"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
requires-python = ">=3.9"
|
||||
dependencies = [
|
||||
"PySide6>=${PB_QT_VERSION},<7",
|
||||
]
|
||||
@@ -16,6 +16,7 @@ classifiers = [
|
||||
"Environment :: X11 Applications :: Qt",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
|
||||
@@ -29,7 +29,7 @@ Example usage:
|
||||
|
||||
ecm_add_qch(KF6::CoreAddons kcoreaddons.qdocconf)
|
||||
|
||||
Documentation is not built as part of the normal build, it needs to be explicity
|
||||
Documentation is not built as part of the normal build, it needs to be explicitly
|
||||
invoked using the following build targets:
|
||||
|
||||
* ``prepare_docs`` runs the prepare step from qdoc, which processes sources and creates index files
|
||||
@@ -48,6 +48,8 @@ When combining documentation from multiple projects the recommended procedure is
|
||||
Since 6.11.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
add_custom_target(prepare_docs)
|
||||
add_custom_target(generate_docs)
|
||||
add_custom_target(install_html_docs)
|
||||
@@ -55,8 +57,13 @@ add_custom_target(generate_qch)
|
||||
add_custom_target(install_qch_docs)
|
||||
|
||||
function(ecm_generate_qdoc target qdocconf_file)
|
||||
find_package(Qt6Tools CONFIG REQUIRED)
|
||||
find_package(Qt6 COMPONENTS ToolsTools CONFIG REQUIRED)
|
||||
find_package(Qt6Tools CONFIG QUIET)
|
||||
find_package(Qt6 OPTIONAL_COMPONENTS ToolsTools CONFIG QUIET)
|
||||
|
||||
if (NOT Qt6Tools_FOUND OR NOT Qt6ToolsTools_FOUND)
|
||||
message(STATUS "Qt6Tools or Qt6ToolsTools not found, not generating API documentation")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (NOT TARGET ${target})
|
||||
message(FATAL_ERROR "${target} is not a target")
|
||||
@@ -71,22 +78,26 @@ function(ecm_generate_qdoc target qdocconf_file)
|
||||
set(qdoc_extra_args "")
|
||||
|
||||
if (NOT QDOC_BIN)
|
||||
if (NOT TARGET Qt6::qdoc)
|
||||
message("qdoc executable not found, not generating API documentation")
|
||||
return()
|
||||
endif()
|
||||
get_target_property(QDOC_BIN Qt6::qdoc LOCATION)
|
||||
endif()
|
||||
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
get_target_property(target_bin_dir ${target} BINARY_DIR)
|
||||
get_target_property(target_source_dir ${target} SOURCE_DIR)
|
||||
set(doc_output_dir "${target_bin_dir}/.doc")
|
||||
set(doc_output_dir "${CMAKE_BINARY_DIR}/.doc")
|
||||
|
||||
# Generate include dir list
|
||||
set(target_include_dirs_file "${doc_output_dir}/$<CONFIG>/includes.txt")
|
||||
set(target_include_dirs_file "${doc_output_dir}/${target}_$<CONFIG>_includes.txt")
|
||||
|
||||
set(include_paths_property "$<TARGET_PROPERTY:${target},INCLUDE_DIRECTORIES>")
|
||||
|
||||
file(GENERATE
|
||||
OUTPUT ${target_include_dirs_file}
|
||||
CONTENT "$<$<BOOL:${include_paths_property}>:-I$<JOIN:${include_paths_property},\n-I>>\n-I$<TARGET_PROPERTY:${target},BINARY_DIR>"
|
||||
CONTENT "$<$<BOOL:${include_paths_property}>:-I$<JOIN:${include_paths_property},\n-I>>\n-I$<TARGET_PROPERTY:${target},BINARY_DIR>\n-I$<TARGET_PROPERTY:${target},SOURCE_DIR>"
|
||||
)
|
||||
set(include_path_args "@${target_include_dirs_file}")
|
||||
|
||||
@@ -156,47 +167,51 @@ function(ecm_generate_qdoc target qdocconf_file)
|
||||
${generate_qdoc_args}
|
||||
)
|
||||
|
||||
# generate .qch
|
||||
set(qch_file_name ${doc_target}.qch)
|
||||
set(qch_file_path ${dest_dir}/${doc_target}/${qch_file_name})
|
||||
|
||||
get_target_property(QHelpGenerator_EXECUTABLE Qt6::qhelpgenerator LOCATION)
|
||||
|
||||
add_custom_target(generate_qch_${target}
|
||||
COMMAND ${QHelpGenerator_EXECUTABLE}
|
||||
"${dest_dir}/html/${doc_target}.qhp"
|
||||
-o "${qch_file_path}"
|
||||
)
|
||||
|
||||
add_dependencies(prepare_docs prepare_docs_${target})
|
||||
add_dependencies(generate_docs generate_docs_${target})
|
||||
add_dependencies(generate_qch generate_qch_${target})
|
||||
add_dependencies(install_html_docs install_html_docs_${target})
|
||||
add_dependencies(install_qch_docs install_qch_docs_${target})
|
||||
|
||||
install(DIRECTORY "${dest_dir}/html/"
|
||||
DESTINATION "${KDE_INSTALL_QTQCHDIR}/${doc_target}"
|
||||
COMPONENT _install_html_docs_${target}
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
# generate .qch
|
||||
if (TARGET Qt6::qhelpgenerator)
|
||||
set(qch_file_name ${doc_target}.qch)
|
||||
set(qch_file_path ${dest_dir}/${qch_file_name})
|
||||
get_target_property(QHelpGenerator_EXECUTABLE Qt6::qhelpgenerator LOCATION)
|
||||
|
||||
add_custom_target(install_html_docs_${target}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
--install "${CMAKE_BINARY_DIR}"
|
||||
--component _install_html_docs_${target}
|
||||
COMMENT "Installing html docs for target ${target}"
|
||||
)
|
||||
add_custom_target(generate_qch_${target}
|
||||
COMMAND ${QHelpGenerator_EXECUTABLE}
|
||||
"${dest_dir}/${doc_target}/${doc_target}.qhp"
|
||||
-o "${qch_file_path}"
|
||||
)
|
||||
|
||||
install(FILES "${qch_file_path}"
|
||||
DESTINATION "${KDE_INSTALL_QTQCHDIR}"
|
||||
COMPONENT _install_qch_docs_${target}
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
add_dependencies(generate_qch generate_qch_${target})
|
||||
add_dependencies(install_html_docs install_html_docs_${target})
|
||||
add_dependencies(install_qch_docs install_qch_docs_${target})
|
||||
|
||||
add_custom_target(install_qch_docs_${target}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
--install "${CMAKE_BINARY_DIR}"
|
||||
--component _install_qch_docs_${target}
|
||||
COMMENT "Installing qch docs for target ${target}"
|
||||
)
|
||||
install(DIRECTORY "${dest_dir}/${doc_target}/"
|
||||
DESTINATION "${KDE_INSTALL_QTQCHDIR}/${doc_target}"
|
||||
COMPONENT _install_html_docs_${target}
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
add_custom_target(install_html_docs_${target}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
--install "${CMAKE_BINARY_DIR}"
|
||||
--component _install_html_docs_${target}
|
||||
COMMENT "Installing html docs for target ${target}"
|
||||
)
|
||||
|
||||
install(FILES "${qch_file_path}"
|
||||
DESTINATION "${KDE_INSTALL_QTQCHDIR}"
|
||||
COMPONENT _install_qch_docs_${target}
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
add_custom_target(install_qch_docs_${target}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
--install "${CMAKE_BINARY_DIR}"
|
||||
--component _install_qch_docs_${target}
|
||||
COMMENT "Installing qch docs for target ${target}"
|
||||
)
|
||||
else()
|
||||
message("qhelpgenerator executable not found, not generating API documentation in QCH format")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@@ -23,10 +23,14 @@ The plugin.qmltypes file will sit in the source directory. This function will
|
||||
include the code that installs the file in the right place and a small unit
|
||||
test named qmltypes-pluginname-version that makes sure that it doesn't need updating.
|
||||
|
||||
With Qt6 prefer using qt_add_qml_module()/ecm_add_qml_module() and declarative
|
||||
type registration, which do this automatically.
|
||||
|
||||
Since 5.33.0
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
function(ecm_generate_qmltypes)
|
||||
if (NOT TARGET qmltypes)
|
||||
add_custom_target(qmltypes)
|
||||
|
||||
@@ -71,6 +71,8 @@ into ``<icon_install_dir>/hicolor/22x22/actions/menu_new.png``
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
# A "map" of short type names to the directories.
|
||||
# Unknown names produce a warning.
|
||||
set(_ECM_ICON_GROUP_mimetypes "mimetypes")
|
||||
|
||||
@@ -22,6 +22,8 @@ This will cause the specified targets to not be built unless either
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
if (NOT BUILD_TESTING)
|
||||
if(NOT TARGET buildtests)
|
||||
add_custom_target(buildtests)
|
||||
|
||||
@@ -19,6 +19,8 @@ than MacOS X or Windows, this will have no effect.
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
function(ecm_mark_nongui_executable)
|
||||
foreach(_target ${ARGN})
|
||||
set_target_properties(${_target}
|
||||
|
||||
+2
@@ -33,6 +33,8 @@ one named "foo":
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
function(ECM_OPTIONAL_ADD_SUBDIRECTORY _dir)
|
||||
get_filename_component(_fullPath ${_dir} ABSOLUTE)
|
||||
if(EXISTS ${_fullPath}/CMakeLists.txt)
|
||||
|
||||
@@ -55,6 +55,8 @@ an informative diagnostic message if the dependency could not be found.
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_ROOT}/Modules/CMakePackageConfigHelpers.cmake)
|
||||
|
||||
set(_ecm_package_config_helpers_included TRUE)
|
||||
|
||||
@@ -82,6 +82,8 @@ it uses ``share/locale``.
|
||||
Since pre-1.0.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/QtVersionOption.cmake)
|
||||
option(KF_SKIP_PO_PROCESSING "Skip processing of po files" OFF)
|
||||
|
||||
@@ -158,7 +160,7 @@ function(ecm_process_po_files_as_qm lang)
|
||||
else()
|
||||
# Qt < 5.3.1 does not define Qt5::lconvert
|
||||
get_target_property(lrelease_location Qt5::lrelease LOCATION)
|
||||
get_filename_component(lrelease_path ${lrelease_location} PATH)
|
||||
get_filename_component(lrelease_path ${lrelease_location} DIRECTORY)
|
||||
find_program(lconvert_executable
|
||||
NAMES lconvert-qt5 lconvert
|
||||
PATHS ${lrelease_path}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
if (${ECM_GLOBAL_FIND_VERSION} VERSION_GREATER_EQUAL 5.88)
|
||||
message(DEPRECATION "ECMQMLModules.cmake is deprecated since 5.88.0, please use ECMFindQmlModule.cmake instead")
|
||||
endif()
|
||||
|
||||
@@ -77,7 +77,11 @@ namespace {
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
# ifdef Q_OS_MACOS
|
||||
const QString fullPath = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, subPath);
|
||||
# else
|
||||
const QString fullPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, subPath);
|
||||
# endif
|
||||
if (fullPath.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -100,16 +104,42 @@ namespace {
|
||||
loadTranslation(QStringLiteral("en"));
|
||||
|
||||
auto langs = getSystemLocale().uiLanguages();
|
||||
for (auto it = langs.begin(); it != langs.end(); ++it) {
|
||||
(*it).replace(QLatin1Char('-'), QLatin1Char('_'));
|
||||
const auto idx = (*it).indexOf(QLatin1Char('_'));
|
||||
|
||||
for (int i = 0; i < langs.size(); i++) {
|
||||
langs[i].replace(QLatin1Char('-'), QLatin1Char('_'));
|
||||
const auto idx = langs[i].indexOf(QLatin1Char('_'));
|
||||
if (idx > 0) {
|
||||
const QString genericLang = (*it).left(idx);
|
||||
it = langs.insert(++it, genericLang);
|
||||
// insert the country stripped language to the ideal position,
|
||||
// that is, after the same language dialects.
|
||||
// if langs is [pt_Latn_BR, pt_BR], the pt should be inserted
|
||||
// after pt_BR
|
||||
const QString genericLang = langs[i].left(idx);
|
||||
int j = i + 1;
|
||||
int insertIdx = j;
|
||||
bool found = false;
|
||||
while (j < langs.size()) {
|
||||
if (langs[j] == genericLang) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (langs[j].startsWith(genericLang)) {
|
||||
insertIdx = j + 1;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (!found) {
|
||||
langs.insert(insertIdx, genericLang);
|
||||
}
|
||||
}
|
||||
}
|
||||
langs.removeDuplicates();
|
||||
for (const auto &lang : langs) {
|
||||
for (const auto &lang :
|
||||
#if QT_VERSION_MAJOR == 5
|
||||
qAsConst(langs)
|
||||
#else
|
||||
std::as_const(langs)
|
||||
#endif
|
||||
) {
|
||||
if (lang == QLatin1String("en") || loadTranslation(lang)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7,32 +7,75 @@
|
||||
ECMQmlModule
|
||||
------------
|
||||
|
||||
This file contains helper functions to make it easier to create QML modules. It
|
||||
takes care of a number of things that often need to be repeated. It also takes
|
||||
care of special handling of QML modules between shared and static builds. When
|
||||
building a static version of a QML module, the relevant QML source files are
|
||||
bundled into the static library. When using a shared build, the QML plugin and
|
||||
relevant QML files are copied to the target's ``RUNTIME_OUTPUT_DIRECTORY`` to make
|
||||
it easier to run things directly from the build directory.
|
||||
Helper functions to make it easier to create QML modules.
|
||||
|
||||
This CMake module lets you create QML-enabled targets, add C++ and QML files
|
||||
to them, and finalize the module if needed. When using Qt 6, it allows for
|
||||
`declarative registration of QML types <https://www.qt.io/blog/qml-type-registration-in-qt-5.15>`_.
|
||||
|
||||
This CMake module reduces boilerplate and takes care of special
|
||||
handling of QML modules between shared and static builds:
|
||||
|
||||
- When building a static version of a QML module, the relevant QML source
|
||||
files are bundled into the static library.
|
||||
|
||||
- When using a shared build, the QML plugin and relevant QML files are copied
|
||||
to the target's ``RUNTIME_OUTPUT_DIRECTORY`` to make it easier to run things
|
||||
directly from the build directory.
|
||||
|
||||
Since 6.0.0, when using Qt 6, most functionality of this module has been
|
||||
implemented by upstream Qt. Most of the functions here will now forward to the
|
||||
similar Qt functions.
|
||||
|
||||
Example usage:
|
||||
Example usage with an executable as backing target:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
ecm_add_qml_module(ExampleModule URI "org.example.Example")
|
||||
add_executable(app)
|
||||
ecm_add_qml_module(app
|
||||
URI "org.example.Example"
|
||||
)
|
||||
|
||||
target_sources(ExampleModule PRIVATE ExamplePlugin.cpp)
|
||||
target_link_libraries(ExampleModule PRIVATE Qt::Quick)
|
||||
target_sources(app PRIVATE main.cpp)
|
||||
target_link_libraries(app PRIVATE Qt::Quick)
|
||||
|
||||
ecm_target_qml_sources(ExampleModule SOURCES ExampleItem.qml) # This will have 1.0 as the default version
|
||||
ecm_target_qml_sources(ExampleModule SOURCES AnotherExampleItem.qml VERSION 1.5)
|
||||
ecm_target_qml_sources(app SOURCES ExampleItem.qml) # This will have 1.0 as the default version
|
||||
ecm_target_qml_sources(app SOURCES AnotherExampleItem.qml VERSION 1.5)
|
||||
|
||||
ecm_finalize_qml_module(ExampleModule DESTINATION ${KDE_INSTALL_QMLDIR})
|
||||
install(TARGETS app ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
||||
The above example creates an executable target, modifies the target to allow it
|
||||
to accept QML files and properties, adds source files to it, and installs it.
|
||||
|
||||
The executable is the backing target for the QML module, which in practical
|
||||
terms means the QML module is "embedded" into the executable, always being
|
||||
loaded as part of the application, and no plugin library is created.
|
||||
|
||||
Example usage with a separate QML module:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
add_library(ExampleModule)
|
||||
ecm_add_qml_module(ExampleModule
|
||||
URI org.example.Example
|
||||
GENERATE_PLUGIN_SOURCE
|
||||
)
|
||||
|
||||
target_sources(ExampleModule PRIVATE ExamplePlugin.cpp)
|
||||
target_link_libraries(ExampleModule PRIVATE Qt::Quick)
|
||||
|
||||
ecm_target_qml_sources(ExampleModule SOURCES ExampleItem.qml)
|
||||
|
||||
ecm_finalize_qml_module(ExampleModule DESTINATION ${KDE_INSTALL_QMLDIR})
|
||||
|
||||
install(TARGETS ExampleModule ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
||||
The above example creates a library target, modifies the target to allow it to accept QML files and
|
||||
properties, adds source files to it, and finalizes the target.
|
||||
|
||||
The library acts as a plugin that is expected to be linked to an
|
||||
executable later on, in which case ``GENERATE_PLUGIN_SOURCE`` and
|
||||
``ecm_finalize_qml_module()`` are both required.
|
||||
|
||||
::
|
||||
|
||||
@@ -43,6 +86,8 @@ Example usage:
|
||||
[CLASSNAME <class name>] # Deprecated since 6.0.0 when using Qt 6, use CLASS_NAME instead
|
||||
[QT_NO_PLUGIN] # Since 6.0.0, when using Qt 6
|
||||
[GENERATE_PLUGIN_SOURCE] # Since 6.0.0, when using Qt 6
|
||||
[DEPENDENCIES <dependency> ...] # Since 6.0.0, when using Qt 6, inherited from qt_add_qml_module()
|
||||
[IMPORTS <import> ...] # Since 6.0.0, when using Qt 6, inherited from qt_add_qml_module()
|
||||
)
|
||||
|
||||
This will declare a new CMake target called ``<target name>``. The ``URI``
|
||||
@@ -54,8 +99,9 @@ version that is used by ``ecm_target_qml_sources`` when adding QML files. If it
|
||||
is not specified, a default of 1.0 is used. Additionally, if a version greater
|
||||
than or equal to 2.0 is specified, the major version is appended to the
|
||||
Qt5 installation path of the module.
|
||||
In case you don't specify and version, but specify a version for the individual sources, the latest
|
||||
will be set as the resulting version for this plugin. This will be used in the ECMFindQmlModule module.
|
||||
In case you don't specify a version for the module, but specify a version for
|
||||
the individual sources, the latter will be set as the resulting version for
|
||||
this module. This will also be used in the ECMFindQmlModule module.
|
||||
|
||||
If the option ``NO_PLUGIN`` is set, a target is declared that is not expected to
|
||||
contain any C++ QML plugin.
|
||||
@@ -73,14 +119,28 @@ Since 6.0.0, when used with Qt 6, this will forward to ``qt_add_qml_module``. An
|
||||
be forwarded as well. The ``NO_PLUGIN`` argument is deprecated and implies ``GENERATE_PLUGIN_SOURCE``,
|
||||
since modules in Qt 6 always require a plugin or backing target. If you want to use Qt's behaviour for
|
||||
``NO_PLUGIN``, use ``QT_NO_PLUGIN`` instead. Additionally, to maintain backward compatibility, by
|
||||
default we pass ``NO_GENERATE_PLUGIN_SOURCE`` to ``qt_add_qml_module``. To have Qt generate the plugin
|
||||
sources, pass ``GENERATE_PLUGIN_SOURCE``.
|
||||
default we pass ``NO_GENERATE_PLUGIN_SOURCE`` to ``qt_add_qml_module``.
|
||||
|
||||
If you are using the executable as backing target for your QML module, the
|
||||
default behavior should suffice. If you are using a separate QML module,
|
||||
you will need to have Qt generate the plugin sources, in which case you
|
||||
should pass ``GENERATE_PLUGIN_SOURCE``.
|
||||
|
||||
The ``DEPENDENCIES`` and ``IMPORTS`` options come from ``qt_add_qml_module()``
|
||||
since Qt 6, and behave as in upstream Qt.
|
||||
|
||||
Use ``DEPENDENCIES`` for things like "QtCore", "QtQuick", "your.custom.qmlmodule",
|
||||
as well as C++ only dependencies. This is required for QML-exposed C++ code, like when subclassing a type or using it as a parameter type in properties and invokables.
|
||||
|
||||
Use ``IMPORTS`` to make a type available a part of a module's public interface. In other words, if a QML file imports this module, it also imports all the modules listed under IMPORTS.
|
||||
|
||||
See `Declaring module dependencies <https://doc.qt.io/qt-6/qt-add-qml-module.html#declaring-module-dependencies>`_ and `10 Tips to Make Your QML Code Faster and More Maintainable <https://www.kdab.com/10-tips-to-make-your-qml-code-faster-and-more-maintainable/>`_ for details.
|
||||
|
||||
::
|
||||
|
||||
ecm_add_qml_module_dependencies(<target> DEPENDS <module string> [<module string> ...])
|
||||
|
||||
Add the list of dependencies specified by the ``DEPENDS`` argument to be listed
|
||||
Adds the list of dependencies specified by the ``DEPENDS`` argument to be listed
|
||||
as dependencies in the generated QMLDIR file of ``<target>``.
|
||||
|
||||
Since 5.91.0
|
||||
@@ -92,7 +152,7 @@ Since 6.0.0, this is deprecated and ignored when using Qt 6, instead use the
|
||||
|
||||
ecm_target_qml_sources(<target> SOURCES <source.qml> [<source.qml> ...] [VERSION <version>] [PATH <path>] [PRIVATE])
|
||||
|
||||
Add the list of QML files specified by the ``SOURCES`` argument as source files
|
||||
Adds the list of QML files specified by the ``SOURCES`` argument as source files
|
||||
to the QML module target ``<target>``.
|
||||
|
||||
If the optional ``VERSION`` argument is specified, all QML files will be added
|
||||
@@ -128,20 +188,24 @@ to ``qt_target_qml_sources()``.
|
||||
[EXPORT <export-set>] # Added for 6.8 when using Qt 6
|
||||
)
|
||||
|
||||
Finalize the specified QML module target. This must be called after all other
|
||||
setup (like adding sources) on the target has been done. It will perform a
|
||||
number of tasks:
|
||||
Finalizes the specified QML module target.
|
||||
|
||||
This is required in case you do not use the executable as backing target.
|
||||
|
||||
This must be called after all other setup (like adding sources) on the target
|
||||
has been done. It will perform a number of tasks:
|
||||
|
||||
- It will generate a qmldir file from the QML files added to the target. If the
|
||||
module has a C++ plugin, this will also be included in the qmldir file.
|
||||
- If ``BUILD_SHARED_LIBS`` is off, a QRC file is generated from the QML files
|
||||
added to the target. This QRC file will be included when compiling the C++ QML
|
||||
module. The built static library will be installed in a subdirection of
|
||||
``DESTINATION`` based on the QML module's uri. If this value is not set, KDE_INSTALL_QMLDIR will be used.
|
||||
Note that if ``NO_PLUGIN`` is set, a C++ QML plugin will be generated to include the QRC files.
|
||||
- If ``BUILD_SHARED_LIBS`` in on, all generated files, QML sources and the C++
|
||||
plugin will be installed in a subdirectory of ``DESTINATION`` based upon the
|
||||
QML module's uri. In addition, these files will also be copied to the target's
|
||||
module. The built static library will be installed in a subdirectory of
|
||||
``DESTINATION`` based on the QML module's URI. If this value is not set,
|
||||
KDE_INSTALL_QMLDIR will be used. Note that if ``NO_PLUGIN`` is set, a C++
|
||||
QML plugin will be generated to include the QRC files.
|
||||
- If ``BUILD_SHARED_LIBS`` is on, all generated files, QML sources and the C++
|
||||
plugin will be installed in a subdirectory of ``DESTINATION`` based on the
|
||||
QML module's URI. In addition, these files will also be copied to the target's
|
||||
``RUNTIME_OUTPUT_DIRECTORY`` in a similar subdirectory.
|
||||
- If ``BUILD_SHARED_LIBS`` is off, ``EXPORT`` allows to specify a CMake export set
|
||||
all installed targets should be added to.
|
||||
@@ -157,10 +221,20 @@ default to ``PROJECT_VERSION`` and which will write a file that is used by
|
||||
|
||||
Since 6.1.0
|
||||
|
||||
Enabling the option ``VERBOSE_QML_COMPILER`` will activate verbose output for qmlcachegen.
|
||||
Enabling the global option ``VERBOSE_QML_COMPILER`` during CMake configuration
|
||||
will activate verbose output for qmlcachegen.
|
||||
|
||||
Since 6.18.0
|
||||
|
||||
Generate code from qmlcachegen is put into the same ``UNITY_GROUP``. Unity builds
|
||||
using this can either be activated manually per target or with the ``ECM_QMLCACHE_UNITY_BUILD``
|
||||
option globally. This can speed up clean builds at the expense of needing more memory
|
||||
and making incremental builds slower.
|
||||
|
||||
#]========================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/QtVersionOption.cmake)
|
||||
|
||||
# This is also used by ECMFindQmlModule, so needs to be available for both
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
# Qt 5 implementation of ECMQmlModule
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
set(_ECM_QMLMODULE_STATIC_QMLONLY_H "${CMAKE_CURRENT_LIST_DIR}/ECMQmlModule.h.in")
|
||||
set(_ECM_QMLMODULE_STATIC_QMLONLY_CPP "${CMAKE_CURRENT_LIST_DIR}/ECMQmlModule.cpp.in")
|
||||
|
||||
@@ -333,7 +335,7 @@ function(ecm_finalize_qml_module ARG_TARGET)
|
||||
WORKING_DIRECTORY ${_runtime_output_dir}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_path}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${_file} ${_file_path}
|
||||
BYPRODUCTS ${_file_path}/${_filename}
|
||||
BYPRODUCTS ${_runtime_output_dir}/${_file_path}/${_filename}
|
||||
)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
# Qt 6 implementation of ECMQmlModule
|
||||
|
||||
set(QT_NO_CREATE_VERSIONLESS_FUNCTIONS ON)
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
find_package(Qt6 COMPONENTS Core Qml CONFIG)
|
||||
unset(QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
|
||||
|
||||
if (NOT TARGET Qt6::Qml)
|
||||
message(WARNING "Target Qt6::Qml was not found. ECMQmlModule requires the QML module when building with Qt 6")
|
||||
@@ -23,6 +23,19 @@ endif()
|
||||
# Stop warning about a changed import prefix.
|
||||
qt6_policy(SET QTP0001 NEW)
|
||||
|
||||
option(ECM_QMLCACHE_UNITY_BUILD "Perform unity builds for source files produced by qmlcachegen." OFF)
|
||||
|
||||
# Internal, puts all qmlcachegen cpp source files into the same unity build group
|
||||
function(_ecm_qml_module_setup_unity_group ARG_TARGET)
|
||||
get_target_property(_sources ${ARG_TARGET} SOURCES)
|
||||
foreach(_src ${_sources})
|
||||
string(REGEX MATCH "\\.rcc/qmlcache/" _is_qmlcache ${_src})
|
||||
if (_is_qmlcache)
|
||||
set_source_files_properties(${_src} PROPERTIES UNITY_GROUP "qmlcache")
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(ecm_add_qml_module ARG_TARGET)
|
||||
cmake_parse_arguments(PARSE_ARGV 1 ARG "NO_PLUGIN;QT_NO_PLUGIN;GENERATE_PLUGIN_SOURCE" "URI;VERSION;CLASSNAME;OUTPUT_TARGETS" "")
|
||||
|
||||
@@ -60,7 +73,7 @@ function(ecm_add_qml_module ARG_TARGET)
|
||||
endif()
|
||||
|
||||
if (NOT ARG_GENERATE_PLUGIN_SOURCE)
|
||||
list(APPEND _arguments NO_GENERATE_PLUGIN_SOURCE)
|
||||
list(APPEND _arguments NO_GENERATE_PLUGIN_SOURCE NO_PLUGIN_OPTIONAL)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET ${ARG_TARGET})
|
||||
@@ -107,6 +120,9 @@ function(ecm_add_qml_module ARG_TARGET)
|
||||
)
|
||||
endif()
|
||||
|
||||
_ecm_qml_module_setup_unity_group(${ARG_TARGET})
|
||||
set_target_properties(${ARG_TARGET} PROPERTIES UNITY_BUILD_MODE GROUP)
|
||||
set_target_properties(${ARG_TARGET} PROPERTIES UNITY_BUILD ${ECM_QMLCACHE_UNITY_BUILD})
|
||||
endfunction()
|
||||
|
||||
function(ecm_add_qml_module_dependencies ARG_TARGET)
|
||||
@@ -159,6 +175,7 @@ function(ecm_target_qml_sources ARG_TARGET)
|
||||
list(APPEND _ecm_output_targets ${_out_targets})
|
||||
set_target_properties(${ARG_TARGET} PROPERTIES _ecm_output_targets "${_ecm_output_targets}")
|
||||
|
||||
_ecm_qml_module_setup_unity_group(${ARG_TARGET})
|
||||
endfunction()
|
||||
|
||||
function(ecm_finalize_qml_module ARG_TARGET)
|
||||
|
||||
+2
@@ -150,6 +150,8 @@ Example usage:
|
||||
Since 5.68.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
set(_ECM_QT_DECLARE_LOGGING_CATEGORY_TEMPLATE_CPP "${CMAKE_CURRENT_LIST_DIR}/ECMQtDeclareLoggingCategory.cpp.in")
|
||||
set(_ECM_QT_DECLARE_LOGGING_CATEGORY_TEMPLATE_H "${CMAKE_CURRENT_LIST_DIR}/ECMQtDeclareLoggingCategory.h.in")
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
if (${ECM_GLOBAL_FIND_VERSION} VERSION_GREATER_EQUAL 5.93)
|
||||
message(DEPRECATION "ECMQueryQmake.cmake is deprecated since 5.93, please use ECMQueryQt.cmake instead.")
|
||||
endif()
|
||||
|
||||
@@ -35,6 +35,8 @@ If the call succeeds ``${bin_dir}`` will be set to ``<prefix>/path/to/bin/dir``
|
||||
Since: 5.93
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/QtVersionOption.cmake)
|
||||
include(CheckLanguage)
|
||||
check_language(CXX)
|
||||
|
||||
+39
-19
@@ -11,6 +11,7 @@ Instruct CMake's automoc about C++ preprocessor macros used to define Qt-style p
|
||||
::
|
||||
|
||||
ecm_setup_qtplugin_macro_names(
|
||||
[MACRO_NAMES <macro_name> [<macro_name> [...]]] # since 6.18
|
||||
[JSON_NONE <macro_name> [<macro_name> [...]]]
|
||||
[JSON_ARG1 <macro_name> [<macro_name> [...]]]
|
||||
[JSON_ARG2 <macro_name> [<macro_name> [...]]]
|
||||
@@ -21,21 +22,28 @@ CMake's automoc needs some support when parsing C++ source files to detect wheth
|
||||
should be run on those files and if there are also dependencies on other files, like those
|
||||
with Qt plugin metadata in JSON format. Because automoc just greps overs the raw plain text
|
||||
of the sources without any C++ preprocessor-like processing.
|
||||
CMake in newer versions provides the variables ``CMAKE_AUTOMOC_DEPEND_FILTERS`` (CMake >= 3.9.0)
|
||||
and ``CMAKE_AUTOMOC_MACRO_NAMES`` (CMake >= 3.10) to allow the developer to assist automoc.
|
||||
CMake in newer versions provides the variable ``CMAKE_AUTOMOC_MACRO_NAMES`` (CMake >= 3.10)
|
||||
to allow the developer to assist automoc. For Qt up to version 5.15 additionally
|
||||
the variable ``CMAKE_AUTOMOC_DEPEND_FILTERS`` (CMake >= 3.9.0) can be used.
|
||||
|
||||
This macro cares for the explicit setup needed for those variables for common cases of
|
||||
C++ preprocessor macros used for Qt-style plugins.
|
||||
|
||||
``MACRO_NAMES`` lists the names of C++ preprocessor macros for Qt-style plugins.
|
||||
Requires at least Qt 5.15. Since 6.18.
|
||||
|
||||
``JSON_NONE`` lists the names of C++ preprocessor macros for Qt-style plugins which do not refer to
|
||||
external files with the plugin metadata.
|
||||
external files with the plugin metadata. Use ``MACRO_NAMES`` instead for Qt >= 5.15.
|
||||
|
||||
``JSON_ARG1`` lists the names of C++ preprocessor macros for Qt-style plugins where the first argument
|
||||
to the macro is the name of the external file with the plugin metadata.
|
||||
Use ``MACRO_NAMES`` instead for Qt >= 5.15.
|
||||
|
||||
``JSON_ARG2`` is the same as ``JSON_ARG1`` but with the file name being the second argument.
|
||||
Use ``MACRO_NAMES`` instead for Qt >= 5.15.
|
||||
|
||||
``JSON_ARG3`` is the same as ``JSON_ARG1`` but with the file name being the third argument.
|
||||
Use ``MACRO_NAMES`` instead for Qt >= 5.15.
|
||||
|
||||
``CONFIG_CODE_VARIABLE`` specifies the name of the variable which will get set as
|
||||
value some generated CMake code for instructing automoc for the given macro names,
|
||||
@@ -63,7 +71,7 @@ In the CMake buildsystem of the library one calls
|
||||
.. code-block:: cmake
|
||||
|
||||
ecm_setup_qtplugin_macro_names(
|
||||
JSON_ARG2
|
||||
MACRO_NAMES
|
||||
EXPORT_MYPLUGIN_WITH_JSON
|
||||
)
|
||||
|
||||
@@ -79,7 +87,7 @@ automoc about the usage of that macro.
|
||||
.. code-block:: cmake
|
||||
|
||||
ecm_setup_qtplugin_macro_names(
|
||||
JSON_ARG2
|
||||
MACRO_NAMES
|
||||
EXPORT_MYPLUGIN_WITH_JSON
|
||||
CONFIG_CODE_VARIABLE
|
||||
PACKAGE_SETUP_AUTOMOC_VARIABLES
|
||||
@@ -97,12 +105,14 @@ automoc is instructed as well as needed:
|
||||
Since 5.45.0.
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
macro(ecm_setup_qtplugin_macro_names)
|
||||
set(options )
|
||||
set(oneValueArgs CONFIG_CODE_VARIABLE)
|
||||
set(multiValueArgs JSON_NONE JSON_ARG1 JSON_ARG2 JSON_ARG3)
|
||||
set(multiValueArgs MACRO_NAMES JSON_NONE JSON_ARG1 JSON_ARG2 JSON_ARG3)
|
||||
|
||||
cmake_parse_arguments(ESQMN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
@@ -110,17 +120,33 @@ macro(ecm_setup_qtplugin_macro_names)
|
||||
message(FATAL_ERROR "Unknown keywords given to ECM_SETUP_QTPLUGIN_MACRO_NAMES(): \"${ESQMN_UNPARSED_ARGUMENTS}\"")
|
||||
endif()
|
||||
|
||||
if(ESQMN_MACRO_NAMES)
|
||||
if(ESQMN_JSON_NONE OR ESQMN_JSON_ARG1 OR ESQMN_JSON_ARG2 OR ESQMN_JSON_ARG3)
|
||||
message(FATAL_ERROR "Use either MACRO_NAMES or any of the JSON_* arguments with ECM_SETUP_QTPLUGIN_MACRO_NAMES()")
|
||||
endif()
|
||||
set(_macro_names ${ESQMN_MACRO_NAMES})
|
||||
else()
|
||||
# nag user to switch to newer args when possible (Qt 5.15 projects ignored nere)
|
||||
if (ECM_GLOBAL_FIND_VERSION VERSION_GREATER_EQUAL 6.18 AND QT_MAJOR_VERSION EQUAL 6)
|
||||
message(WARNING "For ECM >= 6.18, use the MACRO_NAMES argument instead of the JSON_* ones with ECM_SETUP_QTPLUGIN_MACRO_NAMES()")
|
||||
endif()
|
||||
|
||||
set(_macro_names
|
||||
${ESQMN_JSON_NONE}
|
||||
${ESQMN_JSON_ARG1}
|
||||
${ESQMN_JSON_ARG2}
|
||||
${ESQMN_JSON_ARG3}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# CMAKE_AUTOMOC_MACRO_NAMES
|
||||
list(APPEND CMAKE_AUTOMOC_MACRO_NAMES
|
||||
${ESQMN_JSON_NONE}
|
||||
${ESQMN_JSON_ARG1}
|
||||
${ESQMN_JSON_ARG2}
|
||||
${ESQMN_JSON_ARG3}
|
||||
)
|
||||
list(APPEND CMAKE_AUTOMOC_MACRO_NAMES ${_macro_names})
|
||||
|
||||
# CMAKE_AUTOMOC_DEPEND_FILTERS
|
||||
# CMake's automoc needs help to find names of plugin metadata files in case Q_PLUGIN_METADATA
|
||||
# is indirectly used via other C++ preprocessor macros
|
||||
# Note: unused for Qt >= 5.15.
|
||||
foreach(macro_name ${ESQMN_JSON_ARG1})
|
||||
list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS
|
||||
"${macro_name}"
|
||||
@@ -152,16 +178,10 @@ macro(ecm_setup_qtplugin_macro_names)
|
||||
"####################################################################################
|
||||
# CMAKE_AUTOMOC
|
||||
")
|
||||
set(_all_macro_names
|
||||
${ESQMN_JSON_NONE}
|
||||
${ESQMN_JSON_ARG1}
|
||||
${ESQMN_JSON_ARG2}
|
||||
${ESQMN_JSON_ARG3}
|
||||
)
|
||||
string(APPEND _content "
|
||||
# CMake 3.9+ warns about automoc on files without Q_OBJECT, and doesn't know about other macros.
|
||||
# 3.10+ lets us provide more macro names that require automoc.
|
||||
foreach(macro_name ${_all_macro_names})
|
||||
foreach(macro_name ${_macro_names})
|
||||
# we can be run multiple times, so add only once
|
||||
list (FIND CMAKE_AUTOMOC_MACRO_NAMES \"\${macro_name}\" _index)
|
||||
if(_index LESS 0)
|
||||
|
||||
@@ -36,8 +36,8 @@ version of ECM is < 5.83)::
|
||||
|
||||
<prefix>_VERSION_STRING - <version> (use <prefix>_VERSION instead)
|
||||
|
||||
If CMake policy CMP0048 is not ``NEW``, the following CMake variables will also
|
||||
be set::
|
||||
With CMake versions older than 4.0.0 and if CMake policy CMP0048 is not ``NEW``,
|
||||
the following CMake variables will also be set::
|
||||
|
||||
PROJECT_VERSION_MAJOR - <major>
|
||||
PROJECT_VERSION_MINOR - <minor>
|
||||
@@ -72,8 +72,8 @@ relative path, it is interpreted as relative to ``CMAKE_CURRENT_BINARY_DIR``. Th
|
||||
optional ``COMPATIBILITY`` option is forwarded to
|
||||
``write_basic_package_version_file()``, and defaults to ``AnyNewerVersion``.
|
||||
|
||||
If CMake policy CMP0048 is ``NEW``, an alternative form of the command is
|
||||
available::
|
||||
With CMake versions >= 4.0.0 or if CMake policy CMP0048 is ``NEW``, an alternative
|
||||
form of the command is available::
|
||||
|
||||
ecm_setup_version(PROJECT
|
||||
[VARIABLE_PREFIX <prefix>]
|
||||
@@ -91,6 +91,13 @@ Since pre-1.0.0.
|
||||
``COMPATIBILITY`` option available since 1.6.0.
|
||||
#]=======================================================================]
|
||||
|
||||
# cache set policy at time of module inclusion
|
||||
if(CMAKE_MAJOR_VERSION VERSION_LESS 4)
|
||||
cmake_policy(GET CMP0048 _ecm_setup_version_project_version_policy)
|
||||
endif()
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# save the location of the header template while CMAKE_CURRENT_LIST_DIR
|
||||
@@ -110,14 +117,20 @@ function(ecm_setup_version _version)
|
||||
|
||||
set(project_manages_version FALSE)
|
||||
set(use_project_version FALSE)
|
||||
cmake_policy(GET CMP0048 project_version_policy)
|
||||
if(project_version_policy STREQUAL "NEW")
|
||||
if(CMAKE_MAJOR_VERSION VERSION_GREATER_EQUAL 4)
|
||||
set(project_manages_version TRUE)
|
||||
if(_version STREQUAL "PROJECT")
|
||||
set(use_project_version TRUE)
|
||||
endif()
|
||||
elseif(_version STREQUAL "PROJECT")
|
||||
message(FATAL_ERROR "ecm_setup_version given PROJECT argument, but CMP0048 is not NEW")
|
||||
else()
|
||||
if(_ecm_setup_version_project_version_policy STREQUAL "NEW")
|
||||
set(project_manages_version TRUE)
|
||||
if(_version STREQUAL "PROJECT")
|
||||
set(use_project_version TRUE)
|
||||
endif()
|
||||
elseif(_version STREQUAL "PROJECT")
|
||||
message(FATAL_ERROR "ecm_setup_version given PROJECT argument, but CMP0048 is not NEW")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(should_set_prefixed_vars TRUE)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user