From d47ef4776d349110988477ea1836d98a9e393755 Mon Sep 17 00:00:00 2001 From: Christoph Cullmann Date: Wed, 7 Jan 2015 20:16:23 +0100 Subject: fix typo that lead to nearly empty KDE_INSTALL_TARGETS_DEFAULT_ARGS var on mac --- kde-modules/KDEInstallDirs.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kde-modules/KDEInstallDirs.cmake b/kde-modules/KDEInstallDirs.cmake index 8bec5402..7d592afc 100644 --- a/kde-modules/KDEInstallDirs.cmake +++ b/kde-modules/KDEInstallDirs.cmake @@ -587,7 +587,7 @@ set(KF5_INSTALL_TARGETS_DEFAULT_ARGS RUNTIME DESTINATION "${CMAKE_INSTALL_BINDI # on the Mac support an extra install directory for application bundles if(APPLE) - set(KDE_INSTALL_TARGETS_DEFAULT_ARGS ${INSTALL_TARGETS_DEFAULT_ARGS} + set(KDE_INSTALL_TARGETS_DEFAULT_ARGS ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} BUNDLE DESTINATION "${BUNDLE_INSTALL_DIR}" ) set(KF5_INSTALL_TARGETS_DEFAULT_ARGS ${KF5_INSTALL_TARGETS_DEFAULT_ARGS} BUNDLE DESTINATION "${BUNDLE_INSTALL_DIR}" ) -- cgit v1.2.1 From ca6d601ac04f8ef5813f6b02015a37622d68ef6c Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Thu, 8 Jan 2015 22:39:14 +0000 Subject: Upgrade ECM version to 1.7.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c8e5f56..b230bb28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(extra-cmake-modules NONE) set(ECM_MAJOR_VERSION 1) -set(ECM_MINOR_VERSION 6) +set(ECM_MINOR_VERSION 7) set(ECM_PATCH_VERSION 0) set(ECM_VERSION ${ECM_MAJOR_VERSION}.${ECM_MINOR_VERSION}.${ECM_PATCH_VERSION}) -- cgit v1.2.1 From 4462e9ddedb78c31a6f1089d073b1bfde6ce60ce Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 11 Jan 2015 10:57:17 +0000 Subject: Do not unset cache variables in KDEInstallDirs. Cache variables such as CMAKE_INSTALL_BINDIR may be used by other modules included from parallel parts of the tree, so we should not touch them. We still override them in the runtime environment, but this will not interfere with parallel subtrees of the project. As part of this, the order of precedence of variables specified on the command line is changed, so that KDE_INSTALL_* is considered first (although it is still considered "undefined" in the documentation). This means that if you only specify CMAKE_INSTALL_BINDIR, that will be used by both KDEInstallDirs and GNUInstallDirs, but if you specify both that and KDE_INSTALL_BINDIR, KDEInstallDirs will use KDE_INSTALL_BINDIR instead. This is probably not too useful, but seems more useful than any other arrangement. BUG: 342717 REVIEW: 121982 --- kde-modules/KDEInstallDirs.cmake | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/kde-modules/KDEInstallDirs.cmake b/kde-modules/KDEInstallDirs.cmake index 7d592afc..72a67641 100644 --- a/kde-modules/KDEInstallDirs.cmake +++ b/kde-modules/KDEInstallDirs.cmake @@ -163,7 +163,7 @@ # ``${PROJECT_NAME}`` to provide a sensible default for this CMake option. #============================================================================= -# Copyright 2014 Alex Merry +# Copyright 2014-2015 Alex Merry # Copyright 2013 Stephen Kelly # Copyright 2012 David Faure # Copyright 2007 Matthias Kretz @@ -280,7 +280,18 @@ macro(_define_relative varname parent subdir docstring) set(_realpath "${_subdir}") endif() - if(${_oldstylename}) + if(KDE_INSTALL_${varname}) + # make sure the cache documentation is set correctly + get_property(_iscached CACHE KDE_INSTALL_${varname} PROPERTY VALUE SET) + if (_iscached) + # make sure the docs are still set if it was passed on the command line + set_property(CACHE KDE_INSTALL_${varname} + PROPERTY HELPSTRING "${docstring} (${_docpath})") + # make sure the type is correct if it was passed on the command line + set_property(CACHE KDE_INSTALL_${varname} + PROPERTY TYPE PATH) + endif() + elseif(${_oldstylename}) if(NOT CMAKE_VERSION VERSION_LESS 3.0.0) message(DEPRECATION "${_oldstylename} is deprecated, use KDE_INSTALL_${varname} instead.") endif() @@ -290,10 +301,6 @@ macro(_define_relative varname parent subdir docstring) CACHE PATH "${docstring} (${_docpath})" FORCE) - unset(${_oldstylename} CACHE) - if(_cmakename AND ${_cmakename}) - unset(${_cmakename} CACHE) - endif() elseif(${_cmakename}) if(_cmakename_is_deprecated AND NOT CMAKE_VERSION VERSION_LESS 3.0.0) message(DEPRECATION "${_cmakename} is deprecated, use KDE_INSTALL_${varname} instead.") @@ -304,21 +311,12 @@ macro(_define_relative varname parent subdir docstring) CACHE PATH "${docstring} (${_docpath})" FORCE) - unset(${_cmakename} CACHE) - elseif(NOT KDE_INSTALL_${varname}) + else() + # insert an empty value into the cache, indicating the default + # should be used (including compatibility vars above) set(KDE_INSTALL_${varname} "" CACHE PATH "${docstring} (${_docpath})") set(KDE_INSTALL_${varname} "${_realpath}") - else() - get_property(_iscached CACHE KDE_INSTALL_${varname} PROPERTY VALUE SET) - if (_iscached) - # make sure the docs are still set if it was passed on the command line - set_property(CACHE KDE_INSTALL_${varname} - PROPERTY HELPSTRING "${docstring} (${_docpath})") - # make sure the type is correct if it was passed on the command line - set_property(CACHE KDE_INSTALL_${varname} - PROPERTY TYPE PATH) - endif() endif() mark_as_advanced(KDE_INSTALL_${varname}) @@ -330,6 +328,10 @@ macro(_define_relative varname parent subdir docstring) set(KDE_INSTALL_FULL_${varname} "${KDE_INSTALL_${varname}}") endif() + # Override compatibility vars at runtime, even though we don't touch + # them in the cache; this way, we keep the variables in sync where + # KDEInstallDirs is included, but don't interfere with, say, + # GNUInstallDirs in a parallel part of the CMake tree. if(_cmakename) set(${_cmakename} "${KDE_INSTALL_${varname}}") set(CMAKE_INSTALL_FULL_${varname} "${KDE_INSTALL_FULL_${varname}}") -- cgit v1.2.1 From 8b24ae53823a516144d15a10abcee644c4b15354 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Tue, 13 Jan 2015 19:04:55 +0000 Subject: Stop lying in the KDEInstallDirs documentation. --- kde-modules/KDEInstallDirs.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kde-modules/KDEInstallDirs.cmake b/kde-modules/KDEInstallDirs.cmake index 72a67641..6e1ef774 100644 --- a/kde-modules/KDEInstallDirs.cmake +++ b/kde-modules/KDEInstallDirs.cmake @@ -132,7 +132,8 @@ # ``KDE_INSTALL_DIRS_NO_DEPRECATED`` is set to TRUE, only those variables # defined by the ``GNUInstallDirs`` module (shipped with CMake) are defined. # If ``KDE_INSTALL_DIRS_NO_CMAKE_VARIABLES`` is set to TRUE, no variables with -# a ``CMAKE_`` prefix will be defined by this module. +# a ``CMAKE_`` prefix will be defined by this module (other than +# CMAKE_INSTALL_DEFAULT_COMPONENT_NAME - see below). # # The ``KDE_INSTALL_`` variables (or their ``CMAKE_INSTALL_`` or # deprecated counterparts) may be passed to the DESTINATION options of -- cgit v1.2.1 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(-) 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. --- docs/find-module/FindPng2Ico.rst | 1 + docs/module/ECMAddAppIcon.rst | 1 + find-modules/FindPng2Ico.cmake | 115 ++++++++++++++++++++ modules/ECMAddAppIcon.cmake | 227 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 344 insertions(+) create mode 100644 docs/find-module/FindPng2Ico.rst create mode 100644 docs/module/ECMAddAppIcon.rst create mode 100644 find-modules/FindPng2Ico.cmake create mode 100644 modules/ECMAddAppIcon.cmake diff --git a/docs/find-module/FindPng2Ico.rst b/docs/find-module/FindPng2Ico.rst new file mode 100644 index 00000000..db8aa775 --- /dev/null +++ b/docs/find-module/FindPng2Ico.rst @@ -0,0 +1 @@ +.. ecm-module:: ../../find-modules/FindPng2Ico.cmake diff --git a/docs/module/ECMAddAppIcon.rst b/docs/module/ECMAddAppIcon.rst new file mode 100644 index 00000000..31c09a88 --- /dev/null +++ b/docs/module/ECMAddAppIcon.rst @@ -0,0 +1 @@ +.. ecm-module:: ../../modules/ECMAddAppIcon.cmake diff --git a/find-modules/FindPng2Ico.cmake b/find-modules/FindPng2Ico.cmake new file mode 100644 index 00000000..71e2487c --- /dev/null +++ b/find-modules/FindPng2Ico.cmake @@ -0,0 +1,115 @@ +#.rst: +# FindPng2Ico +# ----------- +# +# Try to find png2ico. +# +# If the png2ico executable is not in your PATH, you can provide +# an alternative name or full path location with the ``Png2Ico_EXECUTABLE`` +# variable. +# +# This will define the following variables: +# +# ``Png2Ico_FOUND`` +# True if png2ico is available. +# +# ``Png2Ico_EXECUTABLE`` +# The png2ico executable. +# +# If ``Png2Ico_FOUND`` is TRUE, it will also define the following imported +# target: +# +# ``Png2Ico::Png2Ico`` +# The png2ico executable. +# +# and the following variables: +# +# ``Png2Ico_HAS_COLORS_ARGUMENT`` +# Whether png2ico accepts a ``--colors`` argument. `Matthias Benkmann's +# tool `_ does, while the +# version of png2ico from the `"KDE On Windows" (kdewin) +# `_ project does not. +# +# ``Png2Ico_HAS_RCFILE_ARGUMENT`` +# Whether png2ico accepts an ``--rcfile`` argument. The version of png2ico +# from the `"KDE On Windows" (kdewin) +# `_ project does, +# while `Matthias Benkmann's tool +# `_ does not. +# + +#============================================================================= +# Copyright 2014 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(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) + +ecm_find_package_version_check(Png2Ico) + +# Find png2ico +find_program(Png2Ico_EXECUTABLE NAMES png2ico) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Png2Ico + FOUND_VAR + Png2Ico_FOUND + REQUIRED_VARS + Png2Ico_EXECUTABLE +) + +mark_as_advanced(Png2Ico_EXECUTABLE) + +if (Png2Ico_FOUND) + execute_process( + COMMAND "${Png2Ico_EXECUTABLE}" --help + OUTPUT_VARIABLE _png2ico_help_text + ) + if (_png2ico_help_text MATCHES ".*--rcfile .*") + set(Png2Ico_HAS_RCFILE_ARGUMENT TRUE) + else() + set(Png2Ico_HAS_RCFILE_ARGUMENT FALSE) + endif() + if (_png2ico_help_text MATCHES ".*--colors .*") + set(Png2Ico_HAS_COLORS_ARGUMENT TRUE) + else() + set(Png2Ico_HAS_COLORS_ARGUMENT FALSE) + endif() + unset(_png2ico_help_text) + + if (NOT TARGET Png2Ico::Png2Ico) + add_executable(Png2Ico::Png2Ico IMPORTED) + set_target_properties(Png2Ico::Png2Ico PROPERTIES + IMPORTED_LOCATION "${Png2Ico_EXECUTABLE}" + ) + endif() +endif() + +include(FeatureSummary) +set_package_properties(Png2Ico PROPERTIES + URL "http://www.winterdrache.de/freeware/png2ico/ or https://projects.kde.org/projects/kdesupport/kdewin" + DESCRIPTION "Executable that converts a collection of PNG files into a Windows icon file" +) + 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 ++++++- tests/ECMSetupVersionTest/CMakeLists.txt | 1 + .../old_version_file_prereleases/CMakeLists.txt | 189 +++++++++++++++++++++ .../old_version_file_prereleases/main.c | 4 + tests/test_helpers.cmake | 4 +- 6 files changed, 320 insertions(+), 8 deletions(-) create mode 100644 modules/BasicConfigVersion-SameMajorVersionWithPrereleases.cmake.in create mode 100644 tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt create mode 100644 tests/ECMSetupVersionTest/old_version_file_prereleases/main.c 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) diff --git a/tests/ECMSetupVersionTest/CMakeLists.txt b/tests/ECMSetupVersionTest/CMakeLists.txt index b0845e57..c15af921 100644 --- a/tests/ECMSetupVersionTest/CMakeLists.txt +++ b/tests/ECMSetupVersionTest/CMakeLists.txt @@ -19,6 +19,7 @@ add_version_test(old_version_file dummy) add_version_test(old_version_file_abspath dummy) add_version_test(old_version_file_anynewer dummy) add_version_test(old_version_file_exact dummy) +add_version_test(old_version_file_prereleases dummy) add_version_test(old_version_file_samemajor dummy) add_version_test(old_header check_header) add_version_test(old_header_abspath check_header) diff --git a/tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt b/tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt new file mode 100644 index 00000000..e498fce6 --- /dev/null +++ b/tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt @@ -0,0 +1,189 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(old_version_file_prereleases) + +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules) +include(ECMSetupVersion) + +ecm_setup_version(2.3.4 + VARIABLE_PREFIX Foo + PACKAGE_VERSION_FILE FooVersion.cmake + COMPATIBILITY SameMajorVersionWithPrereleases + FIRST_PRERELEASE_VERSION 90 +) + +include(../../test_helpers.cmake) +include(../version_helpers.cmake) + +macro(find_foo version) + test_version_file("${CMAKE_CURRENT_BINARY_DIR}/FooVersion.cmake" "${version}") + assert_var_str_value(PACKAGE_VERSION "2.3.4") +endmacro() + +standard_version_var_checks(Foo 2.3.4) + +# too old - fails +find_foo("3.1.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("1.1.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# prerelease for wrong major version - fails +find_foo("2.90.0") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# prerelease for correct major version - succeeds +find_foo("1.90") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# prerelease for correct major version - succeeds +find_foo("1.90.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# prerelease for correct major version - succeeds +find_foo("1.95.0") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# correct major version, more recent - succeeds +find_foo("2.1.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# correct major version - succeeds +find_foo("2") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# correct major version, but too old - fails +find_foo("2.4.4") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# exact - succeeds +find_foo("2.3.4") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT TRUE) + + + + +ecm_setup_version(2.90.0 + VARIABLE_PREFIX Foo3Prerelease + PACKAGE_VERSION_FILE Foo3PrereleaseVersion.cmake + COMPATIBILITY SameMajorVersionWithPrereleases + FIRST_PRERELEASE_VERSION 90 +) + +macro(find_foo version) + test_version_file("${CMAKE_CURRENT_BINARY_DIR}/Foo3PrereleaseVersion.cmake" "${version}") + assert_var_str_value(PACKAGE_VERSION "2.90.0") +endmacro() + +standard_version_var_checks(Foo3Prerelease 2.90.0) + +# too old - fails +find_foo("3.1.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# too old - fails +find_foo("2.90.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("2") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# correct major version, but don't want a prerelease - fails +find_foo("3") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("2.89.9") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# exact version - succeeds +find_foo("2.90.0") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT TRUE) + + + + +ecm_setup_version(2.93.4 + VARIABLE_PREFIX Foo3Prerelease2 + PACKAGE_VERSION_FILE Foo3Prerelease2Version.cmake + COMPATIBILITY SameMajorVersionWithPrereleases + FIRST_PRERELEASE_VERSION 90 +) + +macro(find_foo version) + test_version_file("${CMAKE_CURRENT_BINARY_DIR}/Foo3Prerelease2Version.cmake" "${version}") + assert_var_str_value(PACKAGE_VERSION "2.93.4") +endmacro() + +standard_version_var_checks(Foo3Prerelease2 2.93.4) + +# too old - fails +find_foo("3.1.1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# too old - fails +find_foo("2.94.0") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("1") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("2") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# correct major version, but don't want a prerelease - fails +find_foo("3") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# wrong major version - fails +find_foo("2.89.9") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# correct major version - succeeds +find_foo("2.90.0") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) + +# exact version - succeeds +find_foo("2.93.4") +assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) +assert_var_bool_value(PACKAGE_VERSION_EXACT TRUE) + +add_executable(dummy main.c) diff --git a/tests/ECMSetupVersionTest/old_version_file_prereleases/main.c b/tests/ECMSetupVersionTest/old_version_file_prereleases/main.c new file mode 100644 index 00000000..c13815ce --- /dev/null +++ b/tests/ECMSetupVersionTest/old_version_file_prereleases/main.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/tests/test_helpers.cmake b/tests/test_helpers.cmake index 73be343e..236a1868 100644 --- a/tests/test_helpers.cmake +++ b/tests/test_helpers.cmake @@ -38,9 +38,9 @@ macro(assert_var_bool_value varname value) assert_var_defined(${varname}) endif() if(${value} AND NOT ${varname}) - message(FATAL_ERROR "${varname} was FALSE") + message(SEND_ERROR "${varname} was FALSE") elseif(${varname} AND NOT ${value}) - message(FATAL_ERROR "${varname} was TRUE") + message(SEND_ERROR "${varname} was TRUE") endif() endmacro() -- 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 +------ tests/ECMSetupVersionTest/CMakeLists.txt | 1 - .../old_version_file_prereleases/CMakeLists.txt | 189 --------------------- .../old_version_file_prereleases/main.c | 4 - tests/test_helpers.cmake | 4 +- 6 files changed, 8 insertions(+), 320 deletions(-) delete mode 100644 modules/BasicConfigVersion-SameMajorVersionWithPrereleases.cmake.in delete mode 100644 tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt delete mode 100644 tests/ECMSetupVersionTest/old_version_file_prereleases/main.c 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) diff --git a/tests/ECMSetupVersionTest/CMakeLists.txt b/tests/ECMSetupVersionTest/CMakeLists.txt index c15af921..b0845e57 100644 --- a/tests/ECMSetupVersionTest/CMakeLists.txt +++ b/tests/ECMSetupVersionTest/CMakeLists.txt @@ -19,7 +19,6 @@ add_version_test(old_version_file dummy) add_version_test(old_version_file_abspath dummy) add_version_test(old_version_file_anynewer dummy) add_version_test(old_version_file_exact dummy) -add_version_test(old_version_file_prereleases dummy) add_version_test(old_version_file_samemajor dummy) add_version_test(old_header check_header) add_version_test(old_header_abspath check_header) diff --git a/tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt b/tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt deleted file mode 100644 index e498fce6..00000000 --- a/tests/ECMSetupVersionTest/old_version_file_prereleases/CMakeLists.txt +++ /dev/null @@ -1,189 +0,0 @@ -cmake_minimum_required(VERSION 2.8.12) - -project(old_version_file_prereleases) - -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules) -include(ECMSetupVersion) - -ecm_setup_version(2.3.4 - VARIABLE_PREFIX Foo - PACKAGE_VERSION_FILE FooVersion.cmake - COMPATIBILITY SameMajorVersionWithPrereleases - FIRST_PRERELEASE_VERSION 90 -) - -include(../../test_helpers.cmake) -include(../version_helpers.cmake) - -macro(find_foo version) - test_version_file("${CMAKE_CURRENT_BINARY_DIR}/FooVersion.cmake" "${version}") - assert_var_str_value(PACKAGE_VERSION "2.3.4") -endmacro() - -standard_version_var_checks(Foo 2.3.4) - -# too old - fails -find_foo("3.1.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("1.1.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# prerelease for wrong major version - fails -find_foo("2.90.0") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# prerelease for correct major version - succeeds -find_foo("1.90") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# prerelease for correct major version - succeeds -find_foo("1.90.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# prerelease for correct major version - succeeds -find_foo("1.95.0") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# correct major version, more recent - succeeds -find_foo("2.1.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# correct major version - succeeds -find_foo("2") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# correct major version, but too old - fails -find_foo("2.4.4") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# exact - succeeds -find_foo("2.3.4") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT TRUE) - - - - -ecm_setup_version(2.90.0 - VARIABLE_PREFIX Foo3Prerelease - PACKAGE_VERSION_FILE Foo3PrereleaseVersion.cmake - COMPATIBILITY SameMajorVersionWithPrereleases - FIRST_PRERELEASE_VERSION 90 -) - -macro(find_foo version) - test_version_file("${CMAKE_CURRENT_BINARY_DIR}/Foo3PrereleaseVersion.cmake" "${version}") - assert_var_str_value(PACKAGE_VERSION "2.90.0") -endmacro() - -standard_version_var_checks(Foo3Prerelease 2.90.0) - -# too old - fails -find_foo("3.1.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# too old - fails -find_foo("2.90.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("2") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# correct major version, but don't want a prerelease - fails -find_foo("3") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("2.89.9") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# exact version - succeeds -find_foo("2.90.0") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT TRUE) - - - - -ecm_setup_version(2.93.4 - VARIABLE_PREFIX Foo3Prerelease2 - PACKAGE_VERSION_FILE Foo3Prerelease2Version.cmake - COMPATIBILITY SameMajorVersionWithPrereleases - FIRST_PRERELEASE_VERSION 90 -) - -macro(find_foo version) - test_version_file("${CMAKE_CURRENT_BINARY_DIR}/Foo3Prerelease2Version.cmake" "${version}") - assert_var_str_value(PACKAGE_VERSION "2.93.4") -endmacro() - -standard_version_var_checks(Foo3Prerelease2 2.93.4) - -# too old - fails -find_foo("3.1.1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# too old - fails -find_foo("2.94.0") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("1") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("2") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# correct major version, but don't want a prerelease - fails -find_foo("3") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# wrong major version - fails -find_foo("2.89.9") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE FALSE ALLOW_UNDEFINED) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# correct major version - succeeds -find_foo("2.90.0") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT FALSE ALLOW_UNDEFINED) - -# exact version - succeeds -find_foo("2.93.4") -assert_var_bool_value(PACKAGE_VERSION_COMPATIBLE TRUE) -assert_var_bool_value(PACKAGE_VERSION_EXACT TRUE) - -add_executable(dummy main.c) diff --git a/tests/ECMSetupVersionTest/old_version_file_prereleases/main.c b/tests/ECMSetupVersionTest/old_version_file_prereleases/main.c deleted file mode 100644 index c13815ce..00000000 --- a/tests/ECMSetupVersionTest/old_version_file_prereleases/main.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() -{ - return 0; -} diff --git a/tests/test_helpers.cmake b/tests/test_helpers.cmake index 236a1868..73be343e 100644 --- a/tests/test_helpers.cmake +++ b/tests/test_helpers.cmake @@ -38,9 +38,9 @@ macro(assert_var_bool_value varname value) assert_var_defined(${varname}) endif() if(${value} AND NOT ${varname}) - message(SEND_ERROR "${varname} was FALSE") + message(FATAL_ERROR "${varname} was FALSE") elseif(${varname} AND NOT ${value}) - message(SEND_ERROR "${varname} was TRUE") + message(FATAL_ERROR "${varname} was TRUE") endif() endmacro() -- cgit v1.2.1 From cc30b9b9b16f0999dfb97b2e78488abd2c41de43 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 11 Jan 2015 18:40:54 +0000 Subject: Warn when mixing relative and absolute paths in KDEInstallDirs. BUG: 341683 FIXED-IN: 1.7.0 REVIEW: 121999 CHANGELOG: KDEInstallDirs: warn about mixing relative and absolute installation paths on the command line --- kde-modules/KDEInstallDirs.cmake | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/kde-modules/KDEInstallDirs.cmake b/kde-modules/KDEInstallDirs.cmake index 6e1ef774..a690ae9c 100644 --- a/kde-modules/KDEInstallDirs.cmake +++ b/kde-modules/KDEInstallDirs.cmake @@ -162,6 +162,13 @@ # # Additionally, ``CMAKE_INSTALL_DEFAULT_COMPONENT_NAME`` will be set to # ``${PROJECT_NAME}`` to provide a sensible default for this CMake option. +# +# Note that mixing absolute and relative paths, particularly for ``BINDIR``, +# ``LIBDIR`` and ``INCLUDEDIR``, can cause issues with exported targets. Given +# that the default values for these are relative paths, relative paths should +# be used on the command line when possible (eg: use +# ``-DKDE_INSTALL_LIBDIR=lib64`` instead of +# ``-DKDE_INSTALL_LIBDIR=/usr/lib/lib64`` to override the library directory). #============================================================================= # Copyright 2014-2015 Alex Merry @@ -565,6 +572,19 @@ _define_relative(AUTOSTARTDIR CONFDIR "autostart" "autostart files" AUTOSTART_INSTALL_DIR) +set(_mixed_core_path_styles FALSE) +if (IS_ABSOLUTE "${KDE_INSTALL_BINDIR}") + if (NOT IS_ABSOLUTE "${KDE_INSTALL_LIBDIR}" OR NOT IS_ABSOLUTE "${KDE_INSTALL_INCLUDEDIR}") + set(_mixed_core_path_styles ) + endif() +else() + if (IS_ABSOLUTE "${KDE_INSTALL_LIBDIR}" OR IS_ABSOLUTE "${KDE_INSTALL_INCLUDEDIR}") + set(_mixed_core_path_styles TRUE) + endif() +endif() +if (_mixed_core_path_styles) + message(WARNING "KDE_INSTALL_BINDIR, KDE_INSTALL_LIBDIR and KDE_INSTALL_INCLUDEDIR should either all be absolute paths or all be relative paths.") +endif() # For more documentation see above. -- 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. --- find-modules/FindLibGit2.cmake | 2 +- modules/ECMCoverageOption.cmake | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/find-modules/FindLibGit2.cmake b/find-modules/FindLibGit2.cmake index 3bb87c29..fd6f46ca 100644 --- a/find-modules/FindLibGit2.cmake +++ b/find-modules/FindLibGit2.cmake @@ -1,6 +1,6 @@ #.rst: # FindLibGit2 -# ------- +# ----------- # # Try to find libgit2 on a Unix system. # 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 --- docs/module/ECMUninstallTarget.rst | 1 + modules/ECMUninstallTarget.cmake | 56 ++++++++++++++++++++++++++++++++++++++ modules/ecm_uninstall.cmake.in | 21 ++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 docs/module/ECMUninstallTarget.rst create mode 100644 modules/ECMUninstallTarget.cmake create mode 100644 modules/ecm_uninstall.cmake.in diff --git a/docs/module/ECMUninstallTarget.rst b/docs/module/ECMUninstallTarget.rst new file mode 100644 index 00000000..a1895158 --- /dev/null +++ b/docs/module/ECMUninstallTarget.rst @@ -0,0 +1 @@ +.. ecm-module:: ../../modules/ECMUninstallTarget.cmake 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 b03e287f9abe95372b0bc1b1917a006447280c95 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 1 Feb 2015 12:02:39 +0000 Subject: Create an uninstall target by default in KDE projects. REVIEW: 122359 --- kde-modules/KDECMakeSettings.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kde-modules/KDECMakeSettings.cmake b/kde-modules/KDECMakeSettings.cmake index 4ccbf82e..000761fb 100644 --- a/kde-modules/KDECMakeSettings.cmake +++ b/kde-modules/KDECMakeSettings.cmake @@ -41,6 +41,10 @@ # # This section can be disabled by setting ``KDE_SKIP_BUILD_SETTINGS`` to TRUE # before including this module. +# +# This section also provides an "uninstall" target that can be individually +# disabled by setting ``KDE_SKIP_UNINSTALL_TARGET`` to TRUE before including +# this module. #============================================================================= # Copyright 2014 Alex Merry @@ -177,5 +181,10 @@ if(NOT KDE_SKIP_BUILD_SETTINGS) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") endif() + option(KDE_SKIP_UNINSTALL_TARGET "Prevent an \"uninstall\" target from being generated." OFF) + if(NOT KDE_SKIP_UNINSTALL_TARGET) + include("${ECM_MODULE_DIR}/ECMUninstallTarget.cmake") + endif() + endif() ################################################################### -- cgit v1.2.1 From 5b39c909baeb3e4c247a43b91a884d5990c99092 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Fri, 6 Feb 2015 01:24:23 +0100 Subject: Move Android toolchain module to ECM Introduces the new Android toolchain file for being able to easily compile our cmake projects in Android, with an emphasis on Qt projects. CHANGELOG: New Android toolchain support module. REVIEW: 121545 --- CMakeLists.txt | 4 + toolchain/Android.cmake | 183 ++++++++++++++++++++++++++++++++++++++ toolchain/deployment-file.json.in | 15 ++++ 3 files changed, 202 insertions(+) create mode 100644 toolchain/Android.cmake create mode 100644 toolchain/deployment-file.json.in diff --git a/CMakeLists.txt b/CMakeLists.txt index b230bb28..6bccfbc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ if(BUILD_TESTING) endif() set(SHARE_INSTALL_DIR share) +set(TOOLCHAIN_MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/toolchain/) set(MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/modules/) set(KDE_MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/kde-modules/) set(FIND_MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/find-modules/) @@ -33,6 +34,9 @@ install(FILES ${installKdeModuleFiles} DESTINATION ${KDE_MODULES_INSTALL_DIR}) file(GLOB installFindModuleFiles ${CMAKE_SOURCE_DIR}/find-modules/*[^~]) install(FILES ${installFindModuleFiles} DESTINATION ${FIND_MODULES_INSTALL_DIR}) +file(GLOB installToolchainModuleFiles ${CMAKE_SOURCE_DIR}/toolchain/*[^~]) +install(FILES ${installToolchainModuleFiles} DESTINATION ${TOOLCHAIN_MODULES_INSTALL_DIR}) + include(CMakePackageConfigHelpers) diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake new file mode 100644 index 00000000..8272ef9d --- /dev/null +++ b/toolchain/Android.cmake @@ -0,0 +1,183 @@ +#.rst: +# AndroidToolchain +# ------------------- +# +# Enable easy compilation of cmake projects on Android +# +# By using this android toolchain, the projects will be set up to compile the +# specified project targeting an Android platform, depending on its input. +# Furthermore, if desired, an APK can be directly generated by using the +# androiddeployqt tool. +# +# Note: Requires CMake 3.1 +# +# How to use it? +# -------------- +# First of all, to make use of this toolchain file it's required to specify the +# CMAKE_TOOLCHAIN_FILE variable pointing to AndroidToolchain.cmake. +# +# Then, there's many settings that we may want to specify under what circumstances +# the project will be built. This will be done through environment variables: +# - ANDROID_NDK: points to the NDK root path +# - ANDROID_SDK_ROOT: points to the SDK root path +# +# Also there's some cache variables we can pass as well to narrow down the +# preferred settings: +# - ANDROID_NDK: Points to the NDK root, defaults to the environment variable +# with the same name. +# - ANDROID_SDK_ROOT: Points to the Android SDK root, defaults to the environment +# variable with the same name. +# - ANDROID_ARCHITECTURE: Specifies the used architecture, "arm" by default. See +# arch-* directory. +# - ANDROID_TOOLCHAIN: Specifies the toolchain to be used. Defaults to +# "arm-linux-androideabi". See /toolchains/ directory. +# - ANDROID_ABI: Specifies the ABI to be used. Defaults to "armeabi-v7a". See +# /sources/cxx-stl/gnu-libstdc++/*/libs/ directories. +# - ANDROID_GCC_VERSION: Specifies the GCC version. Defaults to "4.9". +# - ANDROID_API_LEVEL: Specifies the API level to require. Defaults to "14". See +# http://developer.android.com/guide/topics/manifest/uses-sdk-element.html +# - ANDROID_SDK_BUILD_TOOLS_REVISION: Specifies the build tools version to be used. +# Defaults to "21.1.1". +# +# Once we have the application built, we will want to generate an APK that we +# can run on an Android device. To this end we've integrated androiddeployqt so +# this can be done easily. This won't work with non-qt projects. +# To make use of the APK generation, we'll define QTANDROID_EXPORTED_TARGET with +# the target we want to have exported. +# Additionally, we'll need to specify a ANDROID_APK_DIR with the base information +# to set the project up. For more information see: +# https://qt-project.org/doc/qt-5-snapshot/deployment-android.html +# +# Once set up, after building, make create-apk- will process this +# input and generate an apk that can be found inside the build directory: +# ${CMAKE_BINARY_DIR}/_build_apk/bin/QtApp-*.apk. +# +# ============================================================================= +# Copyright 2014 Aleix Pol i Gonzalez +# +# 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.) + +cmake_minimum_required(VERSION "3.1") + +#input +set(ANDROID_NDK "$ENV{ANDROID_NDK}" CACHE path "Android NDK path") +set(ANDROID_SDK_ROOT "$ENV{ANDROID_SDK_ROOT}" CACHE path "Android SDK path") +set(ANDROID_ARCHITECTURE "arm" CACHE string "Used Architecture, related to the ABI and TOOLCHAIN") +set(ANDROID_TOOLCHAIN "arm-linux-androideabi" CACHE string "Used SDK") +set(ANDROID_ABI "armeabi-v7a" CACHE string "Used ABI") +set(ANDROID_GCC_VERSION "4.9" CACHE string "Used GCC version" ) +set(ANDROID_API_LEVEL "14" CACHE string "Android API Level") +set(ANDROID_SDK_BUILD_TOOLS_REVISION "21.1.1" CACHE string "Android API Level") + +set(_HOST "${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR}") +string(TOLOWER "${_HOST}" _HOST) + +get_filename_component(_CMAKE_ANDROID_DIR "${CMAKE_TOOLCHAIN_FILE}" PATH) + +cmake_policy(SET CMP0011 OLD) +cmake_policy(SET CMP0017 OLD) + +set(CMAKE_SYSROOT + "${ANDROID_NDK}/platforms/android-${ANDROID_API_LEVEL}/arch-${ANDROID_ARCHITECTURE}") +if(NOT EXISTS ${CMAKE_SYSROOT}) + message(FATAL_ERROR "Couldn't find the Android NDK Root in ${CMAKE_SYSROOT}") +endif() + +#actual code +SET(CMAKE_SYSTEM_NAME Android) +SET(CMAKE_SYSTEM_VERSION 1) + +set(ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN}-${ANDROID_GCC_VERSION}/prebuilt/${_HOST}/bin") +set(ANDROID_LIBS_ROOT "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VERSION}") + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM "${ANDROID_TOOLCHAIN_ROOT}") +set(ANDROID_LIBRARIES_PATH + "${CMAKE_SYSROOT}/usr/lib") +set(CMAKE_SYSTEM_LIBRARY_PATH + ${ANDROID_LIBRARIES_PATH} + "${ANDROID_LIBS_ROOT}/libs/${ANDROID_ABI}/" +) +set(CMAKE_FIND_LIBRARY_SUFFIXES ".so") +set(CMAKE_FIND_LIBRARY_PREFIXES "lib") +find_library(GNUSTL_SHARED gnustl_shared) +if(NOT GNUSTL_SHARED) + message(FATAL_ERROR "you need gnustl_shared: ${CMAKE_SYSTEM_LIBRARY_PATH}") +endif() +include_directories(SYSTEM + "${CMAKE_SYSROOT}/usr/include" + "${ANDROID_LIBS_ROOT}/include/" + "${ANDROID_LIBS_ROOT}/libs/${ANDROID_ABI}/include" +) + +link_directories(${CMAKE_SYSTEM_LIBRARY_PATH}) + +set(CMAKE_C_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN}-gcc") +set(CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN}-g++") + +SET(CMAKE_FIND_ROOT_PATH ${ANDROID_NDK}) +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_EXE_LINKER_FLAGS "${GNUSTL_SHARED} -Wl,-rpath-link,${ANDROID_LIBRARIES_PATH} -llog -lz -lm -ldl -lc -lgcc" CACHE STRING "") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "") +set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "") + +#we want executables to be shared libraries, hooks will invoke the exported cmake function +set(CMAKE_CXX_LINK_EXECUTABLE + " -o " +) + +######### generation + +set(CREATEAPK_TARGET_NAME "create-apk-${QTANDROID_EXPORTED_TARGET}") +if(DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET ${CREATEAPK_TARGET_NAME}) + if(NOT EXISTS "${ANDROID_APK_DIR}/AndroidManifest.xml") + message(FATAL_ERROR "Define an apk dir to initialize from using -DANDROID_APK_DIR=. The specified directory must contain the AndroidManifest.xml file.") + endif() + + function(EOFHook) + if(CMAKE_PARENT_LIST_FILE STREQUAL "") + generate_deployment_file() + endif() + endfunction() + + function(generate_deployment_file) + get_property(_DEPENDENCIES TARGET ${QTANDROID_EXPORTED_TARGET} PROPERTY INTERFACE_LINK_LIBRARIES) + set(_DEPS_LIST) + foreach(_DEP IN LISTS _DEPENDENCIES) + if(NOT _DEP MATCHES "Qt5::.*") + get_property(_DEP_LOCATION TARGET ${_DEP} PROPERTY "LOCATION_${CMAKE_BUILD_TYPE}") + list(APPEND _DEPS_LIST ${_DEP_LOCATION}) + endif() + endforeach() + string(REPLACE ";" "," _DEPS "${_DEPS_LIST}") + configure_file("${_CMAKE_ANDROID_DIR}/deployment-file.json.in" "${QTANDROID_EXPORTED_TARGET}-deployment.json") + endfunction() + +# Create the target that will eventually generate the apk + get_filename_component(QTDIR "${Qt5Core_DIR}/../../../" ABSOLUTE) + find_program(ANDROID_DEPLOY_QT androiddeployqt HINTS "${QTDIR}/bin") + set(EXPORT_DIR "${CMAKE_BINARY_DIR}/${QTANDROID_EXPORTED_TARGET}_build_apk/") + set(EXECUTABLE_DESTINATION_PATH "${EXPORT_DIR}/libs/${ANDROID_ABI}/lib${QTANDROID_EXPORTED_TARGET}.so") + + add_custom_target(${CREATEAPK_TARGET_NAME} + COMMAND cmake -E echo "Generating $ with ${ANDROID_DEPLOY_QT}" + COMMAND cmake -E copy_directory "${ANDROID_APK_DIR}" "${EXPORT_DIR}" + COMMAND cmake -E copy "$" "${EXECUTABLE_DESTINATION_PATH}" + COMMAND ${ANDROID_DEPLOY_QT} --input "${QTANDROID_EXPORTED_TARGET}-deployment.json" --output "${EXPORT_DIR}" --deployment bundled "\\$(ARGS)" + ) + + #we want to call the function after the project has been set up + variable_watch(CMAKE_PARENT_LIST_FILE EOFHook) +else() + message(STATUS "You can export a target by specifying -DQTANDROID_EXPORTED_TARGET=") +endif() diff --git a/toolchain/deployment-file.json.in b/toolchain/deployment-file.json.in new file mode 100644 index 00000000..e662795a --- /dev/null +++ b/toolchain/deployment-file.json.in @@ -0,0 +1,15 @@ +{ + "qt": "@QTDIR@", + "sdk": "@ANDROID_SDK_ROOT@", + "ndk": "@ANDROID_NDK@", + "toolchain-prefix": "@ANDROID_TOOLCHAIN@", + "tool-prefix": "@ANDROID_TOOLCHAIN@", + "toolchain-version": "@ANDROID_GCC_VERSION@", + "ndk-host": "@_HOST@", + "target-architecture": "@ANDROID_ABI@", + "application-binary": "@EXECUTABLE_DESTINATION_PATH@", + "android-extra-libs": "@_DEPS@", + "android-extra-plugins": "@CMAKE_PREFIX_PATH@/share,@CMAKE_PREFIX_PATH@/lib/qml", + "android-package-source-directory": "@ANDROID_APK_DIR@", + "sdkBuildToolsRevision": "@ANDROID_SDK_BUILD_TOOLS_REVISION@" +} -- 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. --- find-modules/FindEGL.cmake | 2 ++ find-modules/FindKF5.cmake | 2 ++ find-modules/FindLibGit2.cmake | 2 ++ find-modules/FindOpenEXR.cmake | 2 ++ find-modules/FindPng2Ico.cmake | 1 + find-modules/FindQtWaylandScanner.cmake | 2 ++ find-modules/FindSharedMimeInfo.cmake | 2 ++ find-modules/FindWayland.cmake | 2 ++ find-modules/FindWaylandScanner.cmake | 2 ++ find-modules/FindX11_XCB.cmake | 2 ++ find-modules/FindXCB.cmake | 2 ++ kde-modules/KDECMakeSettings.cmake | 4 ++++ kde-modules/KDECompilerSettings.cmake | 2 ++ kde-modules/KDEFrameworkCompilerSettings.cmake | 2 ++ kde-modules/KDEInstallDirs.cmake | 5 +++++ 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 ++ 33 files changed, 70 insertions(+) diff --git a/find-modules/FindEGL.cmake b/find-modules/FindEGL.cmake index 99d268df..b96f3b0f 100644 --- a/find-modules/FindEGL.cmake +++ b/find-modules/FindEGL.cmake @@ -29,6 +29,8 @@ # In general we recommend using the imported target, as it is easier to use. # Bear in mind, however, that if the target is in the link interface of an # exported library, it must be made available by the package config file. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/find-modules/FindKF5.cmake b/find-modules/FindKF5.cmake index 2e1fca87..30b20948 100644 --- a/find-modules/FindKF5.cmake +++ b/find-modules/FindKF5.cmake @@ -16,6 +16,8 @@ # If all the required components (those given in the COMPONENTS argument, but # not those given in the OPTIONAL_COMPONENTS argument) are found, ``KF5_FOUND`` # will be set to true. Otherwise, it will be set to false. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/find-modules/FindLibGit2.cmake b/find-modules/FindLibGit2.cmake index fd6f46ca..22fc5ebb 100644 --- a/find-modules/FindLibGit2.cmake +++ b/find-modules/FindLibGit2.cmake @@ -28,6 +28,8 @@ # In general we recommend using the imported target, as it is easier to use. # Bear in mind, however, that if the target is in the link interface of an # exported library, it must be made available by the package config file. +# +# Since 1.3.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/find-modules/FindOpenEXR.cmake b/find-modules/FindOpenEXR.cmake index 85afebdf..b63b8cd0 100644 --- a/find-modules/FindOpenEXR.cmake +++ b/find-modules/FindOpenEXR.cmake @@ -23,6 +23,8 @@ # In general we recommend using the imported target, as it is easier to use. # Bear in mind, however, that if the target is in the link interface of an # exported library, it must be made available by the package config file. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2013-2014 Alex Merry diff --git a/find-modules/FindPng2Ico.cmake b/find-modules/FindPng2Ico.cmake index 71e2487c..7b201988 100644 --- a/find-modules/FindPng2Ico.cmake +++ b/find-modules/FindPng2Ico.cmake @@ -37,6 +37,7 @@ # while `Matthias Benkmann's tool # `_ does not. # +# Since 1.7.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/find-modules/FindQtWaylandScanner.cmake b/find-modules/FindQtWaylandScanner.cmake index 7fb8a009..28a4fda5 100644 --- a/find-modules/FindQtWaylandScanner.cmake +++ b/find-modules/FindQtWaylandScanner.cmake @@ -55,6 +55,8 @@ # names don't start with ``qt_`` or ``wl_``. # # WaylandScanner is required and will be searched for. +# +# Since 1.4.0. #============================================================================= # Copyright 2012-2014 Pier Luigi Fiorini diff --git a/find-modules/FindSharedMimeInfo.cmake b/find-modules/FindSharedMimeInfo.cmake index 263a5028..ebbe3284 100644 --- a/find-modules/FindSharedMimeInfo.cmake +++ b/find-modules/FindSharedMimeInfo.cmake @@ -23,6 +23,8 @@ # Updates the XDG mime database at install time (unless the ``$DESTDIR`` # environment variable is set, in which case it is up to package managers to # perform this task). +# +# Since pre-1.0.0. #============================================================================= # Copyright 2013-2014 Alex Merry diff --git a/find-modules/FindWayland.cmake b/find-modules/FindWayland.cmake index 490ab1be..f69fa18b 100644 --- a/find-modules/FindWayland.cmake +++ b/find-modules/FindWayland.cmake @@ -44,6 +44,8 @@ # and provide more control. Bear in mind, however, that if any target is in the # link interface of an exported library, it must be made available by the # package config file. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/find-modules/FindWaylandScanner.cmake b/find-modules/FindWaylandScanner.cmake index 33c46f9b..4052cdab 100644 --- a/find-modules/FindWaylandScanner.cmake +++ b/find-modules/FindWaylandScanner.cmake @@ -47,6 +47,8 @@ # Generate Wayland server protocol files from ```` XML # definition for the ```` interface and append those files # to ````. +# +# Since 1.4.0. #============================================================================= # Copyright 2012-2014 Pier Luigi Fiorini diff --git a/find-modules/FindX11_XCB.cmake b/find-modules/FindX11_XCB.cmake index eafa08e2..8b975e6a 100644 --- a/find-modules/FindX11_XCB.cmake +++ b/find-modules/FindX11_XCB.cmake @@ -30,6 +30,8 @@ # In general we recommend using the imported target, as it is easier to use. # Bear in mind, however, that if the target is in the link interface of an # exported library, it must be made available by the package config file. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/find-modules/FindXCB.cmake b/find-modules/FindXCB.cmake index 781b15c5..b2a800f7 100644 --- a/find-modules/FindXCB.cmake +++ b/find-modules/FindXCB.cmake @@ -51,6 +51,8 @@ # and provide more control. Bear in mind, however, that if any target is in the # link interface of an exported library, it must be made available by the # package config file. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2011 Fredrik Höglund diff --git a/kde-modules/KDECMakeSettings.cmake b/kde-modules/KDECMakeSettings.cmake index 000761fb..0c997931 100644 --- a/kde-modules/KDECMakeSettings.cmake +++ b/kde-modules/KDECMakeSettings.cmake @@ -45,6 +45,10 @@ # This section also provides an "uninstall" target that can be individually # disabled by setting ``KDE_SKIP_UNINSTALL_TARGET`` to TRUE before including # this module. +# +# Since pre-1.0.0. +# +# Uninstall target functionality since 1.7.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/kde-modules/KDECompilerSettings.cmake b/kde-modules/KDECompilerSettings.cmake index aa0249d9..5a585021 100644 --- a/kde-modules/KDECompilerSettings.cmake +++ b/kde-modules/KDECompilerSettings.cmake @@ -29,6 +29,8 @@ # # Enables exceptions for C++ source files compiled for the # CMakeLists.txt file in the current directory and all subdirectories. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2014 Alex Merry diff --git a/kde-modules/KDEFrameworkCompilerSettings.cmake b/kde-modules/KDEFrameworkCompilerSettings.cmake index 3b77fc3c..1bc23ccf 100644 --- a/kde-modules/KDEFrameworkCompilerSettings.cmake +++ b/kde-modules/KDEFrameworkCompilerSettings.cmake @@ -11,6 +11,8 @@ # For example, constructions like QString("foo") are prohibited, instead # forcing the use of QLatin1String or QStringLiteral, and some # Qt-defined keywords like signals and slots will not be defined. +# +# Since pre-1.0.0. #============================================================================= # Copyright 2013 Albert Astals Cid diff --git a/kde-modules/KDEInstallDirs.cmake b/kde-modules/KDEInstallDirs.cmake index a690ae9c..b7cd34d8 100644 --- a/kde-modules/KDEInstallDirs.cmake +++ b/kde-modules/KDEInstallDirs.cmake @@ -169,6 +169,11 @@ # be used on the command line when possible (eg: use # ``-DKDE_INSTALL_LIBDIR=lib64`` instead of # ``-DKDE_INSTALL_LIBDIR=/usr/lib/lib64`` to override the library directory). +# +# Since pre-1.0.0. +# +# NB: The variables starting ``KDE_INSTALL_`` are only available since 1.6.0. +# The ``APPDIR`` install variable is available since 1.1.0. #============================================================================= # Copyright 2014-2015 Alex Merry 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. --- docs/module/ECMCoverageOption.rst | 1 + docs/module/ECMEnableSanitizers.rst | 1 + docs/module/ECMGeneratePkgConfigFile.rst | 1 + modules/ECMCoverageOption.cmake | 14 +++--- modules/ECMEnableSanitizers.cmake | 65 +++++++++++++++------------- modules/ECMGeneratePkgConfigFile.cmake | 74 +++++++++++++++++--------------- 6 files changed, 86 insertions(+), 70 deletions(-) create mode 100644 docs/module/ECMCoverageOption.rst create mode 100644 docs/module/ECMEnableSanitizers.rst create mode 100644 docs/module/ECMGeneratePkgConfigFile.rst diff --git a/docs/module/ECMCoverageOption.rst b/docs/module/ECMCoverageOption.rst new file mode 100644 index 00000000..41bffd78 --- /dev/null +++ b/docs/module/ECMCoverageOption.rst @@ -0,0 +1 @@ +.. ecm-module:: ../../modules/ECMCoverageOption.cmake diff --git a/docs/module/ECMEnableSanitizers.rst b/docs/module/ECMEnableSanitizers.rst new file mode 100644 index 00000000..e25dd4f8 --- /dev/null +++ b/docs/module/ECMEnableSanitizers.rst @@ -0,0 +1 @@ +.. ecm-module:: ../../modules/ECMEnableSanitizers.cmake diff --git a/docs/module/ECMGeneratePkgConfigFile.rst b/docs/module/ECMGeneratePkgConfigFile.rst new file mode 100644 index 00000000..cd311f6b --- /dev/null +++ b/docs/module/ECMGeneratePkgConfigFile.rst @@ -0,0 +1 @@ +.. ecm-module:: ../../modules/ECMGeneratePkgConfigFile.cmake 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 98a1ac4bf153581865662bd55fd139844d2de5cd Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 6 Feb 2015 12:31:05 +0000 Subject: Add Android toolchain module to the documentation. --- README.rst | 9 ++-- docs/manual/ecm-modules.7.rst | 16 +++--- docs/manual/ecm-toolchains.7.rst | 33 ++++++++++++ docs/sphinx/ecm.py | 3 ++ docs/toolchain/Android.rst | 1 + toolchain/Android.cmake | 114 +++++++++++++++++++++++---------------- 6 files changed, 121 insertions(+), 55 deletions(-) create mode 100644 docs/manual/ecm-toolchains.7.rst create mode 100644 docs/toolchain/Android.rst diff --git a/README.rst b/README.rst index ccc692b7..01c844d2 100644 --- a/README.rst +++ b/README.rst @@ -5,8 +5,9 @@ Introduction ============ The Extra CMake Modules package, or ECM, adds to the modules provided by CMake, -including both ones used by ``find_package()`` to find common software and ones -that can be used directly in ``CMakeLists.txt`` files to perform common tasks. +including ones used by ``find_package()`` to find common software, ones that +can be used directly in ``CMakeLists.txt`` files to perform common tasks and +toolchain files that must be specified on the commandline by the user. In addition, it provides common build settings used in software produced by the KDE community. @@ -54,7 +55,7 @@ some of the settings. Some of the functionality of Organization ------------ -ECM provides three different types of modules. +ECM provides four different types of modules. * Core modules provide helpful macros for use in project CMake scripts. See :manual:`ecm-modules(7)` for more information. @@ -63,6 +64,8 @@ ECM provides three different types of modules. * KDE modules provide common settings for software produced by KDE; much of this may also be useful to other projects. See :manual:`ecm-kde-modules(7)` for more information. +* Toolchain files change the build tools and targets used by CMake. See + :manual:`ecm-toolchains(7)` for more information. The ``${ECM_MODULE_DIR}``, ``${ECM_FIND_MODULE_DIR}`` and ``${ECM_KDE_MODULE_DIR}`` variables may be used instead of diff --git a/docs/manual/ecm-modules.7.rst b/docs/manual/ecm-modules.7.rst index 16fd8612..ee0e4638 100644 --- a/docs/manual/ecm-modules.7.rst +++ b/docs/manual/ecm-modules.7.rst @@ -11,12 +11,12 @@ Introduction ============ Extra CMake Modules (ECM) provides various modules that provide useful functions -for CMake scripts. ECM actually provides three types of modules: those that -extend the functionality of the ``find_package`` command are documented in -:manual:`ecm-find-modules(7)`; those that provide standard settings for software -produced by the KDE community are documented in :manual:`ecm-kde-modules(7)`. -The rest provide macros and functions for general use by CMake scripts and are -documented here. +for CMake scripts. ECM actually provides three types of modules that can be +used from CMake scripts: those that extend the functionality of the +``find_package`` command are documented in :manual:`ecm-find-modules(7)`; those +that provide standard settings for software produced by the KDE community are +documented in :manual:`ecm-kde-modules(7)`. The rest provide macros and +functions for general use by CMake scripts and are documented here. To use these modules, you need to tell CMake to find the ECM package, and then add either ``${ECM_MODULE_PATH}`` or ``${ECM_MODULE_DIR}`` to the @@ -30,6 +30,10 @@ then add either ``${ECM_MODULE_PATH}`` or ``${ECM_MODULE_DIR}`` to the Using ``${ECM_MODULE_PATH}`` will also make the find modules and KDE modules available. +Note that there are also toolchain modules, documented in +:manual:`ecm-toolchains(7)`, but these are used by users building the software +rather than developers writing CMake scripts. + All Modules =========== diff --git a/docs/manual/ecm-toolchains.7.rst b/docs/manual/ecm-toolchains.7.rst new file mode 100644 index 00000000..66f685e2 --- /dev/null +++ b/docs/manual/ecm-toolchains.7.rst @@ -0,0 +1,33 @@ +.. ecm-manual-description: ECM Toolchains Reference + +ecm-toolchains(7) +***************** + +.. only:: html or latex + + .. contents:: + +Introduction +============ + +Extra CMake Modules (ECM) provides some toolchain modules. Unlike normal +modules, these are not included directly in projects, but specified with +the ``CMAKE_TOOLCHAIN_FILE`` cache variable on the commandline. + + +All Modules +=========== + +.. toctree:: + :maxdepth: 1 + :glob: + + /toolchain/* + +.. only:: man + + See Also + ======== + + :manual:`ecm(7)` + diff --git a/docs/sphinx/ecm.py b/docs/sphinx/ecm.py index 3eb75248..ed966bfb 100644 --- a/docs/sphinx/ecm.py +++ b/docs/sphinx/ecm.py @@ -154,6 +154,7 @@ _ecm_index_objs = { 'module': _ecm_index_entry('module'), 'find-module': _ecm_index_entry('find-module'), 'kde-module': _ecm_index_entry('kde-module'), + 'toolchain': _ecm_index_entry('toolchain'), } def _ecm_object_inventory(env, document, line, objtype, targetid): @@ -264,6 +265,7 @@ class ECMDomain(Domain): 'kde-module': ObjType('kde-module', 'kde-module'), 'find-module': ObjType('find-module', 'find-module'), 'manual': ObjType('manual', 'manual'), + 'toolchain': ObjType('toolchain', 'toolchain'), } directives = {} roles = { @@ -271,6 +273,7 @@ class ECMDomain(Domain): 'kde-module': XRefRole(), 'find-module': XRefRole(), 'manual': XRefRole(), + 'toolchain': XRefRole(), } initial_data = { 'objects': {}, # fullname -> docname, objtype diff --git a/docs/toolchain/Android.rst b/docs/toolchain/Android.rst new file mode 100644 index 00000000..9103e622 --- /dev/null +++ b/docs/toolchain/Android.rst @@ -0,0 +1 @@ +.. ecm-module:: ../../toolchain/Android.cmake diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake index 8272ef9d..55d2ca81 100644 --- a/toolchain/Android.cmake +++ b/toolchain/Android.cmake @@ -1,57 +1,79 @@ #.rst: # AndroidToolchain -# ------------------- +# ---------------- # -# Enable easy compilation of cmake projects on Android +# Enable easy compilation of cmake projects on Android. # # By using this android toolchain, the projects will be set up to compile the # specified project targeting an Android platform, depending on its input. # Furthermore, if desired, an APK can be directly generated by using the -# androiddeployqt tool. -# -# Note: Requires CMake 3.1 -# -# How to use it? -# -------------- -# First of all, to make use of this toolchain file it's required to specify the -# CMAKE_TOOLCHAIN_FILE variable pointing to AndroidToolchain.cmake. -# -# Then, there's many settings that we may want to specify under what circumstances -# the project will be built. This will be done through environment variables: -# - ANDROID_NDK: points to the NDK root path -# - ANDROID_SDK_ROOT: points to the SDK root path -# -# Also there's some cache variables we can pass as well to narrow down the -# preferred settings: -# - ANDROID_NDK: Points to the NDK root, defaults to the environment variable -# with the same name. -# - ANDROID_SDK_ROOT: Points to the Android SDK root, defaults to the environment -# variable with the same name. -# - ANDROID_ARCHITECTURE: Specifies the used architecture, "arm" by default. See -# arch-* directory. -# - ANDROID_TOOLCHAIN: Specifies the toolchain to be used. Defaults to -# "arm-linux-androideabi". See /toolchains/ directory. -# - ANDROID_ABI: Specifies the ABI to be used. Defaults to "armeabi-v7a". See -# /sources/cxx-stl/gnu-libstdc++/*/libs/ directories. -# - ANDROID_GCC_VERSION: Specifies the GCC version. Defaults to "4.9". -# - ANDROID_API_LEVEL: Specifies the API level to require. Defaults to "14". See -# http://developer.android.com/guide/topics/manifest/uses-sdk-element.html -# - ANDROID_SDK_BUILD_TOOLS_REVISION: Specifies the build tools version to be used. -# Defaults to "21.1.1". -# -# Once we have the application built, we will want to generate an APK that we -# can run on an Android device. To this end we've integrated androiddeployqt so -# this can be done easily. This won't work with non-qt projects. -# To make use of the APK generation, we'll define QTANDROID_EXPORTED_TARGET with -# the target we want to have exported. -# Additionally, we'll need to specify a ANDROID_APK_DIR with the base information -# to set the project up. For more information see: -# https://qt-project.org/doc/qt-5-snapshot/deployment-android.html -# -# Once set up, after building, make create-apk- will process this -# input and generate an apk that can be found inside the build directory: -# ${CMAKE_BINARY_DIR}/_build_apk/bin/QtApp-*.apk. +# `androiddeployqt `_ tool. # +# .. note:: +# +# This module requires CMake 3.1. +# +# Since 1.7.0. +# +# Usage +# ===== +# +# To use this file, you need to set the ``CMAKE_TOOLCHAIN_FILE`` to point to +# ``AndroidToolchain.cmake`` on the command line:: +# +# cmake -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/AndroidToolchain.cmake +# +# You will also need to provide the locations of the Android NDK and SDK. This +# can be done on the commandline or with environment variables; in either case +# the variable names are: +# +# ``ANDROID_NDK`` +# The NSK root path. +# ``ANDROID_SDK_ROOT`` +# The SSK root path. +# +# Additional options are specified as cache variables (eg: on the command line): +# +# ``ANDROID_ARCHITECTURE`` +# The architecture to compile for. Default: ``arm``. +# ``ANDROID_TOOLCHAIN`` +# The toolchain to use. See the ``toolchains`` directory of the NDK. +# Default: ``arm-linux-androideabi``. +# ``ANDROID_ABI`` +# The ABI to use. See the ``sources/cxx-stl/gnu-libstdc++/*/libs`` +# directories in the NDK. Default: ``armeabi-v7a``. +# ``ANDROID_GCC_VERSION`` +# The GCC version to use. Default: ``4.9``. +# ``ANDROID_API_LEVEL`` +# The `API level +# `_ +# to require. Default: ``14``. +# ``ANDROID_SDK_BUILD_TOOLS_REVISION`` +# The build tools version to use. Default: ``21.1.1``. +# +# Deploying Qt Applications +# ========================= +# +# After building the application, you will need to generate an APK that can be +# deployed to an Android device. This module integrates androiddeployqt support +# to help with this for Qt-based projects. To enable this, set the +# ``QTANDROID_EXPORTED_TARGET`` variable to the target you wish to export as an +# APK, as well as ``ANDROID_APK_DIR`` to a directory containing some basic +# information. This will create a ``create-apk-`` target that will +# generate the APK file. See the `Qt on Android deployment documentation +# `_ for more information. +# +# For example, you could do:: +# +# cmake \ +# -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/AndroidToolchain.cmake \ +# -DQTANDROID_EXPORTED_TARGET=myapp \ +# -DANDROID_APK_DIR=myapp-apk +# make +# make create-apk-myapp +# +# The APK would then be found in ``myapp_build_apk/bin`` in the build directory. + # ============================================================================= # Copyright 2014 Aleix Pol i Gonzalez # -- 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(-) 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 bd7aa7a91ab75639ddc3a274718da55e6cd2ae81 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 9 Feb 2015 12:44:29 +0100 Subject: Add comment to Android toolchain file. --- toolchain/Android.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake index 55d2ca81..0144f379 100644 --- a/toolchain/Android.cmake +++ b/toolchain/Android.cmake @@ -161,6 +161,9 @@ set(CMAKE_CXX_LINK_EXECUTABLE ######### generation set(CREATEAPK_TARGET_NAME "create-apk-${QTANDROID_EXPORTED_TARGET}") +# Need to ensure we only get in here once, as this file is included twice: +# from CMakeDetermineSystem.cmake and from CMakeSystem.cmake generated within the +# build directory. if(DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET ${CREATEAPK_TARGET_NAME}) if(NOT EXISTS "${ANDROID_APK_DIR}/AndroidManifest.xml") message(FATAL_ERROR "Define an apk dir to initialize from using -DANDROID_APK_DIR=. The specified directory must contain the AndroidManifest.xml file.") @@ -184,6 +187,8 @@ if(DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET ${CREATEAPK_TARGET_NAME}) string(REPLACE ";" "," _DEPS "${_DEPS_LIST}") configure_file("${_CMAKE_ANDROID_DIR}/deployment-file.json.in" "${QTANDROID_EXPORTED_TARGET}-deployment.json") endfunction() + #we want to call the function after the project has been set up + variable_watch(CMAKE_PARENT_LIST_FILE EOFHook) # Create the target that will eventually generate the apk get_filename_component(QTDIR "${Qt5Core_DIR}/../../../" ABSOLUTE) @@ -197,9 +202,6 @@ if(DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET ${CREATEAPK_TARGET_NAME}) COMMAND cmake -E copy "$" "${EXECUTABLE_DESTINATION_PATH}" COMMAND ${ANDROID_DEPLOY_QT} --input "${QTANDROID_EXPORTED_TARGET}-deployment.json" --output "${EXPORT_DIR}" --deployment bundled "\\$(ARGS)" ) - - #we want to call the function after the project has been set up - variable_watch(CMAKE_PARENT_LIST_FILE EOFHook) else() message(STATUS "You can export a target by specifying -DQTANDROID_EXPORTED_TARGET=") endif() -- cgit v1.2.1 From 7c20867987d21fe36255e8b84fc0dd3003c88e14 Mon Sep 17 00:00:00 2001 From: Jonathan Riddell Date: Wed, 11 Feb 2015 15:07:50 +0100 Subject: Add Debian path to search path for qtwaylandscanner Debian likes to install qt binaries into an obscure path, search here as well REVIEW: 122526 --- find-modules/FindQtWaylandScanner.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/find-modules/FindQtWaylandScanner.cmake b/find-modules/FindQtWaylandScanner.cmake index 28a4fda5..79a1b051 100644 --- a/find-modules/FindQtWaylandScanner.cmake +++ b/find-modules/FindQtWaylandScanner.cmake @@ -90,7 +90,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) ecm_find_package_version_check(QtWaylandScanner) # Find qtwaylandscanner -find_program(QtWaylandScanner_EXECUTABLE NAMES qtwaylandscanner) +find_program(QtWaylandScanner_EXECUTABLE NAMES qtwaylandscanner HINTS /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt5/bin/) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(QtWaylandScanner -- 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 ++++++++++++++-------- tests/ECMGenerateHeadersTest/CamelCaseHeadTest1.h | 0 tests/ECMGenerateHeadersTest/CamelCaseHeadTest2.h | 0 tests/ECMGenerateHeadersTest/run_test.cmake.config | 45 +++++++++++++ 4 files changed, 94 insertions(+), 28 deletions(-) create mode 100644 tests/ECMGenerateHeadersTest/CamelCaseHeadTest1.h create mode 100644 tests/ECMGenerateHeadersTest/CamelCaseHeadTest2.h 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 () diff --git a/tests/ECMGenerateHeadersTest/CamelCaseHeadTest1.h b/tests/ECMGenerateHeadersTest/CamelCaseHeadTest1.h new file mode 100644 index 00000000..e69de29b diff --git a/tests/ECMGenerateHeadersTest/CamelCaseHeadTest2.h b/tests/ECMGenerateHeadersTest/CamelCaseHeadTest2.h new file mode 100644 index 00000000..e69de29b diff --git a/tests/ECMGenerateHeadersTest/run_test.cmake.config b/tests/ECMGenerateHeadersTest/run_test.cmake.config index 0a2425fe..1db623b7 100644 --- a/tests/ECMGenerateHeadersTest/run_test.cmake.config +++ b/tests/ECMGenerateHeadersTest/run_test.cmake.config @@ -244,4 +244,49 @@ check_files(GENERATED ${expfiles} ORIGINALS ${origfiles}) +########################################################### + +message(STATUS "Test 10: ORIGINAL CAMELCASE") +set(forward_headers) +set(expfiles "${CMAKE_CURRENT_BINARY_DIR}/CamelCaseHeadTest1" + "${CMAKE_CURRENT_BINARY_DIR}/CamelCaseHeadTest2") +set(origfiles CamelCaseHeadTest1.h CamelCaseHeadTest2.h) +file(REMOVE ${expfiles}) +ecm_generate_headers( + forward_headers + ORIGINAL CAMELCASE + HEADER_NAMES CamelCaseHeadTest1 CamelCaseHeadTest2 +) +if (NOT "${expfiles}" STREQUAL "${forward_headers}") + message(FATAL_ERROR "forward_headers was set to \"${forward_headers}\" instead of \"${expfiles}\"") +endif() +check_files(GENERATED ${expfiles} + ORIGINALS ${origfiles}) + + +########################################################### + +message(STATUS "Test 11: PREFIX and ORIGINAL CAMELCASE") +set(forward_headers) +set(expfiles "${CMAKE_CURRENT_BINARY_DIR}/Module/CamelCaseHeadTest1" + "${CMAKE_CURRENT_BINARY_DIR}/Module/CamelCaseHeadTest2") +set(intermediatefiles Module/CamelCaseHeadTest1.h Module/CamelCaseHeadTest2.h) +set(origfiles "${CMAKE_CURRENT_SOURCE_DIR}/headtest1.h" + "${CMAKE_CURRENT_SOURCE_DIR}/headtest2.h") +file(REMOVE ${expfiles} ${intermediatefiles}) +ecm_generate_headers( + forward_headers + ORIGINAL CAMELCASE + HEADER_NAMES CamelCaseHeadTest1 CamelCaseHeadTest2 + PREFIX Module +) +if (NOT "${expfiles}" STREQUAL "${forward_headers}") + message(FATAL_ERROR "forward_headers was set to \"${forward_headers}\" instead of \"${expfiles}\"") +endif() +check_files(GENERATED ${expfiles} + ORIGINALS ${intermediatefiles}) +check_files(GENERATED ${expfiles} + ORIGINALS ${intermediatefiles}) + + # vim:ft=cmake -- cgit v1.2.1 From 1256936453e8215bd009c8d86b4773c6a03d33dc Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sun, 15 Feb 2015 22:31:18 +0000 Subject: Upgrade ECM version to 1.8.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bccfbc5..546cb87d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(extra-cmake-modules NONE) set(ECM_MAJOR_VERSION 1) -set(ECM_MINOR_VERSION 7) +set(ECM_MINOR_VERSION 8) set(ECM_PATCH_VERSION 0) set(ECM_VERSION ${ECM_MAJOR_VERSION}.${ECM_MINOR_VERSION}.${ECM_PATCH_VERSION}) -- 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(-) 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(-) 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 4f81d1a92e4ccc2ce7b33d2860397a526b1a4d2f Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 9 Mar 2015 18:18:16 +0000 Subject: Fix tab characters in regexes. There is no "\t" in CMake's regular expression syntax; we need to make the character be interpreted when CMake parses it as a string. --- find-modules/FindEGL.cmake | 4 ++-- find-modules/FindWayland.cmake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/find-modules/FindEGL.cmake b/find-modules/FindEGL.cmake index b96f3b0f..72474371 100644 --- a/find-modules/FindEGL.cmake +++ b/find-modules/FindEGL.cmake @@ -98,14 +98,14 @@ if(EGL_INCLUDE_DIR) # finding all these defines and selecting the highest numbered. file(READ "${EGL_INCLUDE_DIR}/egl.h" _EGL_header_contents) string(REGEX MATCHALL - "[ \\t]EGL_VERSION_[0-9_]+" + "[ \t]EGL_VERSION_[0-9_]+" _EGL_version_lines "${_EGL_header_contents}" ) unset(_EGL_header_contents) foreach(_EGL_version_line ${_EGL_version_lines}) string(REGEX REPLACE - "[ \\t]EGL_VERSION_([0-9_]+)" + "[ \t]EGL_VERSION_([0-9_]+)" "\\1" _version_candidate "${_EGL_version_line}" diff --git a/find-modules/FindWayland.cmake b/find-modules/FindWayland.cmake index f69fa18b..c5a56c16 100644 --- a/find-modules/FindWayland.cmake +++ b/find-modules/FindWayland.cmake @@ -117,7 +117,7 @@ if(NOT Wayland_VERSION) if(Wayland_VERSION_HEADER) file(READ ${Wayland_VERSION_HEADER} _wayland_version_header_contents) string(REGEX REPLACE - "^.*[ \\t]+WAYLAND_VERSION[ \\t]+\"([0-9.]*)\".*$" + "^.*[ \t]+WAYLAND_VERSION[ \t]+\"([0-9.]*)\".*$" "\\1" Wayland_VERSION "${_wayland_version_header_contents}" -- cgit v1.2.1 From 03d5bbda45a9cc117fd03e272113ddd9439aebf5 Mon Sep 17 00:00:00 2001 From: Heiko Becker Date: Fri, 13 Mar 2015 17:30:46 +0100 Subject: Allow configuration of SHARE_INSTALL_DIR The motivation behind this change is my distribution moving to a multiarch layout. While the architecture specific stuff (binaries, libraries, etc.) is installed under /usr/${host}/{bin,lib,...} architecture-independent data should still be installed to /usr/share/. REVIEW: 122929 From 014d2166e08cbe6f350a8600a93c8f132ee95661 Mon Sep 17 00:00:00 2001 From: Heiko Becker Date: Fri, 13 Mar 2015 12:26:31 +0100 Subject: [PATCH] Allow configuration of SHARE_INSTALL_DIR --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 546cb87d..37e32ebe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ if(BUILD_TESTING) add_subdirectory(tests) endif() -set(SHARE_INSTALL_DIR share) +set(SHARE_INSTALL_DIR share CACHE PATH "read-only architecture-independent data") set(TOOLCHAIN_MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/toolchain/) set(MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/modules/) set(KDE_MODULES_INSTALL_DIR ${SHARE_INSTALL_DIR}/ECM/kde-modules/) -- 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 ++++++++- tests/ECMInstallIconsTest/16-apps-cmake.png | Bin 233 -> 0 bytes tests/ECMInstallIconsTest/CMakeLists.txt | 15 ++++++++------- .../hicolor/16x16/actions/old-style-name.png | Bin 0 -> 233 bytes .../ECMInstallIconsTest/hi16-actions-old-style-name.png | Bin 0 -> 233 bytes tests/ECMInstallIconsTest/subdir/16-apps-cmake.png | Bin 0 -> 233 bytes 6 files changed, 16 insertions(+), 8 deletions(-) delete mode 100644 tests/ECMInstallIconsTest/16-apps-cmake.png create mode 100644 tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/16x16/actions/old-style-name.png create mode 100644 tests/ECMInstallIconsTest/hi16-actions-old-style-name.png create mode 100644 tests/ECMInstallIconsTest/subdir/16-apps-cmake.png 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() diff --git a/tests/ECMInstallIconsTest/16-apps-cmake.png b/tests/ECMInstallIconsTest/16-apps-cmake.png deleted file mode 100644 index ed9a1181..00000000 Binary files a/tests/ECMInstallIconsTest/16-apps-cmake.png and /dev/null differ diff --git a/tests/ECMInstallIconsTest/CMakeLists.txt b/tests/ECMInstallIconsTest/CMakeLists.txt index 85f2d9f5..7fe4ca35 100644 --- a/tests/ECMInstallIconsTest/CMakeLists.txt +++ b/tests/ECMInstallIconsTest/CMakeLists.txt @@ -20,7 +20,7 @@ ecm_install_icons( ICONS 16-actions-computer.png 16-animations-loading.mng - 16-apps-cmake.png + subdir/16-apps-cmake.png 16-categories-system-help.mng 16-emotes-face-smile.png 16-intl-something.png @@ -36,7 +36,7 @@ ecm_install_icons( ICONS 16-actions-computer.png 16-animations-loading.mng - 16-apps-cmake.png + subdir/16-apps-cmake.png 16-categories-system-help.mng 16-emotes-face-smile.png 16-intl-something.png @@ -53,7 +53,7 @@ ecm_install_icons( ICONS 16-actions-computer.png 16-animations-loading.mng - 16-apps-cmake.png + subdir/16-apps-cmake.png 16-categories-system-help.mng 16-emotes-face-smile.png 16-intl-something.png @@ -70,7 +70,7 @@ ecm_install_icons( ICONS 16-actions-computer.png 16-animations-loading.mng - 16-apps-cmake.png + subdir/16-apps-cmake.png 16-categories-system-help.mng 16-emotes-face-smile.png 16-intl-something.png @@ -87,9 +87,10 @@ ecm_install_icons( # all these should be warned about ecm_install_icons( ICONS - aa-actions-badsize.png # ignored - badlynamedfile.png # ignored - 16-actions-badext.txt # copied + aa-actions-badsize.png # ignored + badlynamedfile.png # ignored + 16-actions-badext.txt # copied + hi16-actions-old-style-name.png # copied DESTINATION badly-named-files-test ) diff --git a/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/16x16/actions/old-style-name.png b/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/16x16/actions/old-style-name.png new file mode 100644 index 00000000..ed9a1181 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/16x16/actions/old-style-name.png differ diff --git a/tests/ECMInstallIconsTest/hi16-actions-old-style-name.png b/tests/ECMInstallIconsTest/hi16-actions-old-style-name.png new file mode 100644 index 00000000..ed9a1181 Binary files /dev/null and b/tests/ECMInstallIconsTest/hi16-actions-old-style-name.png differ diff --git a/tests/ECMInstallIconsTest/subdir/16-apps-cmake.png b/tests/ECMInstallIconsTest/subdir/16-apps-cmake.png new file mode 100644 index 00000000..ed9a1181 Binary files /dev/null and b/tests/ECMInstallIconsTest/subdir/16-apps-cmake.png differ -- cgit v1.2.1 From b608b22a972697fee1402e718742787d9f6f07f7 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 4 Apr 2015 07:55:29 +0000 Subject: Upgrade ECM version to 1.9.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37e32ebe..220e261f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(extra-cmake-modules NONE) set(ECM_MAJOR_VERSION 1) -set(ECM_MINOR_VERSION 8) +set(ECM_MINOR_VERSION 9) set(ECM_PATCH_VERSION 0) set(ECM_VERSION ${ECM_MAJOR_VERSION}.${ECM_MINOR_VERSION}.${ECM_PATCH_VERSION}) -- cgit v1.2.1 From ac484a48afbcb9a6129ec4e93c2d4c2ab3e05969 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 4 Apr 2015 10:52:03 +0200 Subject: The next number after 1.8 is 5.9. CHANGELOG: extra-cmake-modules versioning is now aligned with KDE Frameworks. Therefore the last release was 1.8, while this one is 5.9. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 220e261f..aeff66f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(extra-cmake-modules NONE) -set(ECM_MAJOR_VERSION 1) +set(ECM_MAJOR_VERSION 5) set(ECM_MINOR_VERSION 9) set(ECM_PATCH_VERSION 0) -- 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(-) 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 c3a6bd22766446c2fead866b94c2c97385ad8db7 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Fri, 10 Apr 2015 07:32:07 +0000 Subject: Upgrade ECM version to 5.10.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aeff66f3..166337c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(extra-cmake-modules NONE) set(ECM_MAJOR_VERSION 5) -set(ECM_MINOR_VERSION 9) +set(ECM_MINOR_VERSION 10) set(ECM_PATCH_VERSION 0) set(ECM_VERSION ${ECM_MAJOR_VERSION}.${ECM_MINOR_VERSION}.${ECM_PATCH_VERSION}) -- cgit v1.2.1 From 9521e67d6ac24ac52b05f47f384c048999d7df5f Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Sun, 19 Apr 2015 15:01:40 +0200 Subject: execute png2icon --help with ERROR_QUIET, to prevent printing of banner from http://www.winterdrache.de/freeware/png2ico/ --- find-modules/FindPng2Ico.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/find-modules/FindPng2Ico.cmake b/find-modules/FindPng2Ico.cmake index 7b201988..941e9155 100644 --- a/find-modules/FindPng2Ico.cmake +++ b/find-modules/FindPng2Ico.cmake @@ -87,6 +87,7 @@ if (Png2Ico_FOUND) execute_process( COMMAND "${Png2Ico_EXECUTABLE}" --help OUTPUT_VARIABLE _png2ico_help_text + ERROR_QUIET ) if (_png2ico_help_text MATCHES ".*--rcfile .*") set(Png2Ico_HAS_RCFILE_ARGUMENT TRUE) -- cgit v1.2.1 From 8527961d1664b03e563381529f6ae4da83d26550 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Sun, 19 Apr 2015 15:13:32 +0200 Subject: real fix for png2ico, pipe error stream also to result variable --- find-modules/FindPng2Ico.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/find-modules/FindPng2Ico.cmake b/find-modules/FindPng2Ico.cmake index 941e9155..d84f6673 100644 --- a/find-modules/FindPng2Ico.cmake +++ b/find-modules/FindPng2Ico.cmake @@ -87,7 +87,7 @@ if (Png2Ico_FOUND) execute_process( COMMAND "${Png2Ico_EXECUTABLE}" --help OUTPUT_VARIABLE _png2ico_help_text - ERROR_QUIET + ERROR_VARIABLE _png2ico_help_text ) if (_png2ico_help_text MATCHES ".*--rcfile .*") set(Png2Ico_HAS_RCFILE_ARGUMENT TRUE) -- cgit v1.2.1 From 37aa23a96e37fa584a68858aef4b4637078e4779 Mon Sep 17 00:00:00 2001 From: Michael Palimaka Date: Thu, 23 Apr 2015 04:17:30 +1000 Subject: Port remaining find modules to ecm_find_package_version_check. REVIEW: 123470 --- find-modules/FindEGL.cmake | 9 +++------ find-modules/FindKF5.cmake | 9 +++------ find-modules/FindLibGit2.cmake | 9 +++------ find-modules/FindOpenEXR.cmake | 5 ++--- find-modules/FindSharedMimeInfo.cmake | 9 +++------ find-modules/FindX11_XCB.cmake | 9 +++------ 6 files changed, 17 insertions(+), 33 deletions(-) diff --git a/find-modules/FindEGL.cmake b/find-modules/FindEGL.cmake index 72474371..b8787d8b 100644 --- a/find-modules/FindEGL.cmake +++ b/find-modules/FindEGL.cmake @@ -60,12 +60,9 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= -if(CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "CMake 2.8.12 is required by FindEGL.cmake") -endif() -if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) - message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindEGL.cmake") -endif() +include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) + +ecm_find_package_version_check(EGL) # Use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls diff --git a/find-modules/FindKF5.cmake b/find-modules/FindKF5.cmake index 30b20948..b0ba9f6b 100644 --- a/find-modules/FindKF5.cmake +++ b/find-modules/FindKF5.cmake @@ -47,12 +47,9 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= -if(CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "CMake 2.8.12 is required by FindKF5.cmake") -endif() -if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) - message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindKF5.cmake") -endif() +include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) + +ecm_find_package_version_check(KF5) if (NOT KF5_FIND_COMPONENTS) set(KF5_NOT_FOUND_MESSAGE "The KF5 package requires at least one component") diff --git a/find-modules/FindLibGit2.cmake b/find-modules/FindLibGit2.cmake index 22fc5ebb..eaf227fc 100644 --- a/find-modules/FindLibGit2.cmake +++ b/find-modules/FindLibGit2.cmake @@ -60,12 +60,9 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= -if(CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "CMake 2.8.12 is required by FindLibGit2.cmake") -endif() -if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) - message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindLibGit2.cmake") -endif() +include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) + +ecm_find_package_version_check(LibGit2) # Use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls diff --git a/find-modules/FindOpenEXR.cmake b/find-modules/FindOpenEXR.cmake index b63b8cd0..d80caadd 100644 --- a/find-modules/FindOpenEXR.cmake +++ b/find-modules/FindOpenEXR.cmake @@ -54,10 +54,9 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= +include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) -if(${CMAKE_VERSION} VERSION_LESS 2.8.12) - message(FATAL_ERROR "CMake 2.8.12 is required by FindOpenEXR.cmake") -endif() +ecm_find_package_version_check(OpenEXR) # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls diff --git a/find-modules/FindSharedMimeInfo.cmake b/find-modules/FindSharedMimeInfo.cmake index ebbe3284..00bebf16 100644 --- a/find-modules/FindSharedMimeInfo.cmake +++ b/find-modules/FindSharedMimeInfo.cmake @@ -54,12 +54,9 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= -if(CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "CMake 2.8.12 is required by FindSharedMimeInfo.cmake") -endif() -if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) - message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindSharedMimeInfo.cmake") -endif() +include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) + +ecm_find_package_version_check(SharedMimeInfo) find_program (UPDATE_MIME_DATABASE_EXECUTABLE NAMES update-mime-database) diff --git a/find-modules/FindX11_XCB.cmake b/find-modules/FindX11_XCB.cmake index 8b975e6a..dd55fd7b 100644 --- a/find-modules/FindX11_XCB.cmake +++ b/find-modules/FindX11_XCB.cmake @@ -63,12 +63,9 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #============================================================================= -if(CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "CMake 2.8.12 is required by FindX11_XCB.cmake") -endif() -if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) - message(AUTHOR_WARNING "Your project should require at least CMake 2.8.12 to use FindX11_XCB.cmake") -endif() +include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) + +ecm_find_package_version_check(X11_XCB) # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls -- cgit v1.2.1 From 09822e2631644875d3b22fef54b9bfa30a295169 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Fri, 8 May 2015 23:23:28 +0000 Subject: Upgrade ECM version to 5.11.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 166337c2..4f04fc8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(extra-cmake-modules NONE) set(ECM_MAJOR_VERSION 5) -set(ECM_MINOR_VERSION 10) +set(ECM_MINOR_VERSION 11) set(ECM_PATCH_VERSION 0) set(ECM_VERSION ${ECM_MAJOR_VERSION}.${ECM_MINOR_VERSION}.${ECM_PATCH_VERSION}) -- 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 ++- tests/CMakeLists.txt | 1 + tests/ECMAddTests/CMakeLists.txt | 49 +++++++++ tests/ECMAddTests/check_files.cmake | 15 +++ tests/ECMAddTests/multi_tests/CMakeLists.txt | 142 ++++++++++++++++++++++++++ tests/ECMAddTests/multi_tests/test1.cpp | 8 ++ tests/ECMAddTests/multi_tests/test2.cpp | 8 ++ tests/ECMAddTests/multi_tests/test3.cpp | 8 ++ tests/ECMAddTests/multi_tests/test4.cpp | 8 ++ tests/ECMAddTests/multi_tests/test5.cpp | 8 ++ tests/ECMAddTests/multi_tests/test6.cpp | 8 ++ tests/ECMAddTests/multi_tests/test7.cpp | 8 ++ tests/ECMAddTests/multi_tests/test8.cpp | 8 ++ tests/ECMAddTests/multi_tests/test9.cpp | 8 ++ tests/ECMAddTests/single_tests/CMakeLists.txt | 122 ++++++++++++++++++++++ tests/ECMAddTests/single_tests/test1.cpp | 8 ++ tests/ECMAddTests/single_tests/test2.cpp | 8 ++ tests/ECMAddTests/single_tests/test3.cpp | 8 ++ tests/ECMAddTests/single_tests/test4.cpp | 8 ++ tests/ECMAddTests/single_tests/test5.cpp | 8 ++ tests/ECMAddTests/single_tests/test6.cpp | 8 ++ tests/ECMAddTests/single_tests/test6body.cpp | 7 ++ tests/ECMAddTests/testhelper.cpp | 8 ++ tests/ECMAddTests/testhelper.h | 1 + 24 files changed, 476 insertions(+), 2 deletions(-) create mode 100644 tests/ECMAddTests/CMakeLists.txt create mode 100644 tests/ECMAddTests/check_files.cmake create mode 100644 tests/ECMAddTests/multi_tests/CMakeLists.txt create mode 100644 tests/ECMAddTests/multi_tests/test1.cpp create mode 100644 tests/ECMAddTests/multi_tests/test2.cpp create mode 100644 tests/ECMAddTests/multi_tests/test3.cpp create mode 100644 tests/ECMAddTests/multi_tests/test4.cpp create mode 100644 tests/ECMAddTests/multi_tests/test5.cpp create mode 100644 tests/ECMAddTests/multi_tests/test6.cpp create mode 100644 tests/ECMAddTests/multi_tests/test7.cpp create mode 100644 tests/ECMAddTests/multi_tests/test8.cpp create mode 100644 tests/ECMAddTests/multi_tests/test9.cpp create mode 100644 tests/ECMAddTests/single_tests/CMakeLists.txt create mode 100644 tests/ECMAddTests/single_tests/test1.cpp create mode 100644 tests/ECMAddTests/single_tests/test2.cpp create mode 100644 tests/ECMAddTests/single_tests/test3.cpp create mode 100644 tests/ECMAddTests/single_tests/test4.cpp create mode 100644 tests/ECMAddTests/single_tests/test5.cpp create mode 100644 tests/ECMAddTests/single_tests/test6.cpp create mode 100644 tests/ECMAddTests/single_tests/test6body.cpp create mode 100644 tests/ECMAddTests/testhelper.cpp create mode 100644 tests/ECMAddTests/testhelper.h 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() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bc3e5ce8..7960154a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,6 +4,7 @@ # with other files (as ECM itself is architecture-independent). project(ECMTests C) +add_subdirectory(ECMAddTests) add_subdirectory(ECMGenerateHeadersTest) add_subdirectory(ECMSetupVersionTest) add_subdirectory(ECMGeneratePkgConfigFile) diff --git a/tests/ECMAddTests/CMakeLists.txt b/tests/ECMAddTests/CMakeLists.txt new file mode 100644 index 00000000..e77b33f9 --- /dev/null +++ b/tests/ECMAddTests/CMakeLists.txt @@ -0,0 +1,49 @@ +macro(add_check NAME) + string(REPLACE "." "/" dir "${NAME}") + string(REGEX REPLACE "[^.]*\\." "" proj "${NAME}") + add_test( + NAME ecm_add_tests-${NAME} + COMMAND + ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMAKE_CURRENT_SOURCE_DIR}/${dir}" + "${CMAKE_CURRENT_BINARY_DIR}/${dir}" + --build-two-config + --build-generator ${CMAKE_GENERATOR} + --build-makeprogram ${CMAKE_MAKE_PROGRAM} + --build-project ${proj} + --build-options -DBUILD_TESTING:BOOL=ON + ${${NAME}_EXTRA_OPTIONS} + --test-command "${CMAKE_CTEST_COMMAND}" + ) + add_test( + NAME ecm_add_tests_did_run-${NAME} + COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/check_files.cmake" ${ARGN} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${dir}" + ) + set_property(TEST ecm_add_tests_did_run-${NAME} + APPEND + PROPERTY DEPENDS "ecm_add_tests-${NAME}" + ) +endmacro() + +add_check(single_tests + test1.txt + test2.txt + test3.txt + test4.txt + test5.txt + test6.txt + ) +add_check(multi_tests + test1.txt + test2.txt + test3.txt + test4.txt + test5.txt + test6.txt + test7.txt + test8.txt + test9.txt + ) + diff --git a/tests/ECMAddTests/check_files.cmake b/tests/ECMAddTests/check_files.cmake new file mode 100644 index 00000000..fc6003c6 --- /dev/null +++ b/tests/ECMAddTests/check_files.cmake @@ -0,0 +1,15 @@ +set(i 0) +set(in_file_args FALSE) +while (i LESS CMAKE_ARGC) + if (in_file_args) + if (NOT EXISTS "${CMAKE_ARGV${i}}") + message(FATAL_ERROR "${CMAKE_ARGV${i}} does not exist") + endif() + elseif (CMAKE_ARGV${i} STREQUAL "-P") + # skip script name + math(EXPR i "${i} + 1") + set(in_file_args TRUE) + endif() + math(EXPR i "${i} + 1") +endwhile() + diff --git a/tests/ECMAddTests/multi_tests/CMakeLists.txt b/tests/ECMAddTests/multi_tests/CMakeLists.txt new file mode 100644 index 00000000..ca434773 --- /dev/null +++ b/tests/ECMAddTests/multi_tests/CMakeLists.txt @@ -0,0 +1,142 @@ +project(ECMAddTests) +cmake_minimum_required(VERSION 2.8.12) + +set(ECM_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules) +set(CMAKE_MODULE_PATH "${ECM_MODULE_DIR}") + +add_library(testhelper STATIC ../testhelper.cpp) +target_include_directories(testhelper PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") + +enable_testing() + +include(ECMAddTests) + +# clean up to avoid false-positives from check_files.cmake +file(REMOVE + "${CMAKE_CURRENT_BINARY_DIR}/test1.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test2.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test3.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test4.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test5.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test6.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test7.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test8.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test9.txt" + ) + +ecm_add_tests( + test1.cpp + test2.cpp + test3.cpp + LINK_LIBRARIES testhelper + ) +# check targets exist +get_property(_dummy TARGET test1 PROPERTY TYPE) +get_property(_dummy TARGET test2 PROPERTY TYPE) +get_property(_dummy TARGET test3 PROPERTY TYPE) +# check tests exists +get_property(_dummy TEST test1 PROPERTY TIMEOUT) +get_property(_dummy TEST test2 PROPERTY TIMEOUT) +get_property(_dummy TEST test3 PROPERTY TIMEOUT) +get_property(_is_win32 TARGET test1 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test1 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test1 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test1 is an OS/X bundle when it should not be") +endif() +get_property(_is_win32 TARGET test2 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test2 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test2 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test2 is an OS/X bundle when it should not be") +endif() + + +ecm_add_tests( + test4.cpp + test5.cpp + LINK_LIBRARIES testhelper + NAME_PREFIX pref_ + ) +get_property(_dummy TARGET test4 PROPERTY TYPE) +get_property(_dummy TARGET test5 PROPERTY TYPE) +get_property(_dummy TEST pref_test4 PROPERTY TIMEOUT) +get_property(_dummy TEST pref_test5 PROPERTY TIMEOUT) +get_property(_is_win32 TARGET test4 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test4 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test4 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test4 is an OS/X bundle when it should not be") +endif() +get_property(_is_win32 TARGET test5 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test5 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test5 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test5 is an OS/X bundle when it should not be") +endif() + + +ecm_add_tests( + test6.cpp + test7.cpp + LINK_LIBRARIES testhelper + GUI + ) +get_property(_dummy TARGET test6 PROPERTY TYPE) +get_property(_dummy TARGET test7 PROPERTY TYPE) +get_property(_dummy TEST test6 PROPERTY TIMEOUT) +get_property(_dummy TEST test7 PROPERTY TIMEOUT) +get_property(_is_win32 TARGET test6 PROPERTY WIN32_EXECUTABLE) +if (NOT _is_win32) + message(FATAL_ERROR "test6 is not a WIN32 executable when it should be") +endif() +get_property(_is_bundle TARGET test6 PROPERTY MACOSX_BUNDLE) +if (NOT _is_bundle) + message(FATAL_ERROR "test6 is not an OS/X bundle when it should be") +endif() +get_property(_is_win32 TARGET test7 PROPERTY WIN32_EXECUTABLE) +if (NOT _is_win32) + message(FATAL_ERROR "test7 is not a WIN32 executable when it should be") +endif() +get_property(_is_bundle TARGET test7 PROPERTY MACOSX_BUNDLE) +if (NOT _is_bundle) + message(FATAL_ERROR "test7 is not an OS/X bundle when it should be") +endif() + + +ecm_add_tests( + test8.cpp + test9.cpp + LINK_LIBRARIES testhelper + NAME_PREFIX p_ + GUI + ) +get_property(_dummy TARGET test8 PROPERTY TYPE) +get_property(_dummy TARGET test9 PROPERTY TYPE) +get_property(_dummy TEST p_test8 PROPERTY TIMEOUT) +get_property(_dummy TEST p_test9 PROPERTY TIMEOUT) +get_property(_is_win32 TARGET test8 PROPERTY WIN32_EXECUTABLE) +if (NOT _is_win32) + message(FATAL_ERROR "test8 is not a WIN32 executable when it should be") +endif() +get_property(_is_bundle TARGET test8 PROPERTY MACOSX_BUNDLE) +if (NOT _is_bundle) + message(FATAL_ERROR "test8 is not an OS/X bundle when it should be") +endif() +get_property(_is_win32 TARGET test9 PROPERTY WIN32_EXECUTABLE) +if (NOT _is_win32) + message(FATAL_ERROR "test9 is not a WIN32 executable when it should be") +endif() +get_property(_is_bundle TARGET test9 PROPERTY MACOSX_BUNDLE) +if (NOT _is_bundle) + message(FATAL_ERROR "test9 is not an OS/X bundle when it should be") +endif() + diff --git a/tests/ECMAddTests/multi_tests/test1.cpp b/tests/ECMAddTests/multi_tests/test1.cpp new file mode 100644 index 00000000..e5482865 --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test1.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test1.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/multi_tests/test2.cpp b/tests/ECMAddTests/multi_tests/test2.cpp new file mode 100644 index 00000000..7f45bb56 --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test2.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test2.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/multi_tests/test3.cpp b/tests/ECMAddTests/multi_tests/test3.cpp new file mode 100644 index 00000000..142b2765 --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test3.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test3.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/multi_tests/test4.cpp b/tests/ECMAddTests/multi_tests/test4.cpp new file mode 100644 index 00000000..1ba9b148 --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test4.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test4.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/multi_tests/test5.cpp b/tests/ECMAddTests/multi_tests/test5.cpp new file mode 100644 index 00000000..987af36b --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test5.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test5.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/multi_tests/test6.cpp b/tests/ECMAddTests/multi_tests/test6.cpp new file mode 100644 index 00000000..6bda9f0d --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test6.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test6.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/multi_tests/test7.cpp b/tests/ECMAddTests/multi_tests/test7.cpp new file mode 100644 index 00000000..069859e7 --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test7.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test7.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/multi_tests/test8.cpp b/tests/ECMAddTests/multi_tests/test8.cpp new file mode 100644 index 00000000..ce762c8d --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test8.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test8.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/multi_tests/test9.cpp b/tests/ECMAddTests/multi_tests/test9.cpp new file mode 100644 index 00000000..e432aeba --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test9.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test9.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/single_tests/CMakeLists.txt b/tests/ECMAddTests/single_tests/CMakeLists.txt new file mode 100644 index 00000000..6af3857b --- /dev/null +++ b/tests/ECMAddTests/single_tests/CMakeLists.txt @@ -0,0 +1,122 @@ +project(ECMAddTests) +cmake_minimum_required(VERSION 2.8.12) + +set(ECM_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules) +set(CMAKE_MODULE_PATH "${ECM_MODULE_DIR}") + +add_library(testhelper STATIC ../testhelper.cpp) +target_include_directories(testhelper PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") + +enable_testing() + +include(ECMAddTests) + +# clean up to avoid false-positives from check_files.cmake +file(REMOVE + "${CMAKE_CURRENT_BINARY_DIR}/test1.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test2.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test3.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test4.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test5.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test6.txt" + ) + +ecm_add_test(test1.cpp + LINK_LIBRARIES testhelper + ) +# check target exists +get_property(_dummy TARGET test1 PROPERTY TYPE) +# check test exists +get_property(_dummy TEST test1 PROPERTY TIMEOUT) +get_property(_is_win32 TARGET test1 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test1 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test1 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test1 is an OS/X bundle when it should not be") +endif() + + +ecm_add_test(test2.cpp + LINK_LIBRARIES testhelper + TEST_NAME named_test + ) +get_property(_dummy TARGET named_test PROPERTY TYPE) +get_property(_dummy TEST named_test PROPERTY TIMEOUT) +get_property(_is_win32 TARGET named_test PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "named_test is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET named_test PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "named_test is an OS/X bundle when it should not be") +endif() + + +ecm_add_test(test3.cpp + LINK_LIBRARIES testhelper + NAME_PREFIX prefix_ + ) +get_property(_dummy TARGET test3 PROPERTY TYPE) +get_property(_dummy TEST prefix_test3 PROPERTY TIMEOUT) +get_property(_is_win32 TARGET test3 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test3 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test3 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test3 is an OS/X bundle when it should not be") +endif() + + +ecm_add_test(test4.cpp + LINK_LIBRARIES testhelper + GUI + ) +get_property(_dummy TARGET test4 PROPERTY TYPE) +get_property(_dummy TEST test4 PROPERTY TIMEOUT) +get_property(_is_win32 TARGET test4 PROPERTY WIN32_EXECUTABLE) +if (NOT _is_win32) + message(FATAL_ERROR "test4 is not a WIN32 executable when it should be") +endif() +get_property(_is_bundle TARGET test4 PROPERTY MACOSX_BUNDLE) +if (NOT _is_bundle) + message(FATAL_ERROR "test4 is not an OS/X bundle when it should be") +endif() + + +ecm_add_test(test5.cpp + LINK_LIBRARIES testhelper + TEST_NAME combined_test + NAME_PREFIX another_prefix_ + GUI + ) +get_property(_dummy TARGET combined_test PROPERTY TYPE) +get_property(_dummy TEST another_prefix_combined_test PROPERTY TIMEOUT) +get_property(_is_win32 TARGET combined_test PROPERTY WIN32_EXECUTABLE) +if (NOT _is_win32) + message(FATAL_ERROR "combined_test is not a WIN32 executable when it should be") +endif() +get_property(_is_bundle TARGET combined_test PROPERTY MACOSX_BUNDLE) +if (NOT _is_bundle) + message(FATAL_ERROR "combined_test is not an OS/X bundle when it should be") +endif() + + +ecm_add_test(test6.cpp test6body.cpp + LINK_LIBRARIES testhelper + TEST_NAME multifile_test + ) +get_property(_dummy TARGET multifile_test PROPERTY TYPE) +get_property(_dummy TEST multifile_test PROPERTY TIMEOUT) +get_property(_is_win32 TARGET multifile_test PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "multifile_test is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET multifile_test PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "multifile_test is an OS/X bundle when it should not be") +endif() + + diff --git a/tests/ECMAddTests/single_tests/test1.cpp b/tests/ECMAddTests/single_tests/test1.cpp new file mode 100644 index 00000000..e5482865 --- /dev/null +++ b/tests/ECMAddTests/single_tests/test1.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test1.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/single_tests/test2.cpp b/tests/ECMAddTests/single_tests/test2.cpp new file mode 100644 index 00000000..7f45bb56 --- /dev/null +++ b/tests/ECMAddTests/single_tests/test2.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test2.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/single_tests/test3.cpp b/tests/ECMAddTests/single_tests/test3.cpp new file mode 100644 index 00000000..142b2765 --- /dev/null +++ b/tests/ECMAddTests/single_tests/test3.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test3.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/single_tests/test4.cpp b/tests/ECMAddTests/single_tests/test4.cpp new file mode 100644 index 00000000..1ba9b148 --- /dev/null +++ b/tests/ECMAddTests/single_tests/test4.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test4.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/single_tests/test5.cpp b/tests/ECMAddTests/single_tests/test5.cpp new file mode 100644 index 00000000..987af36b --- /dev/null +++ b/tests/ECMAddTests/single_tests/test5.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test5.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/single_tests/test6.cpp b/tests/ECMAddTests/single_tests/test6.cpp new file mode 100644 index 00000000..33cd0421 --- /dev/null +++ b/tests/ECMAddTests/single_tests/test6.cpp @@ -0,0 +1,8 @@ +void test_body(); + +int main() +{ + test_body(); + return 0; +} + diff --git a/tests/ECMAddTests/single_tests/test6body.cpp b/tests/ECMAddTests/single_tests/test6body.cpp new file mode 100644 index 00000000..c3332738 --- /dev/null +++ b/tests/ECMAddTests/single_tests/test6body.cpp @@ -0,0 +1,7 @@ +#include "testhelper.h" + +void test_body() +{ + make_test_file("test6.txt"); +} + diff --git a/tests/ECMAddTests/testhelper.cpp b/tests/ECMAddTests/testhelper.cpp new file mode 100644 index 00000000..00d0ceed --- /dev/null +++ b/tests/ECMAddTests/testhelper.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" +#include +#include + +void make_test_file(const char *filename) +{ + std::ofstream(filename) << "test" << std::endl; +} diff --git a/tests/ECMAddTests/testhelper.h b/tests/ECMAddTests/testhelper.h new file mode 100644 index 00000000..9810ee41 --- /dev/null +++ b/tests/ECMAddTests/testhelper.h @@ -0,0 +1 @@ +void make_test_file(const char *filename); -- 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 +++-- tests/ECMAddTests/CMakeLists.txt | 3 + tests/ECMAddTests/multi_tests/CMakeLists.txt | 96 +++++++++++++++++++++------ tests/ECMAddTests/multi_tests/test10.cpp | 8 +++ tests/ECMAddTests/multi_tests/test11.cpp | 8 +++ tests/ECMAddTests/single_tests/CMakeLists.txt | 39 ++++++++--- tests/ECMAddTests/single_tests/test7.cpp | 8 +++ 7 files changed, 146 insertions(+), 32 deletions(-) create mode 100644 tests/ECMAddTests/multi_tests/test10.cpp create mode 100644 tests/ECMAddTests/multi_tests/test11.cpp create mode 100644 tests/ECMAddTests/single_tests/test7.cpp 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() diff --git a/tests/ECMAddTests/CMakeLists.txt b/tests/ECMAddTests/CMakeLists.txt index e77b33f9..b31934d4 100644 --- a/tests/ECMAddTests/CMakeLists.txt +++ b/tests/ECMAddTests/CMakeLists.txt @@ -34,6 +34,7 @@ add_check(single_tests test4.txt test5.txt test6.txt + test7.txt ) add_check(multi_tests test1.txt @@ -45,5 +46,7 @@ add_check(multi_tests test7.txt test8.txt test9.txt + test10.txt + test11.txt ) diff --git a/tests/ECMAddTests/multi_tests/CMakeLists.txt b/tests/ECMAddTests/multi_tests/CMakeLists.txt index ca434773..bad625b5 100644 --- a/tests/ECMAddTests/multi_tests/CMakeLists.txt +++ b/tests/ECMAddTests/multi_tests/CMakeLists.txt @@ -22,6 +22,8 @@ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test7.txt" "${CMAKE_CURRENT_BINARY_DIR}/test8.txt" "${CMAKE_CURRENT_BINARY_DIR}/test9.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test10.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test11.txt" ) ecm_add_tests( @@ -30,14 +32,6 @@ ecm_add_tests( test3.cpp LINK_LIBRARIES testhelper ) -# check targets exist -get_property(_dummy TARGET test1 PROPERTY TYPE) -get_property(_dummy TARGET test2 PROPERTY TYPE) -get_property(_dummy TARGET test3 PROPERTY TYPE) -# check tests exists -get_property(_dummy TEST test1 PROPERTY TIMEOUT) -get_property(_dummy TEST test2 PROPERTY TIMEOUT) -get_property(_dummy TEST test3 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test1 PROPERTY WIN32_EXECUTABLE) if (_is_win32) message(FATAL_ERROR "test1 is a WIN32 executable when it should not be") @@ -46,6 +40,9 @@ get_property(_is_bundle TARGET test1 PROPERTY MACOSX_BUNDLE) if (_is_bundle) message(FATAL_ERROR "test1 is an OS/X bundle when it should not be") endif() +# existence check +get_property(_dummy TEST test1 PROPERTY TIMEOUT) + get_property(_is_win32 TARGET test2 PROPERTY WIN32_EXECUTABLE) if (_is_win32) message(FATAL_ERROR "test2 is a WIN32 executable when it should not be") @@ -54,6 +51,17 @@ get_property(_is_bundle TARGET test2 PROPERTY MACOSX_BUNDLE) if (_is_bundle) message(FATAL_ERROR "test2 is an OS/X bundle when it should not be") endif() +get_property(_dummy TEST test2 PROPERTY TIMEOUT) + +get_property(_is_win32 TARGET test3 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test3 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test3 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test3 is an OS/X bundle when it should not be") +endif() +get_property(_dummy TEST test3 PROPERTY TIMEOUT) ecm_add_tests( @@ -62,10 +70,6 @@ ecm_add_tests( LINK_LIBRARIES testhelper NAME_PREFIX pref_ ) -get_property(_dummy TARGET test4 PROPERTY TYPE) -get_property(_dummy TARGET test5 PROPERTY TYPE) -get_property(_dummy TEST pref_test4 PROPERTY TIMEOUT) -get_property(_dummy TEST pref_test5 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test4 PROPERTY WIN32_EXECUTABLE) if (_is_win32) message(FATAL_ERROR "test4 is a WIN32 executable when it should not be") @@ -74,6 +78,8 @@ get_property(_is_bundle TARGET test4 PROPERTY MACOSX_BUNDLE) if (_is_bundle) message(FATAL_ERROR "test4 is an OS/X bundle when it should not be") endif() +get_property(_dummy TEST pref_test4 PROPERTY TIMEOUT) + get_property(_is_win32 TARGET test5 PROPERTY WIN32_EXECUTABLE) if (_is_win32) message(FATAL_ERROR "test5 is a WIN32 executable when it should not be") @@ -82,6 +88,7 @@ get_property(_is_bundle TARGET test5 PROPERTY MACOSX_BUNDLE) if (_is_bundle) message(FATAL_ERROR "test5 is an OS/X bundle when it should not be") endif() +get_property(_dummy TEST pref_test5 PROPERTY TIMEOUT) ecm_add_tests( @@ -90,10 +97,6 @@ ecm_add_tests( LINK_LIBRARIES testhelper GUI ) -get_property(_dummy TARGET test6 PROPERTY TYPE) -get_property(_dummy TARGET test7 PROPERTY TYPE) -get_property(_dummy TEST test6 PROPERTY TIMEOUT) -get_property(_dummy TEST test7 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test6 PROPERTY WIN32_EXECUTABLE) if (NOT _is_win32) message(FATAL_ERROR "test6 is not a WIN32 executable when it should be") @@ -102,6 +105,8 @@ get_property(_is_bundle TARGET test6 PROPERTY MACOSX_BUNDLE) if (NOT _is_bundle) message(FATAL_ERROR "test6 is not an OS/X bundle when it should be") endif() +get_property(_dummy TEST test6 PROPERTY TIMEOUT) + get_property(_is_win32 TARGET test7 PROPERTY WIN32_EXECUTABLE) if (NOT _is_win32) message(FATAL_ERROR "test7 is not a WIN32 executable when it should be") @@ -110,6 +115,7 @@ get_property(_is_bundle TARGET test7 PROPERTY MACOSX_BUNDLE) if (NOT _is_bundle) message(FATAL_ERROR "test7 is not an OS/X bundle when it should be") endif() +get_property(_dummy TEST test7 PROPERTY TIMEOUT) ecm_add_tests( @@ -118,11 +124,9 @@ ecm_add_tests( LINK_LIBRARIES testhelper NAME_PREFIX p_ GUI + PROPERTIES + LABELS "somelabel" ) -get_property(_dummy TARGET test8 PROPERTY TYPE) -get_property(_dummy TARGET test9 PROPERTY TYPE) -get_property(_dummy TEST p_test8 PROPERTY TIMEOUT) -get_property(_dummy TEST p_test9 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test8 PROPERTY WIN32_EXECUTABLE) if (NOT _is_win32) message(FATAL_ERROR "test8 is not a WIN32 executable when it should be") @@ -131,6 +135,11 @@ get_property(_is_bundle TARGET test8 PROPERTY MACOSX_BUNDLE) if (NOT _is_bundle) message(FATAL_ERROR "test8 is not an OS/X bundle when it should be") endif() +get_property(_labels TEST p_test8 PROPERTY LABELS) +if (NOT _labels STREQUAL "somelabel") + message(FATAL_ERROR "p_test8 LABELS property was \"${_labels}\", expected \"somelabel\"") +endif() + get_property(_is_win32 TARGET test9 PROPERTY WIN32_EXECUTABLE) if (NOT _is_win32) message(FATAL_ERROR "test9 is not a WIN32 executable when it should be") @@ -139,4 +148,51 @@ get_property(_is_bundle TARGET test9 PROPERTY MACOSX_BUNDLE) if (NOT _is_bundle) message(FATAL_ERROR "test9 is not an OS/X bundle when it should be") endif() +get_property(_labels TEST p_test9 PROPERTY LABELS) +if (NOT _labels STREQUAL "somelabel") + message(FATAL_ERROR "p_test9 LABELS property was \"${_labels}\", expected \"somelabel\"") +endif() + + +ecm_add_tests( + test10.cpp + test11.cpp + LINK_LIBRARIES testhelper + PROPERTIES + LABELS "somelabel" + RUN_SERIAL TRUE + ) +get_property(_is_win32 TARGET test10 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test10 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test10 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test10 is an OS/X bundle when it should not be") +endif() +get_property(_labels TEST test10 PROPERTY LABELS) +if (NOT _labels STREQUAL "somelabel") + message(FATAL_ERROR "test10 LABELS property was \"${_labels}\", expected \"somelabel\"") +endif() +get_property(_run_serial TEST test10 PROPERTY RUN_SERIAL) +if (NOT _run_serial) + message(FATAL_ERROR "test10 LABELS property was \"${_run_serial}\", expected TRUE") +endif() + +get_property(_is_win32 TARGET test11 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test11 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test11 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test11 is an OS/X bundle when it should not be") +endif() +get_property(_labels TEST test11 PROPERTY LABELS) +if (NOT _labels STREQUAL "somelabel") + message(FATAL_ERROR "test11 LABELS property was \"${_labels}\", expected \"somelabel\"") +endif() +get_property(_run_serial TEST test11 PROPERTY RUN_SERIAL) +if (NOT _run_serial) + message(FATAL_ERROR "test11 LABELS property was \"${_run_serial}\", expected TRUE") +endif() diff --git a/tests/ECMAddTests/multi_tests/test10.cpp b/tests/ECMAddTests/multi_tests/test10.cpp new file mode 100644 index 00000000..a34a39df --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test10.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test10.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/multi_tests/test11.cpp b/tests/ECMAddTests/multi_tests/test11.cpp new file mode 100644 index 00000000..82641bbc --- /dev/null +++ b/tests/ECMAddTests/multi_tests/test11.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test11.txt"); + return 0; +} + diff --git a/tests/ECMAddTests/single_tests/CMakeLists.txt b/tests/ECMAddTests/single_tests/CMakeLists.txt index 6af3857b..de1ae6f6 100644 --- a/tests/ECMAddTests/single_tests/CMakeLists.txt +++ b/tests/ECMAddTests/single_tests/CMakeLists.txt @@ -19,13 +19,12 @@ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test4.txt" "${CMAKE_CURRENT_BINARY_DIR}/test5.txt" "${CMAKE_CURRENT_BINARY_DIR}/test6.txt" + "${CMAKE_CURRENT_BINARY_DIR}/test7.txt" ) ecm_add_test(test1.cpp LINK_LIBRARIES testhelper ) -# check target exists -get_property(_dummy TARGET test1 PROPERTY TYPE) # check test exists get_property(_dummy TEST test1 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test1 PROPERTY WIN32_EXECUTABLE) @@ -42,7 +41,6 @@ ecm_add_test(test2.cpp LINK_LIBRARIES testhelper TEST_NAME named_test ) -get_property(_dummy TARGET named_test PROPERTY TYPE) get_property(_dummy TEST named_test PROPERTY TIMEOUT) get_property(_is_win32 TARGET named_test PROPERTY WIN32_EXECUTABLE) if (_is_win32) @@ -58,7 +56,6 @@ ecm_add_test(test3.cpp LINK_LIBRARIES testhelper NAME_PREFIX prefix_ ) -get_property(_dummy TARGET test3 PROPERTY TYPE) get_property(_dummy TEST prefix_test3 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test3 PROPERTY WIN32_EXECUTABLE) if (_is_win32) @@ -74,7 +71,6 @@ ecm_add_test(test4.cpp LINK_LIBRARIES testhelper GUI ) -get_property(_dummy TARGET test4 PROPERTY TYPE) get_property(_dummy TEST test4 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test4 PROPERTY WIN32_EXECUTABLE) if (NOT _is_win32) @@ -91,9 +87,10 @@ ecm_add_test(test5.cpp TEST_NAME combined_test NAME_PREFIX another_prefix_ GUI + PROPERTIES + LABELS "lab" + RUN_SERIAL TRUE ) -get_property(_dummy TARGET combined_test PROPERTY TYPE) -get_property(_dummy TEST another_prefix_combined_test PROPERTY TIMEOUT) get_property(_is_win32 TARGET combined_test PROPERTY WIN32_EXECUTABLE) if (NOT _is_win32) message(FATAL_ERROR "combined_test is not a WIN32 executable when it should be") @@ -102,13 +99,20 @@ get_property(_is_bundle TARGET combined_test PROPERTY MACOSX_BUNDLE) if (NOT _is_bundle) message(FATAL_ERROR "combined_test is not an OS/X bundle when it should be") endif() +get_property(_labels TEST another_prefix_combined_test PROPERTY LABELS) +if (NOT _labels STREQUAL "lab") + message(FATAL_ERROR "another_prefix_combined_test LABELS property was \"${_labels}\", expected \"lab\"") +endif() +get_property(_run_serial TEST another_prefix_combined_test PROPERTY RUN_SERIAL) +if (NOT _run_serial) + message(FATAL_ERROR "another_prefix_combined_test LABELS property was \"${_run_serial}\", expected TRUE") +endif() ecm_add_test(test6.cpp test6body.cpp LINK_LIBRARIES testhelper TEST_NAME multifile_test ) -get_property(_dummy TARGET multifile_test PROPERTY TYPE) get_property(_dummy TEST multifile_test PROPERTY TIMEOUT) get_property(_is_win32 TARGET multifile_test PROPERTY WIN32_EXECUTABLE) if (_is_win32) @@ -120,3 +124,22 @@ if (_is_bundle) endif() +ecm_add_test(test7.cpp + LINK_LIBRARIES testhelper + PROPERTIES + LABELS "somelabel" + ) +get_property(_dummy TEST test7 PROPERTY TIMEOUT) +get_property(_is_win32 TARGET test7 PROPERTY WIN32_EXECUTABLE) +if (_is_win32) + message(FATAL_ERROR "test7 is a WIN32 executable when it should not be") +endif() +get_property(_is_bundle TARGET test7 PROPERTY MACOSX_BUNDLE) +if (_is_bundle) + message(FATAL_ERROR "test7 is an OS/X bundle when it should not be") +endif() +get_property(_labels TEST test7 PROPERTY LABELS) +if (NOT _labels STREQUAL "somelabel") + message(FATAL_ERROR "test7 LABELS property was \"${_labels}\", expected \"somelabel\"") +endif() + diff --git a/tests/ECMAddTests/single_tests/test7.cpp b/tests/ECMAddTests/single_tests/test7.cpp new file mode 100644 index 00000000..069859e7 --- /dev/null +++ b/tests/ECMAddTests/single_tests/test7.cpp @@ -0,0 +1,8 @@ +#include "testhelper.h" + +int main() +{ + make_test_file("test7.txt"); + return 0; +} + -- 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 ++--- tests/ECMAddTests/CMakeLists.txt | 3 - tests/ECMAddTests/multi_tests/CMakeLists.txt | 96 ++++++--------------------- tests/ECMAddTests/multi_tests/test10.cpp | 8 --- tests/ECMAddTests/multi_tests/test11.cpp | 8 --- tests/ECMAddTests/single_tests/CMakeLists.txt | 39 +++-------- tests/ECMAddTests/single_tests/test7.cpp | 8 --- 7 files changed, 32 insertions(+), 146 deletions(-) delete mode 100644 tests/ECMAddTests/multi_tests/test10.cpp delete mode 100644 tests/ECMAddTests/multi_tests/test11.cpp delete mode 100644 tests/ECMAddTests/single_tests/test7.cpp 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() diff --git a/tests/ECMAddTests/CMakeLists.txt b/tests/ECMAddTests/CMakeLists.txt index b31934d4..e77b33f9 100644 --- a/tests/ECMAddTests/CMakeLists.txt +++ b/tests/ECMAddTests/CMakeLists.txt @@ -34,7 +34,6 @@ add_check(single_tests test4.txt test5.txt test6.txt - test7.txt ) add_check(multi_tests test1.txt @@ -46,7 +45,5 @@ add_check(multi_tests test7.txt test8.txt test9.txt - test10.txt - test11.txt ) diff --git a/tests/ECMAddTests/multi_tests/CMakeLists.txt b/tests/ECMAddTests/multi_tests/CMakeLists.txt index bad625b5..ca434773 100644 --- a/tests/ECMAddTests/multi_tests/CMakeLists.txt +++ b/tests/ECMAddTests/multi_tests/CMakeLists.txt @@ -22,8 +22,6 @@ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test7.txt" "${CMAKE_CURRENT_BINARY_DIR}/test8.txt" "${CMAKE_CURRENT_BINARY_DIR}/test9.txt" - "${CMAKE_CURRENT_BINARY_DIR}/test10.txt" - "${CMAKE_CURRENT_BINARY_DIR}/test11.txt" ) ecm_add_tests( @@ -32,6 +30,14 @@ ecm_add_tests( test3.cpp LINK_LIBRARIES testhelper ) +# check targets exist +get_property(_dummy TARGET test1 PROPERTY TYPE) +get_property(_dummy TARGET test2 PROPERTY TYPE) +get_property(_dummy TARGET test3 PROPERTY TYPE) +# check tests exists +get_property(_dummy TEST test1 PROPERTY TIMEOUT) +get_property(_dummy TEST test2 PROPERTY TIMEOUT) +get_property(_dummy TEST test3 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test1 PROPERTY WIN32_EXECUTABLE) if (_is_win32) message(FATAL_ERROR "test1 is a WIN32 executable when it should not be") @@ -40,9 +46,6 @@ get_property(_is_bundle TARGET test1 PROPERTY MACOSX_BUNDLE) if (_is_bundle) message(FATAL_ERROR "test1 is an OS/X bundle when it should not be") endif() -# existence check -get_property(_dummy TEST test1 PROPERTY TIMEOUT) - get_property(_is_win32 TARGET test2 PROPERTY WIN32_EXECUTABLE) if (_is_win32) message(FATAL_ERROR "test2 is a WIN32 executable when it should not be") @@ -51,17 +54,6 @@ get_property(_is_bundle TARGET test2 PROPERTY MACOSX_BUNDLE) if (_is_bundle) message(FATAL_ERROR "test2 is an OS/X bundle when it should not be") endif() -get_property(_dummy TEST test2 PROPERTY TIMEOUT) - -get_property(_is_win32 TARGET test3 PROPERTY WIN32_EXECUTABLE) -if (_is_win32) - message(FATAL_ERROR "test3 is a WIN32 executable when it should not be") -endif() -get_property(_is_bundle TARGET test3 PROPERTY MACOSX_BUNDLE) -if (_is_bundle) - message(FATAL_ERROR "test3 is an OS/X bundle when it should not be") -endif() -get_property(_dummy TEST test3 PROPERTY TIMEOUT) ecm_add_tests( @@ -70,6 +62,10 @@ ecm_add_tests( LINK_LIBRARIES testhelper NAME_PREFIX pref_ ) +get_property(_dummy TARGET test4 PROPERTY TYPE) +get_property(_dummy TARGET test5 PROPERTY TYPE) +get_property(_dummy TEST pref_test4 PROPERTY TIMEOUT) +get_property(_dummy TEST pref_test5 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test4 PROPERTY WIN32_EXECUTABLE) if (_is_win32) message(FATAL_ERROR "test4 is a WIN32 executable when it should not be") @@ -78,8 +74,6 @@ get_property(_is_bundle TARGET test4 PROPERTY MACOSX_BUNDLE) if (_is_bundle) message(FATAL_ERROR "test4 is an OS/X bundle when it should not be") endif() -get_property(_dummy TEST pref_test4 PROPERTY TIMEOUT) - get_property(_is_win32 TARGET test5 PROPERTY WIN32_EXECUTABLE) if (_is_win32) message(FATAL_ERROR "test5 is a WIN32 executable when it should not be") @@ -88,7 +82,6 @@ get_property(_is_bundle TARGET test5 PROPERTY MACOSX_BUNDLE) if (_is_bundle) message(FATAL_ERROR "test5 is an OS/X bundle when it should not be") endif() -get_property(_dummy TEST pref_test5 PROPERTY TIMEOUT) ecm_add_tests( @@ -97,6 +90,10 @@ ecm_add_tests( LINK_LIBRARIES testhelper GUI ) +get_property(_dummy TARGET test6 PROPERTY TYPE) +get_property(_dummy TARGET test7 PROPERTY TYPE) +get_property(_dummy TEST test6 PROPERTY TIMEOUT) +get_property(_dummy TEST test7 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test6 PROPERTY WIN32_EXECUTABLE) if (NOT _is_win32) message(FATAL_ERROR "test6 is not a WIN32 executable when it should be") @@ -105,8 +102,6 @@ get_property(_is_bundle TARGET test6 PROPERTY MACOSX_BUNDLE) if (NOT _is_bundle) message(FATAL_ERROR "test6 is not an OS/X bundle when it should be") endif() -get_property(_dummy TEST test6 PROPERTY TIMEOUT) - get_property(_is_win32 TARGET test7 PROPERTY WIN32_EXECUTABLE) if (NOT _is_win32) message(FATAL_ERROR "test7 is not a WIN32 executable when it should be") @@ -115,7 +110,6 @@ get_property(_is_bundle TARGET test7 PROPERTY MACOSX_BUNDLE) if (NOT _is_bundle) message(FATAL_ERROR "test7 is not an OS/X bundle when it should be") endif() -get_property(_dummy TEST test7 PROPERTY TIMEOUT) ecm_add_tests( @@ -124,9 +118,11 @@ ecm_add_tests( LINK_LIBRARIES testhelper NAME_PREFIX p_ GUI - PROPERTIES - LABELS "somelabel" ) +get_property(_dummy TARGET test8 PROPERTY TYPE) +get_property(_dummy TARGET test9 PROPERTY TYPE) +get_property(_dummy TEST p_test8 PROPERTY TIMEOUT) +get_property(_dummy TEST p_test9 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test8 PROPERTY WIN32_EXECUTABLE) if (NOT _is_win32) message(FATAL_ERROR "test8 is not a WIN32 executable when it should be") @@ -135,11 +131,6 @@ get_property(_is_bundle TARGET test8 PROPERTY MACOSX_BUNDLE) if (NOT _is_bundle) message(FATAL_ERROR "test8 is not an OS/X bundle when it should be") endif() -get_property(_labels TEST p_test8 PROPERTY LABELS) -if (NOT _labels STREQUAL "somelabel") - message(FATAL_ERROR "p_test8 LABELS property was \"${_labels}\", expected \"somelabel\"") -endif() - get_property(_is_win32 TARGET test9 PROPERTY WIN32_EXECUTABLE) if (NOT _is_win32) message(FATAL_ERROR "test9 is not a WIN32 executable when it should be") @@ -148,51 +139,4 @@ get_property(_is_bundle TARGET test9 PROPERTY MACOSX_BUNDLE) if (NOT _is_bundle) message(FATAL_ERROR "test9 is not an OS/X bundle when it should be") endif() -get_property(_labels TEST p_test9 PROPERTY LABELS) -if (NOT _labels STREQUAL "somelabel") - message(FATAL_ERROR "p_test9 LABELS property was \"${_labels}\", expected \"somelabel\"") -endif() - - -ecm_add_tests( - test10.cpp - test11.cpp - LINK_LIBRARIES testhelper - PROPERTIES - LABELS "somelabel" - RUN_SERIAL TRUE - ) -get_property(_is_win32 TARGET test10 PROPERTY WIN32_EXECUTABLE) -if (_is_win32) - message(FATAL_ERROR "test10 is a WIN32 executable when it should not be") -endif() -get_property(_is_bundle TARGET test10 PROPERTY MACOSX_BUNDLE) -if (_is_bundle) - message(FATAL_ERROR "test10 is an OS/X bundle when it should not be") -endif() -get_property(_labels TEST test10 PROPERTY LABELS) -if (NOT _labels STREQUAL "somelabel") - message(FATAL_ERROR "test10 LABELS property was \"${_labels}\", expected \"somelabel\"") -endif() -get_property(_run_serial TEST test10 PROPERTY RUN_SERIAL) -if (NOT _run_serial) - message(FATAL_ERROR "test10 LABELS property was \"${_run_serial}\", expected TRUE") -endif() - -get_property(_is_win32 TARGET test11 PROPERTY WIN32_EXECUTABLE) -if (_is_win32) - message(FATAL_ERROR "test11 is a WIN32 executable when it should not be") -endif() -get_property(_is_bundle TARGET test11 PROPERTY MACOSX_BUNDLE) -if (_is_bundle) - message(FATAL_ERROR "test11 is an OS/X bundle when it should not be") -endif() -get_property(_labels TEST test11 PROPERTY LABELS) -if (NOT _labels STREQUAL "somelabel") - message(FATAL_ERROR "test11 LABELS property was \"${_labels}\", expected \"somelabel\"") -endif() -get_property(_run_serial TEST test11 PROPERTY RUN_SERIAL) -if (NOT _run_serial) - message(FATAL_ERROR "test11 LABELS property was \"${_run_serial}\", expected TRUE") -endif() diff --git a/tests/ECMAddTests/multi_tests/test10.cpp b/tests/ECMAddTests/multi_tests/test10.cpp deleted file mode 100644 index a34a39df..00000000 --- a/tests/ECMAddTests/multi_tests/test10.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "testhelper.h" - -int main() -{ - make_test_file("test10.txt"); - return 0; -} - diff --git a/tests/ECMAddTests/multi_tests/test11.cpp b/tests/ECMAddTests/multi_tests/test11.cpp deleted file mode 100644 index 82641bbc..00000000 --- a/tests/ECMAddTests/multi_tests/test11.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "testhelper.h" - -int main() -{ - make_test_file("test11.txt"); - return 0; -} - diff --git a/tests/ECMAddTests/single_tests/CMakeLists.txt b/tests/ECMAddTests/single_tests/CMakeLists.txt index de1ae6f6..6af3857b 100644 --- a/tests/ECMAddTests/single_tests/CMakeLists.txt +++ b/tests/ECMAddTests/single_tests/CMakeLists.txt @@ -19,12 +19,13 @@ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test4.txt" "${CMAKE_CURRENT_BINARY_DIR}/test5.txt" "${CMAKE_CURRENT_BINARY_DIR}/test6.txt" - "${CMAKE_CURRENT_BINARY_DIR}/test7.txt" ) ecm_add_test(test1.cpp LINK_LIBRARIES testhelper ) +# check target exists +get_property(_dummy TARGET test1 PROPERTY TYPE) # check test exists get_property(_dummy TEST test1 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test1 PROPERTY WIN32_EXECUTABLE) @@ -41,6 +42,7 @@ ecm_add_test(test2.cpp LINK_LIBRARIES testhelper TEST_NAME named_test ) +get_property(_dummy TARGET named_test PROPERTY TYPE) get_property(_dummy TEST named_test PROPERTY TIMEOUT) get_property(_is_win32 TARGET named_test PROPERTY WIN32_EXECUTABLE) if (_is_win32) @@ -56,6 +58,7 @@ ecm_add_test(test3.cpp LINK_LIBRARIES testhelper NAME_PREFIX prefix_ ) +get_property(_dummy TARGET test3 PROPERTY TYPE) get_property(_dummy TEST prefix_test3 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test3 PROPERTY WIN32_EXECUTABLE) if (_is_win32) @@ -71,6 +74,7 @@ ecm_add_test(test4.cpp LINK_LIBRARIES testhelper GUI ) +get_property(_dummy TARGET test4 PROPERTY TYPE) get_property(_dummy TEST test4 PROPERTY TIMEOUT) get_property(_is_win32 TARGET test4 PROPERTY WIN32_EXECUTABLE) if (NOT _is_win32) @@ -87,10 +91,9 @@ ecm_add_test(test5.cpp TEST_NAME combined_test NAME_PREFIX another_prefix_ GUI - PROPERTIES - LABELS "lab" - RUN_SERIAL TRUE ) +get_property(_dummy TARGET combined_test PROPERTY TYPE) +get_property(_dummy TEST another_prefix_combined_test PROPERTY TIMEOUT) get_property(_is_win32 TARGET combined_test PROPERTY WIN32_EXECUTABLE) if (NOT _is_win32) message(FATAL_ERROR "combined_test is not a WIN32 executable when it should be") @@ -99,20 +102,13 @@ get_property(_is_bundle TARGET combined_test PROPERTY MACOSX_BUNDLE) if (NOT _is_bundle) message(FATAL_ERROR "combined_test is not an OS/X bundle when it should be") endif() -get_property(_labels TEST another_prefix_combined_test PROPERTY LABELS) -if (NOT _labels STREQUAL "lab") - message(FATAL_ERROR "another_prefix_combined_test LABELS property was \"${_labels}\", expected \"lab\"") -endif() -get_property(_run_serial TEST another_prefix_combined_test PROPERTY RUN_SERIAL) -if (NOT _run_serial) - message(FATAL_ERROR "another_prefix_combined_test LABELS property was \"${_run_serial}\", expected TRUE") -endif() ecm_add_test(test6.cpp test6body.cpp LINK_LIBRARIES testhelper TEST_NAME multifile_test ) +get_property(_dummy TARGET multifile_test PROPERTY TYPE) get_property(_dummy TEST multifile_test PROPERTY TIMEOUT) get_property(_is_win32 TARGET multifile_test PROPERTY WIN32_EXECUTABLE) if (_is_win32) @@ -124,22 +120,3 @@ if (_is_bundle) endif() -ecm_add_test(test7.cpp - LINK_LIBRARIES testhelper - PROPERTIES - LABELS "somelabel" - ) -get_property(_dummy TEST test7 PROPERTY TIMEOUT) -get_property(_is_win32 TARGET test7 PROPERTY WIN32_EXECUTABLE) -if (_is_win32) - message(FATAL_ERROR "test7 is a WIN32 executable when it should not be") -endif() -get_property(_is_bundle TARGET test7 PROPERTY MACOSX_BUNDLE) -if (_is_bundle) - message(FATAL_ERROR "test7 is an OS/X bundle when it should not be") -endif() -get_property(_labels TEST test7 PROPERTY LABELS) -if (NOT _labels STREQUAL "somelabel") - message(FATAL_ERROR "test7 LABELS property was \"${_labels}\", expected \"somelabel\"") -endif() - diff --git a/tests/ECMAddTests/single_tests/test7.cpp b/tests/ECMAddTests/single_tests/test7.cpp deleted file mode 100644 index 069859e7..00000000 --- a/tests/ECMAddTests/single_tests/test7.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "testhelper.h" - -int main() -{ - make_test_file("test7.txt"); - return 0; -} - -- 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(-) 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 ++++++++++++++++++++-------- tests/ECMAddTests/multi_tests/CMakeLists.txt | 13 ++++++ tests/test_helpers.cmake | 28 +++++++++++++ 3 files changed, 86 insertions(+), 17 deletions(-) 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() diff --git a/tests/ECMAddTests/multi_tests/CMakeLists.txt b/tests/ECMAddTests/multi_tests/CMakeLists.txt index ca434773..0133c7d6 100644 --- a/tests/ECMAddTests/multi_tests/CMakeLists.txt +++ b/tests/ECMAddTests/multi_tests/CMakeLists.txt @@ -10,6 +10,7 @@ target_include_directories(testhelper PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") enable_testing() include(ECMAddTests) +include(../../test_helpers.cmake) # clean up to avoid false-positives from check_files.cmake file(REMOVE @@ -24,12 +25,18 @@ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test9.txt" ) +set(exp_target_names "test1;test2;test3") +set(exp_test_names "test1;test2;test3") ecm_add_tests( test1.cpp test2.cpp test3.cpp LINK_LIBRARIES testhelper + TARGET_NAMES_VAR target_names + TEST_NAMES_VAR test_names ) +assert_vars_setequal(target_names exp_target_names) +assert_vars_setequal(test_names exp_test_names) # check targets exist get_property(_dummy TARGET test1 PROPERTY TYPE) get_property(_dummy TARGET test2 PROPERTY TYPE) @@ -112,13 +119,19 @@ if (NOT _is_bundle) endif() +set(exp_target_names "test8;test9") +set(exp_test_names "p_test8;p_test9") ecm_add_tests( test8.cpp test9.cpp LINK_LIBRARIES testhelper NAME_PREFIX p_ GUI + TARGET_NAMES_VAR target_names + TEST_NAMES_VAR test_names ) +assert_vars_setequal(target_names exp_target_names) +assert_vars_setequal(test_names exp_test_names) get_property(_dummy TARGET test8 PROPERTY TYPE) get_property(_dummy TARGET test9 PROPERTY TYPE) get_property(_dummy TEST p_test8 PROPERTY TIMEOUT) diff --git a/tests/test_helpers.cmake b/tests/test_helpers.cmake index 73be343e..d9314d25 100644 --- a/tests/test_helpers.cmake +++ b/tests/test_helpers.cmake @@ -62,3 +62,31 @@ macro(assert_var_absolute_path varname) endif() endmacro() +function(assert_vars_setequal varname exp_varname) + if(ARGC LESS 3 OR NOT "${ARGV2}" STREQUAL "ALLOW_UNDEFINED") + assert_var_defined(${varname}) + endif() + # need real variables + set(list1 "${${varname}}") + set(list2 "${${exp_varname}}") + list(LENGTH list1 list1_len) + list(LENGTH list2 list2_len) + set(same_els FALSE) + if(list1_len EQUAL list2_len) + set(same_els TRUE) + foreach(item ${list1}) + list(FIND list2 "${item}" pos) + if(pos EQUAL "-1") + set(same_els FALSE) + break() + else() + # deal nicely with duplicates + list(REMOVE_AT list2 "${pos}") + endif() + endforeach() + endif() + if(NOT same_els) + message(SEND_ERROR "${varname} is '${${varname}}', expecting '${${exp_varname}}'.") + endif() +endfunction() + -- cgit v1.2.1 From ef88a6683a2578679b3c98396a9ee3001db69541 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 31 May 2015 21:38:50 +0200 Subject: Fix test on OSX, no bundle expected here. CI said: Linking C executable dummy.app/Contents/MacOS/dummy Built target dummy Could not find path to executable, perhaps it was not built: dummy REVIEW: 123969 --- tests/ExecuteKDEModules/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/ExecuteKDEModules/CMakeLists.txt b/tests/ExecuteKDEModules/CMakeLists.txt index d70ea908..69a19a31 100644 --- a/tests/ExecuteKDEModules/CMakeLists.txt +++ b/tests/ExecuteKDEModules/CMakeLists.txt @@ -7,11 +7,12 @@ set(all_kde_modules KDECMakeSettings KDECompilerSettings KDEFrameworkCompilerSettings + ECMMarkNonGuiExecutable ) set(ECM_KDE_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../kde-modules) set(ECM_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../modules) -set(CMAKE_MODULE_PATH "${ECM_KDE_MODULE_DIR}") +set(CMAKE_MODULE_PATH "${ECM_KDE_MODULE_DIR}" "${ECM_MODULE_DIR}") foreach(module ${all_kde_modules}) message(STATUS "module: ${module}") @@ -19,4 +20,6 @@ foreach(module ${all_kde_modules}) endforeach() add_executable(dummy main.c) +ecm_mark_nongui_executable(dummy) + set_target_properties(dummy PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -- cgit v1.2.1 From cb42a57b1da01b51ce02f86f9a57b5ddbe5196d0 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Fri, 12 Jun 2015 22:23:49 +0000 Subject: Upgrade ECM version to 5.12.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f04fc8b..2c1856b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(extra-cmake-modules NONE) set(ECM_MAJOR_VERSION 5) -set(ECM_MINOR_VERSION 11) +set(ECM_MINOR_VERSION 12) set(ECM_PATCH_VERSION 0) set(ECM_VERSION ${ECM_MAJOR_VERSION}.${ECM_MINOR_VERSION}.${ECM_PATCH_VERSION}) -- 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(-) 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 097c1cf0c2f7c3200abec6bf3fa895073bd25bf0 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Fri, 10 Jul 2015 10:07:44 +0000 Subject: Upgrade ECM version to 5.13.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c1856b3..95329169 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(extra-cmake-modules NONE) set(ECM_MAJOR_VERSION 5) -set(ECM_MINOR_VERSION 12) +set(ECM_MINOR_VERSION 13) set(ECM_PATCH_VERSION 0) set(ECM_VERSION ${ECM_MAJOR_VERSION}.${ECM_MINOR_VERSION}.${ECM_PATCH_VERSION}) -- cgit v1.2.1 From e475b3a68751fae3dc93ec9e7abb9db420eb0fa2 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Wed, 12 Aug 2015 12:29:34 +0000 Subject: Upgrade ECM version to 5.14.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95329169..af9a891a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(extra-cmake-modules NONE) set(ECM_MAJOR_VERSION 5) -set(ECM_MINOR_VERSION 13) +set(ECM_MINOR_VERSION 14) set(ECM_PATCH_VERSION 0) set(ECM_VERSION ${ECM_MAJOR_VERSION}.${ECM_MINOR_VERSION}.${ECM_PATCH_VERSION}) -- cgit v1.2.1 From 2b0951d3b6b3740b12a2cc3eedf8b3d1f6eba943 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Sun, 16 Aug 2015 09:43:29 +0200 Subject: Also set the default visibility for C code to hidden. This prevents accidental "leaking" of symbols from internal code, such as flex/bison generated parsers. REVIEW: 124740 --- kde-modules/KDECompilerSettings.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/kde-modules/KDECompilerSettings.cmake b/kde-modules/KDECompilerSettings.cmake index 5a585021..73d77825 100644 --- a/kde-modules/KDECompilerSettings.cmake +++ b/kde-modules/KDECompilerSettings.cmake @@ -196,6 +196,7 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR endif() # Default to hidden visibility for symbols +set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) -- cgit v1.2.1 From 00b1f67ef595c6fd2b326738ea7ac03c0e23303b Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 16 Aug 2015 01:16:04 +0200 Subject: KDEFrameworkCompilerSettings: only enable strict iterators in debug mode (they are slower). And enable them on MSVC now that we rely on Qt 5.3, as the comment said. REVIEW: 124762 --- kde-modules/KDEFrameworkCompilerSettings.cmake | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/kde-modules/KDEFrameworkCompilerSettings.cmake b/kde-modules/KDEFrameworkCompilerSettings.cmake index 1bc23ccf..d499444f 100644 --- a/kde-modules/KDEFrameworkCompilerSettings.cmake +++ b/kde-modules/KDEFrameworkCompilerSettings.cmake @@ -40,11 +40,7 @@ add_definitions(-DQT_NO_CAST_TO_ASCII -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_QSTRINGBUILDER ) -if(NOT MSVC) - # QT_STRICT_ITERATORS breaks MSVC: it tries to link to QTypedArrayData symbols - # when using foreach. However these symbols don't actually exist. - # Not having QT_STRICT_ITERATORS defined fixes this issue. - # This is fixed by https://codereview.qt-project.org/#change,76311 - # TODO: set QT_STRICT_ITERATORS on all platforms once we depend on Qt 5.3 - add_definitions(-DQT_STRICT_ITERATORS) + +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-DQT_STRICT_ITERATORS) endif() -- cgit v1.2.1 From 7af8bdcc7610df1de24c36ceeedd8c9f82529634 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 16 Aug 2015 01:20:04 +0200 Subject: Add -pedantic for KF5 code (when using gcc or clang) REVIEW: 124763 --- kde-modules/KDEFrameworkCompilerSettings.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kde-modules/KDEFrameworkCompilerSettings.cmake b/kde-modules/KDEFrameworkCompilerSettings.cmake index d499444f..84de77ab 100644 --- a/kde-modules/KDEFrameworkCompilerSettings.cmake +++ b/kde-modules/KDEFrameworkCompilerSettings.cmake @@ -44,3 +44,7 @@ add_definitions(-DQT_NO_CAST_TO_ASCII if (CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions(-DQT_STRICT_ITERATORS) endif() + +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") +endif() -- 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 --- docs/module/ECMQtDeclareLoggingCategory.rst | 1 + modules/ECMQtDeclareLoggingCategory.cmake | 118 +++++++++++++++++++++ modules/ECMQtDeclareLoggingCategory.cpp.in | 11 ++ modules/ECMQtDeclareLoggingCategory.h.in | 11 ++ tests/CMakeLists.txt | 3 + .../ECMQtDeclareLoggingCategoryTest/CMakeLists.txt | 42 ++++++++ tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp | 83 +++++++++++++++ 7 files changed, 269 insertions(+) create mode 100644 docs/module/ECMQtDeclareLoggingCategory.rst create mode 100644 modules/ECMQtDeclareLoggingCategory.cmake create mode 100644 modules/ECMQtDeclareLoggingCategory.cpp.in create mode 100644 modules/ECMQtDeclareLoggingCategory.h.in create mode 100644 tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt create mode 100644 tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp diff --git a/docs/module/ECMQtDeclareLoggingCategory.rst b/docs/module/ECMQtDeclareLoggingCategory.rst new file mode 100644 index 00000000..8f0af2ac --- /dev/null +++ b/docs/module/ECMQtDeclareLoggingCategory.rst @@ -0,0 +1 @@ +.. ecm-module:: ../../modules/ECMQtDeclareLoggingCategory.cmake 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 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7960154a..8a75ae61 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -85,6 +85,9 @@ if (TARGET Qt5::qmake) add_test_variant(KDEInstallDirsTest.relative_or_absolute_qt KDEInstallDirsTest.relative_or_absolute dummy) endif () +if (Qt5Core_FOUND) + add_test_macro(ECMQtDeclareLoggingCategoryTest testmain) +endif() add_test_macro(FindModules dummy) add_test_macro(UseFindModules dummy) diff --git a/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt b/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt new file mode 100644 index 00000000..15ece187 --- /dev/null +++ b/tests/ECMQtDeclareLoggingCategoryTest/CMakeLists.txt @@ -0,0 +1,42 @@ +project(ECMQtDeclareLoggingCategoryTest) +cmake_minimum_required(VERSION 2.8.12) +set(ECM_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../modules") + +set(CMAKE_MODULE_PATH ${ECM_MODULE_DIR}) + +include(ECMQtDeclareLoggingCategory) + +ecm_qt_declare_logging_category( + sources + HEADER "log1.h" + IDENTIFIER "log1" + CATEGORY_NAME "log.one" +) + +ecm_qt_declare_logging_category( + sources + HEADER "log2.h" + IDENTIFIER "foo::bar::log2" + CATEGORY_NAME "log.two" +) + +ecm_qt_declare_logging_category( + sources + HEADER "${CMAKE_CURRENT_BINARY_DIR}/log3.h" + IDENTIFIER "log3" + CATEGORY_NAME "three" + DEFAULT_SEVERITY Critical +) + +find_package(Qt5Core REQUIRED) + +add_executable(testmain testmain.cpp ${sources}) +target_include_directories(testmain + PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}" +) +target_link_libraries(testmain + PRIVATE + Qt5::Core +) + diff --git a/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp b/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp new file mode 100644 index 00000000..a06614a1 --- /dev/null +++ b/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp @@ -0,0 +1,83 @@ +#include + +#include "log1.h" +#include "log2.h" +#include "log3.h" + +#include + +int main(int argc, char **argv) { + QCoreApplication qapp(argc, argv); + + bool success = true; + + // NB: we cannot test against QtInfoMsg, as that (a) does not exist before + // Qt 5.5, and (b) has incorrect semantics in Qt 5.5, in that it is + // treated as more severe than QtCriticalMsg. + + if (log1().categoryName() != QLatin1String("log.one")) { + qWarning("log1 category was \"%s\", expected \"log.one\"", log1().categoryName()); + success = false; + } +#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) + if (!log1().isDebugEnabled()) { + qWarning("log1 debug messages were not enabled"); + success = false; + } +#else + if (log1().isDebugEnabled()) { + qWarning("log1 debug messages were enabled"); + success = false; + } + if (!log1().isWarningEnabled()) { + qWarning("log1 warning messages were not enabled"); + success = false; + } +#endif + + if (foo::bar::log2().categoryName() != QLatin1String("log.two")) { + qWarning("log2 category was \"%s\", expected \"log.two\"", foo::bar::log2().categoryName()); + success = false; + } +#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) + if (!foo::bar::log2().isDebugEnabled()) { + qWarning("log2 debug messages were not enabled"); + success = false; + } +#else + if (foo::bar::log2().isDebugEnabled()) { + qWarning("log2 debug messages were enabled"); + success = false; + } + if (!foo::bar::log2().isWarningEnabled()) { + qWarning("log2 warning messages were not enabled"); + success = false; + } +#endif + + if (log3().categoryName() != QLatin1String("three")) { + qWarning("log3 category was \"%s\", expected \"three\"", log3().categoryName()); + success = false; + } +#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) + if (!log3().isDebugEnabled()) { + qWarning("log3 debug messages were not enabled"); + success = false; + } +#else + if (log3().isDebugEnabled()) { + qWarning("log3 debug messages were enabled"); + success = false; + } + if (log3().isWarningEnabled()) { + qWarning("log3 warning messages were enabled"); + success = false; + } + if (!log3().isCriticalEnabled()) { + qWarning("log3 critical messages were not enabled"); + success = false; + } +#endif + + return success ? 0 : 1; +} -- cgit v1.2.1 From 8e20caf11dbabdf191415589e99ea1b773caedd0 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 19 Aug 2015 22:05:22 +0100 Subject: Add a license to one of the C++ test files. --- tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp b/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp index a06614a1..4abcd527 100644 --- a/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp +++ b/tests/ECMQtDeclareLoggingCategoryTest/testmain.cpp @@ -1,3 +1,28 @@ +/* + * 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 "log1.h" -- cgit v1.2.1 From a1e60b8e6386f3b674d31b6a5e76214cf98a2bd8 Mon Sep 17 00:00:00 2001 From: Patrick Spendrin Date: Thu, 20 Aug 2015 21:44:42 +0200 Subject: correct the test name, so that we don't have a duplicate ECMGenerateHeaders test --- tests/ECMGeneratePkgConfigFile/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ECMGeneratePkgConfigFile/CMakeLists.txt b/tests/ECMGeneratePkgConfigFile/CMakeLists.txt index 9f407cb0..f3bc267d 100644 --- a/tests/ECMGeneratePkgConfigFile/CMakeLists.txt +++ b/tests/ECMGeneratePkgConfigFile/CMakeLists.txt @@ -2,5 +2,5 @@ set(MODULES_DIR "${extra-cmake-modules_SOURCE_DIR}/modules") configure_file(run_test.cmake.config "${CMAKE_CURRENT_BINARY_DIR}/run_test.cmake" @ONLY) add_test( - NAME ECMGenerateHeaders + NAME ECMGeneratePkgConfigFile COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/run_test.cmake") -- 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 ++++++++++++++++------ tests/ECMGenerateHeadersTest/CommonHeader | 4 ++ tests/ECMGenerateHeadersTest/headtest4.h | 0 tests/ECMGenerateHeadersTest/run_test.cmake.config | 65 +++++++++++++++++++ 4 files changed, 123 insertions(+), 21 deletions(-) create mode 100644 tests/ECMGenerateHeadersTest/CommonHeader create mode 100644 tests/ECMGenerateHeadersTest/headtest4.h 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() diff --git a/tests/ECMGenerateHeadersTest/CommonHeader b/tests/ECMGenerateHeadersTest/CommonHeader new file mode 100644 index 00000000..0d101fbc --- /dev/null +++ b/tests/ECMGenerateHeadersTest/CommonHeader @@ -0,0 +1,4 @@ +// convenience header +#include "headtest1.h" +#include "headtest2.h" +#include "headtest4.h" diff --git a/tests/ECMGenerateHeadersTest/headtest4.h b/tests/ECMGenerateHeadersTest/headtest4.h new file mode 100644 index 00000000..e69de29b diff --git a/tests/ECMGenerateHeadersTest/run_test.cmake.config b/tests/ECMGenerateHeadersTest/run_test.cmake.config index 1db623b7..a9027dbc 100644 --- a/tests/ECMGenerateHeadersTest/run_test.cmake.config +++ b/tests/ECMGenerateHeadersTest/run_test.cmake.config @@ -288,5 +288,70 @@ check_files(GENERATED ${expfiles} check_files(GENERATED ${expfiles} ORIGINALS ${intermediatefiles}) +########################################################### + +message(STATUS "Test 12: COMMON_HEADER") + +set(camelcase_headers) +set(expfiles "${CMAKE_CURRENT_BINARY_DIR}/HeadTest1" + "${CMAKE_CURRENT_BINARY_DIR}/HeadTest2" + "${CMAKE_CURRENT_BINARY_DIR}/HeadTest4" + "${CMAKE_CURRENT_BINARY_DIR}/CommonHeader") +set(origfiles headtest1.h headtest2.h) +file(REMOVE ${expfiles}) +ecm_generate_headers( + camelcase_headers + ORIGINAL LOWERCASE + HEADER_NAMES HeadTest1 HeadTest2 HeadTest4 + COMMON_HEADER CommonHeader +) +if (NOT "${expfiles}" STREQUAL "${camelcase_headers}") + message(FATAL_ERROR "camelcase_headers was set to \"${camelcase_headers}\" instead of \"${expfiles}\"") +endif() +check_files(GENERATED ${expfiles} + ORIGINALS ${origfiles}) + +file(READ CommonHeader file_contents) +string(STRIP "${file_contents}" file_contents) +file(READ "${CMAKE_CURRENT_BINARY_DIR}/CommonHeader" exp_contents) +string(STRIP "${exp_contents}" exp_contents) +if (NOT "${file_contents}" STREQUAL "${exp_contents}") + message(FATAL_ERROR "${generated_file} contains '${file_contents}' instead of '${exp_contents}'") +endif() + + +########################################################### + +message(STATUS "Test 13: multiple classes and COMMON_HEADER") + +set(camelcase_headers) +set(expfiles "${CMAKE_CURRENT_BINARY_DIR}/HeadTest1" + "${CMAKE_CURRENT_BINARY_DIR}/HeadTest2" + "${CMAKE_CURRENT_BINARY_DIR}/HeadTest2Add1" + "${CMAKE_CURRENT_BINARY_DIR}/HeadTest2Add2" + "${CMAKE_CURRENT_BINARY_DIR}/HeadTest4" + "${CMAKE_CURRENT_BINARY_DIR}/CommonHeader") +set(origfiles headtest1.h headtest2.h headtest4.h) +file(REMOVE ${expfiles}) +ecm_generate_headers( + camelcase_headers + ORIGINAL LOWERCASE + HEADER_NAMES HeadTest1 HeadTest2,HeadTest2Add1,HeadTest2Add2 HeadTest4 + COMMON_HEADER CommonHeader +) +if (NOT "${expfiles}" STREQUAL "${camelcase_headers}") + message(FATAL_ERROR "camelcase_headers was set to \"${camelcase_headers}\" instead of \"${expfiles}\"") +endif() +check_files(GENERATED ${expfiles} + ORIGINALS ${origfiles}) + +file(READ CommonHeader file_contents) +string(STRIP "${file_contents}" file_contents) +file(READ "${CMAKE_CURRENT_BINARY_DIR}/CommonHeader" exp_contents) +string(STRIP "${exp_contents}" exp_contents) +if (NOT "${file_contents}" STREQUAL "${exp_contents}") + message(FATAL_ERROR "${generated_file} contains '${file_contents}' instead of '${exp_contents}'") +endif() + # vim:ft=cmake -- cgit v1.2.1 From 456d7772dcc2ae2f6f36bb6358d04cbdd1218d30 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Thu, 10 Sep 2015 14:44:33 +0100 Subject: Disable -Wgnu-zero-variadic-macro-arguments when using clang This warning is emitted for every qCDebug() call and is not useful. REVIEW: 125031 --- kde-modules/KDEFrameworkCompilerSettings.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kde-modules/KDEFrameworkCompilerSettings.cmake b/kde-modules/KDEFrameworkCompilerSettings.cmake index 84de77ab..e88c10d9 100644 --- a/kde-modules/KDEFrameworkCompilerSettings.cmake +++ b/kde-modules/KDEFrameworkCompilerSettings.cmake @@ -45,6 +45,11 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions(-DQT_STRICT_ITERATORS) endif() -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # -Wgnu-zero-variadic-macro-arguments is triggered by every qCDebug() call and therefore results + # in a lot of noise. This warning is only notifying us that clang is emulating the GCC behaviour + # instead of the exact standard wording so we can safely ignore it + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-gnu-zero-variadic-macro-arguments") endif() -- cgit v1.2.1 From faedc8d01697ab1d573d5740f24e7279f4dba14f Mon Sep 17 00:00:00 2001 From: Andreas Cord-Landwehr Date: Sat, 12 Sep 2015 10:15:18 +0200 Subject: Add definition ANDROID as needed in qsystemdetection.h. QtCore/qsystemdetection.h sets the define Q_OS_ANDROID based on having ANDROID defined. Hence, adding the ANDROID define allows applications to use the Q_OS_ANDROID for ifdef'ing. REVIEW: 125183 --- toolchain/Android.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake index 0144f379..bfc166a8 100644 --- a/toolchain/Android.cmake +++ b/toolchain/Android.cmake @@ -139,6 +139,9 @@ include_directories(SYSTEM "${ANDROID_LIBS_ROOT}/libs/${ANDROID_ABI}/include" ) +# needed for Qt to define Q_OS_ANDROID +add_definitions(-DANDROID) + link_directories(${CMAKE_SYSTEM_LIBRARY_PATH}) set(CMAKE_C_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN}-gcc") -- cgit v1.2.1 From 06bda539ab490a9ff96ed03c2817d9317fd9b880 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 12 Sep 2015 08:49:12 +0000 Subject: Upgrade ECM version to 5.15.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af9a891a..d67c477c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(extra-cmake-modules NONE) set(ECM_MAJOR_VERSION 5) -set(ECM_MINOR_VERSION 14) +set(ECM_MINOR_VERSION 15) set(ECM_PATCH_VERSION 0) set(ECM_VERSION ${ECM_MAJOR_VERSION}.${ECM_MINOR_VERSION}.${ECM_PATCH_VERSION}) -- cgit v1.2.1 From 3915bacd6055087bf71ccabc5c9ddf15743f4e9a Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sun, 13 Sep 2015 01:57:58 +0200 Subject: Use Qt5 to specify what's Qt5 installation prefix --- toolchain/Android.cmake | 2 ++ toolchain/deployment-file.json.in | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake index bfc166a8..9b104747 100644 --- a/toolchain/Android.cmake +++ b/toolchain/Android.cmake @@ -172,6 +172,8 @@ if(DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET ${CREATEAPK_TARGET_NAME}) message(FATAL_ERROR "Define an apk dir to initialize from using -DANDROID_APK_DIR=. The specified directory must contain the AndroidManifest.xml file.") endif() + find_package(Qt5Core REQUIRED) + function(EOFHook) if(CMAKE_PARENT_LIST_FILE STREQUAL "") generate_deployment_file() diff --git a/toolchain/deployment-file.json.in b/toolchain/deployment-file.json.in index e662795a..1e52e5a0 100644 --- a/toolchain/deployment-file.json.in +++ b/toolchain/deployment-file.json.in @@ -1,5 +1,5 @@ { - "qt": "@QTDIR@", + "qt": "@_qt5Core_install_prefix@", "sdk": "@ANDROID_SDK_ROOT@", "ndk": "@ANDROID_NDK@", "toolchain-prefix": "@ANDROID_TOOLCHAIN@", -- cgit v1.2.1 From 94c9958d41b145124ba5c96777f29e8eb81df160 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sun, 13 Sep 2015 02:04:07 +0200 Subject: Look for the files in the installed prefix rather the prefix path In general, we are looking for what we're installing, not for what we already had. --- toolchain/deployment-file.json.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolchain/deployment-file.json.in b/toolchain/deployment-file.json.in index 1e52e5a0..8534cd2f 100644 --- a/toolchain/deployment-file.json.in +++ b/toolchain/deployment-file.json.in @@ -9,7 +9,7 @@ "target-architecture": "@ANDROID_ABI@", "application-binary": "@EXECUTABLE_DESTINATION_PATH@", "android-extra-libs": "@_DEPS@", - "android-extra-plugins": "@CMAKE_PREFIX_PATH@/share,@CMAKE_PREFIX_PATH@/lib/qml", + "android-extra-plugins": "@CMAKE_INSTALL_PREFIX@/share,@CMAKE_INSTALL_PREFIX@/lib/qml", "android-package-source-directory": "@ANDROID_APK_DIR@", "sdkBuildToolsRevision": "@ANDROID_SDK_BUILD_TOOLS_REVISION@" } -- cgit v1.2.1 From d4bcaf7eb3ff501ad0a5f06ed0724964e0e0f404 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Wed, 16 Sep 2015 00:40:18 +0200 Subject: Disable X11,XCB etc. detection on OS X Reviewed at https://git.reviewboard.kde.org/r/125163/ --- kde-modules/KDECMakeSettings.cmake | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/kde-modules/KDECMakeSettings.cmake b/kde-modules/KDECMakeSettings.cmake index 0c997931..cefd6daa 100644 --- a/kde-modules/KDECMakeSettings.cmake +++ b/kde-modules/KDECMakeSettings.cmake @@ -46,9 +46,18 @@ # disabled by setting ``KDE_SKIP_UNINSTALL_TARGET`` to TRUE before including # this module. # +# By default on OS X, X11 and XCB related detections are disabled. However if +# the need would arise to use these technologies, the detection can be enabled +# by setting ``APPLE_FORCE_X11`` to ``ON``. +# +# A warning is printed for the developer to know that the detection is disabled on OS X. +# This message can be turned off by setting ``APPLE_SUPPRESS_X11_WARNING`` to ``ON``. +# # Since pre-1.0.0. # -# Uninstall target functionality since 1.7.0. +# - Uninstall target functionality since 1.7.0. +# - ``APPLE_FORCE_X11`` option since 5.14.0 (detecting X11 was previously the default behavior) +# - ``APPLE_SUPPRESS_X11_WARNING`` option since 5.14.0 #============================================================================= # Copyright 2014 Alex Merry @@ -185,6 +194,21 @@ if(NOT KDE_SKIP_BUILD_SETTINGS) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") endif() + # Disable detection of X11 and related package on OS X because when using + # brew or macports, X11 can be installed and thus is detected. + option(APPLE_FORCE_X11 "Force enable X11 related detection on OS X" OFF) + option(APPLE_SUPPRESS_X11_WARNING "Suppress X11 and related technologies search disabling warning on OS X" OFF) + + if(APPLE AND NOT APPLE_FORCE_X11) + if (NOT APPLE_SUPPRESS_X11_WARNING) + message(WARNING "Searching for X11 and related technologies is disabled on Apple systems. Set APPLE_FORCE_X11 to ON to change this behaviour. Set APPLE_SUPPRESS_X11_WARNING to ON to hide this warning.") + endif() + + set(CMAKE_DISABLE_FIND_PACKAGE_X11 true) + set(CMAKE_DISABLE_FIND_PACKAGE_XCB true) + set(CMAKE_DISABLE_FIND_PACKAGE_Qt5X11Extras true) + endif() + option(KDE_SKIP_UNINSTALL_TARGET "Prevent an \"uninstall\" target from being generated." OFF) if(NOT KDE_SKIP_UNINSTALL_TARGET) include("${ECM_MODULE_DIR}/ECMUninstallTarget.cmake") -- 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(-) 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 3b20ef911eb83b7bd37315ace682e0e6bc6195d9 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Thu, 1 Oct 2015 01:25:03 +0200 Subject: Remove workaround to delay execution on Android * Remove get_property calls on targets, this way we don't need to be called right before configuration time. * Removes EOFHook Instead we process it at generation time using the link.txt file (which is probably another hack) REVIEW: 125084 --- toolchain/Android.cmake | 30 ++++-------------------------- toolchain/deployment-file.json.in | 2 +- toolchain/specifydependencies.cmake | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 27 deletions(-) create mode 100644 toolchain/specifydependencies.cmake diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake index 9b104747..a60771bc 100644 --- a/toolchain/Android.cmake +++ b/toolchain/Android.cmake @@ -174,38 +174,16 @@ if(DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET ${CREATEAPK_TARGET_NAME}) find_package(Qt5Core REQUIRED) - function(EOFHook) - if(CMAKE_PARENT_LIST_FILE STREQUAL "") - generate_deployment_file() - endif() - endfunction() - - function(generate_deployment_file) - get_property(_DEPENDENCIES TARGET ${QTANDROID_EXPORTED_TARGET} PROPERTY INTERFACE_LINK_LIBRARIES) - set(_DEPS_LIST) - foreach(_DEP IN LISTS _DEPENDENCIES) - if(NOT _DEP MATCHES "Qt5::.*") - get_property(_DEP_LOCATION TARGET ${_DEP} PROPERTY "LOCATION_${CMAKE_BUILD_TYPE}") - list(APPEND _DEPS_LIST ${_DEP_LOCATION}) - endif() - endforeach() - string(REPLACE ";" "," _DEPS "${_DEPS_LIST}") - configure_file("${_CMAKE_ANDROID_DIR}/deployment-file.json.in" "${QTANDROID_EXPORTED_TARGET}-deployment.json") - endfunction() - #we want to call the function after the project has been set up - variable_watch(CMAKE_PARENT_LIST_FILE EOFHook) - -# Create the target that will eventually generate the apk - get_filename_component(QTDIR "${Qt5Core_DIR}/../../../" ABSOLUTE) - find_program(ANDROID_DEPLOY_QT androiddeployqt HINTS "${QTDIR}/bin") set(EXPORT_DIR "${CMAKE_BINARY_DIR}/${QTANDROID_EXPORTED_TARGET}_build_apk/") set(EXECUTABLE_DESTINATION_PATH "${EXPORT_DIR}/libs/${ANDROID_ABI}/lib${QTANDROID_EXPORTED_TARGET}.so") + configure_file("${_CMAKE_ANDROID_DIR}/deployment-file.json.in" "${QTANDROID_EXPORTED_TARGET}-deployment.json.in") add_custom_target(${CREATEAPK_TARGET_NAME} - COMMAND cmake -E echo "Generating $ with ${ANDROID_DEPLOY_QT}" + COMMAND cmake -E echo "Generating $ with $/androiddeployqt" COMMAND cmake -E copy_directory "${ANDROID_APK_DIR}" "${EXPORT_DIR}" COMMAND cmake -E copy "$" "${EXECUTABLE_DESTINATION_PATH}" - COMMAND ${ANDROID_DEPLOY_QT} --input "${QTANDROID_EXPORTED_TARGET}-deployment.json" --output "${EXPORT_DIR}" --deployment bundled "\\$(ARGS)" + COMMAND cmake -DINPUT_FILE="${QTANDROID_EXPORTED_TARGET}-deployment.json.in" -DOUTPUT_FILE="${QTANDROID_EXPORTED_TARGET}-deployment.json" "-DTARGET_DIR=$" "-DTARGET_NAME=${QTANDROID_EXPORTED_TARGET}" -P ${_CMAKE_ANDROID_DIR}/specifydependencies.cmake + COMMAND $/androiddeployqt --input "${QTANDROID_EXPORTED_TARGET}-deployment.json" --output "${EXPORT_DIR}" --deployment bundled "\\$(ARGS)" ) else() message(STATUS "You can export a target by specifying -DQTANDROID_EXPORTED_TARGET=") diff --git a/toolchain/deployment-file.json.in b/toolchain/deployment-file.json.in index 8534cd2f..9367bc1b 100644 --- a/toolchain/deployment-file.json.in +++ b/toolchain/deployment-file.json.in @@ -8,7 +8,7 @@ "ndk-host": "@_HOST@", "target-architecture": "@ANDROID_ABI@", "application-binary": "@EXECUTABLE_DESTINATION_PATH@", - "android-extra-libs": "@_DEPS@", + "android-extra-libs": "##EXTRALIBS##", "android-extra-plugins": "@CMAKE_INSTALL_PREFIX@/share,@CMAKE_INSTALL_PREFIX@/lib/qml", "android-package-source-directory": "@ANDROID_APK_DIR@", "sdkBuildToolsRevision": "@ANDROID_SDK_BUILD_TOOLS_REVISION@" diff --git a/toolchain/specifydependencies.cmake b/toolchain/specifydependencies.cmake new file mode 100644 index 00000000..21b169ae --- /dev/null +++ b/toolchain/specifydependencies.cmake @@ -0,0 +1,22 @@ +file(READ "${TARGET_DIR}/CMakeFiles/${TARGET_NAME}.dir/link.txt" out) + +string(FIND "${out}" "-o ${TARGET_NAME}" POS) #we trim the initial arguments, we want the ones in the end. we find the target +string(SUBSTRING "${out}" ${POS} -1 out) #we +string(REGEX MATCHALL " /.+\\.so" outout "${out}") +string(STRIP "${outout}" outout) +string(REPLACE " /" ";/" outout "${outout}") + +set(extralibs) +foreach(lib IN LISTS outout) #now we filter Qt5 libraries, because Qt wants to take care about these itself + if(NOT ${lib} MATCHES ".*/libQt5.*") + if(extralibs) + set(extralibs "${extralibs},${lib}") + else() + set(extralibs "${lib}") + endif() + endif() +endforeach() + +file(READ "${INPUT_FILE}" CONTENTS) +string(REPLACE "##EXTRALIBS##" "${extralibs}" NEWCONTENTS "${CONTENTS}") +file(WRITE "${OUTPUT_FILE}" ${NEWCONTENTS}) -- 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(+) 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 7d148e333bd8d371cc67a767922ccaa64bcab8f5 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 10 Oct 2015 10:01:00 +0000 Subject: Upgrade ECM version to 5.16.0. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d67c477c..c1abd6c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(extra-cmake-modules NONE) set(ECM_MAJOR_VERSION 5) -set(ECM_MINOR_VERSION 15) +set(ECM_MINOR_VERSION 16) set(ECM_PATCH_VERSION 0) set(ECM_VERSION ${ECM_MAJOR_VERSION}.${ECM_MINOR_VERSION}.${ECM_PATCH_VERSION}) -- cgit v1.2.1 From 20bf1de42b035eb669d0250f4d549c15f9256e58 Mon Sep 17 00:00:00 2001 From: Christoph Cullmann Date: Tue, 13 Oct 2015 13:33:26 +0200 Subject: make it possible to build KDE Frameworks 5 with a plain qt 5.5.x installed from the normal qt.io installer on mac os we can revisit this change, if it leads to problems for mac ports or homebrew REVIEW: 125614 --- kde-modules/KDECMakeSettings.cmake | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/kde-modules/KDECMakeSettings.cmake b/kde-modules/KDECMakeSettings.cmake index cefd6daa..8e7ff359 100644 --- a/kde-modules/KDECMakeSettings.cmake +++ b/kde-modules/KDECMakeSettings.cmake @@ -95,21 +95,23 @@ if(NOT KDE_SKIP_RPATH_SETTINGS) endif() if (UNIX) + # for mac os: add install name dir in addition + # check: is the rpath stuff below really required on mac os? at least it seems so to use a stock qt from qt.io if (APPLE) set(CMAKE_INSTALL_NAME_DIR ${_abs_LIB_INSTALL_DIR}) - else () - # add our LIB_INSTALL_DIR to the RPATH (but only when it is not one of - # the standard system link directories - such as /usr/lib on UNIX) - list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_abs_LIB_INSTALL_DIR}" _isSystemLibDir) - list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${_abs_LIB_INSTALL_DIR}" _isSystemCxxLibDir) - list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${_abs_LIB_INSTALL_DIR}" _isSystemCLibDir) - if("${_isSystemLibDir}" STREQUAL "-1" AND "${_isSystemCxxLibDir}" STREQUAL "-1" AND "${_isSystemCLibDir}" STREQUAL "-1") - set(CMAKE_INSTALL_RPATH "${_abs_LIB_INSTALL_DIR}") - endif() - - # Append directories in the linker search path (but outside the project) - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) endif () + + # add our LIB_INSTALL_DIR to the RPATH (but only when it is not one of + # the standard system link directories - such as /usr/lib on UNIX) + list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_abs_LIB_INSTALL_DIR}" _isSystemLibDir) + list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${_abs_LIB_INSTALL_DIR}" _isSystemCxxLibDir) + list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES "${_abs_LIB_INSTALL_DIR}" _isSystemCLibDir) + if("${_isSystemLibDir}" STREQUAL "-1" AND "${_isSystemCxxLibDir}" STREQUAL "-1" AND "${_isSystemCLibDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${_abs_LIB_INSTALL_DIR}") + endif() + + # Append directories in the linker search path (but outside the project) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) endif (UNIX) endif() -- 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 +++++++++- tests/ECMInstallIconsTest/CMakeLists.txt | 7 +++++++ tests/ECMInstallIconsTest/check_tree.cmake.in | 7 +++++++ .../badly-named-files-test/hicolor/icon-theme.cache | Bin 0 -> 124 bytes .../expected-tree/lang-test/hicolor/icon-theme.cache | Bin 0 -> 548 bytes .../multi-file-test/hicolor/icon-theme.cache | Bin 0 -> 472 bytes .../single-file-test/hicolor/icon-theme.cache | Bin 0 -> 120 bytes .../themed-lang-test/oxygen/icon-theme.cache | Bin 0 -> 548 bytes .../themed-test/theme-name-2/icon-theme.cache | Bin 0 -> 472 bytes .../expected-tree/v1-icons/crystalsvg/icon-theme.cache | Bin 0 -> 164 bytes .../expected-tree/v1-icons/hicolor/icon-theme.cache | Bin 0 -> 452 bytes 11 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/lang-test/hicolor/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/multi-file-test/hicolor/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/single-file-test/hicolor/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/themed-lang-test/oxygen/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/themed-test/theme-name-2/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/v1-icons/crystalsvg/icon-theme.cache create mode 100644 tests/ECMInstallIconsTest/expected-tree/v1-icons/hicolor/icon-theme.cache 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() diff --git a/tests/ECMInstallIconsTest/CMakeLists.txt b/tests/ECMInstallIconsTest/CMakeLists.txt index 7fe4ca35..738cba91 100644 --- a/tests/ECMInstallIconsTest/CMakeLists.txt +++ b/tests/ECMInstallIconsTest/CMakeLists.txt @@ -94,5 +94,12 @@ ecm_install_icons( DESTINATION badly-named-files-test ) +find_program(icon_cache_generator NAMES gtk-update-icon-cache) +if (icon_cache_generator) + set(GENERATE_ICON_CACHE TRUE) +else() + set(GENERATE_ICON_CACHE FALSE) +endif() + # this will be run by CTest configure_file(check_tree.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check_tree.cmake" @ONLY) diff --git a/tests/ECMInstallIconsTest/check_tree.cmake.in b/tests/ECMInstallIconsTest/check_tree.cmake.in index 6d14246b..b9da1715 100644 --- a/tests/ECMInstallIconsTest/check_tree.cmake.in +++ b/tests/ECMInstallIconsTest/check_tree.cmake.in @@ -1,8 +1,15 @@ set(EXP_TREE "@CMAKE_CURRENT_SOURCE_DIR@/expected-tree") set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") +set(GENERATE_ICON_CACHE "@GENERATE_ICON_CACHE@") file(GLOB_RECURSE exp_files RELATIVE "${EXP_TREE}" "${EXP_TREE}/*") file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") +if (NOT GENERATE_ICON_CACHE) + file(GLOB_RECURSE cache_files RELATIVE "${EXP_TREE}" "${EXP_TREE}/*.cache") + foreach(f ${cache_files}) + list(REMOVE_ITEM exp_files "${f}") + endforeach() +endif() list(SORT exp_files) list(SORT actual_files) diff --git a/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/icon-theme.cache new file mode 100644 index 00000000..50d52976 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/badly-named-files-test/hicolor/icon-theme.cache differ diff --git a/tests/ECMInstallIconsTest/expected-tree/lang-test/hicolor/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/lang-test/hicolor/icon-theme.cache new file mode 100644 index 00000000..babadff0 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/lang-test/hicolor/icon-theme.cache differ diff --git a/tests/ECMInstallIconsTest/expected-tree/multi-file-test/hicolor/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/multi-file-test/hicolor/icon-theme.cache new file mode 100644 index 00000000..60ac05d6 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/multi-file-test/hicolor/icon-theme.cache differ diff --git a/tests/ECMInstallIconsTest/expected-tree/single-file-test/hicolor/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/single-file-test/hicolor/icon-theme.cache new file mode 100644 index 00000000..f385659f Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/single-file-test/hicolor/icon-theme.cache differ diff --git a/tests/ECMInstallIconsTest/expected-tree/themed-lang-test/oxygen/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/themed-lang-test/oxygen/icon-theme.cache new file mode 100644 index 00000000..babadff0 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/themed-lang-test/oxygen/icon-theme.cache differ diff --git a/tests/ECMInstallIconsTest/expected-tree/themed-test/theme-name-2/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/themed-test/theme-name-2/icon-theme.cache new file mode 100644 index 00000000..60ac05d6 Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/themed-test/theme-name-2/icon-theme.cache differ diff --git a/tests/ECMInstallIconsTest/expected-tree/v1-icons/crystalsvg/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/v1-icons/crystalsvg/icon-theme.cache new file mode 100644 index 00000000..8b9c8d0c Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/v1-icons/crystalsvg/icon-theme.cache differ diff --git a/tests/ECMInstallIconsTest/expected-tree/v1-icons/hicolor/icon-theme.cache b/tests/ECMInstallIconsTest/expected-tree/v1-icons/hicolor/icon-theme.cache new file mode 100644 index 00000000..ab56337b Binary files /dev/null and b/tests/ECMInstallIconsTest/expected-tree/v1-icons/hicolor/icon-theme.cache differ -- 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 +++++++++++++++------- tests/CMakeLists.txt | 4 +- tests/ECMPoQmToolsTest/CMakeLists.txt | 32 ++++++-- tests/ECMPoQmToolsTest/check.cmake.in | 81 +++++++++++++++++++ tests/ECMPoQmToolsTest/check_conf.cmake.in | 2 + tests/ECMPoQmToolsTest/check_tree.cmake.in | 61 --------------- tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po | 22 ++++++ tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po | 22 ++++++ tests/ECMPoQmToolsTest/tr_test.cpp | 16 ++++ tests/ECMPoQmToolsTest/tr_thread_test.cpp | 68 ++++++++++++++++ tests/ECMPoQmToolsTest/tr_thread_test_module.cpp | 12 +++ 12 files changed, 328 insertions(+), 97 deletions(-) create mode 100644 tests/ECMPoQmToolsTest/check.cmake.in create mode 100644 tests/ECMPoQmToolsTest/check_conf.cmake.in delete mode 100644 tests/ECMPoQmToolsTest/check_tree.cmake.in create mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po create mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po create mode 100644 tests/ECMPoQmToolsTest/tr_test.cpp create mode 100644 tests/ECMPoQmToolsTest/tr_thread_test.cpp create mode 100644 tests/ECMPoQmToolsTest/tr_thread_test_module.cpp 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" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8a75ae61..9e6de12f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -101,13 +101,13 @@ add_test_macro(ECMInstallIconsTest ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMInstallIconsTest/check_tree.cmake" ) -if (Qt5LinguistTools_FOUND) +if (Qt5Core_FOUND AND Qt5LinguistTools_FOUND) set(ECMPoQmToolsTest_EXTRA_OPTIONS --build-target install --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/InstallDirectory" ) add_test_macro(ECMPoQmToolsTest - ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/check_tree.cmake" + ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/check.cmake" ) endif() diff --git a/tests/ECMPoQmToolsTest/CMakeLists.txt b/tests/ECMPoQmToolsTest/CMakeLists.txt index 15351d2f..e08a2b8c 100644 --- a/tests/ECMPoQmToolsTest/CMakeLists.txt +++ b/tests/ECMPoQmToolsTest/CMakeLists.txt @@ -9,9 +9,14 @@ file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}") include(ECMPoQmTools) -# Should create ${CMAKE_CURRENT_BINARY_DIR}/qmloader.cpp and set QMLOADER_PATH -# to its path -ecm_create_qm_loader(QMLOADER_PATH catalog) +include(../test_helpers.cmake) + +unset(QMLOADER_FILES) +ecm_create_qm_loader(QMLOADER_FILES catalog) +assert_var_defined(QMLOADER_FILES) + +# These will be used to test the above-generated loader +ecm_install_po_files_as_qm(tr_test-po) # Should create a process-and-install.qm file and install it ecm_process_po_files_as_qm(fr ALL @@ -39,5 +44,22 @@ ecm_install_po_files_as_qm(po-custom-dir1) set(LOCALE_INSTALL_DIR custom-dir2) ecm_install_po_files_as_qm(po-custom-dir2) -# this will be run by CTest -configure_file(check_tree.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check_tree.cmake" @ONLY) +find_package(Qt5Core CONFIG REQUIRED) + +add_executable(tr_test tr_test.cpp ${QMLOADER_FILES}) +target_link_libraries(tr_test PRIVATE Qt5::Core) + +add_library(tr_thread_module MODULE tr_thread_test_module.cpp ${QMLOADER_FILES}) +target_link_libraries(tr_thread_module PRIVATE Qt5::Core) + +add_executable(tr_thread_test tr_thread_test.cpp) +set_target_properties(tr_thread_test PROPERTIES AUTOMOC ON) +target_include_directories(tr_thread_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") +target_compile_definitions(tr_thread_test PRIVATE "MODULE_PATH=\"$\"") +target_link_libraries(tr_thread_test PRIVATE Qt5::Core) + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/check_conf.cmake" + INPUT "${CMAKE_CURRENT_SOURCE_DIR}/check_conf.cmake.in" +) +configure_file(check.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check.cmake" @ONLY) diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in new file mode 100644 index 00000000..2f0cc205 --- /dev/null +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -0,0 +1,81 @@ +set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") +set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") +include("${BINARY_DIR}/check_conf.cmake") + +set(fail OFF) + +macro(mark_failed msg) + message(WARNING "FAIL: ${msg}") + set(fail ON) +endmacro() + +macro(check_exists file) + message(STATUS "Checking for ${file}") + if (NOT EXISTS ${file}) + mark_failed("File \"${file}\" does not exist") + endif() +endmacro() + +check_exists(${BINARY_DIR}/fr/only-process.qm) + +set(exp_files + "share/locale/fr/LC_MESSAGES/process-and-install.qm" + "share/locale/es/LC_MESSAGES/install-test.qm" + "share/locale/fr/LC_MESSAGES/install-test.qm" + "share/locale/en/LC_MESSAGES/catalog.qm" + "share/locale/en_GB/LC_MESSAGES/catalog.qm" + "custom-dir1/es/LC_MESSAGES/custom-dir1-install-test.qm" + "custom-dir1/fr/LC_MESSAGES/custom-dir1-install-test.qm" + "custom-dir2/es/LC_MESSAGES/custom-dir2-install-test.qm" + "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm" +) +file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") +list(SORT exp_files) +list(SORT actual_files) + +if(NOT exp_files STREQUAL actual_files) + foreach(f ${exp_files}) + list(FIND actual_files "${f}" result) + if(result EQUAL -1) + message(WARNING "${f} was expected, but not found") + set(fail ON) + endif() + endforeach() + foreach(f ${actual_files}) + list(FIND exp_files "${f}" result) + if(result EQUAL -1) + message(WARNING "${f} was found, but not expected") + set(fail ON) + endif() + endforeach() +else() + message(STATUS "Installed translations in expected locations") +endif() + +# we know we can modify the executable environment on Linux +if("@CMAKE_SYSTEM_NAME@" STREQUAL "Linux") + set(exp_output_en "english text:english plural form 5") + set(exp_output_en_GB "british english text:british english plural form 5") + # no french translation provided -> english fallback + set(exp_output_fr "${exp_output_en}") + foreach(exec TR_TEST TR_THREAD_TEST) + foreach(lang en en_GB fr) + execute_process( + COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" + LC_ALL=${lang} "${${exec}_EXEC}" + OUTPUT_VARIABLE output + ) + string(STRIP "${output}" stripped_output) + if(NOT stripped_output STREQUAL exp_output_${lang}) + message(WARNING "${exec}[${lang}] output was \"${stripped_output}\", but expected \"${exp_output_${lang}}\"") + set(fail ON) + else() + message(STATUS "${exec}[${lang}] output was \"${stripped_output}\", as expected") + endif() + endforeach() + endforeach() +endif() + +if (fail) + message(FATAL_ERROR "Test failed!") +endif() diff --git a/tests/ECMPoQmToolsTest/check_conf.cmake.in b/tests/ECMPoQmToolsTest/check_conf.cmake.in new file mode 100644 index 00000000..0bbab1d9 --- /dev/null +++ b/tests/ECMPoQmToolsTest/check_conf.cmake.in @@ -0,0 +1,2 @@ +set(TR_TEST_EXEC "$") +set(TR_THREAD_TEST_EXEC "$") diff --git a/tests/ECMPoQmToolsTest/check_tree.cmake.in b/tests/ECMPoQmToolsTest/check_tree.cmake.in deleted file mode 100644 index 9f4f7c0d..00000000 --- a/tests/ECMPoQmToolsTest/check_tree.cmake.in +++ /dev/null @@ -1,61 +0,0 @@ -set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") -set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") -set(QMLOADER_PATH "@QMLOADER_PATH@") - -set(fail OFF) - -macro(mark_failed msg) - message(WARNING "FAIL: ${msg}") - set(fail ON) -endmacro() - -macro(check_strequal var expected) - if (NOT "${${var}}" STREQUAL "${expected}") - mark_failed("${var} is:\n \"${${var}}\"\nExpected:\n \"${expected}\"") - endif() -endmacro() - -macro(check_exists file) - if (NOT EXISTS ${file}) - mark_failed("File \"${file}\" does not exist") - endif() -endmacro() - -check_exists(${BINARY_DIR}/ECMQmLoader.cpp) -check_strequal(QMLOADER_PATH "${BINARY_DIR}/ECMQmLoader.cpp") - -check_exists(${BINARY_DIR}/fr/only-process.qm) - -set(exp_files - "share/locale/fr/LC_MESSAGES/process-and-install.qm" - "share/locale/es/LC_MESSAGES/install-test.qm" - "share/locale/fr/LC_MESSAGES/install-test.qm" - "custom-dir1/es/LC_MESSAGES/custom-dir1-install-test.qm" - "custom-dir1/fr/LC_MESSAGES/custom-dir1-install-test.qm" - "custom-dir2/es/LC_MESSAGES/custom-dir2-install-test.qm" - "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm" -) -file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") -list(SORT exp_files) -list(SORT actual_files) - -if(NOT exp_files STREQUAL actual_files) - foreach(f ${exp_files}) - list(FIND actual_files "${f}" result) - if(result EQUAL -1) - message(WARNING "${f} was expected, but not found") - set(fail ON) - endif() - endforeach() - foreach(f ${actual_files}) - list(FIND exp_files "${f}" result) - if(result EQUAL -1) - message(WARNING "${f} was found, but not expected") - set(fail ON) - endif() - endforeach() -endif() - -if (fail) - message(FATAL_ERROR "Test failed!") -endif() diff --git a/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po new file mode 100644 index 00000000..2a7b6d28 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po @@ -0,0 +1,22 @@ +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Language: en\n" +"X-Qt-Contexts: true\n" + +#: main.cpp:12 +msgctxt "testcontext|" +msgid "test string" +msgstr "english text" + +#: main.cpp:13 +#, qt-format +#| msgid "test plural" +msgctxt "testcontext|" +msgid "test plural %n" +msgid_plural "test plural %n" +msgstr[0] "english singular form %n" +msgstr[1] "english plural form %n" diff --git a/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po new file mode 100644 index 00000000..ec5ad857 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po @@ -0,0 +1,22 @@ +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Language: en_GB\n" +"X-Qt-Contexts: true\n" + +#: main.cpp:12 +msgctxt "testcontext|" +msgid "test string" +msgstr "british english text" + +#: main.cpp:13 +#, qt-format +#| msgid "test plural" +msgctxt "testcontext|" +msgid "test plural %n" +msgid_plural "test plural %n" +msgstr[0] "british english singular form %n" +msgstr[1] "british english plural form %n" diff --git a/tests/ECMPoQmToolsTest/tr_test.cpp b/tests/ECMPoQmToolsTest/tr_test.cpp new file mode 100644 index 00000000..be5d3427 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test.cpp @@ -0,0 +1,16 @@ +#include +#include + +#include + +int main(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + + QTextStream output(stdout); + + output << QCoreApplication::translate("testcontext", "test string") << ":"; + output << QCoreApplication::translate("testcontext", "test plural %n", 0, 5) << '\n'; + + return 0; +} diff --git a/tests/ECMPoQmToolsTest/tr_thread_test.cpp b/tests/ECMPoQmToolsTest/tr_thread_test.cpp new file mode 100644 index 00000000..3ed30ee1 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_thread_test.cpp @@ -0,0 +1,68 @@ +#include +#include +#include +#include + +class Thread : public QThread +{ + Q_OBJECT + + QLibrary *m_lib; + +public: + Thread() + : m_lib(0) + {} + ~Thread() + { + delete m_lib; + } + +Q_SIGNALS: + void libraryLoaded(); + +public Q_SLOTS: + void printStrings() + { + // NB: this will run on the *main* event loop. + QFunctionPointer print_strings = m_lib->resolve("print_strings"); + if (print_strings) { + print_strings(); + } else { + qFatal("Could not resolve print_strings: %s", m_lib->errorString().toUtf8().data()); + } + + QCoreApplication::instance()->quit(); + } +protected: + void run() + { + m_lib = new QLibrary(MODULE_PATH); + + if (!m_lib->load()) { + qFatal("Could not load module: %s", m_lib->errorString().toUtf8().data()); + } + + // Queue a call to printStrings() on the main event loop (giving the + // translations a chance to be loaded). + QMetaObject::invokeMethod(this, "printStrings", Qt::QueuedConnection); + } +}; + +int main(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + + Thread thread; + + // Start the thread *after* QCoreApplication is started (otherwise the + // plugin's startup function won't be run on the Thread, and we won't test + // what we wanted to test). + QMetaObject::invokeMethod(&thread, "start", Qt::QueuedConnection); + + app.exec(); + + return 0; +} + +#include "tr_thread_test.moc" diff --git a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp new file mode 100644 index 00000000..b9000ffa --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp @@ -0,0 +1,12 @@ +#include +#include + +#include + +extern "C" Q_DECL_EXPORT void print_strings() +{ + QTextStream output(stdout); + + output << QCoreApplication::translate("testcontext", "test string") << ":"; + output << QCoreApplication::translate("testcontext", "test plural %n", 0, 5) << '\n'; +} -- cgit v1.2.1 From 634a0a2d3d7ba1bec2bae846acf0faf6184f4c71 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Tue, 3 Nov 2015 10:30:14 +0000 Subject: Add license to tests. --- tests/ECMPoQmToolsTest/tr_test.cpp | 27 ++++++++++++++++++++++++ tests/ECMPoQmToolsTest/tr_thread_test.cpp | 27 ++++++++++++++++++++++++ tests/ECMPoQmToolsTest/tr_thread_test_module.cpp | 27 ++++++++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/tests/ECMPoQmToolsTest/tr_test.cpp b/tests/ECMPoQmToolsTest/tr_test.cpp index be5d3427..6536b60d 100644 --- a/tests/ECMPoQmToolsTest/tr_test.cpp +++ b/tests/ECMPoQmToolsTest/tr_test.cpp @@ -1,3 +1,30 @@ +/* + * 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 diff --git a/tests/ECMPoQmToolsTest/tr_thread_test.cpp b/tests/ECMPoQmToolsTest/tr_thread_test.cpp index 3ed30ee1..e128dc9d 100644 --- a/tests/ECMPoQmToolsTest/tr_thread_test.cpp +++ b/tests/ECMPoQmToolsTest/tr_thread_test.cpp @@ -1,3 +1,30 @@ +/* + * 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 #include diff --git a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp index b9000ffa..d13539e2 100644 --- a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp +++ b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp @@ -1,3 +1,30 @@ +/* + * 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 0496f8ae020c497b5f65234063150781d023f8ba Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Tue, 3 Nov 2015 17:13:00 +0000 Subject: Change ecm_create_po_loader test language to German. This is easier to distinguish from "english" in the test output than "british english". --- tests/ECMPoQmToolsTest/check.cmake.in | 6 +++--- tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po | 22 ++++++++++++++++++++++ tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po | 22 ---------------------- 3 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po delete mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in index 2f0cc205..8089db6e 100644 --- a/tests/ECMPoQmToolsTest/check.cmake.in +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -23,7 +23,7 @@ set(exp_files "share/locale/es/LC_MESSAGES/install-test.qm" "share/locale/fr/LC_MESSAGES/install-test.qm" "share/locale/en/LC_MESSAGES/catalog.qm" - "share/locale/en_GB/LC_MESSAGES/catalog.qm" + "share/locale/de/LC_MESSAGES/catalog.qm" "custom-dir1/es/LC_MESSAGES/custom-dir1-install-test.qm" "custom-dir1/fr/LC_MESSAGES/custom-dir1-install-test.qm" "custom-dir2/es/LC_MESSAGES/custom-dir2-install-test.qm" @@ -55,11 +55,11 @@ endif() # we know we can modify the executable environment on Linux if("@CMAKE_SYSTEM_NAME@" STREQUAL "Linux") set(exp_output_en "english text:english plural form 5") - set(exp_output_en_GB "british english text:british english plural form 5") + set(exp_output_de "german text:german plural form 5") # no french translation provided -> english fallback set(exp_output_fr "${exp_output_en}") foreach(exec TR_TEST TR_THREAD_TEST) - foreach(lang en en_GB fr) + foreach(lang en de fr) execute_process( COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" LC_ALL=${lang} "${${exec}_EXEC}" diff --git a/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po new file mode 100644 index 00000000..6f3e328f --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po @@ -0,0 +1,22 @@ +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Language: de\n" +"X-Qt-Contexts: true\n" + +#: main.cpp:12 +msgctxt "testcontext|" +msgid "test string" +msgstr "german text" + +#: main.cpp:13 +#, qt-format +#| msgid "test plural" +msgctxt "testcontext|" +msgid "test plural %n" +msgid_plural "test plural %n" +msgstr[0] "german singular form %n" +msgstr[1] "german plural form %n" diff --git a/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po deleted file mode 100644 index ec5ad857..00000000 --- a/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po +++ /dev/null @@ -1,22 +0,0 @@ -msgid "" -msgstr "" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Language: en_GB\n" -"X-Qt-Contexts: true\n" - -#: main.cpp:12 -msgctxt "testcontext|" -msgid "test string" -msgstr "british english text" - -#: main.cpp:13 -#, qt-format -#| msgid "test plural" -msgctxt "testcontext|" -msgid "test plural %n" -msgid_plural "test plural %n" -msgstr[0] "british english singular form %n" -msgstr[1] "british english plural form %n" -- cgit v1.2.1 From 39484722101730d4f1a4bccbc5467c0eb2cc0f6f Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Tue, 3 Nov 2015 17:27:45 +0000 Subject: Fix ECMPoQmToolsTest. LANGUAGE has higher priority than LC_ALL. --- tests/ECMPoQmToolsTest/check.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in index 8089db6e..6e6d46fe 100644 --- a/tests/ECMPoQmToolsTest/check.cmake.in +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -62,7 +62,7 @@ if("@CMAKE_SYSTEM_NAME@" STREQUAL "Linux") foreach(lang en de fr) execute_process( COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" - LC_ALL=${lang} "${${exec}_EXEC}" + LANGUAGE=${lang} "${${exec}_EXEC}" OUTPUT_VARIABLE output ) string(STRIP "${output}" stripped_output) -- 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(+) 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 ++++++++---- tests/ECMInstallIconsTest/CMakeLists.txt | 1 + tests/ECMInstallIconsTest/v1-syntax-no-icons/CMakeLists.txt | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 tests/ECMInstallIconsTest/v1-syntax-no-icons/CMakeLists.txt 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() diff --git a/tests/ECMInstallIconsTest/CMakeLists.txt b/tests/ECMInstallIconsTest/CMakeLists.txt index 738cba91..f048889e 100644 --- a/tests/ECMInstallIconsTest/CMakeLists.txt +++ b/tests/ECMInstallIconsTest/CMakeLists.txt @@ -10,6 +10,7 @@ include(ECMInstallIcons) add_subdirectory(v1-syntax) add_subdirectory(v1-syntax-l10n) +add_subdirectory(v1-syntax-no-icons) ecm_install_icons( ICONS 16-actions-computer.png diff --git a/tests/ECMInstallIconsTest/v1-syntax-no-icons/CMakeLists.txt b/tests/ECMInstallIconsTest/v1-syntax-no-icons/CMakeLists.txt new file mode 100644 index 00000000..e0cacec2 --- /dev/null +++ b/tests/ECMInstallIconsTest/v1-syntax-no-icons/CMakeLists.txt @@ -0,0 +1 @@ +ecm_install_icons(v1-icons-dummy) -- cgit v1.2.1 From 994940ae780a860935f5321830fab1955a687b44 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 8 Nov 2015 19:20:15 +0000 Subject: Revert "Fix ECMPoQmToolsTest." This commit is dependent on 009c480413910e8c1a18f4d1420f4a517ea606e6, which is the primary commit to be reverted. This reverts commit 39484722101730d4f1a4bccbc5467c0eb2cc0f6f. --- tests/ECMPoQmToolsTest/check.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in index 6e6d46fe..8089db6e 100644 --- a/tests/ECMPoQmToolsTest/check.cmake.in +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -62,7 +62,7 @@ if("@CMAKE_SYSTEM_NAME@" STREQUAL "Linux") foreach(lang en de fr) execute_process( COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" - LANGUAGE=${lang} "${${exec}_EXEC}" + LC_ALL=${lang} "${${exec}_EXEC}" OUTPUT_VARIABLE output ) string(STRIP "${output}" stripped_output) -- cgit v1.2.1 From 9d4be698a3a9a0b81730d2d54de5dd33b7dc61dc Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 8 Nov 2015 19:23:14 +0000 Subject: Revert "Change ecm_create_po_loader test language to German." This commit is dependent on 009c480413910e8c1a18f4d1420f4a517ea606e6, which is the primary commit to be reverted. This reverts commit 0496f8ae020c497b5f65234063150781d023f8ba. --- tests/ECMPoQmToolsTest/check.cmake.in | 6 +++--- tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po | 22 ---------------------- tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po create mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in index 8089db6e..2f0cc205 100644 --- a/tests/ECMPoQmToolsTest/check.cmake.in +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -23,7 +23,7 @@ set(exp_files "share/locale/es/LC_MESSAGES/install-test.qm" "share/locale/fr/LC_MESSAGES/install-test.qm" "share/locale/en/LC_MESSAGES/catalog.qm" - "share/locale/de/LC_MESSAGES/catalog.qm" + "share/locale/en_GB/LC_MESSAGES/catalog.qm" "custom-dir1/es/LC_MESSAGES/custom-dir1-install-test.qm" "custom-dir1/fr/LC_MESSAGES/custom-dir1-install-test.qm" "custom-dir2/es/LC_MESSAGES/custom-dir2-install-test.qm" @@ -55,11 +55,11 @@ endif() # we know we can modify the executable environment on Linux if("@CMAKE_SYSTEM_NAME@" STREQUAL "Linux") set(exp_output_en "english text:english plural form 5") - set(exp_output_de "german text:german plural form 5") + set(exp_output_en_GB "british english text:british english plural form 5") # no french translation provided -> english fallback set(exp_output_fr "${exp_output_en}") foreach(exec TR_TEST TR_THREAD_TEST) - foreach(lang en de fr) + foreach(lang en en_GB fr) execute_process( COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" LC_ALL=${lang} "${${exec}_EXEC}" diff --git a/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po deleted file mode 100644 index 6f3e328f..00000000 --- a/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po +++ /dev/null @@ -1,22 +0,0 @@ -msgid "" -msgstr "" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Language: de\n" -"X-Qt-Contexts: true\n" - -#: main.cpp:12 -msgctxt "testcontext|" -msgid "test string" -msgstr "german text" - -#: main.cpp:13 -#, qt-format -#| msgid "test plural" -msgctxt "testcontext|" -msgid "test plural %n" -msgid_plural "test plural %n" -msgstr[0] "german singular form %n" -msgstr[1] "german plural form %n" diff --git a/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po new file mode 100644 index 00000000..ec5ad857 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po @@ -0,0 +1,22 @@ +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Language: en_GB\n" +"X-Qt-Contexts: true\n" + +#: main.cpp:12 +msgctxt "testcontext|" +msgid "test string" +msgstr "british english text" + +#: main.cpp:13 +#, qt-format +#| msgid "test plural" +msgctxt "testcontext|" +msgid "test plural %n" +msgid_plural "test plural %n" +msgstr[0] "british english singular form %n" +msgstr[1] "british english plural form %n" -- cgit v1.2.1 From c58a8eefb05d0749bb4cc26a6cd74dee34e1f4be Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sun, 8 Nov 2015 19:23:21 +0000 Subject: Revert "Add license to tests." This commit is dependent on 009c480413910e8c1a18f4d1420f4a517ea606e6, which is the primary commit to be reverted. This reverts commit 634a0a2d3d7ba1bec2bae846acf0faf6184f4c71. --- tests/ECMPoQmToolsTest/tr_test.cpp | 27 ------------------------ tests/ECMPoQmToolsTest/tr_thread_test.cpp | 27 ------------------------ tests/ECMPoQmToolsTest/tr_thread_test_module.cpp | 27 ------------------------ 3 files changed, 81 deletions(-) diff --git a/tests/ECMPoQmToolsTest/tr_test.cpp b/tests/ECMPoQmToolsTest/tr_test.cpp index 6536b60d..be5d3427 100644 --- a/tests/ECMPoQmToolsTest/tr_test.cpp +++ b/tests/ECMPoQmToolsTest/tr_test.cpp @@ -1,30 +1,3 @@ -/* - * 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 diff --git a/tests/ECMPoQmToolsTest/tr_thread_test.cpp b/tests/ECMPoQmToolsTest/tr_thread_test.cpp index e128dc9d..3ed30ee1 100644 --- a/tests/ECMPoQmToolsTest/tr_thread_test.cpp +++ b/tests/ECMPoQmToolsTest/tr_thread_test.cpp @@ -1,30 +1,3 @@ -/* - * 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 #include diff --git a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp index d13539e2..b9000ffa 100644 --- a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp +++ b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp @@ -1,30 +1,3 @@ -/* - * 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 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 +++++++--------------- tests/CMakeLists.txt | 4 +- tests/ECMPoQmToolsTest/CMakeLists.txt | 32 ++------ tests/ECMPoQmToolsTest/check.cmake.in | 81 -------------------- tests/ECMPoQmToolsTest/check_conf.cmake.in | 2 - tests/ECMPoQmToolsTest/check_tree.cmake.in | 61 +++++++++++++++ tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po | 22 ------ tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po | 22 ------ tests/ECMPoQmToolsTest/tr_test.cpp | 16 ---- tests/ECMPoQmToolsTest/tr_thread_test.cpp | 68 ----------------- tests/ECMPoQmToolsTest/tr_thread_test_module.cpp | 12 --- 12 files changed, 96 insertions(+), 327 deletions(-) delete mode 100644 tests/ECMPoQmToolsTest/check.cmake.in delete mode 100644 tests/ECMPoQmToolsTest/check_conf.cmake.in create mode 100644 tests/ECMPoQmToolsTest/check_tree.cmake.in delete mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po delete mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po delete mode 100644 tests/ECMPoQmToolsTest/tr_test.cpp delete mode 100644 tests/ECMPoQmToolsTest/tr_thread_test.cpp delete mode 100644 tests/ECMPoQmToolsTest/tr_thread_test_module.cpp 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) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9e6de12f..8a75ae61 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -101,13 +101,13 @@ add_test_macro(ECMInstallIconsTest ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMInstallIconsTest/check_tree.cmake" ) -if (Qt5Core_FOUND AND Qt5LinguistTools_FOUND) +if (Qt5LinguistTools_FOUND) set(ECMPoQmToolsTest_EXTRA_OPTIONS --build-target install --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/InstallDirectory" ) add_test_macro(ECMPoQmToolsTest - ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/check.cmake" + ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/check_tree.cmake" ) endif() diff --git a/tests/ECMPoQmToolsTest/CMakeLists.txt b/tests/ECMPoQmToolsTest/CMakeLists.txt index e08a2b8c..15351d2f 100644 --- a/tests/ECMPoQmToolsTest/CMakeLists.txt +++ b/tests/ECMPoQmToolsTest/CMakeLists.txt @@ -9,14 +9,9 @@ file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}") include(ECMPoQmTools) -include(../test_helpers.cmake) - -unset(QMLOADER_FILES) -ecm_create_qm_loader(QMLOADER_FILES catalog) -assert_var_defined(QMLOADER_FILES) - -# These will be used to test the above-generated loader -ecm_install_po_files_as_qm(tr_test-po) +# Should create ${CMAKE_CURRENT_BINARY_DIR}/qmloader.cpp and set QMLOADER_PATH +# to its path +ecm_create_qm_loader(QMLOADER_PATH catalog) # Should create a process-and-install.qm file and install it ecm_process_po_files_as_qm(fr ALL @@ -44,22 +39,5 @@ ecm_install_po_files_as_qm(po-custom-dir1) set(LOCALE_INSTALL_DIR custom-dir2) ecm_install_po_files_as_qm(po-custom-dir2) -find_package(Qt5Core CONFIG REQUIRED) - -add_executable(tr_test tr_test.cpp ${QMLOADER_FILES}) -target_link_libraries(tr_test PRIVATE Qt5::Core) - -add_library(tr_thread_module MODULE tr_thread_test_module.cpp ${QMLOADER_FILES}) -target_link_libraries(tr_thread_module PRIVATE Qt5::Core) - -add_executable(tr_thread_test tr_thread_test.cpp) -set_target_properties(tr_thread_test PROPERTIES AUTOMOC ON) -target_include_directories(tr_thread_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") -target_compile_definitions(tr_thread_test PRIVATE "MODULE_PATH=\"$\"") -target_link_libraries(tr_thread_test PRIVATE Qt5::Core) - -file(GENERATE - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/check_conf.cmake" - INPUT "${CMAKE_CURRENT_SOURCE_DIR}/check_conf.cmake.in" -) -configure_file(check.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check.cmake" @ONLY) +# this will be run by CTest +configure_file(check_tree.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check_tree.cmake" @ONLY) diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in deleted file mode 100644 index 2f0cc205..00000000 --- a/tests/ECMPoQmToolsTest/check.cmake.in +++ /dev/null @@ -1,81 +0,0 @@ -set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") -set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") -include("${BINARY_DIR}/check_conf.cmake") - -set(fail OFF) - -macro(mark_failed msg) - message(WARNING "FAIL: ${msg}") - set(fail ON) -endmacro() - -macro(check_exists file) - message(STATUS "Checking for ${file}") - if (NOT EXISTS ${file}) - mark_failed("File \"${file}\" does not exist") - endif() -endmacro() - -check_exists(${BINARY_DIR}/fr/only-process.qm) - -set(exp_files - "share/locale/fr/LC_MESSAGES/process-and-install.qm" - "share/locale/es/LC_MESSAGES/install-test.qm" - "share/locale/fr/LC_MESSAGES/install-test.qm" - "share/locale/en/LC_MESSAGES/catalog.qm" - "share/locale/en_GB/LC_MESSAGES/catalog.qm" - "custom-dir1/es/LC_MESSAGES/custom-dir1-install-test.qm" - "custom-dir1/fr/LC_MESSAGES/custom-dir1-install-test.qm" - "custom-dir2/es/LC_MESSAGES/custom-dir2-install-test.qm" - "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm" -) -file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") -list(SORT exp_files) -list(SORT actual_files) - -if(NOT exp_files STREQUAL actual_files) - foreach(f ${exp_files}) - list(FIND actual_files "${f}" result) - if(result EQUAL -1) - message(WARNING "${f} was expected, but not found") - set(fail ON) - endif() - endforeach() - foreach(f ${actual_files}) - list(FIND exp_files "${f}" result) - if(result EQUAL -1) - message(WARNING "${f} was found, but not expected") - set(fail ON) - endif() - endforeach() -else() - message(STATUS "Installed translations in expected locations") -endif() - -# we know we can modify the executable environment on Linux -if("@CMAKE_SYSTEM_NAME@" STREQUAL "Linux") - set(exp_output_en "english text:english plural form 5") - set(exp_output_en_GB "british english text:british english plural form 5") - # no french translation provided -> english fallback - set(exp_output_fr "${exp_output_en}") - foreach(exec TR_TEST TR_THREAD_TEST) - foreach(lang en en_GB fr) - execute_process( - COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" - LC_ALL=${lang} "${${exec}_EXEC}" - OUTPUT_VARIABLE output - ) - string(STRIP "${output}" stripped_output) - if(NOT stripped_output STREQUAL exp_output_${lang}) - message(WARNING "${exec}[${lang}] output was \"${stripped_output}\", but expected \"${exp_output_${lang}}\"") - set(fail ON) - else() - message(STATUS "${exec}[${lang}] output was \"${stripped_output}\", as expected") - endif() - endforeach() - endforeach() -endif() - -if (fail) - message(FATAL_ERROR "Test failed!") -endif() diff --git a/tests/ECMPoQmToolsTest/check_conf.cmake.in b/tests/ECMPoQmToolsTest/check_conf.cmake.in deleted file mode 100644 index 0bbab1d9..00000000 --- a/tests/ECMPoQmToolsTest/check_conf.cmake.in +++ /dev/null @@ -1,2 +0,0 @@ -set(TR_TEST_EXEC "$") -set(TR_THREAD_TEST_EXEC "$") diff --git a/tests/ECMPoQmToolsTest/check_tree.cmake.in b/tests/ECMPoQmToolsTest/check_tree.cmake.in new file mode 100644 index 00000000..9f4f7c0d --- /dev/null +++ b/tests/ECMPoQmToolsTest/check_tree.cmake.in @@ -0,0 +1,61 @@ +set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") +set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") +set(QMLOADER_PATH "@QMLOADER_PATH@") + +set(fail OFF) + +macro(mark_failed msg) + message(WARNING "FAIL: ${msg}") + set(fail ON) +endmacro() + +macro(check_strequal var expected) + if (NOT "${${var}}" STREQUAL "${expected}") + mark_failed("${var} is:\n \"${${var}}\"\nExpected:\n \"${expected}\"") + endif() +endmacro() + +macro(check_exists file) + if (NOT EXISTS ${file}) + mark_failed("File \"${file}\" does not exist") + endif() +endmacro() + +check_exists(${BINARY_DIR}/ECMQmLoader.cpp) +check_strequal(QMLOADER_PATH "${BINARY_DIR}/ECMQmLoader.cpp") + +check_exists(${BINARY_DIR}/fr/only-process.qm) + +set(exp_files + "share/locale/fr/LC_MESSAGES/process-and-install.qm" + "share/locale/es/LC_MESSAGES/install-test.qm" + "share/locale/fr/LC_MESSAGES/install-test.qm" + "custom-dir1/es/LC_MESSAGES/custom-dir1-install-test.qm" + "custom-dir1/fr/LC_MESSAGES/custom-dir1-install-test.qm" + "custom-dir2/es/LC_MESSAGES/custom-dir2-install-test.qm" + "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm" +) +file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") +list(SORT exp_files) +list(SORT actual_files) + +if(NOT exp_files STREQUAL actual_files) + foreach(f ${exp_files}) + list(FIND actual_files "${f}" result) + if(result EQUAL -1) + message(WARNING "${f} was expected, but not found") + set(fail ON) + endif() + endforeach() + foreach(f ${actual_files}) + list(FIND exp_files "${f}" result) + if(result EQUAL -1) + message(WARNING "${f} was found, but not expected") + set(fail ON) + endif() + endforeach() +endif() + +if (fail) + message(FATAL_ERROR "Test failed!") +endif() diff --git a/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po deleted file mode 100644 index 2a7b6d28..00000000 --- a/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po +++ /dev/null @@ -1,22 +0,0 @@ -msgid "" -msgstr "" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Language: en\n" -"X-Qt-Contexts: true\n" - -#: main.cpp:12 -msgctxt "testcontext|" -msgid "test string" -msgstr "english text" - -#: main.cpp:13 -#, qt-format -#| msgid "test plural" -msgctxt "testcontext|" -msgid "test plural %n" -msgid_plural "test plural %n" -msgstr[0] "english singular form %n" -msgstr[1] "english plural form %n" diff --git a/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po deleted file mode 100644 index ec5ad857..00000000 --- a/tests/ECMPoQmToolsTest/tr_test-po/en_GB/catalog.po +++ /dev/null @@ -1,22 +0,0 @@ -msgid "" -msgstr "" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Language: en_GB\n" -"X-Qt-Contexts: true\n" - -#: main.cpp:12 -msgctxt "testcontext|" -msgid "test string" -msgstr "british english text" - -#: main.cpp:13 -#, qt-format -#| msgid "test plural" -msgctxt "testcontext|" -msgid "test plural %n" -msgid_plural "test plural %n" -msgstr[0] "british english singular form %n" -msgstr[1] "british english plural form %n" diff --git a/tests/ECMPoQmToolsTest/tr_test.cpp b/tests/ECMPoQmToolsTest/tr_test.cpp deleted file mode 100644 index be5d3427..00000000 --- a/tests/ECMPoQmToolsTest/tr_test.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -#include - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - - QTextStream output(stdout); - - output << QCoreApplication::translate("testcontext", "test string") << ":"; - output << QCoreApplication::translate("testcontext", "test plural %n", 0, 5) << '\n'; - - return 0; -} diff --git a/tests/ECMPoQmToolsTest/tr_thread_test.cpp b/tests/ECMPoQmToolsTest/tr_thread_test.cpp deleted file mode 100644 index 3ed30ee1..00000000 --- a/tests/ECMPoQmToolsTest/tr_thread_test.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include -#include - -class Thread : public QThread -{ - Q_OBJECT - - QLibrary *m_lib; - -public: - Thread() - : m_lib(0) - {} - ~Thread() - { - delete m_lib; - } - -Q_SIGNALS: - void libraryLoaded(); - -public Q_SLOTS: - void printStrings() - { - // NB: this will run on the *main* event loop. - QFunctionPointer print_strings = m_lib->resolve("print_strings"); - if (print_strings) { - print_strings(); - } else { - qFatal("Could not resolve print_strings: %s", m_lib->errorString().toUtf8().data()); - } - - QCoreApplication::instance()->quit(); - } -protected: - void run() - { - m_lib = new QLibrary(MODULE_PATH); - - if (!m_lib->load()) { - qFatal("Could not load module: %s", m_lib->errorString().toUtf8().data()); - } - - // Queue a call to printStrings() on the main event loop (giving the - // translations a chance to be loaded). - QMetaObject::invokeMethod(this, "printStrings", Qt::QueuedConnection); - } -}; - -int main(int argc, char** argv) -{ - QCoreApplication app(argc, argv); - - Thread thread; - - // Start the thread *after* QCoreApplication is started (otherwise the - // plugin's startup function won't be run on the Thread, and we won't test - // what we wanted to test). - QMetaObject::invokeMethod(&thread, "start", Qt::QueuedConnection); - - app.exec(); - - return 0; -} - -#include "tr_thread_test.moc" diff --git a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp b/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp deleted file mode 100644 index b9000ffa..00000000 --- a/tests/ECMPoQmToolsTest/tr_thread_test_module.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -#include - -extern "C" Q_DECL_EXPORT void print_strings() -{ - QTextStream output(stdout); - - output << QCoreApplication::translate("testcontext", "test string") << ":"; - output << QCoreApplication::translate("testcontext", "test plural %n", 0, 5) << '\n'; -} -- cgit v1.2.1 From c88bc78e0ca3834c46b89ca9d14b404751da5d4a Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Wed, 14 Oct 2015 12:18:40 +0100 Subject: Add unit test for ecm_create_qm_loader. This is based on commit 6745bd7e4796560959bb67e33b7c7f86f96a5a94 (and the subsequent fix-up commits). --- tests/CMakeLists.txt | 4 +- tests/ECMPoQmToolsTest/CMakeLists.txt | 57 +++++++++++++++-- tests/ECMPoQmToolsTest/check.cmake.in | 81 +++++++++++++++++++++++++ tests/ECMPoQmToolsTest/check_conf.cmake.in | 2 + tests/ECMPoQmToolsTest/check_tree.cmake.in | 61 ------------------- tests/ECMPoQmToolsTest/subdir/CMakeLists.txt | 5 ++ tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po | 22 +++++++ tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po | 22 +++++++ tests/ECMPoQmToolsTest/tr_test.cpp | 43 +++++++++++++ 9 files changed, 229 insertions(+), 68 deletions(-) create mode 100644 tests/ECMPoQmToolsTest/check.cmake.in create mode 100644 tests/ECMPoQmToolsTest/check_conf.cmake.in delete mode 100644 tests/ECMPoQmToolsTest/check_tree.cmake.in create mode 100644 tests/ECMPoQmToolsTest/subdir/CMakeLists.txt create mode 100644 tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po create mode 100644 tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po create mode 100644 tests/ECMPoQmToolsTest/tr_test.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8a75ae61..9e6de12f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -101,13 +101,13 @@ add_test_macro(ECMInstallIconsTest ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMInstallIconsTest/check_tree.cmake" ) -if (Qt5LinguistTools_FOUND) +if (Qt5Core_FOUND AND Qt5LinguistTools_FOUND) set(ECMPoQmToolsTest_EXTRA_OPTIONS --build-target install --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/InstallDirectory" ) add_test_macro(ECMPoQmToolsTest - ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/check_tree.cmake" + ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/ECMPoQmToolsTest/check.cmake" ) endif() diff --git a/tests/ECMPoQmToolsTest/CMakeLists.txt b/tests/ECMPoQmToolsTest/CMakeLists.txt index 15351d2f..76d80141 100644 --- a/tests/ECMPoQmToolsTest/CMakeLists.txt +++ b/tests/ECMPoQmToolsTest/CMakeLists.txt @@ -9,9 +9,13 @@ file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}") include(ECMPoQmTools) -# Should create ${CMAKE_CURRENT_BINARY_DIR}/qmloader.cpp and set QMLOADER_PATH -# to its path -ecm_create_qm_loader(QMLOADER_PATH catalog) +include(../test_helpers.cmake) + + +# +# ecm_process_po_files_as_qm +# + # Should create a process-and-install.qm file and install it ecm_process_po_files_as_qm(fr ALL @@ -24,20 +28,63 @@ ecm_process_po_files_as_qm(fr ALL PO_FILES only-process.po ) + + +# +# ecm_install_po_files_as_qm +# + # Should create a bunch of .qm files and install them in share/locale. # Should ignore files directly under po/ as well as directories under po/ which # do not contain any .po files. ecm_install_po_files_as_qm(po) + # Should create a bunch of .qm files and install them in # ${CMAKE_INSTALL_LOCALEDIR} set(CMAKE_INSTALL_LOCALEDIR custom-dir1) ecm_install_po_files_as_qm(po-custom-dir1) + # Should create a bunch of .qm files and install them in # ${LOCALE_INSTALL_DIR} set(LOCALE_INSTALL_DIR custom-dir2) ecm_install_po_files_as_qm(po-custom-dir2) -# this will be run by CTest -configure_file(check_tree.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check_tree.cmake" @ONLY) +unset(CMAKE_INSTALL_LOCALEDIR) +unset(LOCALE_INSTALL_DIR) + + + +# +# ecm_create_qm_loader +# + +find_package(Qt5Core CONFIG REQUIRED) +ecm_install_po_files_as_qm(tr_test-po) + + +set(tr_test_SRCS + tr_test.cpp +) +ecm_create_qm_loader(tr_test_SRCS catalog) +add_executable(tr_test ${tr_test_SRCS}) +target_link_libraries(tr_test PRIVATE Qt5::Core) + + +# This is not something we want people to do (putting the ecm_create_qm_loader +# call in one CMakeLists.txt file and the target it is used for in another), +# but it's unfortunately something projects have done and we need to keep them +# building +unset(QMLOADER_FILES) +ecm_create_qm_loader(QMLOADER_FILES catalog) +assert_var_defined(QMLOADER_FILES) +add_subdirectory(subdir) + + + +file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/check_conf.cmake" + INPUT "${CMAKE_CURRENT_SOURCE_DIR}/check_conf.cmake.in" +) +configure_file(check.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check.cmake" @ONLY) diff --git a/tests/ECMPoQmToolsTest/check.cmake.in b/tests/ECMPoQmToolsTest/check.cmake.in new file mode 100644 index 00000000..ab434d2e --- /dev/null +++ b/tests/ECMPoQmToolsTest/check.cmake.in @@ -0,0 +1,81 @@ +set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") +set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") +include("${BINARY_DIR}/check_conf.cmake") + +set(fail OFF) + +macro(mark_failed msg) + message(WARNING "FAIL: ${msg}") + set(fail ON) +endmacro() + +macro(check_exists file) + message(STATUS "Checking for ${file}") + if (NOT EXISTS ${file}) + mark_failed("File \"${file}\" does not exist") + endif() +endmacro() + +check_exists(${BINARY_DIR}/fr/only-process.qm) + +set(exp_files + "share/locale/fr/LC_MESSAGES/process-and-install.qm" + "share/locale/es/LC_MESSAGES/install-test.qm" + "share/locale/fr/LC_MESSAGES/install-test.qm" + "share/locale/en/LC_MESSAGES/catalog.qm" + "share/locale/de/LC_MESSAGES/catalog.qm" + "custom-dir1/es/LC_MESSAGES/custom-dir1-install-test.qm" + "custom-dir1/fr/LC_MESSAGES/custom-dir1-install-test.qm" + "custom-dir2/es/LC_MESSAGES/custom-dir2-install-test.qm" + "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm" +) +file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") +list(SORT exp_files) +list(SORT actual_files) + +if(NOT exp_files STREQUAL actual_files) + foreach(f ${exp_files}) + list(FIND actual_files "${f}" result) + if(result EQUAL -1) + message(WARNING "${f} was expected, but not found") + set(fail ON) + endif() + endforeach() + foreach(f ${actual_files}) + list(FIND exp_files "${f}" result) + if(result EQUAL -1) + message(WARNING "${f} was found, but not expected") + set(fail ON) + endif() + endforeach() +else() + message(STATUS "Installed translations in expected locations") +endif() + +# we know we can modify the executable environment on Linux +if("@CMAKE_SYSTEM_NAME@" STREQUAL "Linux") + set(exp_output_en "english text:english plural form 5") + set(exp_output_de "german text:german plural form 5") + # no french translation provided -> english fallback + set(exp_output_fr "${exp_output_en}") + foreach(exec TR_TEST TR_TEST_SUBDIR) + foreach(lang en de fr) + execute_process( + COMMAND "${CMAKE_COMMAND}" -E env "XDG_DATA_DIRS=${ACTUAL_TREE}/share" + LANGUAGE=${lang} "${${exec}_EXEC}" + OUTPUT_VARIABLE output + ) + string(STRIP "${output}" stripped_output) + if(NOT stripped_output STREQUAL exp_output_${lang}) + message(WARNING "${exec}[${lang}] output was \"${stripped_output}\", but expected \"${exp_output_${lang}}\"") + set(fail ON) + else() + message(STATUS "${exec}[${lang}] output was \"${stripped_output}\", as expected") + endif() + endforeach() + endforeach() +endif() + +if (fail) + message(FATAL_ERROR "Test failed!") +endif() diff --git a/tests/ECMPoQmToolsTest/check_conf.cmake.in b/tests/ECMPoQmToolsTest/check_conf.cmake.in new file mode 100644 index 00000000..9ab02e72 --- /dev/null +++ b/tests/ECMPoQmToolsTest/check_conf.cmake.in @@ -0,0 +1,2 @@ +set(TR_TEST_EXEC "$") +set(TR_TEST_SUBDIR_EXEC "$") diff --git a/tests/ECMPoQmToolsTest/check_tree.cmake.in b/tests/ECMPoQmToolsTest/check_tree.cmake.in deleted file mode 100644 index 9f4f7c0d..00000000 --- a/tests/ECMPoQmToolsTest/check_tree.cmake.in +++ /dev/null @@ -1,61 +0,0 @@ -set(BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") -set(ACTUAL_TREE "@CMAKE_INSTALL_PREFIX@") -set(QMLOADER_PATH "@QMLOADER_PATH@") - -set(fail OFF) - -macro(mark_failed msg) - message(WARNING "FAIL: ${msg}") - set(fail ON) -endmacro() - -macro(check_strequal var expected) - if (NOT "${${var}}" STREQUAL "${expected}") - mark_failed("${var} is:\n \"${${var}}\"\nExpected:\n \"${expected}\"") - endif() -endmacro() - -macro(check_exists file) - if (NOT EXISTS ${file}) - mark_failed("File \"${file}\" does not exist") - endif() -endmacro() - -check_exists(${BINARY_DIR}/ECMQmLoader.cpp) -check_strequal(QMLOADER_PATH "${BINARY_DIR}/ECMQmLoader.cpp") - -check_exists(${BINARY_DIR}/fr/only-process.qm) - -set(exp_files - "share/locale/fr/LC_MESSAGES/process-and-install.qm" - "share/locale/es/LC_MESSAGES/install-test.qm" - "share/locale/fr/LC_MESSAGES/install-test.qm" - "custom-dir1/es/LC_MESSAGES/custom-dir1-install-test.qm" - "custom-dir1/fr/LC_MESSAGES/custom-dir1-install-test.qm" - "custom-dir2/es/LC_MESSAGES/custom-dir2-install-test.qm" - "custom-dir2/fr/LC_MESSAGES/custom-dir2-install-test.qm" -) -file(GLOB_RECURSE actual_files RELATIVE "${ACTUAL_TREE}" "${ACTUAL_TREE}/*") -list(SORT exp_files) -list(SORT actual_files) - -if(NOT exp_files STREQUAL actual_files) - foreach(f ${exp_files}) - list(FIND actual_files "${f}" result) - if(result EQUAL -1) - message(WARNING "${f} was expected, but not found") - set(fail ON) - endif() - endforeach() - foreach(f ${actual_files}) - list(FIND exp_files "${f}" result) - if(result EQUAL -1) - message(WARNING "${f} was found, but not expected") - set(fail ON) - endif() - endforeach() -endif() - -if (fail) - message(FATAL_ERROR "Test failed!") -endif() diff --git a/tests/ECMPoQmToolsTest/subdir/CMakeLists.txt b/tests/ECMPoQmToolsTest/subdir/CMakeLists.txt new file mode 100644 index 00000000..ee06b971 --- /dev/null +++ b/tests/ECMPoQmToolsTest/subdir/CMakeLists.txt @@ -0,0 +1,5 @@ +# QMLOADER_FILES comes from parent CMakeLists.txt. This is not something we +# want people to do, but it's unfortunately something projects have done and we +# need to keep them building +add_executable(tr_test_subdir ../tr_test.cpp ${QMLOADER_FILES}) +target_link_libraries(tr_test_subdir PRIVATE Qt5::Core) diff --git a/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po new file mode 100644 index 00000000..6f3e328f --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test-po/de/catalog.po @@ -0,0 +1,22 @@ +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Language: de\n" +"X-Qt-Contexts: true\n" + +#: main.cpp:12 +msgctxt "testcontext|" +msgid "test string" +msgstr "german text" + +#: main.cpp:13 +#, qt-format +#| msgid "test plural" +msgctxt "testcontext|" +msgid "test plural %n" +msgid_plural "test plural %n" +msgstr[0] "german singular form %n" +msgstr[1] "german plural form %n" diff --git a/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po b/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po new file mode 100644 index 00000000..2a7b6d28 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test-po/en/catalog.po @@ -0,0 +1,22 @@ +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Language: en\n" +"X-Qt-Contexts: true\n" + +#: main.cpp:12 +msgctxt "testcontext|" +msgid "test string" +msgstr "english text" + +#: main.cpp:13 +#, qt-format +#| msgid "test plural" +msgctxt "testcontext|" +msgid "test plural %n" +msgid_plural "test plural %n" +msgstr[0] "english singular form %n" +msgstr[1] "english plural form %n" diff --git a/tests/ECMPoQmToolsTest/tr_test.cpp b/tests/ECMPoQmToolsTest/tr_test.cpp new file mode 100644 index 00000000..22101263 --- /dev/null +++ b/tests/ECMPoQmToolsTest/tr_test.cpp @@ -0,0 +1,43 @@ +/* + * 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 + +#include + +int main(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + + QTextStream output(stdout); + + output << QCoreApplication::translate("testcontext", "test string") << ":"; + output << QCoreApplication::translate("testcontext", "test plural %n", 0, 5) << '\n'; + + return 0; +} -- cgit v1.2.1