From 1dd2029e5585385ea42d3092b010a8879ff00201 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sat, 10 Jan 2015 17:15:33 +0000 Subject: Fix CMP0053 warning with CMake 3.1. With CMake 3.1, @-style variable expansion is deprecated outside of configure_file() or string(CONFIGURE) contexts (CMP0053). This causes ecm_generate_pri_file() to produce dev warnings with this verison of CMake, and would break this function in projects that set CMake 3.1 as their required version. REVIEW: 121971 --- modules/ECMGeneratePriFile.cmake | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'modules') diff --git a/modules/ECMGeneratePriFile.cmake b/modules/ECMGeneratePriFile.cmake index b353e867..3a409723 100644 --- a/modules/ECMGeneratePriFile.cmake +++ b/modules/ECMGeneratePriFile.cmake @@ -156,16 +156,16 @@ function(ECM_GENERATE_PRI_FILE) file(GENERATE OUTPUT ${PRI_FILENAME} CONTENT - "QT.@PRI_TARGET_BASENAME@.VERSION = @PROJECT_VERSION_STRING@ -QT.@PRI_TARGET_BASENAME@.MAJOR_VERSION = @PROJECT_VERSION_MAJOR@ -QT.@PRI_TARGET_BASENAME@.MINOR_VERSION = @PROJECT_VERSION_MINOR@ -QT.@PRI_TARGET_BASENAME@.PATCH_VERSION = @PROJECT_VERSION_PATCH@ -QT.@PRI_TARGET_BASENAME@.name = @PRI_TARGET_LIBNAME@ -QT.@PRI_TARGET_BASENAME@.defines = @PRI_TARGET_DEFINES@ -QT.@PRI_TARGET_BASENAME@.includes = @PRI_TARGET_INCLUDES@ -QT.@PRI_TARGET_BASENAME@.private_includes = -QT.@PRI_TARGET_BASENAME@.libs = @PRI_TARGET_LIBS@ -QT.@PRI_TARGET_BASENAME@.depends = @PRI_TARGET_QTDEPS@ + "QT.${PRI_TARGET_BASENAME}.VERSION = ${PROJECT_VERSION_STRING} +QT.${PRI_TARGET_BASENAME}.MAJOR_VERSION = ${PROJECT_VERSION_MAJOR} +QT.${PRI_TARGET_BASENAME}.MINOR_VERSION = ${PROJECT_VERSION_MINOR} +QT.${PRI_TARGET_BASENAME}.PATCH_VERSION = ${PROJECT_VERSION_PATCH} +QT.${PRI_TARGET_BASENAME}.name = ${PRI_TARGET_LIBNAME} +QT.${PRI_TARGET_BASENAME}.defines = ${PRI_TARGET_DEFINES} +QT.${PRI_TARGET_BASENAME}.includes = ${PRI_TARGET_INCLUDES} +QT.${PRI_TARGET_BASENAME}.private_includes = +QT.${PRI_TARGET_BASENAME}.libs = ${PRI_TARGET_LIBS} +QT.${PRI_TARGET_BASENAME}.depends = ${PRI_TARGET_QTDEPS} " ) endfunction() -- cgit v1.2.1 From cf5ccc7d9eba368846fae043855d9b064dac786d Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 18 Jan 2015 22:25:26 +0000 Subject: Add ecm_add_app_icon function. This adds an application icon to an executable from PNG files for Windows and Mac OS X. Unlike the similar kde4_add_app_icon macro from kdelibs, this requires icons to be explicitly listed as arguments (meaning CMake can tell when ones are added or deleted and reconfigure as appropriate), and it works with Matthias Benkmann's png2ico tool, as well as the KDE-Win tool of the same name. Currently missing unit tests. Also completely untested (except that `make test` runs on Linux, so there are no obvious syntax errors). With thanks to Ralf Habacker for the inital work on porting kde4_add_app_icon. CHANGELOG: Add ECMAddAppIcon module to add icons to executable targets on Windows and Mac OS X. --- modules/ECMAddAppIcon.cmake | 227 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 modules/ECMAddAppIcon.cmake (limited to 'modules') diff --git a/modules/ECMAddAppIcon.cmake b/modules/ECMAddAppIcon.cmake new file mode 100644 index 00000000..4efdd392 --- /dev/null +++ b/modules/ECMAddAppIcon.cmake @@ -0,0 +1,227 @@ +#.rst: +# ECMAddAppIcon +# ------------- +# +# Add icons to executable files and packages. +# +# :: +# +# ecm_add_app_icon( +# ICONS [ [...]]) +# +# The given icons, whose names must match the pattern:: +# +# -.png +# +# will be added to the executable target whose sources are specified by +# ```` on platforms that support it (Windows and Mac OS X). +# +# ```` is a numeric pixel size (typically 16, 32, 48, 64, 128 or 256). +# ```` can be any other text. See the platform notes below for any +# recommendations about icon sizes. +# +# Windows notes +# * Icons are compiled into the executable using a resource file. +# * Icons may not show up in Windows Explorer if the executable +# target does not have the ``WIN32_EXECUTABLE`` property set. +# * The tool png2ico is required. See :find-module:`FindPng2Ico`. +# * Supported sizes: 16, 32, 48, 64, 128. +# +# Mac OS X notes +# * The executable target must have the ``MACOSX_BUNDLE`` property set. +# * Icons are added to the bundle. +# * The tool iconutil (provided by Apple) is required. +# * Supported sizes: 16, 32, 64, 128, 256, 512, 1024. +# * At least a 128x128px icon is required. +# * Larger sizes are automatically used to substitute for smaller sizes on +# "Retina" (high-resolution) displays. For example, a 32px icon, if +# provided, will be used as a 32px icon on standard-resolution displays, +# and as a 16px-equivalent icon (with an "@2x" tag) on high-resolution +# displays. +# * This function sets the ``MACOSX_BUNDLE_ICON_FILE`` variable to the name +# of the generated icns file, so that it will be used as the +# ``MACOSX_BUNDLE_ICON_FILE`` target property when you call +# ``add_executable``. + +#============================================================================= +# Copyright 2014 Alex Merry +# Copyright 2014 Ralf Habacker +# Copyright 2006-2009 Alexander Neundorf, +# Copyright 2006, 2007, Laurent Montel, +# Copyright 2007 Matthias Kretz +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file COPYING-CMAKE-SCRIPTS for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of extra-cmake-modules, substitute the full +# License text for the above reference.) + +include(CMakeParseArguments) + +function(ecm_add_app_icon appsources) + set(options) + set(oneValueArgs) + set(multiValueArgs ICONS) + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT ARG_ICONS) + message(FATAL_ERROR "No ICONS argument given to ecm_add_app_icon") + endif() + if(ARG_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unexpected arguments to ecm_add_app_icon: ${ARG_UNPARSED_ARGUMENTS}") + endif() + + set(known_sizes 16 32 48 64 128 256 512 1024) + foreach(size ${known_sizes}) + set(icons_at_${size}px) + endforeach() + + foreach(icon ${ARG_ICONS}) + if (NOT EXISTS "${icon}") + message(AUTHOR_WARNING "${icon} does not exist, ignoring") + else() + string(REGEX MATCH "([0-9]+)\\-[^/]+\\.([a-z]+)$" + _dummy "${icon}") + set(size "${CMAKE_MATCH_1}") + set(ext "${CMAKE_MATCH_2}") + if (NOT size) + message(AUTHOR_WARNING "${icon} is not named correctly for ecm_add_app_icon - ignoring") + elseif (NOT ext STREQUAL "png") + message(AUTHOR_WARNING "${icon} is not a png file - ignoring") + else() + list(FIND known_sizes "${size}" offset) + if (offset GREATER -1) + list(APPEND icons_at_${size}px "${icon}") + endif() + endif() + endif() + endforeach() + + set(mac_icons ${icons_at_16px} + ${icons_at_32px} + ${icons_at_64px} + ${icons_at_128px} + ${icons_at_256px} + ${icons_at_512px} + ${icons_at_1024px}) + if (NOT icons_at_128px) + message(AUTHOR_WARNING "No 128px icon provided; this will not work on Mac OS X") + endif() + + set(windows_icons ${icons_at_16px} + ${icons_at_32px} + ${icons_at_48px} + ${icons_at_64px} + ${icons_at_128px}) + if (NOT windows_icons) + message(AUTHOR_WARNING "No icons suitable for use on Windows provided") + endif() + + set (_outfilename "${CMAKE_CURRENT_BINARY_DIR}/${appsources}") + + if (WIN32 AND windows_icons) + set(saved_CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}") + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_FIND_MODULE_DIR}) + find_package(Png2Ico) + set(CMAKE_MODULE_PATH "${saved_CMAKE_MODULE_PATH}") + + if (Png2Ico_FOUND) + if (Png2Ico_HAS_RCFILE_ARGUMENT) + add_custom_command( + OUTPUT "${_outfilename}.rc" "${_outfilename}.ico" + COMMAND Png2Ico::Png2Ico + ARGS + --rcfile "${_outfilename}.rc" + "${_outfilename}.ico" + ${windows_icons} + DEPENDS ${windows_icons} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + ) + else() + add_custom_command( + OUTPUT "${_outfilename}.ico" + COMMAND Png2Ico::Png2Ico + ARGS "${_outfilename}.ico" ${windows_icons} + DEPENDS ${windows_icons} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + ) + # this bit's a little hacky to make the dependency stuff work + file(WRITE "${_outfilename}.rc.in" "IDI_ICON1 ICON DISCARDABLE \"${_outfilename}.ico\"\n") + add_custom_command( + OUTPUT "${_outfilename}.rc" + COMMAND ${CMAKE_COMMAND} + ARGS -E copy "${_outfilename}.rc.in" "${_outfilename}.rc" + DEPENDS "${_outfilename}.ico" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + ) + endif() + set(${appsources} "${${appsources}};${_outfilename}.rc" PARENT_SCOPE) + else() + message(WARNING "Unable to find the png2ico utility - application will not have an application icon!") + endif() + elseif (APPLE AND mac_icons) + # first generate .iconset directory structure, then convert to .icns format using the Mac OS X "iconutil" utility, + # to create retina compatible icon, you need png source files in pixel resolution 16x16, 32x32, 64x64, 128x128, + # 256x256, 512x512, 1024x1024 + find_program(ICONUTIL_EXECUTABLE NAMES iconutil) + if (ICONUTIL_EXECUTABLE) + add_custom_command( + OUTPUT "${_outfilename}.iconset" + COMMAND ${CMAKE_COMMAND} + ARGS -E make_directory "${_outfilename}.iconset" + ) + set(iconset_icons) + macro(copy_icon filename sizename) + add_custom_command( + OUTPUT "${_outfilename}.iconset/icon_${sizename}.png" + COMMAND ${CMAKE_COMMAND} + ARGS -E copy + "${filename}" + "${_outfilename}.iconset/icon_${sizename}.png" + DEPENDS + "${_outfilename}.iconset" + "${filename}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + ) + list(APPEND iconset_icons + "${_outfilename}.iconset/icon_${sizename}.png") + endmacro() + foreach(size 16 32 64 128 256 512) + math(EXPR double_size "2 * ${size}") + foreach(file ${icons_at_${size}px}) + copy_icon("${file}" "${size}x${size}") + endforeach() + foreach(file ${icons_at_${double_size}px}) + copy_icon("${file}" "${size}x${size}@2x") + endforeach() + endforeach() + + # generate .icns icon file + add_custom_command( + OUTPUT "${_outfilename}.icns" + COMMAND ${ICONUTIL_EXECUTABLE} + ARGS + --convert icns + --output "${_outfilename}.icns" + "${_outfilename}.iconset" + DEPENDS ${iconset_icons} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + ) + # This will register the icon into the bundle + set(MACOSX_BUNDLE_ICON_FILE ${appsources}.icns PARENT_SCOPE) + + # Append the icns file to the sources list so it will be a dependency to the + # main target + set(${appsources} "${${appsources}};${_outfilename}.icns" PARENT_SCOPE) + + # Install the icon into the Resources dir in the bundle + set_source_files_properties(${_outfilename}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + else(ICONUTIL_EXECUTABLE) + message(STATUS "Unable to find the iconutil utility - application will not have an application icon!") + endif(ICONUTIL_EXECUTABLE) + endif() +endfunction() -- cgit v1.2.1 From 959c374c022394a116e8ceb2b1fce2df11752068 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 28 Dec 2014 15:03:07 +0000 Subject: Add SameMajorVersionWithPreleases compat option to ecm_setup_version. SameMajorVersionWithPreleases is intended implement the versioning scheme followed by many KDE projects: minor releases after some high number (eg: 90) are considered to be pre-releases of the next major version, and are not compatible with the current major version. This allows alpha and beta releases to be ordered correctly by version-number-aware software like package managers (an alpha of version 2 should have a higher number than any release of version 1, but less than version 2.0). So a request for version 2.1.0 of a piece of software should not be satisfied by 2.93.4, because that is actually a pre-release of version 3. On the other hand, a request for version 2.91.0 should be satisfied by version 3.1.0. Note that prereleases are not considered unless explicitly requested, so 2.93.4 will not satisfy requests for version 3 (or version 2) of a piece of software. --- ...ersion-SameMajorVersionWithPrereleases.cmake.in | 64 +++++++++++++++++++++ modules/ECMSetupVersion.cmake | 66 ++++++++++++++++++++-- 2 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 modules/BasicConfigVersion-SameMajorVersionWithPrereleases.cmake.in (limited to 'modules') diff --git a/modules/BasicConfigVersion-SameMajorVersionWithPrereleases.cmake.in b/modules/BasicConfigVersion-SameMajorVersionWithPrereleases.cmake.in new file mode 100644 index 00000000..6d4e16f4 --- /dev/null +++ b/modules/BasicConfigVersion-SameMajorVersionWithPrereleases.cmake.in @@ -0,0 +1,64 @@ +# This is a basic version file for the Config-mode of find_package(). +# It is used by write_basic_package_version_file() as input file for configure_file() +# to create a version-file which can be installed along a config.cmake file. +# +# The created file sets PACKAGE_VERSION_EXACT if the current version string and +# the requested version string are exactly the same and it sets +# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version, +# but only if the requested major version is the same as the current one EXCEPT +# that all minor releases after (and including) @CVF_FIRST_PRERELEASE_VERSION@ +# are considered to be part of the next major release. +# +# The variables CVF_VERSION and CVF_FIRST_PRERELEASE_VERSION must be set before +# calling configure_file(). + + +set(PACKAGE_VERSION "@CVF_VERSION@") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + + if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.([0-9]+)(\\.|$)") + set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(CVF_VERSION_MINOR "${CMAKE_MATCH_2}") + else() + set(CVF_VERSION_MAJOR "@CVF_VERSION@") + set(CVF_VERSION_MINOR "0") + endif() + + set(_real_version_major "${CVF_VERSION_MAJOR}") + if(NOT "${CVF_VERSION_MINOR}" LESS "@CVF_FIRST_PRERELEASE_VERSION@") + math(EXPR _real_version_major "${CVF_VERSION_MAJOR}+1") + endif() + + set(_real_find_version_major "${PACKAGE_FIND_VERSION_MAJOR}") + if("${PACKAGE_FIND_VERSION_COUNT}" GREATER 1) + if(NOT "${PACKAGE_FIND_VERSION_MINOR}" LESS "@CVF_FIRST_PRERELEASE_VERSION@") + math(EXPR _real_find_version_major "${PACKAGE_FIND_VERSION_MAJOR}+1") + endif() + endif() + + if("${_real_find_version_major}" STREQUAL "${_real_version_major}") + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() + + +# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: +if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") + return() +endif() + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@") + math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/modules/ECMSetupVersion.cmake b/modules/ECMSetupVersion.cmake index b908f96e..5f738c53 100644 --- a/modules/ECMSetupVersion.cmake +++ b/modules/ECMSetupVersion.cmake @@ -10,7 +10,9 @@ # VARIABLE_PREFIX # [SOVERSION ] # [VERSION_HEADER ] -# [PACKAGE_VERSION_FILE [COMPATIBILITY ]] ) +# [PACKAGE_VERSION_FILE +# [COMPATIBILITY +# [FIRST_PRERELEASE_VERSION ]]] ) # # This parses a version string and sets up a standard set of version variables. # It can optionally also create a C version header file and a CMake package @@ -55,9 +57,20 @@ # file is created using the write_basic_package_version_file() macro provided by # CMake. It should be installed in the same location as the Config.cmake file of # the library so that it can be found by find_package(). If the filename is a -# relative path, it is interpreted as relative to CMAKE_CURRENT_BINARY_DIR. The -# optional COMPATIBILITY option is forwarded to -# write_basic_package_version_file(), and defaults to AnyNewerVersion. +# relative path, it is interpreted as relative to CMAKE_CURRENT_BINARY_DIR. +# +# The optional COMPATIBILITY option is similar to that accepted by +# write_basic_package_version_file(), except that it defaults to +# AnyNewerVersion if it is omitted, and it also accepts +# ``SameMajorVersionWithPrereleases`` as a value, in which case the +# ``FIRST_PRERELEASE_VERSION`` option must also be given. This versioning +# system behaves like SameMajorVersion, except that it treats all x.y releases, +# where y is at least ````, as (x+1) releases. So if +# ```` is 90, a request for version 2.90.0 will be satisfied +# by 3.1.0, while a request for 2.89.0 will not be. Note that in this scenario, +# version 2.90.0 of the software will not satisfy requests for version 2, version +# version 2.1.1 *or* version 3 of the software, as prereleases are not considered +# unless explicitly requested. # # If CMake policy CMP0048 is NEW, an alternative form of the command is # available:: @@ -93,10 +106,47 @@ include(CMakePackageConfigHelpers) # save the location of the header template while CMAKE_CURRENT_LIST_DIR # has the value we want set(_ECM_SETUP_VERSION_HEADER_TEMPLATE "${CMAKE_CURRENT_LIST_DIR}/ECMVersionHeader.h.in") +set(_ECM_PACKAGE_VERSION_TEMPLATE_DIR "${CMAKE_CURRENT_LIST_DIR}") + +# like write_basic_package_version_file from CMake, but +# looks for our template files as well +function(ecm_write_package_version_file _filename) + set(options ) + set(oneValueArgs VERSION COMPATIBILITY FIRST_PRERELEASE_VERSION) + set(multiValueArgs ) + + cmake_parse_arguments(CVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(CVF_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to ecm_write_basic_package_version_file(): \"${CVF_UNPARSED_ARGUMENTS}\"") + endif() + + set(versionTemplateFile "${_ECM_PACKAGE_VERSION_TEMPLATE_DIR}/BasicConfigVersion-${CVF_COMPATIBILITY}.cmake.in") + if(NOT EXISTS "${versionTemplateFile}") + write_basic_package_version_file("${_filename}" VERSION "${CVF_VERSION}" COMPATIBILITY "${CVF_COMPATIBILITY}") + return() + endif() + + if("${CVF_COMPATIBILITY}" STREQUAL "SameMajorVersionWithPrereleases") + if("${CVF_FIRST_PRERELEASE_VERSION}" STREQUAL "") + message(FATAL_ERROR "No FIRST_PRERELEASE_VERSION specified for ecm_write_basic_package_version_file()") + endif() + endif() + + if("${CVF_VERSION}" STREQUAL "") + if ("${PROJECT_VERSION}" STREQUAL "") + message(FATAL_ERROR "No VERSION specified for ecm_write_basic_package_version_file()") + else() + set(CVF_VERSION "${PROJECT_VERSION}") + endif() + endif() + + configure_file("${versionTemplateFile}" "${_filename}" @ONLY) +endfunction() function(ecm_setup_version _version) set(options ) - set(oneValueArgs VARIABLE_PREFIX SOVERSION VERSION_HEADER PACKAGE_VERSION_FILE COMPATIBILITY) + set(oneValueArgs VARIABLE_PREFIX SOVERSION VERSION_HEADER PACKAGE_VERSION_FILE COMPATIBILITY FIRST_PRERELEASE_VERSION) set(multiValueArgs ) cmake_parse_arguments(ESV "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -180,7 +230,11 @@ function(ecm_setup_version _version) if(NOT ESV_COMPATIBILITY) set(ESV_COMPATIBILITY AnyNewerVersion) endif() - write_basic_package_version_file("${ESV_PACKAGE_VERSION_FILE}" VERSION ${_version} COMPATIBILITY ${ESV_COMPATIBILITY}) + ecm_write_package_version_file("${ESV_PACKAGE_VERSION_FILE}" + VERSION ${_version} + COMPATIBILITY ${ESV_COMPATIBILITY} + FIRST_PRERELEASE_VERSION "${ESV_FIRST_PRERELEASE_VERSION}" + ) endif() if(should_set_prefixed_vars) -- cgit v1.2.1 From d609e598170064b4ee65392177a9d07f4302698d Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sat, 24 Jan 2015 14:47:59 +0000 Subject: Revert "Add SameMajorVersionWithPreleases compat option to ecm_setup_version." This reverts commit 959c374c022394a116e8ceb2b1fce2df11752068. I merged and pushed the wrong branch. --- ...ersion-SameMajorVersionWithPrereleases.cmake.in | 64 --------------------- modules/ECMSetupVersion.cmake | 66 ++-------------------- 2 files changed, 6 insertions(+), 124 deletions(-) delete mode 100644 modules/BasicConfigVersion-SameMajorVersionWithPrereleases.cmake.in (limited to 'modules') diff --git a/modules/BasicConfigVersion-SameMajorVersionWithPrereleases.cmake.in b/modules/BasicConfigVersion-SameMajorVersionWithPrereleases.cmake.in deleted file mode 100644 index 6d4e16f4..00000000 --- a/modules/BasicConfigVersion-SameMajorVersionWithPrereleases.cmake.in +++ /dev/null @@ -1,64 +0,0 @@ -# This is a basic version file for the Config-mode of find_package(). -# It is used by write_basic_package_version_file() as input file for configure_file() -# to create a version-file which can be installed along a config.cmake file. -# -# The created file sets PACKAGE_VERSION_EXACT if the current version string and -# the requested version string are exactly the same and it sets -# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version, -# but only if the requested major version is the same as the current one EXCEPT -# that all minor releases after (and including) @CVF_FIRST_PRERELEASE_VERSION@ -# are considered to be part of the next major release. -# -# The variables CVF_VERSION and CVF_FIRST_PRERELEASE_VERSION must be set before -# calling configure_file(). - - -set(PACKAGE_VERSION "@CVF_VERSION@") - -if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - - if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.([0-9]+)(\\.|$)") - set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") - set(CVF_VERSION_MINOR "${CMAKE_MATCH_2}") - else() - set(CVF_VERSION_MAJOR "@CVF_VERSION@") - set(CVF_VERSION_MINOR "0") - endif() - - set(_real_version_major "${CVF_VERSION_MAJOR}") - if(NOT "${CVF_VERSION_MINOR}" LESS "@CVF_FIRST_PRERELEASE_VERSION@") - math(EXPR _real_version_major "${CVF_VERSION_MAJOR}+1") - endif() - - set(_real_find_version_major "${PACKAGE_FIND_VERSION_MAJOR}") - if("${PACKAGE_FIND_VERSION_COUNT}" GREATER 1) - if(NOT "${PACKAGE_FIND_VERSION_MINOR}" LESS "@CVF_FIRST_PRERELEASE_VERSION@") - math(EXPR _real_find_version_major "${PACKAGE_FIND_VERSION_MAJOR}+1") - endif() - endif() - - if("${_real_find_version_major}" STREQUAL "${_real_version_major}") - set(PACKAGE_VERSION_COMPATIBLE TRUE) - else() - set(PACKAGE_VERSION_COMPATIBLE FALSE) - endif() - - if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") - set(PACKAGE_VERSION_EXACT TRUE) - endif() -endif() - - -# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: -if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") - return() -endif() - -# check that the installed version has the same 32/64bit-ness as the one which is currently searching: -if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@") - math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") - set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") - set(PACKAGE_VERSION_UNSUITABLE TRUE) -endif() diff --git a/modules/ECMSetupVersion.cmake b/modules/ECMSetupVersion.cmake index 5f738c53..b908f96e 100644 --- a/modules/ECMSetupVersion.cmake +++ b/modules/ECMSetupVersion.cmake @@ -10,9 +10,7 @@ # VARIABLE_PREFIX # [SOVERSION ] # [VERSION_HEADER ] -# [PACKAGE_VERSION_FILE -# [COMPATIBILITY -# [FIRST_PRERELEASE_VERSION ]]] ) +# [PACKAGE_VERSION_FILE [COMPATIBILITY ]] ) # # This parses a version string and sets up a standard set of version variables. # It can optionally also create a C version header file and a CMake package @@ -57,20 +55,9 @@ # file is created using the write_basic_package_version_file() macro provided by # CMake. It should be installed in the same location as the Config.cmake file of # the library so that it can be found by find_package(). If the filename is a -# relative path, it is interpreted as relative to CMAKE_CURRENT_BINARY_DIR. -# -# The optional COMPATIBILITY option is similar to that accepted by -# write_basic_package_version_file(), except that it defaults to -# AnyNewerVersion if it is omitted, and it also accepts -# ``SameMajorVersionWithPrereleases`` as a value, in which case the -# ``FIRST_PRERELEASE_VERSION`` option must also be given. This versioning -# system behaves like SameMajorVersion, except that it treats all x.y releases, -# where y is at least ````, as (x+1) releases. So if -# ```` is 90, a request for version 2.90.0 will be satisfied -# by 3.1.0, while a request for 2.89.0 will not be. Note that in this scenario, -# version 2.90.0 of the software will not satisfy requests for version 2, version -# version 2.1.1 *or* version 3 of the software, as prereleases are not considered -# unless explicitly requested. +# relative path, it is interpreted as relative to CMAKE_CURRENT_BINARY_DIR. The +# 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:: @@ -106,47 +93,10 @@ include(CMakePackageConfigHelpers) # save the location of the header template while CMAKE_CURRENT_LIST_DIR # has the value we want set(_ECM_SETUP_VERSION_HEADER_TEMPLATE "${CMAKE_CURRENT_LIST_DIR}/ECMVersionHeader.h.in") -set(_ECM_PACKAGE_VERSION_TEMPLATE_DIR "${CMAKE_CURRENT_LIST_DIR}") - -# like write_basic_package_version_file from CMake, but -# looks for our template files as well -function(ecm_write_package_version_file _filename) - set(options ) - set(oneValueArgs VERSION COMPATIBILITY FIRST_PRERELEASE_VERSION) - set(multiValueArgs ) - - cmake_parse_arguments(CVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if(CVF_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown keywords given to ecm_write_basic_package_version_file(): \"${CVF_UNPARSED_ARGUMENTS}\"") - endif() - - set(versionTemplateFile "${_ECM_PACKAGE_VERSION_TEMPLATE_DIR}/BasicConfigVersion-${CVF_COMPATIBILITY}.cmake.in") - if(NOT EXISTS "${versionTemplateFile}") - write_basic_package_version_file("${_filename}" VERSION "${CVF_VERSION}" COMPATIBILITY "${CVF_COMPATIBILITY}") - return() - endif() - - if("${CVF_COMPATIBILITY}" STREQUAL "SameMajorVersionWithPrereleases") - if("${CVF_FIRST_PRERELEASE_VERSION}" STREQUAL "") - message(FATAL_ERROR "No FIRST_PRERELEASE_VERSION specified for ecm_write_basic_package_version_file()") - endif() - endif() - - if("${CVF_VERSION}" STREQUAL "") - if ("${PROJECT_VERSION}" STREQUAL "") - message(FATAL_ERROR "No VERSION specified for ecm_write_basic_package_version_file()") - else() - set(CVF_VERSION "${PROJECT_VERSION}") - endif() - endif() - - configure_file("${versionTemplateFile}" "${_filename}" @ONLY) -endfunction() function(ecm_setup_version _version) set(options ) - set(oneValueArgs VARIABLE_PREFIX SOVERSION VERSION_HEADER PACKAGE_VERSION_FILE COMPATIBILITY FIRST_PRERELEASE_VERSION) + set(oneValueArgs VARIABLE_PREFIX SOVERSION VERSION_HEADER PACKAGE_VERSION_FILE COMPATIBILITY) set(multiValueArgs ) cmake_parse_arguments(ESV "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -230,11 +180,7 @@ function(ecm_setup_version _version) if(NOT ESV_COMPATIBILITY) set(ESV_COMPATIBILITY AnyNewerVersion) endif() - ecm_write_package_version_file("${ESV_PACKAGE_VERSION_FILE}" - VERSION ${_version} - COMPATIBILITY ${ESV_COMPATIBILITY} - FIRST_PRERELEASE_VERSION "${ESV_FIRST_PRERELEASE_VERSION}" - ) + write_basic_package_version_file("${ESV_PACKAGE_VERSION_FILE}" VERSION ${_version} COMPATIBILITY ${ESV_COMPATIBILITY}) endif() if(should_set_prefixed_vars) -- cgit v1.2.1 From fea3b11ca01677e60d552ac29091b28946c99f08 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 1 Feb 2015 12:02:14 +0000 Subject: Minor documentation syntax fixes. --- modules/ECMCoverageOption.cmake | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/ECMCoverageOption.cmake b/modules/ECMCoverageOption.cmake index 8d435de8..92fcf74d 100644 --- a/modules/ECMCoverageOption.cmake +++ b/modules/ECMCoverageOption.cmake @@ -11,10 +11,7 @@ # # If it's on, the project will be compiled with code coverage support, using # gcov. Otherwise, it will be built normally. -# -# :: -# -# + #============================================================================= # Copyright 2014 Aleix Pol Gonzalez # -- cgit v1.2.1 From 807ace309a489d21163b5c671d9e449c06e14e20 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 1 Feb 2015 11:20:43 +0000 Subject: Add a module to provide an uninstall target. This is basically just the code available on the CMake FAQ item about `make uninstall`, but packaged up in a convenient module. REVIEW: 122359 --- modules/ECMUninstallTarget.cmake | 56 ++++++++++++++++++++++++++++++++++++++++ modules/ecm_uninstall.cmake.in | 21 +++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 modules/ECMUninstallTarget.cmake create mode 100644 modules/ecm_uninstall.cmake.in (limited to 'modules') diff --git a/modules/ECMUninstallTarget.cmake b/modules/ECMUninstallTarget.cmake new file mode 100644 index 00000000..d9363125 --- /dev/null +++ b/modules/ECMUninstallTarget.cmake @@ -0,0 +1,56 @@ +#.rst: +# ECMUninstallTarget +# ------------------ +# +# Add an ``uninstall`` target. +# +# By including this module, an ``uninstall`` target will be added to your CMake +# project. This will remove all files installed (or updated) by a previous +# invocation of the ``install`` target. It will not remove files created or +# modified by an ``install(SCRIPT)`` or ``install(CODE)`` command; you should +# create a custom uninstallation target for these and use ``add_dependency`` to +# make the ``uninstall`` target depend on it: +# +# .. code-block:: cmake +# +# include(ECMUninstallTarget) +# install(SCRIPT install-foo.cmake) +# add_custom_target(uninstall_foo COMMAND ${CMAKE_COMMAND} -P uninstall-foo.cmake) +# add_dependency(uninstall uninstall_foo) +# +# The target will fail if the ``install`` target has not yet been run (so it is +# not possible to run CMake on the project and then immediately run the +# ``uninstall`` target). +# +# .. warning:: +# +# CMake deliberately does not provide an ``uninstall`` target by default on +# the basis that such a target has the potential to remove important files +# from a user's computer. Use with caution. + +#============================================================================= +# Copyright 2015 Alex Merry +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file COPYING-CMAKE-SCRIPTS for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of extra-cmake-modules, substitute the full +# License text for the above reference.) + +if (NOT TARGET uninstall) + configure_file( + "${CMAKE_CURRENT_LIST_DIR}/ecm_uninstall.cmake.in" + "${CMAKE_BINARY_DIR}/ecm_uninstall.cmake" + IMMEDIATE + @ONLY + ) + + add_custom_target(uninstall + COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/ecm_uninstall.cmake" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + ) +endif() diff --git a/modules/ecm_uninstall.cmake.in b/modules/ecm_uninstall.cmake.in new file mode 100644 index 00000000..d0cf1241 --- /dev/null +++ b/modules/ecm_uninstall.cmake.in @@ -0,0 +1,21 @@ +if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") +endif() + +file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach(file ${files}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + exec_program( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif(NOT "${rm_retval}" STREQUAL 0) + else() + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif() +endforeach() -- cgit v1.2.1 From a1d6d8f7259ade901a87b33edbef8b31bffb5e26 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 6 Feb 2015 11:31:19 +0000 Subject: Document when modules were added to ECM. --- modules/ECMAddAppIcon.cmake | 2 ++ modules/ECMAddTests.cmake | 2 ++ modules/ECMCoverageOption.cmake | 2 ++ modules/ECMCreateQmFromPoFiles.cmake | 2 ++ modules/ECMEnableSanitizers.cmake | 2 ++ modules/ECMFindModuleHelpers.cmake | 2 ++ modules/ECMGenerateHeaders.cmake | 2 ++ modules/ECMGeneratePkgConfigFile.cmake | 1 + modules/ECMGeneratePriFile.cmake | 2 ++ modules/ECMInstallIcons.cmake | 2 ++ modules/ECMMarkAsTest.cmake | 2 ++ modules/ECMMarkNonGuiExecutable.cmake | 2 ++ modules/ECMOptionalAddSubdirectory.cmake | 2 ++ modules/ECMPackageConfigHelpers.cmake | 2 ++ modules/ECMPoQmTools.cmake | 2 ++ modules/ECMSetupVersion.cmake | 3 +++ modules/ECMUninstallTarget.cmake | 2 ++ modules/ECMUseFindModules.cmake | 2 ++ 18 files changed, 36 insertions(+) (limited to 'modules') diff --git a/modules/ECMAddAppIcon.cmake b/modules/ECMAddAppIcon.cmake index 4efdd392..f90d4c33 100644 --- a/modules/ECMAddAppIcon.cmake +++ b/modules/ECMAddAppIcon.cmake @@ -42,6 +42,8 @@ # of the generated icns file, so that it will be used as the # ``MACOSX_BUNDLE_ICON_FILE`` target property when you call # ``add_executable``. +# +# Since 1.7.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/modules/ECMAddTests.cmake b/modules/ECMAddTests.cmake index ed1e0f66..de06315d 100644 --- a/modules/ECMAddTests.cmake +++ b/modules/ECMAddTests.cmake @@ -36,6 +36,8 @@ # This is a convenient version of ecm_add_test() for when you have many tests # that consist of a single source file each. It behaves like calling # ecm_add_test() once for each source file, with the same named arguments. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2013 Alexander Richardson diff --git a/modules/ECMCoverageOption.cmake b/modules/ECMCoverageOption.cmake index 92fcf74d..4cfe6641 100644 --- a/modules/ECMCoverageOption.cmake +++ b/modules/ECMCoverageOption.cmake @@ -11,6 +11,8 @@ # # If it's on, the project will be compiled with code coverage support, using # gcov. Otherwise, it will be built normally. +# +# Since 1.3.0. #============================================================================= # Copyright 2014 Aleix Pol Gonzalez diff --git a/modules/ECMCreateQmFromPoFiles.cmake b/modules/ECMCreateQmFromPoFiles.cmake index b66e5989..3f134fbb 100644 --- a/modules/ECMCreateQmFromPoFiles.cmake +++ b/modules/ECMCreateQmFromPoFiles.cmake @@ -68,6 +68,8 @@ # # This generates a C++ file which loads "mylib.qm" at startup, assuming it has # been installed by ecm_create_qm_from_po_files(), and compiles it into ``mylib``. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2014 Aurélien Gâteau diff --git a/modules/ECMEnableSanitizers.cmake b/modules/ECMEnableSanitizers.cmake index a0df80e2..568fa397 100644 --- a/modules/ECMEnableSanitizers.cmake +++ b/modules/ECMEnableSanitizers.cmake @@ -61,6 +61,8 @@ # => Most of the sanitizers will require Clang. To enable it, use : # -DCMAKE_CXX_COMPILER=clang++ # +# Since 1.3.0. + #============================================================================= # Copyright 2014 Mathieu Tarral # diff --git a/modules/ECMFindModuleHelpers.cmake b/modules/ECMFindModuleHelpers.cmake index 79bd6fb8..63cccb93 100644 --- a/modules/ECMFindModuleHelpers.cmake +++ b/modules/ECMFindModuleHelpers.cmake @@ -92,6 +92,8 @@ # different components (typically because of multiple find_package() calls) then # ``_TARGETS``, for example, will contain all the targets found in any # call (although no duplicates). +# +# Since pre-1.0.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/modules/ECMGenerateHeaders.cmake b/modules/ECMGenerateHeaders.cmake index bac50869..5e5615b6 100644 --- a/modules/ECMGenerateHeaders.cmake +++ b/modules/ECMGenerateHeaders.cmake @@ -88,6 +88,8 @@ # install(FILES ${MyLib_HEADERS} # DESTINATION ${CMAKE_INSTALL_PREFIX}/include/mylib # COMPONENT Devel) +# +# Since pre-1.0.0. #============================================================================= # Copyright 2013 Aleix Pol Gonzalez diff --git a/modules/ECMGeneratePkgConfigFile.cmake b/modules/ECMGeneratePkgConfigFile.cmake index eb0e385d..052dcb1e 100644 --- a/modules/ECMGeneratePkgConfigFile.cmake +++ b/modules/ECMGeneratePkgConfigFile.cmake @@ -59,6 +59,7 @@ # INSTALL # ) # +# Since 1.3.0. #============================================================================= # Copyright 2014 Aleix Pol Gonzalez diff --git a/modules/ECMGeneratePriFile.cmake b/modules/ECMGeneratePriFile.cmake index 3a409723..af4b8771 100644 --- a/modules/ECMGeneratePriFile.cmake +++ b/modules/ECMGeneratePriFile.cmake @@ -68,6 +68,8 @@ # QT += KArchive # # in their ``.pro`` file. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2014 David Faure diff --git a/modules/ECMInstallIcons.cmake b/modules/ECMInstallIcons.cmake index 19d44d36..34d5a485 100644 --- a/modules/ECMInstallIcons.cmake +++ b/modules/ECMInstallIcons.cmake @@ -59,6 +59,8 @@ # # With this syntax, the file ``hi22-actions-menu_new.png`` would be installed # into ``/hicolor/22x22/actions/menu_new.png`` +# +# Since pre-1.0.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/modules/ECMMarkAsTest.cmake b/modules/ECMMarkAsTest.cmake index 24b8cfc7..9027bf30 100644 --- a/modules/ECMMarkAsTest.cmake +++ b/modules/ECMMarkAsTest.cmake @@ -13,6 +13,8 @@ # # BUILD_TESTING is created as a cache variable by the CTest module and by the # :kde-module:`KDECMakeSettings` module. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2012 Stephen Kelly diff --git a/modules/ECMMarkNonGuiExecutable.cmake b/modules/ECMMarkNonGuiExecutable.cmake index 9b680216..59737d4c 100644 --- a/modules/ECMMarkNonGuiExecutable.cmake +++ b/modules/ECMMarkNonGuiExecutable.cmake @@ -11,6 +11,8 @@ # This will indicate to CMake that the specified targets should not be included # in a MACOSX_BUNDLE and should not be WIN32_EXECUTABLEs. On platforms other # than MacOS X or Windows, this will have no effect. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2012 Stephen Kelly diff --git a/modules/ECMOptionalAddSubdirectory.cmake b/modules/ECMOptionalAddSubdirectory.cmake index 6cbafa2d..2b890055 100644 --- a/modules/ECMOptionalAddSubdirectory.cmake +++ b/modules/ECMOptionalAddSubdirectory.cmake @@ -24,6 +24,8 @@ # .. code-block:: sh # # cmake -DDISABLE_ALL_OPTIONAL_SUBDIRECTORIES=TRUE -DBUILD_foo=TRUE myproject +# +# Since pre-1.0.0. #============================================================================= # Copyright 2007 Alexander Neundorf diff --git a/modules/ECMPackageConfigHelpers.cmake b/modules/ECMPackageConfigHelpers.cmake index bc99d1cb..6e69fb80 100644 --- a/modules/ECMPackageConfigHelpers.cmake +++ b/modules/ECMPackageConfigHelpers.cmake @@ -37,6 +37,8 @@ # the find_dependency() macro (which you can include() in your package config # file), so this file is only useful for projects whose minimum required version # is 2.8.12. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/modules/ECMPoQmTools.cmake b/modules/ECMPoQmTools.cmake index 74dc6563..015b7f90 100644 --- a/modules/ECMPoQmTools.cmake +++ b/modules/ECMPoQmTools.cmake @@ -65,6 +65,8 @@ # ```` defaults to ``${LOCALE_INSTALL_DIR}`` if defined, # otherwise it uses ``${CMAKE_INSTALL_LOCALEDIR}`` if that is defined, otherwise # it uses ``share/locale``. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2007-2009 Kitware, Inc. diff --git a/modules/ECMSetupVersion.cmake b/modules/ECMSetupVersion.cmake index b908f96e..33d0ada1 100644 --- a/modules/ECMSetupVersion.cmake +++ b/modules/ECMSetupVersion.cmake @@ -73,6 +73,9 @@ # first argument. In all other respects, it behaves like the other form of the # command. # +# Since pre-1.0.0. +# +# COMPATIBLITY option available since 1.6.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/modules/ECMUninstallTarget.cmake b/modules/ECMUninstallTarget.cmake index d9363125..1e9bb91e 100644 --- a/modules/ECMUninstallTarget.cmake +++ b/modules/ECMUninstallTarget.cmake @@ -27,6 +27,8 @@ # CMake deliberately does not provide an ``uninstall`` target by default on # the basis that such a target has the potential to remove important files # from a user's computer. Use with caution. +# +# Since 1.7.0. #============================================================================= # Copyright 2015 Alex Merry diff --git a/modules/ECMUseFindModules.cmake b/modules/ECMUseFindModules.cmake index a48f599b..0a8a40fb 100644 --- a/modules/ECMUseFindModules.cmake +++ b/modules/ECMUseFindModules.cmake @@ -44,6 +44,8 @@ # be installed along with config files if they are required as a dependency (for # example, if targets provided by the find module are in the link interface of a # library). +# +# Since pre-1.0.0. #============================================================================= # Copyright 2011 Alexander Neundorf -- cgit v1.2.1 From ce678b32de12e6bb3c2b470111a3fcbadcca3a38 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 6 Feb 2015 11:50:31 +0000 Subject: Add missing documentation. Three modules (ECMCoverageOption, ECMEnableSanitizers and ECMGeneratePkgConfigFile) were not being documented. This commit fixes that situation. --- modules/ECMCoverageOption.cmake | 14 ++++--- modules/ECMEnableSanitizers.cmake | 65 +++++++++++++++-------------- modules/ECMGeneratePkgConfigFile.cmake | 74 ++++++++++++++++++---------------- 3 files changed, 83 insertions(+), 70 deletions(-) (limited to 'modules') diff --git a/modules/ECMCoverageOption.cmake b/modules/ECMCoverageOption.cmake index 4cfe6641..4c1db9de 100644 --- a/modules/ECMCoverageOption.cmake +++ b/modules/ECMCoverageOption.cmake @@ -2,15 +2,17 @@ # ECMCoverageOption # -------------------- # -# Creates a BUILD_COVERAGE option, so the project can be built with code coverage -# support. +# Allow users to easily enable GCov code coverage support. # -# :: +# Code coverage allows you to check how much of your codebase is covered by +# your tests. This module makes it easy to build with support for +# `GCov `_. # -# BUILD_COVERAGE +# When this module is included, a ``BUILD_COVERAGE`` option is added (default +# OFF). Turning this option on enables GCC's coverage instrumentation, and +# links against ``libgcov``. # -# If it's on, the project will be compiled with code coverage support, using -# gcov. Otherwise, it will be built normally. +# Note that this will probably break the build if you are not using GCC. # # Since 1.3.0. diff --git a/modules/ECMEnableSanitizers.cmake b/modules/ECMEnableSanitizers.cmake index 568fa397..d55b2525 100644 --- a/modules/ECMEnableSanitizers.cmake +++ b/modules/ECMEnableSanitizers.cmake @@ -2,9 +2,10 @@ # ECMEnableSanitizers # ------------------- # -# Enable compiler sanitizer flags +# Enable compiler sanitizer flags. +# +# The following sanitizers are supported: # -# The following sanitizers are supported : # - Address Sanitizer # - Memory Sanitizer # - Thread Sanitizer @@ -14,52 +15,56 @@ # 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 # implemented. -# This module will check your current compiler version to see if it support -# the sanitizers that you want to enable # -# How to use it ? -# --------------- -# This module is included in KDECompilerSettings. Therefore you don't have -# to change your CMakeLists.txt +# This module will check your current compiler version to see if it +# supports the sanitizers that you want to enable +# +# Usage +# ===== +# +# Simply add:: +# +# include(ECMEnableSanitizers) # -# It introduce a new cached variable : -# ECM_ENABLE_SANITIZERS +# to your ``CMakeLists.txt``. Note that this module is included in +# KDECompilerSettings, so projects using that module do not need to also +# include this one. +# +# The sanitizers are not enabled by default. Instead, you must set +# ``ECM_ENABLE_SANITIZERS`` (either in your ``CMakeLists.txt`` or on the +# command line) to a semicolon-separated list of sanitizers you wish to enable. +# The options are: # -# which can take the following values : # - address # - memory # - thread # - leak # - undefined # -# You can enable two sanitizers in the same build, depending on their -# compatibility by separating each one with a semicolon : -# ECM_ENABLE_SANITIZERS='address;undefined' +# The sanitizers "address", "memory" and "thread" are mutually exclusive. You +# cannot enable two of them in the same build. # +# "leak" requires the "address" sanitizer. # -# The sanitizers `address`, `memory` and `thread` are mutually exclusive. -# You cannot enable two of them in the same build. +# .. note:: # -# `undefined` can be used with every other sanitizers +# To reduce the overhead induced by the instrumentation of the sanitizers, it +# is advised to enable compiler optimizations (``-O1`` or higher). # -# `leak` can be enable with the `address` sanitizer. +# Example +# ======= # -# Finally, to reduce the overhead induced by the instrumentation of the -# sanitizers, it is advised to use -O1, or higher to improve the performances. +# This is an example of usage:: # -# Example -# ------- -# This is an example of usage : -# mkdir _build -# cd _build -# cmake -DECM_ENABLE_SANITIZERS='address' .. +# mkdir build +# cd build +# cmake -DECM_ENABLE_SANITIZERS='address;leak;undefined' .. # -# If you want to use multiple sanitizers +# .. note:: # -# cmake -DECM_ENABLE_SANITIZERS='address;leak;undefined' .. +# Most of the sanitizers will require Clang. To enable it, use:: # -# => Most of the sanitizers will require Clang. To enable it, use : -# -DCMAKE_CXX_COMPILER=clang++ +# -DCMAKE_CXX_COMPILER=clang++ # # Since 1.3.0. diff --git a/modules/ECMGeneratePkgConfigFile.cmake b/modules/ECMGeneratePkgConfigFile.cmake index 052dcb1e..eaef7b41 100644 --- a/modules/ECMGeneratePkgConfigFile.cmake +++ b/modules/ECMGeneratePkgConfigFile.cmake @@ -1,8 +1,11 @@ #.rst: # ECMGeneratePkgConfigFile -# ------------------ +# ------------------------ # -# Generate a ``.pc`` file for the benefit of autotools-based projects. +# Generate a `pkg-config `_ +# file for the benefit of +# `autotools `_-based +# projects. # # :: # @@ -15,38 +18,41 @@ # [DEFINES -D...] # [INSTALL]) # -# BASE_NAME is the name of the module. It's the name projects will use to find -# the module. -# -# LIB_NAME is the name of the library that is being exported. If undefined, it -# will default to the BASE_NAME. That means the LIB_NAME will be set as the name -# field as well as the library to link to. -# -# FILENAME_VAR is specified with a variable name. This variable will receive the -# location of the generated file will be set, within the build directory. This -# way it can be used in case some processing is required. See also INSTALL. -# -# INCLUDE_INSTALL_DIR specifies where the includes will be installed. If it's not -# specified, it will default to INSTALL_INCLUDEDIR, CMAKE_INSTALL_INCLUDEDIR or just -# "include/" in case they are specified, with the BASE_NAME postfixed. -# -# LIB_INSTALL_DIR specifies where the library is being installed. If it's not -# specified, it will default to LIB_INSTALL_DIR, CMAKE_INSTALL_LIBDIR or just -# "lib/" in case they are specified. -# -# DEFINES is a list of preprocessor defines that it is recommended users of the -# library pass to the compiler when using it. -# -# INSTALL will cause the module to be installed to the ``pkgconfig`` subdirectory -# of LIB_INSTALL_DIR, unless the ECM_PKGCONFIG_INSTALL_DIR cache variable is set -# to something different. Note that the first call to ecm_generate_pkgconfig_file -# with the INSTALL argument will cause ECM_PKGCONFIG_INSTALL_DIR to be set to the -# cache, and will be used in any subsequent calls. -# -# 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 (only available since CMake 3.0) or the -# ecm_setup_version() macro. -# +# ``BASE_NAME`` is the name of the module. It's the name projects will use to +# find the module. +# +# ``LIB_NAME`` is the name of the library that is being exported. If undefined, +# it will default to the ``BASE_NAME``. That means the ``LIB_NAME`` will be set +# as the name field as well as the library to link to. +# +# ``FILENAME_VAR`` is specified with a variable name. This variable will +# receive the location of the generated file will be set, within the build +# directory. This way it can be used in case some processing is required. See +# also ``INSTALL``. +# +# ``INCLUDE_INSTALL_DIR`` specifies where the includes will be installed. If +# it's not specified, it will default to ``INSTALL_INCLUDEDIR``, +# ``CMAKE_INSTALL_INCLUDEDIR`` or just "include/" in case they are specified, +# with the BASE_NAME postfixed. +# +# ``LIB_INSTALL_DIR`` specifies where the library is being installed. If it's +# not specified, it will default to ``LIB_INSTALL_DIR``, +# ``CMAKE_INSTALL_LIBDIR`` or just "lib/" in case they are specified. +# +# ``DEFINES`` is a list of preprocessor defines that it is recommended users of +# the library pass to the compiler when using it. +# +# ``INSTALL`` will cause the module to be installed to the ``pkgconfig`` +# subdirectory of ``LIB_INSTALL_DIR``, unless the ``ECM_PKGCONFIG_INSTALL_DIR`` +# cache variable is set to something different. Note that the first call to +# ecm_generate_pkgconfig_file with the ``INSTALL`` argument will cause +# ``ECM_PKGCONFIG_INSTALL_DIR`` to be set to the cache, and will be used in any +# subsequent calls. +# +# 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 (only available since CMake 3.0) or the ecm_setup_version() +# macro. # # Example usage: # -- cgit v1.2.1 From 0772adcc6d4600c54ef6f97b4e8a5e3d298af9f5 Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Fri, 6 Feb 2015 15:00:52 +0100 Subject: Minor: Cleanup --- modules/ecm_uninstall.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/ecm_uninstall.cmake.in b/modules/ecm_uninstall.cmake.in index d0cf1241..379239ba 100644 --- a/modules/ecm_uninstall.cmake.in +++ b/modules/ecm_uninstall.cmake.in @@ -14,7 +14,7 @@ foreach(file ${files}) ) if(NOT "${rm_retval}" STREQUAL 0) message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") - endif(NOT "${rm_retval}" STREQUAL 0) + endif() else() message(STATUS "File $ENV{DESTDIR}${file} does not exist.") endif() -- cgit v1.2.1 From fc56bfbb62a9438960fec9e5960fde5f3e5c1a46 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Sun, 15 Feb 2015 21:45:34 +0100 Subject: Extend ecm_generate_headers macro to also support CamelCase.h headers REVIEW: 122317 Thanks alexmerry and dvratil for review --- modules/ECMGenerateHeaders.cmake | 77 +++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 28 deletions(-) (limited to 'modules') diff --git a/modules/ECMGenerateHeaders.cmake b/modules/ECMGenerateHeaders.cmake index 5e5615b6..b6290223 100644 --- a/modules/ECMGenerateHeaders.cmake +++ b/modules/ECMGenerateHeaders.cmake @@ -6,26 +6,31 @@ # # :: # -# ecm_generate_headers( -# HEADER_NAMES [ [...]] +# ecm_generate_headers( +# HEADER_NAMES [ [...]] +# [ORIGINAL ] # [OUTPUT_DIR ] # [PREFIX ] # [REQUIRED_HEADERS ] # [RELATIVE ]) # # For each CamelCase header name passed to HEADER_NAMES, a file of that name -# will be generated that will include a lowercased version with ``.h`` appended. -# For example, the header ``ClassA`` will include ``classa.h``. The file -# locations of these generated headers will be stored in -# . -# -# PREFIX places the headers in subdirectories. This should be a CamelCase name -# like KParts, which will cause the CamelCase headers to be placed in the KParts -# directory (eg: KParts/Part). It will also, for the convenience of code in the -# source distribution, generate forwarding lowercase headers, like -# kparts/part.h. This allows includes like "#include " to be -# used before installation, as long as the include_directories are set -# appropriately. +# will be generated that will include a version with ``.h`` appended. +# For example, the generated header ``ClassA`` will include ``classa.h`` (or +# ``ClassA.h``, see ORIGINAL). +# The file locations of these generated headers will be stored in +# . +# +# ORIGINAL specifies how the name of the original header is written: lowercased +# or also camelcased. The default is LOWERCASE. Since 1.8.0. +# +# PREFIX places the generated headers in subdirectories. This should be a +# CamelCase name like ``KParts``, which will cause the CamelCase forwarding +# headers to be placed in the ``KParts`` directory (e.g. ``KParts/Part``). It +# will also, for the convenience of code in the source distribution, generate +# forwarding headers based on the original names (e.g. ``kparts/part.h``). This +# allows includes like ``"#include "`` to be used before +# installation, as long as the include_directories are set appropriately. # # 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. @@ -35,14 +40,14 @@ # headers will be appended so that they can be installed together with the # generated ones. This is mostly intended as a convenience so that adding a new # header to a project only requires specifying the CamelCase variant in the -# CMakeLists.txt file; the lowercase variant will then be added to this +# CMakeLists.txt file; the original variant will then be added to this # variable. # -# The RELATIVE argument indicates where the lowercase headers can be found +# The RELATIVE argument indicates where the original headers can be found # relative to CMAKE_CURRENT_SOURCE_DIR. It does not affect the generated -# CamelCase files, but ecm_generate_headers() uses it when checking that the -# lowercase header exists, and to generate lowercase forwarding headers when -# PREFIX is set. +# 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. # # To allow other parts of the source distribution (eg: tests) to use the # generated headers before installation, it may be desirable to set the @@ -107,9 +112,9 @@ include(CMakeParseArguments) -function(ECM_GENERATE_HEADERS camelcase_headers_var) +function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var) set(options) - set(oneValueArgs OUTPUT_DIR PREFIX REQUIRED_HEADERS RELATIVE) + set(oneValueArgs ORIGINAL OUTPUT_DIR PREFIX REQUIRED_HEADERS RELATIVE) set(multiValueArgs HEADER_NAMES) cmake_parse_arguments(EGH "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -121,6 +126,14 @@ function(ECM_GENERATE_HEADERS camelcase_headers_var) message(FATAL_ERROR "Missing header_names argument to ECM_GENERATE_HEADERS") endif() + if(NOT EGH_ORIGINAL) + # default + set(EGH_ORIGINAL "LOWERCASE") + endif() + if(NOT EGH_ORIGINAL STREQUAL "LOWERCASE" AND NOT EGH_ORIGINAL STREQUAL "CAMELCASE") + message(FATAL_ERROR "Unexpected value for original argument to ECM_GENERATE_HEADERS: ${EGH_ORIGINAL}") + endif() + if(NOT EGH_OUTPUT_DIR) set(EGH_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") endif() @@ -134,33 +147,41 @@ function(ECM_GENERATE_HEADERS camelcase_headers_var) if (NOT "${EGH_PREFIX}" MATCHES "^.*/$") set(EGH_PREFIX "${EGH_PREFIX}/") endif() - string(TOLOWER "${EGH_PREFIX}" lowercaseprefix) + if (EGH_ORIGINAL STREQUAL "CAMELCASE") + set(originalprefix "${EGH_PREFIX}") + else() + string(TOLOWER "${EGH_PREFIX}" originalprefix) + endif() endif() foreach(_CLASSNAME ${EGH_HEADER_NAMES}) - string(TOLOWER "${_CLASSNAME}" lowercaseclassname) + if (EGH_ORIGINAL STREQUAL "CAMELCASE") + set(originalclassname "${_CLASSNAME}") + else() + string(TOLOWER "${_CLASSNAME}" originalclassname) + endif() set(FANCY_HEADER_FILE "${EGH_OUTPUT_DIR}/${EGH_PREFIX}${_CLASSNAME}") - set(_actualheader "${CMAKE_CURRENT_SOURCE_DIR}/${EGH_RELATIVE}${lowercaseclassname}.h") + set(_actualheader "${CMAKE_CURRENT_SOURCE_DIR}/${EGH_RELATIVE}${originalclassname}.h") if (NOT EXISTS ${_actualheader}) message(FATAL_ERROR "Could not find \"${_actualheader}\"") endif() if (NOT EXISTS ${FANCY_HEADER_FILE}) - file(WRITE ${FANCY_HEADER_FILE} "#include \"${lowercaseprefix}${lowercaseclassname}.h\"\n") + file(WRITE ${FANCY_HEADER_FILE} "#include \"${originalprefix}${originalclassname}.h\"\n") endif() - list(APPEND ${camelcase_headers_var} "${FANCY_HEADER_FILE}") + list(APPEND ${camelcase_forwarding_headers_var} "${FANCY_HEADER_FILE}") if (EGH_REQUIRED_HEADERS) list(APPEND ${EGH_REQUIRED_HEADERS} "${_actualheader}") endif() if (EGH_PREFIX) # Local forwarding header, for namespaced headers, e.g. kparts/part.h - set(REGULAR_HEADER_NAME ${EGH_OUTPUT_DIR}/${lowercaseprefix}${lowercaseclassname}.h) + set(REGULAR_HEADER_NAME ${EGH_OUTPUT_DIR}/${originalprefix}${originalclassname}.h) if (NOT EXISTS ${REGULAR_HEADER_NAME}) file(WRITE ${REGULAR_HEADER_NAME} "#include \"${_actualheader}\"\n") endif() endif() endforeach() - set(${camelcase_headers_var} ${${camelcase_headers_var}} PARENT_SCOPE) + set(${camelcase_forwarding_headers_var} ${${camelcase_forwarding_headers_var}} PARENT_SCOPE) if (NOT EGH_REQUIRED_HEADERS STREQUAL "") set(${EGH_REQUIRED_HEADERS} ${${EGH_REQUIRED_HEADERS}} PARENT_SCOPE) endif () -- cgit v1.2.1 From 0466f8f95e214d91b17ef078be221c6d0025e466 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sat, 28 Feb 2015 10:37:45 +0000 Subject: Improve ECMPackageConfigHelpers documentation. In particular, strongly recommend looking at the equivalent CMake documentation with regard to PATH_VARS, as a lot of projects that should be making use of it are not. --- modules/ECMPackageConfigHelpers.cmake | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'modules') diff --git a/modules/ECMPackageConfigHelpers.cmake b/modules/ECMPackageConfigHelpers.cmake index 6e69fb80..d1d0408f 100644 --- a/modules/ECMPackageConfigHelpers.cmake +++ b/modules/ECMPackageConfigHelpers.cmake @@ -5,7 +5,9 @@ # Helper macros for generating CMake package config files. # # ``write_basic_package_version_file()`` is the same as the one provided by the -# CMakePackageConfigHelpers module in CMake; see that module's documentation for +# `CMakePackageConfigHelpers +# `_ +# module in CMake; see that module's documentation for # more information. # # :: @@ -18,7 +20,23 @@ # # # This behaves in the same way as configure_package_config_file() from CMake -# 2.8.12, except that it adds an extra helper macro: find_dependency(). +# 2.8.12, except that it adds an extra helper macro: find_dependency(). It is +# highly recommended that you read the `documentation for +# CMakePackageConfigHelpers +# `_ +# for more information, particularly with regard to the PATH_VARS argument. +# +# Note that there is no argument that will disable the find_dependency() macro; +# if you do not require this macro, you should use +# ``configure_package_config_file`` from the CMakePackageConfigHelpers module. +# +# CMake 3.0 includes a CMakeFindDependencyMacro module that provides the +# find_dependency() macro (which you can ``include()`` in your package config +# file), so this file is only useful for projects wishing to provide config +# files that will work with CMake 2.8.12. +# +# Additional Config File Macros +# ============================= # # :: # @@ -29,15 +47,6 @@ # REQUIRED which were passed to the original find_package() call. It also sets # an informative diagnostic message if the dependency could not be found. # -# Note that there is no argument to disable the find_dependency() macro; if you -# do not require this macro, you should just use the CMakeFindDependencyMacro -# module directly. -# -# CMake 3.0.0 will include a CMakeFindDependencyMacro module that will provide -# the find_dependency() macro (which you can include() in your package config -# file), so this file is only useful for projects whose minimum required version -# is 2.8.12. -# # Since pre-1.0.0. #============================================================================= -- cgit v1.2.1 From bc27ee561756cb6e1e51e3589addab8656fd4b03 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Fri, 6 Mar 2015 12:13:38 +0100 Subject: Use lconvert path from Qt cmake config when on Qt >= 5.3.1 Qt5LinguistToolsConfig.cmake defines CMake target for lconvert since Qt 5.3.1, so we should use that if it is available. Our own hacks were not working in some configurations (i.e. when there is /usr/bin/lconvert managed by qtchooser, but no qtchooser configuration file). REVIEW: 122626 --- modules/ECMCreateQmFromPoFiles.cmake | 19 ++++++++++++------- modules/ECMPoQmTools.cmake | 22 ++++++++++++---------- 2 files changed, 24 insertions(+), 17 deletions(-) (limited to 'modules') diff --git a/modules/ECMCreateQmFromPoFiles.cmake b/modules/ECMCreateQmFromPoFiles.cmake index 3f134fbb..afd6f786 100644 --- a/modules/ECMCreateQmFromPoFiles.cmake +++ b/modules/ECMCreateQmFromPoFiles.cmake @@ -110,13 +110,18 @@ endfunction() function(_ECM_QM_CREATE_TARGET install_destination catalog_name) # Find lconvert - get_target_property(lrelease_location Qt5::lrelease LOCATION) - get_filename_component(lrelease_path ${lrelease_location} PATH) - find_program(lconvert_executable - NAMES lconvert-qt5 lconvert - PATHS ${lrelease_path} - NO_DEFAULT_PATH - ) + if(TARGET Qt5::lconvert) + set(lconvert_executable Qt5::lconvert) + 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) + find_program(lconvert_executable + NAMES lconvert-qt5 lconvert + PATHS ${lrelease_path} + NO_DEFAULT_PATH + ) + endif() if (catalog_name) set(install_args RENAME ${catalog_name}.qm) diff --git a/modules/ECMPoQmTools.cmake b/modules/ECMPoQmTools.cmake index 015b7f90..b25c1bbf 100644 --- a/modules/ECMPoQmTools.cmake +++ b/modules/ECMPoQmTools.cmake @@ -121,18 +121,20 @@ function(ecm_process_po_files_as_qm lang) endif() # Find lrelease and lconvert - - # This gives us Qt5::lrelease but unfortunately no Qt5::lconvert See - # https://bugreports.qt-project.org/browse/QTBUG-37937 find_package(Qt5LinguistTools CONFIG REQUIRED) - get_target_property(lrelease_location Qt5::lrelease LOCATION) - get_filename_component(lrelease_path ${lrelease_location} PATH) - find_program(lconvert_executable - NAMES lconvert-qt5 lconvert - PATHS ${lrelease_path} - NO_DEFAULT_PATH - ) + if(TARGET Qt5::lconvert) + set(lconvert_executable Qt5::lconvert) + 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) + find_program(lconvert_executable + NAMES lconvert-qt5 lconvert + PATHS ${lrelease_path} + NO_DEFAULT_PATH + ) + endif() # Create commands to turn po files into qm files set(qm_files) -- cgit v1.2.1 From 19353c9857d1e26c6508c2fc7dd530e6ee0ef316 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sat, 14 Mar 2015 12:44:49 +0000 Subject: Warn about icon filenames with leading characters. Through a quirk of implementation, old-style icon filenames are accepted by the new-style ecm_install_icons function. It's too late to change it now, as that would break existing projects, but we can warn about it. REVIEW: 122941 --- modules/ECMInstallIcons.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/ECMInstallIcons.cmake b/modules/ECMInstallIcons.cmake index 34d5a485..79dc5150 100644 --- a/modules/ECMInstallIcons.cmake +++ b/modules/ECMInstallIcons.cmake @@ -223,8 +223,9 @@ function(ecm_install_icons) endif() foreach(icon ${ARG_ICONS}) + get_filename_component(filename "${icon}" NAME) string(REGEX MATCH "([0-9sc]+)\\-([a-z]+)\\-([^/]+)\\.([a-z]+)$" - _dummy "${icon}") + complete_match "${filename}") set(size "${CMAKE_MATCH_1}") set(group "${CMAKE_MATCH_2}") set(name "${CMAKE_MATCH_3}") @@ -234,6 +235,12 @@ function(ecm_install_icons) elseif(NOT size STREQUAL "sc" AND NOT size GREATER 0) message(WARNING "${icon} size (${size}) is invalid - ignoring") else() + if (NOT complete_match STREQUAL filename) + # We can't stop accepting filenames with leading characters, + # because that would break existing projects, so just warn + # about them instead. + message(AUTHOR_WARNING "\"${icon}\" has characters before the size; it should be renamed to \"${size}-${group}-${name}.${ext}\"") + endif() if(NOT _ECM_ICON_GROUP_${group}) message(WARNING "${icon} group (${group}) is not recognized") endif() -- cgit v1.2.1 From 90db6547801ec0f637799117ac494ca503f39362 Mon Sep 17 00:00:00 2001 From: Lasse Liehu Date: Thu, 9 Apr 2015 15:36:43 +0300 Subject: Do not call lrelease with -compress According to Oswald Buddenhagen "it doesn't buy much, and there are some long-standing issues with it". Qt bug report: https://bugreports.qt.io/browse/QTBUG-44362 REVIEW: 122501 --- modules/ECMCreateQmFromPoFiles.cmake | 2 +- modules/ECMPoQmTools.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/ECMCreateQmFromPoFiles.cmake b/modules/ECMCreateQmFromPoFiles.cmake index afd6f786..b4194723 100644 --- a/modules/ECMCreateQmFromPoFiles.cmake +++ b/modules/ECMCreateQmFromPoFiles.cmake @@ -145,7 +145,7 @@ function(_ECM_QM_CREATE_TARGET install_destination catalog_name) COMMAND ${lconvert_executable} ARGS -i ${it} -o ${tsfile} -target-language ${language} COMMAND Qt5::lrelease - ARGS -compress -removeidentical -silent ${tsfile} -qm ${qmfile} + ARGS -removeidentical -silent ${tsfile} -qm ${qmfile} DEPENDS ${it} ) install( diff --git a/modules/ECMPoQmTools.cmake b/modules/ECMPoQmTools.cmake index b25c1bbf..12bcf6b6 100644 --- a/modules/ECMPoQmTools.cmake +++ b/modules/ECMPoQmTools.cmake @@ -155,7 +155,7 @@ function(ecm_process_po_files_as_qm lang) COMMAND ${lconvert_executable} ARGS -i ${po_file} -o ${ts_file} -target-language ${lang} COMMAND Qt5::lrelease - ARGS -compress -removeidentical -silent ${ts_file} -qm ${qm_file} + ARGS -removeidentical -silent ${ts_file} -qm ${qm_file} DEPENDS ${po_file} ) if (ARGS_INSTALL_DESTINATION) -- cgit v1.2.1 From 1b636b43d2bf4dca0332a2e2b36affa67fbe1e0b Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 11 May 2015 13:56:28 +0100 Subject: Add unit tests for ECMAddTests module. REVIEW: 123722 --- modules/ECMAddTests.cmake | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/ECMAddTests.cmake b/modules/ECMAddTests.cmake index de06315d..bdb60691 100644 --- a/modules/ECMAddTests.cmake +++ b/modules/ECMAddTests.cmake @@ -23,9 +23,13 @@ # give an indication of where to look for a failing test. # # If the flag GUI is passed the test binary will be a GUI executable, otherwise -# the resulting binary will be a console application. The test will be linked +# the resulting binary will be a console application (regardless of the value +# of CMAKE_WIN32_EXECUTABLE or CMAKE_MACOSX_BUNDLE). The test will be linked # against the libraries and/or targets passed to LINK_LIBRARIES. # +# The generated target executable will have the effects of ecm_mark_as_test() +# (from the :module:`ECMMarkAsTest` module) applied to it. +# # # :: # @@ -52,6 +56,7 @@ # (To distribute this file outside of extra-cmake-modules, substitute the full # License text for the above reference.) +include(CMakeParseArguments) include(ECMMarkAsTest) include(ECMMarkNonGuiExecutable) @@ -73,7 +78,11 @@ function(ecm_add_test) endif() set(_testname "${ECM_ADD_TEST_NAME_PREFIX}${_targetname}") - add_executable(${_targetname} ${_sources}) + set(gui_args) + if(ECM_ADD_TEST_GUI) + set(gui_args WIN32 MACOSX_BUNDLE) + endif() + add_executable(${_targetname} ${gui_args} ${_sources}) if(NOT ECM_ADD_TEST_GUI) ecm_mark_nongui_executable(${_targetname}) endif() -- cgit v1.2.1 From 0c224194ea7f12eaed32af746fc9138537f1919c Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 11 May 2015 13:56:28 +0100 Subject: Add PROPERTIES argument to ecm_add_test and ecm_add_tests. This is particularly useful with ecm_add_tests, where you may want to force a suite of tests to run in serial, or alter the timeout for multiple tests at once. BUG: 345797 REVIEW: 123722 --- modules/ECMAddTests.cmake | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/ECMAddTests.cmake b/modules/ECMAddTests.cmake index bdb60691..ee7e63e3 100644 --- a/modules/ECMAddTests.cmake +++ b/modules/ECMAddTests.cmake @@ -9,7 +9,8 @@ # ecm_add_test( LINK_LIBRARIES [ [...]] # [TEST_NAME ] # [NAME_PREFIX ] -# [GUI]) +# [GUI] +# [PROPERTIES [ [...]]]) # # Add a new unit test using the passed source files. The parameter TEST_NAME is # used to set the name of the resulting test, and the target built for and run @@ -27,6 +28,8 @@ # of CMAKE_WIN32_EXECUTABLE or CMAKE_MACOSX_BUNDLE). The test will be linked # against the libraries and/or targets passed to LINK_LIBRARIES. # +# The PROPERTIES argument sets the given properties on the test. +# # The generated target executable will have the effects of ecm_mark_as_test() # (from the :module:`ECMMarkAsTest` module) applied to it. # @@ -35,7 +38,8 @@ # # ecm_add_tests( LINK_LIBRARIES [ [...]] # [NAME_PREFIX ] -# [GUI]) +# [GUI] +# [PROPERTIES [ [...]]]) # # This is a convenient version of ecm_add_test() for when you have many tests # that consist of a single source file each. It behaves like calling @@ -63,7 +67,7 @@ include(ECMMarkNonGuiExecutable) function(ecm_add_test) set(options GUI) set(oneValueArgs TEST_NAME NAME_PREFIX) - set(multiValueArgs LINK_LIBRARIES) + set(multiValueArgs LINK_LIBRARIES PROPERTIES) cmake_parse_arguments(ECM_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set(_sources ${ECM_ADD_TEST_UNPARSED_ARGUMENTS}) list(LENGTH _sources _sourceCount) @@ -89,12 +93,15 @@ function(ecm_add_test) add_test(NAME ${_testname} COMMAND ${_targetname}) target_link_libraries(${_targetname} ${ECM_ADD_TEST_LINK_LIBRARIES}) ecm_mark_as_test(${_targetname}) + if (ECM_ADD_TEST_PROPERTIES) + set_tests_properties(${_testname} PROPERTIES ${ECM_ADD_TEST_PROPERTIES}) + endif() endfunction() function(ecm_add_tests) set(options GUI) set(oneValueArgs NAME_PREFIX) - set(multiValueArgs LINK_LIBRARIES) + set(multiValueArgs LINK_LIBRARIES PROPERTIES) cmake_parse_arguments(ECM_ADD_TESTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if(ECM_ADD_TESTS_GUI) set(_exe_type GUI) @@ -106,6 +113,7 @@ function(ecm_add_tests) NAME_PREFIX ${ECM_ADD_TESTS_NAME_PREFIX} LINK_LIBRARIES ${ECM_ADD_TESTS_LINK_LIBRARIES} ${_exe_type} + PROPERTIES ${ECM_ADD_TESTS_PROPERTIES} ) endforeach() endfunction() -- cgit v1.2.1 From 70b13693478b296b8a3cd1654baa8013434358c5 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sat, 16 May 2015 14:06:34 +0100 Subject: Revert "Add PROPERTIES argument to ecm_add_test and ecm_add_tests." This reverts commit 0c224194ea7f12eaed32af746fc9138537f1919c. Stephen Kelly pointed out that this is probably not the best approach to the problem, and runs counter to the direction KDE's CMake code has been going (splitting functions up and using CMake built-ins where possible). I have a better solution in mind, which I'll post a review for later. CCMAIL: kde-buildsystem@kde.org CCBUG: 345797 --- modules/ECMAddTests.cmake | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'modules') diff --git a/modules/ECMAddTests.cmake b/modules/ECMAddTests.cmake index ee7e63e3..bdb60691 100644 --- a/modules/ECMAddTests.cmake +++ b/modules/ECMAddTests.cmake @@ -9,8 +9,7 @@ # ecm_add_test( LINK_LIBRARIES [ [...]] # [TEST_NAME ] # [NAME_PREFIX ] -# [GUI] -# [PROPERTIES [ [...]]]) +# [GUI]) # # Add a new unit test using the passed source files. The parameter TEST_NAME is # used to set the name of the resulting test, and the target built for and run @@ -28,8 +27,6 @@ # of CMAKE_WIN32_EXECUTABLE or CMAKE_MACOSX_BUNDLE). The test will be linked # against the libraries and/or targets passed to LINK_LIBRARIES. # -# The PROPERTIES argument sets the given properties on the test. -# # The generated target executable will have the effects of ecm_mark_as_test() # (from the :module:`ECMMarkAsTest` module) applied to it. # @@ -38,8 +35,7 @@ # # ecm_add_tests( LINK_LIBRARIES [ [...]] # [NAME_PREFIX ] -# [GUI] -# [PROPERTIES [ [...]]]) +# [GUI]) # # This is a convenient version of ecm_add_test() for when you have many tests # that consist of a single source file each. It behaves like calling @@ -67,7 +63,7 @@ include(ECMMarkNonGuiExecutable) function(ecm_add_test) set(options GUI) set(oneValueArgs TEST_NAME NAME_PREFIX) - set(multiValueArgs LINK_LIBRARIES PROPERTIES) + set(multiValueArgs LINK_LIBRARIES) cmake_parse_arguments(ECM_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set(_sources ${ECM_ADD_TEST_UNPARSED_ARGUMENTS}) list(LENGTH _sources _sourceCount) @@ -93,15 +89,12 @@ function(ecm_add_test) add_test(NAME ${_testname} COMMAND ${_targetname}) target_link_libraries(${_targetname} ${ECM_ADD_TEST_LINK_LIBRARIES}) ecm_mark_as_test(${_targetname}) - if (ECM_ADD_TEST_PROPERTIES) - set_tests_properties(${_testname} PROPERTIES ${ECM_ADD_TEST_PROPERTIES}) - endif() endfunction() function(ecm_add_tests) set(options GUI) set(oneValueArgs NAME_PREFIX) - set(multiValueArgs LINK_LIBRARIES PROPERTIES) + set(multiValueArgs LINK_LIBRARIES) cmake_parse_arguments(ECM_ADD_TESTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if(ECM_ADD_TESTS_GUI) set(_exe_type GUI) @@ -113,7 +106,6 @@ function(ecm_add_tests) NAME_PREFIX ${ECM_ADD_TESTS_NAME_PREFIX} LINK_LIBRARIES ${ECM_ADD_TESTS_LINK_LIBRARIES} ${_exe_type} - PROPERTIES ${ECM_ADD_TESTS_PROPERTIES} ) endforeach() endfunction() -- cgit v1.2.1 From 9f96174b61fbc1145fda4cfba573361a0aa8746d Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 18 May 2015 11:30:10 +0100 Subject: Rework ECMAddTests documentation to emphasis ecm_add_tests(). ecm_add_test is the less useful (and less used) version of the functions (because you really might as well just use add_executable() and add_test() manually in that case). REVIEW: 123841 --- modules/ECMAddTests.cmake | 50 ++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'modules') diff --git a/modules/ECMAddTests.cmake b/modules/ECMAddTests.cmake index bdb60691..cee6da4b 100644 --- a/modules/ECMAddTests.cmake +++ b/modules/ECMAddTests.cmake @@ -2,44 +2,46 @@ # ECMAddTests # ----------- # -# Add test executables. +# Convenience functions for adding tests. # # :: # -# ecm_add_test( LINK_LIBRARIES [ [...]] -# [TEST_NAME ] -# [NAME_PREFIX ] -# [GUI]) +# ecm_add_tests( LINK_LIBRARIES [ [...]] +# [NAME_PREFIX ] +# [GUI]) # -# Add a new unit test using the passed source files. The parameter TEST_NAME is -# used to set the name of the resulting test, and the target built for and run -# by the test. It may be omitted if there is exactly one source file. In that -# case the name of the source file (without the file extension) will be used as -# the test name. +# A convenience function for adding multiple tests, each consisting of a +# single source file. For each file in , 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. # -# If NAME_PREFIX is given, this prefix will be prepended to the test name, but -# not the target name. As a result, it will not prevent clashes between tests +# 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 the flag GUI is passed the test binary will be a GUI executable, otherwise -# the resulting binary will be a console application (regardless of the value -# of CMAKE_WIN32_EXECUTABLE or CMAKE_MACOSX_BUNDLE). The test will be linked -# against the libraries and/or targets passed to LINK_LIBRARIES. +# 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 +# of CMAKE_WIN32_EXECUTABLE or CMAKE_MACOSX_BUNDLE). Be aware that this changes +# the executable entry point on Windows (although some frameworks, such as Qt, +# abstract this difference away). # -# The generated target executable will have the effects of ecm_mark_as_test() +# The generated target executables will have the effects of ecm_mark_as_test() # (from the :module:`ECMMarkAsTest` module) applied to it. # -# # :: # -# ecm_add_tests( LINK_LIBRARIES [ [...]] -# [NAME_PREFIX ] -# [GUI]) +# ecm_add_test( LINK_LIBRARIES [ [...]] +# [TEST_NAME ] +# [NAME_PREFIX ] +# [GUI]) +# +# 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). # -# This is a convenient version of ecm_add_test() for when you have many tests -# that consist of a single source file each. It behaves like calling -# ecm_add_test() once for each source file, with the same named arguments. # # Since pre-1.0.0. -- cgit v1.2.1 From be390dcc4d77d7faa95d040b1a346ac3c0405eac Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 18 May 2015 19:12:06 +0100 Subject: Add arguments to ecm_add_tests for listing added tests. This makes it convenient to make further modifications to the tests, such as setting properties on either the tests or the targets. CHANGELOG: New arguments for ecm_add_tests(). BUG: 345797 REVIEW: 123841 --- modules/ECMAddTests.cmake | 62 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 17 deletions(-) (limited to 'modules') diff --git a/modules/ECMAddTests.cmake b/modules/ECMAddTests.cmake index cee6da4b..e9e2fc53 100644 --- a/modules/ECMAddTests.cmake +++ b/modules/ECMAddTests.cmake @@ -8,7 +8,9 @@ # # ecm_add_tests( LINK_LIBRARIES [ [...]] # [NAME_PREFIX ] -# [GUI]) +# [GUI] +# [TARGET_NAMES_VAR ] +# [TEST_NAMES_VAR ]) # # A convenience function for adding multiple tests, each consisting of a # single source file. For each file in , an executable target will be @@ -27,6 +29,11 @@ # the executable entry point on Windows (although some frameworks, such as Qt, # abstract this difference away). # +# The TARGET_NAMES_VAR and TEST_NAMES_VAR arguments, if given, should specify a +# variable name to receive the list of generated target and test names, +# respectively. This makes it convenient to apply properties to them as a +# whole, for example, using set_target_properties() or set_tests_properties(). +# # The generated target executables will have the effects of ecm_mark_as_test() # (from the :module:`ECMMarkAsTest` module) applied to it. # @@ -47,6 +54,7 @@ #============================================================================= # Copyright 2013 Alexander Richardson +# Copyright 2015 Alex Merry # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file COPYING-CMAKE-SCRIPTS for details. @@ -64,13 +72,15 @@ include(ECMMarkNonGuiExecutable) function(ecm_add_test) set(options GUI) - set(oneValueArgs TEST_NAME NAME_PREFIX) + # TARGET_NAME_VAR and TEST_NAME_VAR are undocumented args used by + # ecm_add_tests + set(oneValueArgs TEST_NAME NAME_PREFIX TARGET_NAME_VAR TEST_NAME_VAR) set(multiValueArgs LINK_LIBRARIES) - cmake_parse_arguments(ECM_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - set(_sources ${ECM_ADD_TEST_UNPARSED_ARGUMENTS}) + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + set(_sources ${ARG_UNPARSED_ARGUMENTS}) list(LENGTH _sources _sourceCount) - if(ECM_ADD_TEST_TEST_NAME) - set(_targetname ${ECM_ADD_TEST_TEST_NAME}) + if(ARG_TEST_NAME) + set(_targetname ${ARG_TEST_NAME}) elseif(${_sourceCount} EQUAL "1") #use the source file name without extension as the testname get_filename_component(_targetname ${_sources} NAME_WE) @@ -79,35 +89,53 @@ function(ecm_add_test) message(FATAL_ERROR "ecm_add_test() called with multiple source files but without setting \"TEST_NAME\"") endif() - set(_testname "${ECM_ADD_TEST_NAME_PREFIX}${_targetname}") + set(_testname ${ARG_NAME_PREFIX}${_targetname}) set(gui_args) - if(ECM_ADD_TEST_GUI) + if(ARG_GUI) set(gui_args WIN32 MACOSX_BUNDLE) endif() add_executable(${_targetname} ${gui_args} ${_sources}) - if(NOT ECM_ADD_TEST_GUI) + if(NOT ARG_GUI) ecm_mark_nongui_executable(${_targetname}) endif() add_test(NAME ${_testname} COMMAND ${_targetname}) - target_link_libraries(${_targetname} ${ECM_ADD_TEST_LINK_LIBRARIES}) + target_link_libraries(${_targetname} ${ARG_LINK_LIBRARIES}) ecm_mark_as_test(${_targetname}) + if (ARG_TARGET_NAME_VAR) + set(${ARG_TARGET_NAME_VAR} "${_targetname}" PARENT_SCOPE) + endif() + if (ARG_TEST_NAME_VAR) + set(${ARG_TEST_NAME_VAR} "${_testname}" PARENT_SCOPE) + endif() endfunction() function(ecm_add_tests) set(options GUI) - set(oneValueArgs NAME_PREFIX) + set(oneValueArgs NAME_PREFIX TARGET_NAMES_VAR TEST_NAMES_VAR) set(multiValueArgs LINK_LIBRARIES) - cmake_parse_arguments(ECM_ADD_TESTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(ECM_ADD_TESTS_GUI) + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(ARG_GUI) set(_exe_type GUI) else() set(_exe_type "") endif() - foreach(_test_source ${ECM_ADD_TESTS_UNPARSED_ARGUMENTS}) + set(test_names) + set(target_names) + foreach(_test_source ${ARG_UNPARSED_ARGUMENTS}) ecm_add_test(${_test_source} - NAME_PREFIX ${ECM_ADD_TESTS_NAME_PREFIX} - LINK_LIBRARIES ${ECM_ADD_TESTS_LINK_LIBRARIES} - ${_exe_type} + NAME_PREFIX ${ARG_NAME_PREFIX} + LINK_LIBRARIES ${ARG_LINK_LIBRARIES} + TARGET_NAME_VAR target_name + TEST_NAME_VAR test_name + ${_exe_type} ) + list(APPEND _test_names "${test_name}") + list(APPEND _target_names "${target_name}") endforeach() + if (ARG_TARGET_NAMES_VAR) + set(${ARG_TARGET_NAMES_VAR} "${_target_names}" PARENT_SCOPE) + endif() + if (ARG_TEST_NAMES_VAR) + set(${ARG_TEST_NAMES_VAR} "${_test_names}" PARENT_SCOPE) + endif() endfunction() -- cgit v1.2.1 From 51fb1c07bd9e6fcbb4204feb817fe94451593133 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 23 Jun 2015 22:54:11 +0200 Subject: Improve error reporting of query_qmake macro In case it fails, offer an error message and the attempted call, to make sure we can react accordingly. Note that the proper error argument is FATAL_ERROR, not FATAL. REVIEW: 124106 --- modules/ECMQueryQmake.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/ECMQueryQmake.cmake b/modules/ECMQueryQmake.cmake index c880671f..8f4cf177 100644 --- a/modules/ECMQueryQmake.cmake +++ b/modules/ECMQueryQmake.cmake @@ -19,6 +19,7 @@ function(query_qmake result_variable qt_variable) file(TO_CMAKE_PATH "${output}" output_path) set(${result_variable} "${output_path}" PARENT_SCOPE) else() - message(FATAL "QMake call failed: ${error}") + message(WARNING "Failed call: ${QMAKE_EXECUTABLE} -query \"${qt_variable}\"") + message(FATAL_ERROR "QMake call failed: ${return_code}") endif() endfunction() -- cgit v1.2.1 From 9bffa7a202cad3a29103f3e9a8b50b9a61277310 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 29 Jul 2015 22:46:44 +0200 Subject: Add macro to generate logging category declarations for Qt5. This makes life a bit easier for developers who use the categorised logging in Qt5 in the common case - rather than creating two new files, and remembering to put in the #ifdef for the default verbosity settings in Qt 5.4, they can just add a couple of lines to their CMakeLists.txt. REVIEW: 124595 --- modules/ECMQtDeclareLoggingCategory.cmake | 118 +++++++++++++++++++++++++++++ modules/ECMQtDeclareLoggingCategory.cpp.in | 11 +++ modules/ECMQtDeclareLoggingCategory.h.in | 11 +++ 3 files changed, 140 insertions(+) create mode 100644 modules/ECMQtDeclareLoggingCategory.cmake create mode 100644 modules/ECMQtDeclareLoggingCategory.cpp.in create mode 100644 modules/ECMQtDeclareLoggingCategory.h.in (limited to 'modules') diff --git a/modules/ECMQtDeclareLoggingCategory.cmake b/modules/ECMQtDeclareLoggingCategory.cmake new file mode 100644 index 00000000..b7f1ad39 --- /dev/null +++ b/modules/ECMQtDeclareLoggingCategory.cmake @@ -0,0 +1,118 @@ +#.rst: +# ECMQtDeclareLoggingCategory +# --------------------------- +# +# Generate declarations for logging categories in Qt5. +# +# :: +# +# ecm_qt_declare_logging_category( +# HEADER +# IDENTIFIER +# CATEGORY_NAME +# [DEFAULT_SEVERITY +# ]) +# +# A header file, ````, will be generated along with a corresponding +# source file, which will be added to ````. These will provide a +# QLoggingCategory category that can be referred to from C++ code using +# ````, and from the logging configuration using +# ````. +# +# If ```` is not absolute, it will be taken relative to the current +# binary directory. +# +# If the code is compiled against Qt 5.4 or later, by default it will only log +# output that is at least the severity specified by ``DEFAULT_SEVERITY``, or +# "Warning" level if ``DEFAULT_SEVERITY`` is not given. Note that, due to a +# bug in Qt 5.5, "Info" may be treated as more severe than "Fatal". +# +# ```` may include namespaces (eg: ``foo::bar::IDENT``). +# +# Since 5.14.0. + +#============================================================================= +# Copyright 2015 Alex Merry +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file COPYING-CMAKE-SCRIPTS for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of extra-cmake-modules, substitute the full +# License text for the above reference.) + +include(CMakeParseArguments) + +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") + +function(ecm_qt_declare_logging_category sources_var) + set(options) + set(oneValueArgs HEADER IDENTIFIER CATEGORY_NAME DEFAULT_SEVERITY) + set(multiValueArgs) + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(ARG_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unexpected arguments to ecm_qt_declare_logging_category: ${ARG_UNPARSED_ARGUMENTS}") + endif() + if(NOT ARG_HEADER) + message(FATAL_ERROR "Missing HEADER argument for ecm_qt_declare_logging_category") + endif() + if(NOT ARG_IDENTIFIER) + message(FATAL_ERROR "Missing IDENTIFIER argument for ecm_qt_declare_logging_category") + endif() + if(NOT ARG_CATEGORY_NAME) + message(FATAL_ERROR "Missing CATEGORY_NAME argument for ecm_qt_declare_logging_category") + endif() + if(NOT ARG_DEFAULT_SEVERITY) + set(ARG_DEFAULT_SEVERITY Warning) + else() + set(acceptible_severities Debug Info Warning Critical Fatal) + list(FIND acceptible_severities "${ARG_DEFAULT_SEVERITY}" pos) + if (pos EQUAL -1) + message(FATAL_ERROR "Unknown DEFAULT_SEVERITY ${pos}") + endif() + endif() + + if (NOT IS_ABSOLUTE "${ARG_HEADER}") + set(ARG_HEADER "${CMAKE_CURRENT_BINARY_DIR}/${ARG_HEADER}") + endif() + + string(REPLACE "::" ";" namespaces "${ARG_IDENTIFIER}") + list(LENGTH namespaces len) + math(EXPR last_pos "${len} - 1") + list(GET namespaces ${last_pos} IDENTIFIER) + list(REMOVE_AT namespaces ${last_pos}) + + set(OPEN_NAMESPACES) + set(CLOSE_NAMESPACES) + foreach(ns ${namespaces}) + set(OPEN_NAMESPACES "${OPEN_NAMESPACES} namespace ${ns} {") + set(CLOSE_NAMESPACES "} ${CLOSE_NAMESPACES}") + endforeach() + + string(FIND "${ARG_HEADER}" "." pos REVERSE) + if (pos EQUAL -1) + set(cpp_filename "${ARG_HEADER}.cpp") + else() + string(SUBSTRING "${ARG_HEADER}" 0 ${pos} cpp_filename) + set(cpp_filename "${cpp_filename}.cpp") + endif() + + get_filename_component(HEADER_NAME "${ARG_HEADER}" NAME) + + string(REPLACE "::" "_" GUARD_NAME "${ARG_IDENTIFIER}_H") + string(TOUPPER "${GUARD_NAME}" GUARD_NAME) + + configure_file("${_ECM_QT_DECLARE_LOGGING_CATEGORY_TEMPLATE_CPP}" "${cpp_filename}") + configure_file("${_ECM_QT_DECLARE_LOGGING_CATEGORY_TEMPLATE_H}" "${ARG_HEADER}") + + set(sources "${${sources_var}}") + list(APPEND sources "${cpp_filename}") + set(${sources_var} "${sources}" PARENT_SCOPE) +endfunction() + diff --git a/modules/ECMQtDeclareLoggingCategory.cpp.in b/modules/ECMQtDeclareLoggingCategory.cpp.in new file mode 100644 index 00000000..20c14af5 --- /dev/null +++ b/modules/ECMQtDeclareLoggingCategory.cpp.in @@ -0,0 +1,11 @@ +// This file is autogenerated by CMake: DO NOT EDIT + +#include "@HEADER_NAME@" + +@OPEN_NAMESPACES@ +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) +Q_LOGGING_CATEGORY(@IDENTIFIER@, "@ARG_CATEGORY_NAME@", Qt@ARG_DEFAULT_SEVERITY@Msg) +#else +Q_LOGGING_CATEGORY(@IDENTIFIER@, "@ARG_CATEGORY_NAME@") +#endif +@CLOSE_NAMESPACES@ diff --git a/modules/ECMQtDeclareLoggingCategory.h.in b/modules/ECMQtDeclareLoggingCategory.h.in new file mode 100644 index 00000000..fedecd2f --- /dev/null +++ b/modules/ECMQtDeclareLoggingCategory.h.in @@ -0,0 +1,11 @@ +// This file is autogenerated by CMake: DO NOT EDIT + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include +@OPEN_NAMESPACES@ +Q_DECLARE_LOGGING_CATEGORY(@IDENTIFIER@) +@CLOSE_NAMESPACES@ + +#endif -- cgit v1.2.1 From 8ef3f474e3a6def47dce36b54fbdce2d98c79342 Mon Sep 17 00:00:00 2001 From: Patrick Spendrin Date: Thu, 20 Aug 2015 21:46:20 +0200 Subject: add COMMON_HEADER option and multiple header functionality This adds a new keyword COMMON_HEADER which generates a new header containing all other headers. Also it is possible now to have multiple dummy headers per header file. It is assumed that the first header is the existing one. REVIEW: 124847 --- modules/ECMGenerateHeaders.cmake | 75 +++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 21 deletions(-) (limited to 'modules') diff --git a/modules/ECMGenerateHeaders.cmake b/modules/ECMGenerateHeaders.cmake index b6290223..cefc82df 100644 --- a/modules/ECMGenerateHeaders.cmake +++ b/modules/ECMGenerateHeaders.cmake @@ -12,12 +12,16 @@ # [OUTPUT_DIR ] # [PREFIX ] # [REQUIRED_HEADERS ] +# [COMMON_HEADER ] # [RELATIVE ]) # # For each CamelCase header name passed to HEADER_NAMES, a file of that name # will be generated that will include a version with ``.h`` appended. # For example, the generated header ``ClassA`` will include ``classa.h`` (or # ``ClassA.h``, see ORIGINAL). +# If a CamelCaseName consists of multiple comma-separated files, e.g. +# ``ClassA,ClassB,ClassC``, then multiple camelcase header files will be +# generated which are redirects to the first header file. # The file locations of these generated headers will be stored in # . # @@ -43,6 +47,9 @@ # CMakeLists.txt file; the original variant will then be added to this # variable. # +# COMMON_HEADER generates an additional convenience header which includes all +# other header files. +# # 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 @@ -69,6 +76,7 @@ # MLBar # # etc # REQUIRED_HEADERS MyLib_HEADERS +# COMMON_HEADER MLGeneral # ) # install(FILES ${MyLib_FORWARDING_HEADERS} ${MyLib_HEADERS} # DESTINATION ${CMAKE_INSTALL_PREFIX}/include @@ -82,7 +90,9 @@ # MyLib_FORWARDING_HEADERS # HEADERS # Foo -# Bar +# # several classes are contained in bar.h, so generate +# # additional files +# Bar,BarList # # etc # PREFIX MyLib # REQUIRED_HEADERS MyLib_HEADERS @@ -99,6 +109,7 @@ #============================================================================= # Copyright 2013 Aleix Pol Gonzalez # Copyright 2014 Alex Merry +# Copyright 2015 Patrick Spendrin # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file COPYING-CMAKE-SCRIPTS for details. @@ -114,7 +125,7 @@ include(CMakeParseArguments) function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var) set(options) - set(oneValueArgs ORIGINAL OUTPUT_DIR PREFIX REQUIRED_HEADERS RELATIVE) + set(oneValueArgs ORIGINAL OUTPUT_DIR PREFIX REQUIRED_HEADERS COMMON_HEADER RELATIVE) set(multiValueArgs HEADER_NAMES) cmake_parse_arguments(EGH "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -154,35 +165,57 @@ function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var) endif() endif() - foreach(_CLASSNAME ${EGH_HEADER_NAMES}) + foreach(_classnameentry ${EGH_HEADER_NAMES}) + string(REPLACE "," ";" _classnames ${_classnameentry}) + list(GET _classnames 0 _baseclass) + if (EGH_ORIGINAL STREQUAL "CAMELCASE") - set(originalclassname "${_CLASSNAME}") + set(originalbasename "${_baseclass}") else() - string(TOLOWER "${_CLASSNAME}" originalclassname) + string(TOLOWER "${_baseclass}" originalbasename) endif() - set(FANCY_HEADER_FILE "${EGH_OUTPUT_DIR}/${EGH_PREFIX}${_CLASSNAME}") - set(_actualheader "${CMAKE_CURRENT_SOURCE_DIR}/${EGH_RELATIVE}${originalclassname}.h") + + set(_actualheader "${CMAKE_CURRENT_SOURCE_DIR}/${EGH_RELATIVE}${originalbasename}.h") if (NOT EXISTS ${_actualheader}) message(FATAL_ERROR "Could not find \"${_actualheader}\"") endif() - if (NOT EXISTS ${FANCY_HEADER_FILE}) - file(WRITE ${FANCY_HEADER_FILE} "#include \"${originalprefix}${originalclassname}.h\"\n") - endif() - list(APPEND ${camelcase_forwarding_headers_var} "${FANCY_HEADER_FILE}") - if (EGH_REQUIRED_HEADERS) - list(APPEND ${EGH_REQUIRED_HEADERS} "${_actualheader}") - endif() - if (EGH_PREFIX) - # Local forwarding header, for namespaced headers, e.g. kparts/part.h - set(REGULAR_HEADER_NAME ${EGH_OUTPUT_DIR}/${originalprefix}${originalclassname}.h) - if (NOT EXISTS ${REGULAR_HEADER_NAME}) - file(WRITE ${REGULAR_HEADER_NAME} "#include \"${_actualheader}\"\n") + + foreach(_CLASSNAME ${_classnames}) + set(FANCY_HEADER_FILE "${EGH_OUTPUT_DIR}/${EGH_PREFIX}${_CLASSNAME}") + if (NOT EXISTS ${FANCY_HEADER_FILE}) + file(WRITE ${FANCY_HEADER_FILE} "#include \"${originalprefix}${originalbasename}.h\"\n") endif() - 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(EGH_ORIGINAL STREQUAL "CAMELCASE") + set(originalclassname "${_CLASSNAME}") + else() + string(TOLOWER "${_CLASSNAME}" originalclassname) + endif() + set(REGULAR_HEADER_NAME ${EGH_OUTPUT_DIR}/${originalprefix}${originalclassname}.h) + if (NOT EXISTS ${REGULAR_HEADER_NAME}) + file(WRITE ${REGULAR_HEADER_NAME} "#include \"${_actualheader}\"\n") + endif() + endif() + endforeach() + + list(APPEND _REQUIRED_HEADERS "${_actualheader}") endforeach() + if(EGH_COMMON_HEADER) + #combine required headers into 1 big convenience header + set(COMMON_HEADER ${EGH_OUTPUT_DIR}/${EGH_PREFIX}${EGH_COMMON_HEADER}) + file(WRITE ${COMMON_HEADER} "// convenience header\n") + foreach(_header ${_REQUIRED_HEADERS}) + get_filename_component(_base ${_header} NAME) + file(APPEND ${COMMON_HEADER} "#include \"${_base}\"\n") + endforeach() + list(APPEND ${camelcase_forwarding_headers_var} "${COMMON_HEADER}") + endif() + set(${camelcase_forwarding_headers_var} ${${camelcase_forwarding_headers_var}} PARENT_SCOPE) if (NOT EGH_REQUIRED_HEADERS STREQUAL "") - set(${EGH_REQUIRED_HEADERS} ${${EGH_REQUIRED_HEADERS}} PARENT_SCOPE) + set(${EGH_REQUIRED_HEADERS} ${${EGH_REQUIRED_HEADERS}} ${_REQUIRED_HEADERS} PARENT_SCOPE) endif () endfunction() -- cgit v1.2.1 From 1c20edb86115ecf788f64cb8563b85129c7a669d Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 25 Sep 2015 17:43:49 +0200 Subject: ECMEnableSanitizers: The undefined sanitizer is supported by gcc 4.9 --- modules/ECMEnableSanitizers.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/ECMEnableSanitizers.cmake b/modules/ECMEnableSanitizers.cmake index d55b2525..e64599b6 100644 --- a/modules/ECMEnableSanitizers.cmake +++ b/modules/ECMEnableSanitizers.cmake @@ -125,7 +125,7 @@ macro (enable_sanitizer_flags sanitize_option) set(XSAN_COMPILE_FLAGS "-fsanitize=leak") set(XSAN_LINKER_FLAGS "lsan") elseif (${sanitize_option} MATCHES "undefined") - check_compiler_version("99.99" "3.1") + check_compiler_version("4.9" "3.1") set(XSAN_COMPILE_FLAGS "-fsanitize=undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls") else () message(FATAL_ERROR "Compiler sanitizer option \"${sanitize_option}\" not supported.") -- cgit v1.2.1 From 12908eafb494ed32a96a5573f0446cc1528265ca Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Sat, 12 Sep 2015 14:20:25 +0200 Subject: Update GTK icon cache when installing icons. Despite the name, Qt is also using this, and it considerably speeds up icon lookup. REVIEW: 125192 --- modules/ECMInstallIcons.cmake | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'modules') diff --git a/modules/ECMInstallIcons.cmake b/modules/ECMInstallIcons.cmake index 79dc5150..920c9490 100644 --- a/modules/ECMInstallIcons.cmake +++ b/modules/ECMInstallIcons.cmake @@ -186,7 +186,9 @@ endmacro() # Updates the mtime of the icon theme directory, so caches that # watch for changes to the directory will know to update. +# If present, this also runs gtk-update-icon-cache (which despite the name is also used by Qt). function(_ecm_update_iconcache installdir theme) + find_program(GTK_UPDATE_ICON_CACHE_EXECUTABLE NAMES gtk-update-icon-cache) # We don't always have touch command (e.g. on Windows), so instead # create and delete a temporary file in the theme dir. install(CODE " @@ -194,6 +196,10 @@ function(_ecm_update_iconcache installdir theme) if (NOT DESTDIR_VALUE) file(WRITE \"${installdir}/${theme}/temp.txt\" \"update\") file(REMOVE \"${installdir}/${theme}/temp.txt\") + set(HAVE_GTK_UPDATE_ICON_CACHE_EXEC ${GTK_UPDATE_ICON_CACHE_EXECUTABLE}) + if (HAVE_GTK_UPDATE_ICON_CACHE_EXEC) + execute_process(COMMAND ${GTK_UPDATE_ICON_CACHE_EXECUTABLE} -q -t -i . WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/${installdir}/${theme}\") + endif () endif (NOT DESTDIR_VALUE) ") endfunction() -- cgit v1.2.1 From fb7b8eea7d91772f989d5b060c86df20f2ebdb66 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 14 Oct 2015 12:10:31 +0100 Subject: Fix ECMInstallIconsTest. ECMInstallIcons now updates the theme cache if gtk-update-icon-cache is available, producing files the test hadn't been expecting.. Updating the test revealed that the old-style ecm_install_icons call only updated the hicolor cache, and not any of the other themes. REVIEW: 125631 --- modules/ECMInstallIcons.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/ECMInstallIcons.cmake b/modules/ECMInstallIcons.cmake index 920c9490..8db486e7 100644 --- a/modules/ECMInstallIcons.cmake +++ b/modules/ECMInstallIcons.cmake @@ -111,6 +111,8 @@ macro(_ecm_install_icons_v1 _defaultpath) set(_l10n_SUBDIR ".") endif(_lang) + set(_themes) + # first the png icons file(GLOB _icons *.png) foreach (_current_ICON ${_icons} ) @@ -123,6 +125,7 @@ macro(_ecm_install_icons_v1 _defaultpath) set(_theme_GROUP ${_ECM_ICON_THEME_${_type}}) if( _theme_GROUP) + list(APPEND _themes "${_theme_GROUP}") _ECM_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake ${_defaultpath}/${_theme_GROUP}/${_size}x${_size} ${_group} ${_current_ICON} ${_name} ${_l10n_SUBDIR}) @@ -141,6 +144,7 @@ macro(_ecm_install_icons_v1 _defaultpath) set(_theme_GROUP ${_ECM_ICON_THEME_${_type}}) if( _theme_GROUP) + list(APPEND _themes "${_theme_GROUP}") _ECM_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake ${_defaultpath}/${_theme_GROUP}/${_size}x${_size} ${_group} ${_current_ICON} ${_name} ${_l10n_SUBDIR}) @@ -158,13 +162,17 @@ macro(_ecm_install_icons_v1 _defaultpath) set(_theme_GROUP ${_ECM_ICON_THEME_${_type}}) if( _theme_GROUP) + list(APPEND _themes "${_theme_GROUP}") _ECM_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake ${_defaultpath}/${_theme_GROUP}/scalable ${_group} ${_current_ICON} ${_name} ${_l10n_SUBDIR}) endif( _theme_GROUP) endforeach (_current_ICON) - _ecm_update_iconcache("${_defaultpath}" hicolor) + list(REMOVE_DUPLICATES _themes) + foreach(_theme ${_themes}) + _ecm_update_iconcache("${_defaultpath}" "${_theme}") + endforeach() endmacro() -- cgit v1.2.1 From 009c480413910e8c1a18f4d1420f4a517ea606e6 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 14 Oct 2015 12:18:40 +0100 Subject: Make sure we load translations on the main thread. BUG: 346188 REVIEW: 123726 --- modules/ECMPoQmTools.cmake | 15 ++++++-- modules/ECMQmLoader.cpp.in | 90 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 76 insertions(+), 29 deletions(-) (limited to 'modules') diff --git a/modules/ECMPoQmTools.cmake b/modules/ECMPoQmTools.cmake index 12bcf6b6..22258dc8 100644 --- a/modules/ECMPoQmTools.cmake +++ b/modules/ECMPoQmTools.cmake @@ -99,9 +99,20 @@ endfunction() function(ecm_create_qm_loader out_var catalog_name) + set(loader_cpp ${CMAKE_CURRENT_BINARY_DIR}/ECMQmLoader.cpp) + set(loader_moc ${CMAKE_CURRENT_BINARY_DIR}/ECMQmLoader.moc) + # catalog_name is used in ECMQmLoader.cpp.in - configure_file(${ECM_MODULE_DIR}/ECMQmLoader.cpp.in ECMQmLoader.cpp @ONLY) - set(${out_var} ${${out_var}} ${CMAKE_CURRENT_BINARY_DIR}/ECMQmLoader.cpp PARENT_SCOPE) + configure_file(${ECM_MODULE_DIR}/ECMQmLoader.cpp.in "${loader_cpp}" @ONLY) + set(${out_var} "${${out_var}}" "${loader_cpp}" "${loader_moc}" PARENT_SCOPE) + + # can't assume target has AUTOMOC turned on + if(NOT Qt5Core_FOUND) + find_package(Qt5Core) + endif() + if(Qt5Core_FOUND) + qt5_generate_moc("${loader_cpp}" "${loader_moc}") + endif() endfunction() diff --git a/modules/ECMQmLoader.cpp.in b/modules/ECMQmLoader.cpp.in index bc01bf98..f6b98e7b 100644 --- a/modules/ECMQmLoader.cpp.in +++ b/modules/ECMQmLoader.cpp.in @@ -5,41 +5,77 @@ */ #include #include +#include #include +#include #include -#include +namespace { -static bool loadTranslation(const QString &localeDirName) -{ - QString subPath = QStringLiteral("locale/") + localeDirName + QStringLiteral("/LC_MESSAGES/@catalog_name@.qm"); - QString fullPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, subPath); - if (fullPath.isEmpty()) { - return false; + bool loadTranslation(const QString &localeDirName) + { + QString subPath = QStringLiteral("locale/") + localeDirName + QStringLiteral("/LC_MESSAGES/@catalog_name@.qm"); + QString fullPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, subPath); + if (fullPath.isEmpty()) { + return false; + } + QTranslator *translator = new QTranslator(QCoreApplication::instance()); + if (!translator->load(fullPath)) { + delete translator; + return false; + } + QCoreApplication::instance()->installTranslator(translator); + return true; } - QTranslator *translator = new QTranslator(QCoreApplication::instance()); - if (!translator->load(fullPath)) { - delete translator; - return false; + + void load() + { + // The way Qt translation system handles plural forms makes it necessary to + // have a translation file which contains only plural forms for `en`. That's + // why we load the `en` translation unconditionally, then load the + // translation for the current locale to overload it. + loadTranslation(QStringLiteral("en")); + + QLocale locale = QLocale::system(); + if (locale.name() != QStringLiteral("en")) { + if (!loadTranslation(locale.name())) { + loadTranslation(locale.bcp47Name()); + } + } } - QCoreApplication::instance()->installTranslator(translator); - return true; -} -static void load() -{ - // The way Qt translation system handles plural forms makes it necessary to - // have a translation file which contains only plural forms for `en`. That's - // why we load the `en` translation unconditionally, then load the - // translation for the current locale to overload it. - loadTranslation(QStringLiteral("en")); - - QLocale locale = QLocale::system(); - if (locale.name() != QStringLiteral("en")) { - if (!loadTranslation(locale.name())) { - loadTranslation(locale.bcp47Name()); + // helper to call load() on the correct thread + class Loader : public QObject + { + Q_OBJECT + + public Q_SLOTS: + void callLoadAndDeleteSelf() + { + load(); + this->deleteLater(); + } + }; + + void loadOnMainThread() + { + // If this library is loaded after the QCoreApplication instance is created + // (eg: because it is brought in by a plugin), there is no guarantee this + // function will be called on the main thread. + // QCoreApplication::installTranslator needs to be called on the main + // thread, because it uses QCoreApplication::sendEvent. + if (QThread::currentThread() == QCoreApplication::instance()->thread()) { + load(); + } else { + // QObjects inherit their parent object's thread + Loader *loader = new Loader(); + loader->moveToThread(QCoreApplication::instance()->thread()); + QMetaObject::invokeMethod(loader, "callLoadAndDeleteSelf", Qt::AutoConnection); } } + } -Q_COREAPP_STARTUP_FUNCTION(load) +Q_COREAPP_STARTUP_FUNCTION(loadOnMainThread) + +#include "ECMQmLoader.moc" -- cgit v1.2.1 From a76e17ab8f527930c7c6b90f7d87f35c8ceb0ad2 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Tue, 3 Nov 2015 17:32:04 +0000 Subject: Add BSD license to ECMQmLoader.cpp.in. CCMAIL: kde-licensing@kde.org CCMAIL: agateau@kde.org --- modules/ECMQmLoader.cpp.in | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'modules') diff --git a/modules/ECMQmLoader.cpp.in b/modules/ECMQmLoader.cpp.in index f6b98e7b..fc667ba2 100644 --- a/modules/ECMQmLoader.cpp.in +++ b/modules/ECMQmLoader.cpp.in @@ -2,6 +2,33 @@ * * Building this file in a library ensures translations are automatically loaded * when an application makes use of the library. + * + * + * Copyright 2014 Aurélien Gâteau + * Copyright 2015 Alex Merry + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include -- cgit v1.2.1 From 21629f651a6a5d9d977be03fd9f98417c4fa27ae Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Tue, 3 Nov 2015 12:00:44 +0000 Subject: Warn instead of error if ecm_install_icons finds no icons. The V1 syntax of ecm_install_icons searched for icons by globbing files with a particular naming pattern. If there were no such icons, this used to do nothing, but silently. Commit fb7b8eea7d accidentally made this an error. More sensible would be to make it a warning. BUG: 354610 REVIEW: 125931 --- modules/ECMInstallIcons.cmake | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/ECMInstallIcons.cmake b/modules/ECMInstallIcons.cmake index 8db486e7..549ebe19 100644 --- a/modules/ECMInstallIcons.cmake +++ b/modules/ECMInstallIcons.cmake @@ -169,10 +169,14 @@ macro(_ecm_install_icons_v1 _defaultpath) endif( _theme_GROUP) endforeach (_current_ICON) - list(REMOVE_DUPLICATES _themes) - foreach(_theme ${_themes}) - _ecm_update_iconcache("${_defaultpath}" "${_theme}") - endforeach() + if (_themes) + list(REMOVE_DUPLICATES _themes) + foreach(_theme ${_themes}) + _ecm_update_iconcache("${_defaultpath}" "${_theme}") + endforeach() + else() + message(AUTHOR_WARNING "No suitably-named icons found") + endif() endmacro() -- cgit v1.2.1 From 6745bd7e4796560959bb67e33b7c7f86f96a5a94 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 8 Nov 2015 19:23:22 +0000 Subject: Revert "Make sure we load translations on the main thread." This broke the build for projects which used ecm_create_qm_loader in unusual ways. A better approach is coming, but won't be in e-c-m 5.16. This reverts commit 009c480413910e8c1a18f4d1420f4a517ea606e6. CCBUG: 346188 CCMAIL: release-team@kde.org CCMAIL: kde-buildsystem@kde.org --- modules/ECMPoQmTools.cmake | 15 ++------ modules/ECMQmLoader.cpp.in | 88 ++++++++++++++-------------------------------- 2 files changed, 28 insertions(+), 75 deletions(-) (limited to 'modules') diff --git a/modules/ECMPoQmTools.cmake b/modules/ECMPoQmTools.cmake index 22258dc8..12bcf6b6 100644 --- a/modules/ECMPoQmTools.cmake +++ b/modules/ECMPoQmTools.cmake @@ -99,20 +99,9 @@ endfunction() function(ecm_create_qm_loader out_var catalog_name) - set(loader_cpp ${CMAKE_CURRENT_BINARY_DIR}/ECMQmLoader.cpp) - set(loader_moc ${CMAKE_CURRENT_BINARY_DIR}/ECMQmLoader.moc) - # catalog_name is used in ECMQmLoader.cpp.in - configure_file(${ECM_MODULE_DIR}/ECMQmLoader.cpp.in "${loader_cpp}" @ONLY) - set(${out_var} "${${out_var}}" "${loader_cpp}" "${loader_moc}" PARENT_SCOPE) - - # can't assume target has AUTOMOC turned on - if(NOT Qt5Core_FOUND) - find_package(Qt5Core) - endif() - if(Qt5Core_FOUND) - qt5_generate_moc("${loader_cpp}" "${loader_moc}") - endif() + configure_file(${ECM_MODULE_DIR}/ECMQmLoader.cpp.in ECMQmLoader.cpp @ONLY) + set(${out_var} ${${out_var}} ${CMAKE_CURRENT_BINARY_DIR}/ECMQmLoader.cpp PARENT_SCOPE) endfunction() diff --git a/modules/ECMQmLoader.cpp.in b/modules/ECMQmLoader.cpp.in index fc667ba2..423d1c93 100644 --- a/modules/ECMQmLoader.cpp.in +++ b/modules/ECMQmLoader.cpp.in @@ -32,77 +32,41 @@ */ #include #include -#include #include -#include #include -namespace { +#include - bool loadTranslation(const QString &localeDirName) - { - QString subPath = QStringLiteral("locale/") + localeDirName + QStringLiteral("/LC_MESSAGES/@catalog_name@.qm"); - QString fullPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, subPath); - if (fullPath.isEmpty()) { - return false; - } - QTranslator *translator = new QTranslator(QCoreApplication::instance()); - if (!translator->load(fullPath)) { - delete translator; - return false; - } - QCoreApplication::instance()->installTranslator(translator); - return true; +static bool loadTranslation(const QString &localeDirName) +{ + QString subPath = QStringLiteral("locale/") + localeDirName + QStringLiteral("/LC_MESSAGES/@catalog_name@.qm"); + QString fullPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, subPath); + if (fullPath.isEmpty()) { + return false; } - - void load() - { - // The way Qt translation system handles plural forms makes it necessary to - // have a translation file which contains only plural forms for `en`. That's - // why we load the `en` translation unconditionally, then load the - // translation for the current locale to overload it. - loadTranslation(QStringLiteral("en")); - - QLocale locale = QLocale::system(); - if (locale.name() != QStringLiteral("en")) { - if (!loadTranslation(locale.name())) { - loadTranslation(locale.bcp47Name()); - } - } + QTranslator *translator = new QTranslator(QCoreApplication::instance()); + if (!translator->load(fullPath)) { + delete translator; + return false; } + QCoreApplication::instance()->installTranslator(translator); + return true; +} - // helper to call load() on the correct thread - class Loader : public QObject - { - Q_OBJECT - - public Q_SLOTS: - void callLoadAndDeleteSelf() - { - load(); - this->deleteLater(); - } - }; +static void load() +{ + // The way Qt translation system handles plural forms makes it necessary to + // have a translation file which contains only plural forms for `en`. That's + // why we load the `en` translation unconditionally, then load the + // translation for the current locale to overload it. + loadTranslation(QStringLiteral("en")); - void loadOnMainThread() - { - // If this library is loaded after the QCoreApplication instance is created - // (eg: because it is brought in by a plugin), there is no guarantee this - // function will be called on the main thread. - // QCoreApplication::installTranslator needs to be called on the main - // thread, because it uses QCoreApplication::sendEvent. - if (QThread::currentThread() == QCoreApplication::instance()->thread()) { - load(); - } else { - // QObjects inherit their parent object's thread - Loader *loader = new Loader(); - loader->moveToThread(QCoreApplication::instance()->thread()); - QMetaObject::invokeMethod(loader, "callLoadAndDeleteSelf", Qt::AutoConnection); + QLocale locale = QLocale::system(); + if (locale.name() != QStringLiteral("en")) { + if (!loadTranslation(locale.name())) { + loadTranslation(locale.bcp47Name()); } } - } -Q_COREAPP_STARTUP_FUNCTION(loadOnMainThread) - -#include "ECMQmLoader.moc" +Q_COREAPP_STARTUP_FUNCTION(load) -- cgit v1.2.1