diff options
122 files changed, 975 insertions, 318 deletions
diff --git a/Auxiliary/vim/indent/cmake.vim b/Auxiliary/vim/indent/cmake.vim index f7ab24a..672bdcc 100644 --- a/Auxiliary/vim/indent/cmake.vim +++ b/Auxiliary/vim/indent/cmake.vim @@ -3,7 +3,7 @@ " Author: Andy Cedilnik <andy.cedilnik@kitware.com> " Maintainer: Dimitri Merejkowsky <d.merej@gmail.com> " Former Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com> -" Last Change: 2017 Aug 30 +" Last Change: 2022 Mar 22 " " License: The CMake license applies to this file. See " https://cmake.org/licensing @@ -14,9 +14,6 @@ if exists("b:did_indent") endif let b:did_indent = 1 -let s:keepcpo= &cpo -set cpo&vim - setlocal indentexpr=CMakeGetIndent(v:lnum) setlocal indentkeys+==ENDIF(,ENDFOREACH(,ENDMACRO(,ELSE(,ELSEIF(,ENDWHILE( @@ -24,6 +21,8 @@ setlocal indentkeys+==ENDIF(,ENDFOREACH(,ENDMACRO(,ELSE(,ELSEIF(,ENDWHILE( if exists("*CMakeGetIndent") finish endif +let s:keepcpo= &cpo +set cpo&vim fun! CMakeGetIndent(lnum) let this_line = getline(a:lnum) @@ -54,32 +53,41 @@ fun! CMakeGetIndent(lnum) let cmake_indent_open_regex = '^\s*' . cmake_regex_identifier . \ '\s*(' . cmake_regex_arguments . \ '\(' . cmake_regex_comment . '\)\?$' - let cmake_indent_close_regex = '^' . cmake_regex_arguments . \ ')\s*' . \ '\(' . cmake_regex_comment . '\)\?$' + let cmake_closing_parens_line = '^\s*\()\+\)\s*$' + let cmake_indent_begin_regex = '^\s*\(IF\|MACRO\|FOREACH\|ELSE\|ELSEIF\|WHILE\|FUNCTION\)\s*(' let cmake_indent_end_regex = '^\s*\(ENDIF\|ENDFOREACH\|ENDMACRO\|ELSE\|ELSEIF\|ENDWHILE\|ENDFUNCTION\)\s*(' - " Add - if previous_line =~? cmake_indent_comment_line " Handle comments - let ind = ind - else - if previous_line =~? cmake_indent_begin_regex - let ind = ind + shiftwidth() + if this_line =~? cmake_closing_parens_line + if previous_line !~? cmake_indent_open_regex + let ind = ind - shiftwidth() endif - if previous_line =~? cmake_indent_open_regex - let ind = ind + shiftwidth() + else + " Add + if previous_line =~? cmake_indent_comment_line " Handle comments + let ind = ind + else + if previous_line =~? cmake_indent_begin_regex + let ind = ind + shiftwidth() + endif + if previous_line =~? cmake_indent_open_regex + let ind = ind + shiftwidth() + endif endif - endif - " Subtract - if this_line =~? cmake_indent_end_regex - let ind = ind - shiftwidth() - endif - if previous_line =~? cmake_indent_close_regex - let ind = ind - shiftwidth() + " Subtract + if this_line =~? cmake_indent_end_regex + let ind = ind - shiftwidth() + endif + if previous_line !~? cmake_closing_parens_line + if previous_line =~? cmake_indent_close_regex + let ind = ind - shiftwidth() + endif + endif endif return ind diff --git a/Help/command/define_property.rst b/Help/command/define_property.rst index c882347..76b060b 100644 --- a/Help/command/define_property.rst +++ b/Help/command/define_property.rst @@ -69,5 +69,7 @@ project via corresponding options to the :command:`get_property` command. The ``INITIALIZE_FROM_VARIABLE`` option specifies a variable from which the property should be initialized. It can only be used with target properties. - The ``<variable>`` name must end with the property name, must have a prefix - before the property name, and must not begin with ``CMAKE_`` or ``_CMAKE_``. + The ``<variable>`` name must end with the property name and must not begin + with ``CMAKE_`` or ``_CMAKE_``. The property name must contain at least one + underscore. It is recommended that the property name have a prefix specific + to the project. diff --git a/Help/command/file.rst b/Help/command/file.rst index 2769577..3374d2d 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -1227,7 +1227,8 @@ the ``MTIME`` option. [DESTINATION <dir>] [PATTERNS <patterns>...] [LIST_ONLY] - [VERBOSE]) + [VERBOSE] + [TOUCH]) .. versionadded:: 3.18 @@ -1245,4 +1246,8 @@ extracted. ``LIST_ONLY`` will list the files in the archive rather than extract them. +.. versionadded:: 3.24 + The ``TOUCH`` option gives extracted files a current local + timestamp instead of extracting file timestamps from the archive. + With ``VERBOSE``, the command will produce verbose output. diff --git a/Help/cpack_gen/ifw.rst b/Help/cpack_gen/ifw.rst index a293a16..c23bab4 100644 --- a/Help/cpack_gen/ifw.rst +++ b/Help/cpack_gen/ifw.rst @@ -24,12 +24,12 @@ Microsoft Windows, and macOS. To make use of this generator, QtIFW needs to be installed. The :module:`CPackIFW` module looks for the location of the QtIFW command-line utilities, and defines several commands to -control the behavior of this generator. +control the behavior of this generator. See `Hints for Finding QtIFW`_. Variables ^^^^^^^^^ -You can use the following variables to change behavior of CPack ``IFW`` +You can use the following variables to change the behavior of the CPack ``IFW`` generator. Debug @@ -48,12 +48,12 @@ Package .. variable:: CPACK_IFW_PACKAGE_TITLE Name of the installer as displayed on the title bar. - By default used :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`. + If not specified, it defaults to :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`. .. variable:: CPACK_IFW_PACKAGE_PUBLISHER Publisher of the software (as shown in the Windows Control Panel). - By default used :variable:`CPACK_PACKAGE_VENDOR`. + If not specified, it defaults to :variable:`CPACK_PACKAGE_VENDOR`. .. variable:: CPACK_IFW_PRODUCT_URL @@ -61,83 +61,93 @@ Package .. variable:: CPACK_IFW_PACKAGE_ICON - Filename for a custom installer icon. The actual file is '.icns' (macOS), - '.ico' (Windows). No functionality on Unix. + Filename for a custom installer icon. It must be an absolute path. + This should be a ``.icns`` file on macOS and a ``.ico`` file on Windows. + It is ignored on other platforms. .. variable:: CPACK_IFW_PACKAGE_WINDOW_ICON Filename for a custom window icon in PNG format for the Installer - application. + application. It must be an absolute path. .. variable:: CPACK_IFW_PACKAGE_LOGO - Filename for a logo is used as QWizard::LogoPixmap. + Filename for a logo image in PNG format, used as ``QWizard::LogoPixmap``. + It must be an absolute path. .. variable:: CPACK_IFW_PACKAGE_WATERMARK .. versionadded:: 3.8 - Filename for a watermark is used as QWizard::WatermarkPixmap. + Filename for a watermark image in PNG format, used as + ``QWizard::WatermarkPixmap``. It must be an absolute path. .. variable:: CPACK_IFW_PACKAGE_BANNER .. versionadded:: 3.8 - Filename for a banner is used as QWizard::BannerPixmap. + Filename for a banner image in PNG format, used as ``QWizard::BannerPixmap``. + It must be an absolute path. .. variable:: CPACK_IFW_PACKAGE_BACKGROUND .. versionadded:: 3.8 - Filename for an image used as QWizard::BackgroundPixmap (only used by MacStyle). + Filename for a background image in PNG format, used as + ``QWizard::BackgroundPixmap`` (only used by ``MacStyle``). It must be an + absolute path. .. variable:: CPACK_IFW_PACKAGE_WIZARD_STYLE .. versionadded:: 3.8 - Wizard style to be used ("Modern", "Mac", "Aero" or "Classic"). + Wizard style to be used (``Modern``, ``Mac``, ``Aero`` or ``Classic``). .. variable:: CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH .. versionadded:: 3.8 - Default width of the wizard in pixels. Setting a banner image will override this. + Default width of the wizard in pixels. Setting a banner image will override + this. .. variable:: CPACK_IFW_PACKAGE_WIZARD_DEFAULT_HEIGHT .. versionadded:: 3.8 - Default height of the wizard in pixels. Setting a watermark image will override this. + Default height of the wizard in pixels. Setting a watermark image will + override this. .. variable:: CPACK_IFW_PACKAGE_WIZARD_SHOW_PAGE_LIST .. versionadded:: 3.20 - Set to ``OFF`` if the widget listing installer pages on the left side of the wizard should not be shown. + Set to ``OFF`` if the widget listing installer pages on the left side of the + wizard should not be shown. - It is ``ON`` by default, but will only have an effect if using QtIFW 4.0 or later. + It is ``ON`` by default, but will only have an effect if using QtIFW 4.0 or + later. .. variable:: CPACK_IFW_PACKAGE_TITLE_COLOR .. versionadded:: 3.8 - Color of the titles and subtitles (takes an HTML color code, such as "#88FF33"). + Color of the titles and subtitles (takes an HTML color code, such as + ``#88FF33``). .. variable:: CPACK_IFW_PACKAGE_STYLE_SHEET .. versionadded:: 3.15 - Filename for a stylesheet. + Filename for a stylesheet. It must be an absolute path. .. variable:: CPACK_IFW_TARGET_DIRECTORY Default target directory for installation. - By default used - "@ApplicationsDir@/:variable:`CPACK_PACKAGE_INSTALL_DIRECTORY`" - (variables embedded in '@' are expanded by the - `QtIFW scripting engine <https://doc.qt.io/qtinstallerframework/scripting.html>`_). - - You can use predefined variables. + If :variable:`CPACK_PACKAGE_INSTALL_DIRECTORY` is set, this defaults to + ``@ApplicationsDir@/${CPACK_PACKAGE_INSTALL_DIRECTORY}``. If that variable + isn't set either, the default used is ``@RootDir@/usr/local``. + Predefined variables of the form ``@...@`` are expanded by the + `QtIFW scripting engine <https://doc.qt.io/qtinstallerframework/scripting.html>`_. .. variable:: CPACK_IFW_ADMIN_TARGET_DIRECTORY @@ -155,29 +165,28 @@ Package .. variable:: CPACK_IFW_PACKAGE_GROUP - The group, which will be used to configure the root package + The group, which will be used to configure the root package. .. variable:: CPACK_IFW_PACKAGE_NAME - The root package name, which will be used if configuration group is not - specified + The root package name, which will be used if the configuration group is not + specified. .. variable:: CPACK_IFW_PACKAGE_START_MENU_DIRECTORY .. versionadded:: 3.3 Name of the default program group for the product in the Windows Start menu. - - By default used :variable:`CPACK_IFW_PACKAGE_NAME`. + If not specified, it defaults to :variable:`CPACK_IFW_PACKAGE_NAME`. .. variable:: CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME .. versionadded:: 3.3 Filename of the generated maintenance tool. - The platform-specific executable file extension is appended. + The platform-specific executable file extension will be appended. - By default used QtIFW defaults (``maintenancetool``). + If not specified, QtIFW provides a default name (``maintenancetool``). .. variable:: CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE @@ -185,23 +194,15 @@ Package Filename for the configuration of the generated maintenance tool. - By default used QtIFW defaults (``maintenancetool.ini``). + If not specified, QtIFW uses a default file name (``maintenancetool.ini``). .. variable:: CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS .. versionadded:: 3.3 Set to ``ON`` if the installation path can contain non-ASCII characters. - - Is ``ON`` for QtIFW less 2.0 tools. - -.. variable:: CPACK_IFW_PACKAGE_DISABLE_COMMAND_LINE_INTERFACE - - .. versionadded:: 3.23 - - Set to ``ON`` if command line interface features should be disabled. - - Is ``OFF`` by default, but will only have an effect if using QtIFW 4.0 or later. + Only supported for QtIFW 2.0 and later. Older QtIFW versions will always + allow non-ASCII characters. .. variable:: CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH @@ -211,6 +212,14 @@ Package Is ``ON`` for QtIFW less 2.0 tools. +.. variable:: CPACK_IFW_PACKAGE_DISABLE_COMMAND_LINE_INTERFACE + + .. versionadded:: 3.23 + + Set to ``ON`` if command line interface features should be disabled. + It is ``OFF`` by default and will only have an effect if using QtIFW 4.0 or + later. + .. variable:: CPACK_IFW_PACKAGE_CONTROL_SCRIPT .. versionadded:: 3.3 @@ -221,10 +230,11 @@ Package .. versionadded:: 3.7 - List of additional resources ('.qrc' files) to include in the installer - binary. + List of additional resources (``.qrc`` files) to include in the installer + binary. They should be specified as absolute paths and no two resource files + can have the same file name. - You can use :command:`cpack_ifw_add_package_resources` command to resolve + You can use the :command:`cpack_ifw_add_package_resources` command to resolve relative paths. .. variable:: CPACK_IFW_PACKAGE_FILE_EXTENSION @@ -234,44 +244,47 @@ Package The target binary extension. On Linux, the name of the target binary is automatically extended with - '.run', if you do not specify the extension. + ``.run``, if you do not specify the extension. On Windows, the target is created as an application with the extension - '.exe', which is automatically added, if not supplied. + ``.exe``, which is automatically added, if not supplied. On Mac, the target is created as an DMG disk image with the extension - '.dmg', which is automatically added, if not supplied. + ``.dmg``, which is automatically added, if not supplied. .. variable:: CPACK_IFW_REPOSITORIES_ALL The list of remote repositories. The default value of this variable is computed by CPack and contains - all repositories added with command :command:`cpack_ifw_add_repository` - or updated with command :command:`cpack_ifw_update_repository`. + all repositories added with :command:`cpack_ifw_add_repository` + or updated with :command:`cpack_ifw_update_repository`. .. variable:: CPACK_IFW_DOWNLOAD_ALL - If this is ``ON`` all components will be downloaded. - By default is ``OFF`` or used value - from ``CPACK_DOWNLOAD_ALL`` if set + If this is ``ON``, all components will be downloaded. If not set, the + behavior is determined by whether :command:`cpack_configure_downloads` has + been called with the ``ALL`` option or not. .. variable:: CPACK_IFW_PACKAGE_PRODUCT_IMAGES .. versionadded:: 3.23 - A list of images to be shown on the ``PerformInstallationPage``. + A list of images to be shown on the ``PerformInstallationPage``. These + must be absolute paths and the images must be in PNG format. - This feature is available for QtIFW 4.0.0 or newer. + This feature is available for QtIFW 4.0.0 and later. .. variable:: CPACK_IFW_PACKAGE_RUN_PROGRAM .. versionadded:: 3.23 - Command executed after the installer is done if the user accepts the action. - Provide the full path to the application. + Command executed after the installer is finished, if the user accepts the + action. Provide the full path to the application, as found when installed. + This typically means the path should begin with the QtIFW predefined variable + ``@TargetDir@``. - This feature is available for QtIFW 4.0.0 and newer. + This feature is available for QtIFW 4.0.0 and later. .. variable:: CPACK_IFW_PACKAGE_RUN_PROGRAM_ARGUMENTS @@ -280,7 +293,7 @@ Package List of arguments passed to the program specified in :variable:`CPACK_IFW_PACKAGE_RUN_PROGRAM`. - This feature is available for QtIFW 4.0.0 and newer. + This feature is available for QtIFW 4.0.0 and later. .. variable:: CPACK_IFW_PACKAGE_RUN_PROGRAM_DESCRIPTION @@ -288,16 +301,17 @@ Package Text shown next to the check box for running the program after the installation. If :variable:`CPACK_IFW_PACKAGE_RUN_PROGRAM` is set but no - description provided, the UI will display ``Run <Name> now``. instead. + description is provided, QtIFW will use a default message like + ``Run <Name> now``. - This feature is available for QtIFW 4.0.0 and newer. + This feature is available for QtIFW 4.0.0 and later. .. variable:: CPACK_IFW_PACKAGE_SIGNING_IDENTITY - .. versionadded: 3.23 + .. versionadded:: 3.23 Allows specifying a code signing identity to be used for signing the generated - app bundle. Only available on macOS. + app bundle. Only available on macOS, ignored on other platforms. .. variable:: CPACK_IFW_ARCHIVE_FORMAT @@ -317,27 +331,30 @@ Package If the Qt Installer Framework tools were built without libarchive support, only ``7z`` format is supported. - This feature is available for QtIFW 4.2.0 and newer. + This feature is available for QtIFW 4.2.0 and later. .. variable:: CPACK_IFW_ARCHIVE_COMPRESSION .. versionadded:: 3.23 - Archive compression level. Defaults to 5 (*Normal compression*). + Archive compression level. The allowable values are: * 0 (*No compression*) - * 1 (*Fastest compressing*) - * 3 (*Fast compressing*) - * 5 (*Normal compressing*) - * 7 (*Maximum compressing*) - * 9 (*Ultra compressing*) + * 1 (*Fastest compression*) + * 3 (*Fast compression*) + * 5 (*Normal compression*) + * 7 (*Maximum compression*) + * 9 (*Ultra compression*) + + If this variable is not set, QtIFW will use a default compression level, + which will typically be 5 (*Normal compression*). .. note:: Some formats do not support all the possible values. For example ``zip`` compression only supports values from 1 to 7. - This feature is available for QtIFW 4.2.0 and newer. + This feature is available for QtIFW 4.2.0 and later. Components """""""""" @@ -348,16 +365,17 @@ Components .. variable:: CPACK_IFW_PACKAGES_DIRECTORIES - Additional prepared packages dirs that will be used to resolve + Additional prepared packages directories that will be used to resolve dependent components. .. variable:: CPACK_IFW_REPOSITORIES_DIRECTORIES .. versionadded:: 3.10 - Additional prepared repository dirs that will be used to resolve and - repack dependent components. This feature available only - since QtIFW 3.1. + Additional prepared repository directories that will be used to resolve and + repack dependent components. + + This feature is available for QtIFW 3.1 and later. QtIFW Tools """"""""""" @@ -366,10 +384,11 @@ QtIFW Tools .. versionadded:: 3.3 - The version of used QtIFW tools. + The version of the QtIFW tools that will be used. This variable is set + by the :module:`CPackIFW` module. The following variables provide the locations of the QtIFW -command-line tools as discovered by the module :module:`CPackIFW`. +command-line tools as discovered by the :module:`CPackIFW` module. These variables are cached, and may be configured if needed. .. variable:: CPACK_IFW_ARCHIVEGEN_EXECUTABLE @@ -397,30 +416,33 @@ These variables are cached, and may be configured if needed. Hints for Finding QtIFW """"""""""""""""""""""" -Generally, the CPack ``IFW`` generator automatically finds QtIFW tools, -but if you don't use a default path for installation of the QtIFW tools, -the path may be specified in either a CMake or an environment variable: +Generally, the CPack ``IFW`` generator automatically finds QtIFW tools. +The following (in order of precedence) can also be set to augment the +locations normally searched by :command:`find_program`: .. variable:: CPACK_IFW_ROOT - .. versionadded:: 3.9 + .. versionadded:: 3.9 + + CMake variable + +.. envvar:: CPACK_IFW_ROOT - An CMake variable which specifies the location of the QtIFW tool suite. + .. versionadded:: 3.9 - The variable will be cached in the ``CPackConfig.cmake`` file and used at - CPack runtime. + Environment variable .. variable:: QTIFWDIR - An environment variable which specifies the location of the QtIFW tool - suite. + CMake variable -.. note:: - The specified path should not contain "bin" at the end - (for example: "D:\\DevTools\\QtIFW2.0.5"). +.. envvar:: QTIFWDIR + + Environment variable -The :variable:`CPACK_IFW_ROOT` variable has a higher priority and overrides -the value of the :variable:`QTIFWDIR` variable. +.. note:: + The specified path should not contain ``bin`` at the end + (for example: ``D:\\DevTools\\QtIFW2.0.5``). Other Settings ^^^^^^^^^^^^^^ @@ -428,7 +450,7 @@ Other Settings Online installer """""""""""""""" -By default, this generator generates an *offline installer*. This means that +By default, this generator generates an *offline installer*. This means that all packaged files are fully contained in the installer executable. In contrast, an *online installer* will download some or all components from @@ -458,14 +480,13 @@ CMake script. This is an optional feature. Installers created by QtIFW tools have built-in support for internationalization and many phrases are localized to many languages, -but this does not apply to the description of the your components and groups -that will be distributed. +but this does not apply to the description of your components and groups. Localization of the description of your components and groups is useful for users of your installers. -A localized variable or argument can contain a single default value, and a -set of pairs the name of the locale and the localized value. +A localized variable or argument can contain a single default value, and +after that a set of pairs with the name of the locale and the localized value. For example: @@ -483,16 +504,16 @@ See Also Qt Installer Framework Manual: * Index page: - http://doc.qt.io/qtinstallerframework/index.html + https://doc.qt.io/qtinstallerframework/index.html * Component Scripting: - http://doc.qt.io/qtinstallerframework/scripting.html + https://doc.qt.io/qtinstallerframework/scripting.html * Predefined Variables: - http://doc.qt.io/qtinstallerframework/scripting.html#predefined-variables + https://doc.qt.io/qtinstallerframework/scripting.html#predefined-variables * Promoting Updates: - http://doc.qt.io/qtinstallerframework/ifw-updates.html + https://doc.qt.io/qtinstallerframework/ifw-updates.html Download Qt Installer Framework for your platform from Qt site: - http://download.qt.io/official_releases/qt-installer-framework + https://download.qt.io/official_releases/qt-installer-framework diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index b79cf3a..530a406 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -1106,12 +1106,15 @@ Output-Related Expressions .. versionadded:: 3.1 - Content of ``...`` except when evaluated in a link interface while - propagating :ref:`Target Usage Requirements`, in which case it is the - empty string. - Intended for use only in an :prop_tgt:`INTERFACE_LINK_LIBRARIES` target - property, perhaps via the :command:`target_link_libraries` command, - to specify private link dependencies without other usage requirements. + Content of ``...``, except while collecting :ref:`Target Usage Requirements`, + in which case it is the empty string. This is intended for use in an + :prop_tgt:`INTERFACE_LINK_LIBRARIES` target property, typically populated + via the :command:`target_link_libraries` command, to specify private link + dependencies without other usage requirements. + + .. versionadded:: 3.24 + ``LINK_ONLY`` may also be used in a :prop_tgt:`LINK_LIBRARIES` target + property. See policy :policy:`CMP0131`. .. genex:: $<LINK_LIBRARY:feature,library-list> diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index dfc5de6..17a3764 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -58,6 +58,8 @@ Policies Introduced by CMake 3.24 .. toctree:: :maxdepth: 1 + CMP0132: Do not set compiler environment variables on first run. </policy/CMP0132> + CMP0131: LINK_LIBRARIES supports the LINK_ONLY generator expression. </policy/CMP0131> CMP0130: while() diagnoses condition evaluation errors. </policy/CMP0130> Policies Introduced by CMake 3.23 diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index e93cbe5..3ef7b3f 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -197,6 +197,13 @@ Options .. include:: OPTIONS_BUILD.txt +``--fresh`` + .. versionadded:: 3.24 + + Perform a fresh configuration of the build tree. + This removes any existing ``CMakeCache.txt`` file and associated + ``CMakeFiles/`` directory, and recreates them from scratch. + ``-L[A][H]`` List non-advanced cached variables. @@ -948,6 +955,12 @@ Available commands are: Specify modification time recorded in tarball entries. + ``--touch`` + .. versionadded:: 3.24 + + Use current local timestamp instead of extracting file timestamps + from the archive. + ``--`` .. versionadded:: 3.1 diff --git a/Help/policy/CMP0131.rst b/Help/policy/CMP0131.rst new file mode 100644 index 0000000..e85b8ab --- /dev/null +++ b/Help/policy/CMP0131.rst @@ -0,0 +1,31 @@ +CMP0131 +------- + +.. versionadded:: 3.24 + +:prop_tgt:`LINK_LIBRARIES` supports the :genex:`$<LINK_ONLY:...>` +generator expression. + +CMake 3.23 and below documented the :genex:`$<LINK_ONLY:...>` generator +expression only for use in :prop_tgt:`INTERFACE_LINK_LIBRARIES`. +When used in :prop_tgt:`LINK_LIBRARIES`, the content guarded inside +:genex:`$<LINK_ONLY:...>` was always used, even when collecting non-linking +usage requirements such as :prop_tgt:`INTERFACE_COMPILE_DEFINITIONS`. + +CMake 3.24 and above prefer to support :genex:`$<LINK_ONLY:...>`, when +used in :prop_tgt:`LINK_LIBRARIES`, by using the guarded content only +for link dependencies and not other usage requirements. This policy +provides compatibility for projects that have not been updated to +account for this change. + +The ``OLD`` behavior for this policy is to use :prop_tgt:`LINK_LIBRARIES` +content guarded by :genex:`$<LINK_ONLY:...>` even for non-linking +usage requirements. The ``NEW`` behavior for this policy is to to use +the guarded content only for link dependencies. + +This policy was introduced in CMake version 3.24. Use the +:command:`cmake_policy` command to set this policy to ``OLD`` or ``NEW`` +explicitly. Unlike many policies, CMake version |release| does *not* +warn when this policy is not set, and simply uses ``OLD`` behavior. + +.. include:: DEPRECATED.txt diff --git a/Help/policy/CMP0132.rst b/Help/policy/CMP0132.rst new file mode 100644 index 0000000..fadbbdc --- /dev/null +++ b/Help/policy/CMP0132.rst @@ -0,0 +1,26 @@ +CMP0132 +------- + +.. versionadded:: 3.24 + +Apart from when using the Xcode generator and some Visual Studio generators, +CMake 3.23 and below will set environment variables like :envvar:`CC`, +:envvar:`CXX`, etc. when the corresponding language is enabled. +This only occurs on the very first time CMake is run in a build directory, +and the environment variables are only defined at configure time, not build +time. On subsequent CMake runs, these environment variables are not set, +opening up the opportunity for different behavior between the first and +subsequent CMake runs. CMake 3.24 and above prefer to not set these +environment variables when a language is enabled, even on the first run in +a build directory. + +The ``OLD`` behavior for this policy sets the relevant environment variable +on the first run when a language is enabled. The ``NEW`` behavior for this +policy does not set any such environment variables. + +This policy was introduced in CMake version 3.24. Use the +:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly. +Unlike many policies, CMake version |release| does *not* warn +when this policy is not set and simply uses ``OLD`` behavior. + +.. include:: DEPRECATED.txt diff --git a/Help/prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT.rst b/Help/prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT.rst index aa8cc2e..b8b73df 100644 --- a/Help/prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT.rst +++ b/Help/prop_tgt/INTERFACE_LINK_LIBRARIES_DIRECT.rst @@ -56,11 +56,27 @@ on ``X``'s dependents: target_link_libraries(X PUBLIC Y) then ``Y`` is placed in ``X``'s :prop_tgt:`INTERFACE_LINK_LIBRARIES`, - so ``Y``'s usage requirements, including ``INTERFACE_PROPERTY_LINK_DIRECT`` - and ``INTERFACE_PROPERTY_LINK_DIRECT_EXCLUDE``, are propagated - to ``X``'s dependents. + so ``Y``'s usage requirements, including ``INTERFACE_PROPERTY_LINK_DIRECT``, + ``INTERFACE_PROPERTY_LINK_DIRECT_EXCLUDE``, and the usage requirements + declared by the direct link dependencies they add, are propagated to + ``X``'s dependents. -* If ``X`` links ``Y`` privately: +* If ``X`` is a static library or object library, and links ``Y`` privately: + + .. code-block:: cmake + + target_link_libraries(X PRIVATE Y) + + then ``$<LINK_ONLY:Y>`` is placed in ``X``'s + :prop_tgt:`INTERFACE_LINK_LIBRARIES`. ``Y``'s linking requirements, + including ``INTERFACE_PROPERTY_LINK_DIRECT``, + ``INTERFACE_PROPERTY_LINK_DIRECT_EXCLUDE``, and the transitive link + dependencies declared by the direct link dependencies they add, are + propagated to ``X``'s dependents. However, ``Y``'s non-linking + usage requirements are blocked by the :genex:`LINK_ONLY` generator + expression, and are not propagated to ``X``'s dependents. + +* If ``X`` is a shared library or executable, and links ``Y`` privately: .. code-block:: cmake @@ -68,13 +84,10 @@ on ``X``'s dependents: then ``Y`` is not placed in ``X``'s :prop_tgt:`INTERFACE_LINK_LIBRARIES`, so ``Y``'s usage requirements, even ``INTERFACE_PROPERTY_LINK_DIRECT`` - and ``INTERFACE_PROPERTY_LINK_DIRECT_EXCLUDE``, are not propagated - to ``X``'s dependents. - (If ``X`` is a static library or object library, then ``$<LINK_ONLY:Y>`` - is placed in ``X``'s :prop_tgt:`INTERFACE_LINK_LIBRARIES`, but the - :genex:`LINK_ONLY` generator expression block ``Y``'s usage requirements.) + and ``INTERFACE_PROPERTY_LINK_DIRECT_EXCLUDE``, are not propagated to + ``X``'s dependents. -* In either case, the content of ``X``'s :prop_tgt:`INTERFACE_LINK_LIBRARIES` +* In all cases, the content of ``X``'s :prop_tgt:`INTERFACE_LINK_LIBRARIES` is not affected by ``Y``'s ``INTERFACE_PROPERTY_LINK_DIRECT`` or ``INTERFACE_PROPERTY_LINK_DIRECT_EXCLUDE``. @@ -184,7 +197,7 @@ be an intermediate library: .. code-block:: cmake add_library(app_impl STATIC app_impl.cpp) - target_link_libraries(app_impl PUBLIC Foo) + target_link_libraries(app_impl PRIVATE Foo) add_executable(app main.cpp) target_link_libraries(app PRIVATE app_impl) diff --git a/Help/release/dev/cmake-E-tar-touch.rst b/Help/release/dev/cmake-E-tar-touch.rst new file mode 100644 index 0000000..6d1338d --- /dev/null +++ b/Help/release/dev/cmake-E-tar-touch.rst @@ -0,0 +1,6 @@ +cmake-E-tar-touch +----------------- + +* The :manual:`cmake(1)` ``-E tar`` command gained the ``--touch`` option + to keep the current local timestamp instead of extracting file timestamps + from the archive. diff --git a/Help/release/dev/cmake-fresh.rst b/Help/release/dev/cmake-fresh.rst new file mode 100644 index 0000000..6de5b4e --- /dev/null +++ b/Help/release/dev/cmake-fresh.rst @@ -0,0 +1,5 @@ +cmake-fresh +----------- + +* :manual:`cmake(1)` gained the ``--fresh`` command-line option to remove + any existing ``CMakeCache.txt`` when configuring a build tree. diff --git a/Help/release/dev/link-interface-direct.rst b/Help/release/dev/link-interface-direct.rst index 2e9a59e..8b858e2 100644 --- a/Help/release/dev/link-interface-direct.rst +++ b/Help/release/dev/link-interface-direct.rst @@ -5,3 +5,7 @@ link-interface-direct :prop_tgt:`INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE` target properties were added to express usage requirements affecting a consumer's direct link dependencies. + +* The :prop_tgt:`LINK_LIBRARIES` target property now supports + the :genex:`$<LINK_ONLY:...>` generator expression. + See policy :policy:`CMP0131`. diff --git a/Help/release/dev/rescan-static-libraries.rst b/Help/release/dev/rescan-static-libraries.rst index 1ab3485..8892d70 100644 --- a/Help/release/dev/rescan-static-libraries.rst +++ b/Help/release/dev/rescan-static-libraries.rst @@ -1,5 +1,6 @@ rescan-static-libraries ----------------------- -* The :genex:`LINK_GROUP` generator expression gained the ability to manage - circular references between static libraries by using ``RESCAN`` feature. +* The :genex:`LINK_GROUP` generator expression gained the ability to manage, on + ``Linux`` and ``BSD`` systems, circular references between static libraries + by using ``RESCAN`` feature. diff --git a/Help/release/dev/set-env-var-first-run.rst b/Help/release/dev/set-env-var-first-run.rst new file mode 100644 index 0000000..c3f7d9f --- /dev/null +++ b/Help/release/dev/set-env-var-first-run.rst @@ -0,0 +1,6 @@ +set-env-var-first-run +--------------------- + +* CMake no longer sets environment variables like :envvar:`CC`, :envvar:`CXX`, + etc. when enabling the corresponding language during the first CMake run in + a build directory. See policy :policy:`CMP0132`. diff --git a/Help/variable/CMAKE_INSTALL_PREFIX.rst b/Help/variable/CMAKE_INSTALL_PREFIX.rst index b92d3ef..6d42ea8 100644 --- a/Help/variable/CMAKE_INSTALL_PREFIX.rst +++ b/Help/variable/CMAKE_INSTALL_PREFIX.rst @@ -16,7 +16,9 @@ variable for more information. The installation prefix is also added to :variable:`CMAKE_SYSTEM_PREFIX_PATH` so that :command:`find_package`, :command:`find_program`, :command:`find_library`, :command:`find_path`, and :command:`find_file` -will search the prefix for other software. +will search the prefix for other software. This behavior can be disabled by +setting the :variable:`CMAKE_FIND_NO_INSTALL_PREFIX` to ``TRUE`` before the +first :command:`project` invocation. .. note:: diff --git a/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE.rst b/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE.rst index fad1837..692c099 100644 --- a/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE.rst +++ b/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE.rst @@ -19,8 +19,9 @@ of features dependent from the link language. This variable will be used by :genex:`LINK_GROUP` generator expression if, for the linker language, the variable -:variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED` is false or not -set. +:variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED` is not defined +and the variable :variable:`CMAKE_LINK_GROUP_USING_<FEATURE>_SUPPORTED` is +``TRUE``.. .. include:: CMAKE_LINK_GROUP_USING_FEATURE.txt diff --git a/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE_SUPPORTED.rst b/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE_SUPPORTED.rst index 249ccbc..318892f 100644 --- a/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE_SUPPORTED.rst +++ b/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE_SUPPORTED.rst @@ -10,5 +10,4 @@ linker language. .. note:: This variable is evaluated if, and only if, the variable - :variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED` evaluates to - ``FALSE``. + :variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED` is not defined. diff --git a/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.rst b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.rst index 05de570..9f1cede 100644 --- a/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.rst +++ b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.rst @@ -19,8 +19,9 @@ definition of features dependent from the link language. This variable will be used by :genex:`LINK_LIBRARY` generator expression if, for the linker language, the variable -:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` is false or not -set. +:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` is not defined +and the variable :variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` is +``TRUE``. .. include:: CMAKE_LINK_LIBRARY_USING_FEATURE.txt diff --git a/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE_SUPPORTED.rst b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE_SUPPORTED.rst index 42b75fc..417724b 100644 --- a/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE_SUPPORTED.rst +++ b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE_SUPPORTED.rst @@ -10,5 +10,5 @@ linker language. .. note:: This variable is evaluated if, and only if, the variable - :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` evaluates to - ``FALSE``. + :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` is not + defined. diff --git a/Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst b/Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst index 81a7a0b..c8b5815 100644 --- a/Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst +++ b/Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst @@ -11,7 +11,8 @@ documentation. By default this contains the system directories for the current system, the :variable:`CMAKE_INSTALL_PREFIX`, and the :variable:`CMAKE_STAGING_PREFIX`. The installation and staging prefixes may be excluded by setting -the :variable:`CMAKE_FIND_NO_INSTALL_PREFIX` variable. +the :variable:`CMAKE_FIND_NO_INSTALL_PREFIX` variable before the +first :command:`project` invocation. The system directories that are contained in ``CMAKE_SYSTEM_PREFIX_PATH`` are locations that typically include installed software. An example being diff --git a/Help/variable/LINK_GROUP_PREDEFINED_FEATURES.txt b/Help/variable/LINK_GROUP_PREDEFINED_FEATURES.txt index 7c5b458..5f1a11b 100644 --- a/Help/variable/LINK_GROUP_PREDEFINED_FEATURES.txt +++ b/Help/variable/LINK_GROUP_PREDEFINED_FEATURES.txt @@ -15,8 +15,8 @@ static libraries, the following feature can be used: ``-z rescan-start`` and ``-z rescan-end``). Using this feature has a significant performance cost. It is best to use it - only when there are unavoidable circular references between two or more static - libraries. + only when there are unavoidable circular references between two or more + static libraries. - This feature is available on ``Linux`` and ``SunOS`` platforms as well as - ``Windows`` when ``GNU`` toolchain is used. + This feature is available on ``Linux``, ``BSD``, and ``SunOS`` target + platforms as well as ``Windows`` when ``GNU`` toolchain is used. diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake index aec86d9..ec2a865 100644 --- a/Modules/CMakeDetermineCompiler.cmake +++ b/Modules/CMakeDetermineCompiler.cmake @@ -119,9 +119,15 @@ macro(_cmake_find_compiler_path lang) # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE # if CMAKE_${lang}_COMPILER is a list, use the first item as # CMAKE_${lang}_COMPILER and the rest as CMAKE_${lang}_COMPILER_ARG1 - set(CMAKE_${lang}_COMPILER_ARG1 "${CMAKE_${lang}_COMPILER}") - list(POP_FRONT CMAKE_${lang}_COMPILER_ARG1 CMAKE_${lang}_COMPILER) - list(JOIN CMAKE_${lang}_COMPILER_ARG1 " " CMAKE_${lang}_COMPILER_ARG1) + # Otherwise, preserve any existing CMAKE_${lang}_COMPILER_ARG1 that might + # have been saved by CMakeDetermine${lang}Compiler in a previous run. + list(LENGTH CMAKE_${lang}_COMPILER _CMAKE_${lang}_COMPILER_LENGTH) + if(_CMAKE_${lang}_COMPILER_LENGTH GREATER 1) + set(CMAKE_${lang}_COMPILER_ARG1 "${CMAKE_${lang}_COMPILER}") + list(POP_FRONT CMAKE_${lang}_COMPILER_ARG1 CMAKE_${lang}_COMPILER) + list(JOIN CMAKE_${lang}_COMPILER_ARG1 " " CMAKE_${lang}_COMPILER_ARG1) + endif() + unset(_CMAKE_${lang}_COMPILER_LENGTH) # find the compiler in the PATH if necessary # if compiler (and arguments) comes from cache then synchronize cache with updated CMAKE_<LANG>_COMPILER diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index 85108db..003cf3f 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -439,6 +439,7 @@ set(_CPACK_IFW_PREFIXES "QtIFW-") set(_CPACK_IFW_VERSIONS + "4.3" "4.2" "4.1" "4.0" diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 53584c6..0ba35b6 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -755,11 +755,13 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa # objdump generates copious output so we create a grep filter to pre-filter results if(WIN32) find_program(gp_grep_cmd findstr) + set(gp_grep_cmd_arg "") else() find_program(gp_grep_cmd grep) + set(gp_grep_cmd_arg "-a") endif() if(gp_grep_cmd) - set(gp_cmd_maybe_filter COMMAND ${gp_grep_cmd} "-a" "^[[:blank:]]*DLL Name: ") + set(gp_cmd_maybe_filter COMMAND ${gp_grep_cmd} "${gp_grep_cmd_arg}" "^[[:blank:]]*DLL Name: ") endif() else() message(STATUS "warning: gp_tool='${gp_tool}' is an unknown tool...") diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake index 4c8cb6a..bd5a786 100644 --- a/Modules/Platform/FreeBSD.cmake +++ b/Modules/Platform/FreeBSD.cmake @@ -53,4 +53,11 @@ endif() set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) +# Features for LINK_GROUP generator expression +## RESCAN: request the linker to rescan static libraries until there is +## no pending undefined symbols +set(CMAKE_LINK_GROUP_USING_RESCAN "LINKER:--start-group" "LINKER:--end-group") +set(CMAKE_LINK_GROUP_USING_RESCAN_SUPPORTED TRUE) + + include(Platform/UnixPaths) diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake index 8774159..ab85923 100644 --- a/Modules/Platform/NetBSD.cmake +++ b/Modules/Platform/NetBSD.cmake @@ -39,4 +39,11 @@ endif() set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) +# Features for LINK_GROUP generator expression +## RESCAN: request the linker to rescan static libraries until there is +## no pending undefined symbols +set(CMAKE_LINK_GROUP_USING_RESCAN "LINKER:--start-group" "LINKER:--end-group") +set(CMAKE_LINK_GROUP_USING_RESCAN_SUPPORTED TRUE) + + include(Platform/UnixPaths) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index fc6fc5f..1ea4df3 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 23) -set(CMake_VERSION_PATCH 20220322) +set(CMake_VERSION_PATCH 20220330) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 6fc4848..92ff6df 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -26,7 +26,7 @@ void cmCPackIFWInstaller::printSkippedOptionWarning( cmCPackIFWLogger( WARNING, "Option " - << optionName << " is set to \"" << optionValue + << optionName << " contains the value \"" << optionValue << "\" but will be skipped because the specified file does not exist." << std::endl); } @@ -276,7 +276,12 @@ void cmCPackIFWInstaller::ConfigureFromOptions() // Control script if (cmValue optIFW_CONTROL_SCRIPT = this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT")) { - this->ControlScript = *optIFW_CONTROL_SCRIPT; + if (!cmSystemTools::FileExists(optIFW_CONTROL_SCRIPT)) { + this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_CONTROL_SCRIPT", + optIFW_CONTROL_SCRIPT); + } else { + this->ControlScript = *optIFW_CONTROL_SCRIPT; + } } // Resources @@ -284,6 +289,13 @@ void cmCPackIFWInstaller::ConfigureFromOptions() this->GetOption("CPACK_IFW_PACKAGE_RESOURCES")) { this->Resources.clear(); cmExpandList(optIFW_PACKAGE_RESOURCES, this->Resources); + for (const auto& file : this->Resources) { + if (!cmSystemTools::FileExists(file)) { + // The warning will say skipped, but there will later be a hard error + // when the binarycreator tool tries to read the missing file. + this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_RESOURCES", file); + } + } } // ProductImages @@ -291,6 +303,14 @@ void cmCPackIFWInstaller::ConfigureFromOptions() this->GetOption("CPACK_IFW_PACKAGE_PRODUCT_IMAGES")) { this->ProductImages.clear(); cmExpandList(productImages, this->ProductImages); + for (const auto& file : this->ProductImages) { + if (!cmSystemTools::FileExists(file)) { + // The warning will say skipped, but there will later be a hard error + // when the binarycreator tool tries to read the missing file. + this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_PRODUCT_IMAGES", + file); + } + } } // Run program, run program arguments, and run program description diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index 017fdc0..52e200c 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -95,6 +95,10 @@ # define IMAGE_FILE_MACHINE_ARM64 0xaa64 // ARM64 Little-Endian # endif +# ifndef IMAGE_FILE_MACHINE_ARM64EC +# define IMAGE_FILE_MACHINE_ARM64EC 0xa641 // ARM64EC Little-Endian +# endif + typedef struct cmANON_OBJECT_HEADER_BIGOBJ { /* same as ANON_OBJECT_HEADER_V2 */ @@ -135,6 +139,13 @@ typedef struct _cmIMAGE_SYMBOL_EX } cmIMAGE_SYMBOL_EX; typedef cmIMAGE_SYMBOL_EX UNALIGNED* cmPIMAGE_SYMBOL_EX; +enum class Arch +{ + Generic, + I386, + ARM64EC, +}; + PIMAGE_SECTION_HEADER GetSectionHeaderOffset( PIMAGE_FILE_HEADER pImageFileHeader) { @@ -193,7 +204,8 @@ public: */ DumpSymbols(ObjectHeaderType* ih, std::set<std::string>& symbols, - std::set<std::string>& dataSymbols, bool isI386) + std::set<std::string>& dataSymbols, + Arch symbolArch = Arch::Generic) : Symbols(symbols) , DataSymbols(dataSymbols) { @@ -203,7 +215,7 @@ public: this->ObjectImageHeader->PointerToSymbolTable); this->SectionHeaders = GetSectionHeaderOffset(this->ObjectImageHeader); this->SymbolCount = this->ObjectImageHeader->NumberOfSymbols; - this->IsI386 = isI386; + this->SymbolArch = symbolArch; } /* @@ -259,7 +271,7 @@ public: } } // For i386 builds we need to remove _ - if (this->IsI386 && symbol[0] == '_') { + if (this->SymbolArch == Arch::I386 && symbol[0] == '_') { symbol.erase(0, 1); } @@ -279,13 +291,20 @@ public: // skip symbols containing a dot or are from managed code if (symbol.find('.') == std::string::npos && !SymbolIsFromManagedCode(symbol)) { - if (!pSymbolTable->Type && (SectChar & IMAGE_SCN_MEM_WRITE)) { - // Read only (i.e. constants) must be excluded - this->DataSymbols.insert(symbol); - } else { - if (pSymbolTable->Type || !(SectChar & IMAGE_SCN_MEM_READ) || - (SectChar & IMAGE_SCN_MEM_EXECUTE)) { - this->Symbols.insert(symbol); + // skip arm64ec thunk symbols + if (this->SymbolArch != Arch::ARM64EC || + (symbol.find("$ientry_thunk") == std::string::npos && + symbol.find("$entry_thunk") == std::string::npos && + symbol.find("$iexit_thunk") == std::string::npos && + symbol.find("$exit_thunk") == std::string::npos)) { + if (!pSymbolTable->Type && (SectChar & IMAGE_SCN_MEM_WRITE)) { + // Read only (i.e. constants) must be excluded + this->DataSymbols.insert(symbol); + } else { + if (pSymbolTable->Type || !(SectChar & IMAGE_SCN_MEM_READ) || + (SectChar & IMAGE_SCN_MEM_EXECUTE)) { + this->Symbols.insert(symbol); + } } } } @@ -316,7 +335,7 @@ private: PIMAGE_SECTION_HEADER SectionHeaders; ObjectHeaderType* ObjectImageHeader; SymbolTableType* SymbolTable; - bool IsI386; + Arch SymbolArch; }; #endif @@ -421,7 +440,8 @@ static bool DumpFile(std::string const& nmPath, const char* filename, (imageHeader->Machine == IMAGE_FILE_MACHINE_AMD64) || (imageHeader->Machine == IMAGE_FILE_MACHINE_ARM) || (imageHeader->Machine == IMAGE_FILE_MACHINE_ARMNT) || - (imageHeader->Machine == IMAGE_FILE_MACHINE_ARM64)) && + (imageHeader->Machine == IMAGE_FILE_MACHINE_ARM64) || + (imageHeader->Machine == IMAGE_FILE_MACHINE_ARM64EC)) && (imageHeader->Characteristics == 0)) { /* * The tests above are checking for IMAGE_FILE_HEADER.Machine @@ -431,7 +451,11 @@ static bool DumpFile(std::string const& nmPath, const char* filename, */ DumpSymbols<IMAGE_FILE_HEADER, IMAGE_SYMBOL> symbolDumper( (PIMAGE_FILE_HEADER)lpFileBase, symbols, dataSymbols, - (imageHeader->Machine == IMAGE_FILE_MACHINE_I386)); + (imageHeader->Machine == IMAGE_FILE_MACHINE_I386 + ? Arch::I386 + : (imageHeader->Machine == IMAGE_FILE_MACHINE_ARM64EC + ? Arch::ARM64EC + : Arch::Generic))); symbolDumper.DumpObjFile(); } else { // check for /bigobj and llvm LTO format @@ -440,8 +464,12 @@ static bool DumpFile(std::string const& nmPath, const char* filename, if (h->Sig1 == 0x0 && h->Sig2 == 0xffff) { // bigobj DumpSymbols<cmANON_OBJECT_HEADER_BIGOBJ, cmIMAGE_SYMBOL_EX> - symbolDumper((cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase, symbols, - dataSymbols, (h->Machine == IMAGE_FILE_MACHINE_I386)); + symbolDumper( + (cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase, symbols, dataSymbols, + (h->Machine == IMAGE_FILE_MACHINE_I386 + ? Arch::I386 + : (h->Machine == IMAGE_FILE_MACHINE_ARM64EC ? Arch::ARM64EC + : Arch::Generic))); symbolDumper.DumpObjFile(); } else if ( // BCexCODE - llvm bitcode diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index a4dc01b..8cbdcaa 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -677,8 +677,8 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. - cmLinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + cmLinkImplementation const* impl = this->Target->GetLinkImplementation( + this->Config, cmGeneratorTarget::LinkInterfaceFor::Link); this->AddLinkEntries(-1, impl->Libraries); this->AddLinkObjects(impl->Objects); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 67214f1..e156e3d 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -803,7 +803,9 @@ bool cmComputeLinkInformation::AddLibraryFeature(std::string const& feature) cmStrCat("CMAKE_", this->LinkLanguage, "_LINK_LIBRARY_USING_", feature); cmValue featureSupported = this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED")); - if (!featureSupported.IsOn()) { + if (!featureSupported) { + // language specific variable is not defined, fallback to the more generic + // one featureName = cmStrCat("CMAKE_LINK_LIBRARY_USING_", feature); featureSupported = this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED")); @@ -965,7 +967,9 @@ cmComputeLinkInformation::GetGroupFeature(std::string const& feature) cmStrCat("CMAKE_", this->LinkLanguage, "_LINK_GROUP_USING_", feature); cmValue featureSupported = this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED")); - if (!featureSupported.IsOn()) { + if (!featureSupported) { + // language specific variable is not defined, fallback to the more generic + // one featureName = cmStrCat("CMAKE_LINK_GROUP_USING_", feature); featureSupported = this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED")); @@ -1551,8 +1555,7 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry) this->AddLibraryFeature("FRAMEWORK"); } - if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s) && - target->IsFrameworkOnApple() && !this->GlobalGenerator->IsXcode()) { + if (target->IsFrameworkOnApple() && !this->GlobalGenerator->IsXcode()) { // Add the framework directory and the framework item itself auto fwItems = this->GlobalGenerator->SplitFrameworkPath(item.Value, true); if (!fwItems) { @@ -1567,8 +1570,15 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry) // Add the directory portion to the framework search path. this->AddFrameworkPath(fwItems->first); } - this->Items.emplace_back(fwItems->second, ItemIsPath::Yes, target, - this->FindLibraryFeature(entry.Feature)); + if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s)) { + this->Items.emplace_back(fwItems->second, ItemIsPath::Yes, target, + this->FindLibraryFeature(entry.Feature)); + } else { + this->Items.emplace_back( + item, ItemIsPath::Yes, target, + this->FindLibraryFeature( + entry.Feature == DEFAULT ? "__CMAKE_LINK_LIBRARY" : entry.Feature)); + } } else { // Now add the full path to the library. this->Items.emplace_back( diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index ef89c8b..3ff16a4 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -218,8 +218,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) emitted.insert(cmLinkItem(depender, false, cmListFileBacktrace())); emitted.insert(cmLinkItem(depender, true, cmListFileBacktrace())); - if (cmLinkImplementation const* impl = - depender->GetLinkImplementation(it)) { + if (cmLinkImplementation const* impl = depender->GetLinkImplementation( + it, cmGeneratorTarget::LinkInterfaceFor::Link)) { for (cmLinkImplItem const& lib : impl->Libraries) { // Don't emit the same library twice for this target. if (emitted.insert(lib).second) { diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx index 15b2652..faefcb8 100644 --- a/Source/cmDefinePropertyCommand.cxx +++ b/Source/cmDefinePropertyCommand.cxx @@ -91,10 +91,10 @@ bool cmDefinePropertyCommand(std::vector<std::string> const& args, PropertyName, "\"")); return false; } - if (initializeFromVariable == PropertyName) { - status.SetError(cmStrCat( - "Variable name must have a non-empty prefix before property name \"", - PropertyName, "\"")); + if (PropertyName.find('_') == std::string::npos) { + status.SetError(cmStrCat("Property name \"", PropertyName, + "\" defined with INITIALIZE_FROM_VARIABLE does " + "not contain underscore")); return false; } diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx index bcd8c64..1441925 100644 --- a/Source/cmExportBuildAndroidMKGenerator.cxx +++ b/Source/cmExportBuildAndroidMKGenerator.cxx @@ -168,7 +168,8 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties( // Tell the NDK build system if prebuilt static libraries use C++. if (target->GetType() == cmStateEnums::STATIC_LIBRARY) { - cmLinkImplementation const* li = target->GetLinkImplementation(config); + cmLinkImplementation const* li = target->GetLinkImplementation( + config, cmGeneratorTarget::LinkInterfaceFor::Link); if (cm::contains(li->Languages, "CXX")) { os << "LOCAL_HAS_CPP := true\n"; } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 09e5015..e4728ac 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3507,6 +3507,7 @@ bool HandleArchiveExtractCommand(std::vector<std::string> const& args, bool ListOnly = false; std::string Destination; std::vector<std::string> Patterns; + bool Touch = false; }; static auto const parser = cmArgumentParser<Arguments>{} @@ -3514,7 +3515,8 @@ bool HandleArchiveExtractCommand(std::vector<std::string> const& args, .Bind("VERBOSE"_s, &Arguments::Verbose) .Bind("LIST_ONLY"_s, &Arguments::ListOnly) .Bind("DESTINATION"_s, &Arguments::Destination) - .Bind("PATTERNS"_s, &Arguments::Patterns); + .Bind("PATTERNS"_s, &Arguments::Patterns) + .Bind("TOUCH"_s, &Arguments::Touch); std::vector<std::string> unrecognizedArguments; std::vector<std::string> keywordsMissingValues; @@ -3577,8 +3579,11 @@ bool HandleArchiveExtractCommand(std::vector<std::string> const& args, return false; } - if (!cmSystemTools::ExtractTar(inFile, parsedArgs.Patterns, - parsedArgs.Verbose)) { + if (!cmSystemTools::ExtractTar( + inFile, parsedArgs.Patterns, + parsedArgs.Touch ? cmSystemTools::cmTarExtractTimestamps::No + : cmSystemTools::cmTarExtractTimestamps::Yes, + parsedArgs.Verbose)) { status.SetError(cmStrCat("failed to extract: ", inFile)); cmSystemTools::SetFatalErrorOccured(); return false; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index db043ec..3d1cfbf 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1415,7 +1415,8 @@ static std::string getLinkedTargetsContent( { std::string result; if (cmLinkImplementationLibraries const* impl = - target->GetLinkImplementationLibraries(context->Config)) { + target->GetLinkImplementationLibraries( + context->Config, cmGeneratorTarget::LinkInterfaceFor::Usage)) { for (cmLinkImplItem const& lib : impl->Libraries) { if (lib.Target) { // Pretend $<TARGET_PROPERTY:lib.Target,prop> appeared in our diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index ab3ed12..1a13bdb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -752,6 +752,7 @@ void cmGeneratorTarget::ClearSourcesCache() this->Objects.clear(); this->VisitedConfigsForObjects.clear(); this->LinkImplMap.clear(); + this->LinkImplUsageRequirementsOnlyMap.clear(); } void cmGeneratorTarget::ClearLinkInterfaceCache() @@ -1302,7 +1303,8 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( &dagChecker, result, excludeImported, language); } - cmLinkImplementation const* impl = this->GetLinkImplementation(config); + cmLinkImplementation const* impl = + this->GetLinkImplementation(config, LinkInterfaceFor::Usage); if (impl != nullptr) { auto runtimeEntries = impl->LanguageRuntimeLibraries.find(language); if (runtimeEntries != impl->LanguageRuntimeLibraries.end()) { @@ -1519,7 +1521,8 @@ void AddLangSpecificImplicitIncludeDirectories( const std::string& config, const std::string& propertyName, IncludeDirectoryFallBack mode, EvaluatedTargetPropertyEntries& entries) { - if (const auto* libraries = target->GetLinkImplementationLibraries(config)) { + if (const auto* libraries = target->GetLinkImplementationLibraries( + config, LinkInterfaceFor::Usage)) { cmGeneratorExpressionDAGChecker dag{ target->GetBacktrace(), target, propertyName, nullptr, nullptr }; @@ -1609,7 +1612,7 @@ void AddInterfaceEntries( { if (searchRuntime == IncludeRuntimeInterface::Yes) { if (cmLinkImplementation const* impl = - headTarget->GetLinkImplementation(config)) { + headTarget->GetLinkImplementation(config, interfaceFor)) { entries.HadContextSensitiveCondition = impl->HadContextSensitiveCondition; @@ -1623,7 +1626,7 @@ void AddInterfaceEntries( } } else { if (cmLinkImplementationLibraries const* impl = - headTarget->GetLinkImplementationLibraries(config)) { + headTarget->GetLinkImplementationLibraries(config, interfaceFor)) { entries.HadContextSensitiveCondition = impl->HadContextSensitiveCondition; addInterfaceEntry(headTarget, config, prop, lang, dagChecker, entries, @@ -1638,7 +1641,8 @@ void AddObjectEntries(cmGeneratorTarget const* headTarget, EvaluatedTargetPropertyEntries& entries) { if (cmLinkImplementationLibraries const* impl = - headTarget->GetLinkImplementationLibraries(config)) { + headTarget->GetLinkImplementationLibraries(config, + LinkInterfaceFor::Usage)) { entries.HadContextSensitiveCondition = impl->HadContextSensitiveCondition; for (cmLinkImplItem const& lib : impl->Libraries) { if (lib.Target && @@ -2821,7 +2825,7 @@ bool cmGeneratorTarget::ComputeLinkClosure(const std::string& config, // Get languages built in this target. std::unordered_set<std::string> languages; cmLinkImplementation const* impl = - this->GetLinkImplementation(config, secondPass); + this->GetLinkImplementation(config, LinkInterfaceFor::Link, secondPass); assert(impl); languages.insert(impl->Languages.cbegin(), impl->Languages.cend()); @@ -3089,7 +3093,7 @@ cmGeneratorTarget::GetLinkImplementationClosure( std::set<cmGeneratorTarget const*> emitted; cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibraries(config); + this->GetLinkImplementationLibraries(config, LinkInterfaceFor::Usage); assert(impl); for (cmLinkImplItem const& lib : impl->Libraries) { @@ -3831,7 +3835,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories( if (this->Makefile->IsOn("APPLE")) { if (cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibraries(config)) { + this->GetLinkImplementationLibraries(config, + LinkInterfaceFor::Usage)) { for (cmLinkImplItem const& lib : impl->Libraries) { std::string libDir = cmSystemTools::CollapseFullPath( lib.AsStr(), this->Makefile->GetHomeOutputDirectory()); @@ -6845,8 +6850,8 @@ void cmGeneratorTarget::ComputeLinkInterface( emitted.insert(lib); } if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) { - cmLinkImplementation const* impl = - this->GetLinkImplementation(config, secondPass); + cmLinkImplementation const* impl = this->GetLinkImplementation( + config, LinkInterfaceFor::Link, secondPass); for (cmLinkImplItem const& lib : impl->Libraries) { if (emitted.insert(lib).second) { if (lib.Target) { @@ -6868,15 +6873,16 @@ void cmGeneratorTarget::ComputeLinkInterface( this->GetPolicyStatusCMP0022() == cmPolicies::OLD) { // The link implementation is the default link interface. cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibrariesInternal(config, headTarget); + this->GetLinkImplementationLibrariesInternal(config, headTarget, + LinkInterfaceFor::Link); iface.ImplementationIsInterface = true; iface.WrongConfigLibraries = impl->WrongConfigLibraries; } if (this->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. - if (cmLinkImplementation const* impl = - this->GetLinkImplementation(config, secondPass)) { + if (cmLinkImplementation const* impl = this->GetLinkImplementation( + config, LinkInterfaceFor::Link, secondPass)) { iface.Languages = impl->Languages; } } @@ -7307,7 +7313,8 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries( // The link implementation is the default link interface. if (cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibrariesInternal(config, headTarget)) { + this->GetLinkImplementationLibrariesInternal(config, headTarget, + interfaceFor)) { iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN && @@ -7686,27 +7693,30 @@ cmGeneratorTarget::GetHeadToLinkInterfaceUsageRequirementsMap( } const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation( - const std::string& config) const + const std::string& config, LinkInterfaceFor implFor) const { - return this->GetLinkImplementation(config, false); + return this->GetLinkImplementation(config, implFor, false); } const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation( - const std::string& config, bool secondPass) const + const std::string& config, LinkInterfaceFor implFor, bool secondPass) const { // There is no link implementation for targets that cannot compile sources. if (!this->CanCompileSources()) { return nullptr; } - cmOptionalLinkImplementation& impl = - this->LinkImplMap[cmSystemTools::UpperCase(config)][this]; + HeadToLinkImplementationMap& hm = + (implFor == LinkInterfaceFor::Usage + ? this->GetHeadToLinkImplementationUsageRequirementsMap(config) + : this->GetHeadToLinkImplementationMap(config)); + cmOptionalLinkImplementation& impl = hm[this]; if (secondPass) { impl = cmOptionalLinkImplementation(); } if (!impl.LibrariesDone) { impl.LibrariesDone = true; - this->ComputeLinkImplementationLibraries(config, impl, this); + this->ComputeLinkImplementationLibraries(config, impl, this, implFor); } if (!impl.LanguagesDone) { impl.LanguagesDone = true; @@ -7716,6 +7726,21 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation( return &impl; } +cmGeneratorTarget::HeadToLinkImplementationMap& +cmGeneratorTarget::GetHeadToLinkImplementationMap( + std::string const& config) const +{ + return this->LinkImplMap[cmSystemTools::UpperCase(config)]; +} + +cmGeneratorTarget::HeadToLinkImplementationMap& +cmGeneratorTarget::GetHeadToLinkImplementationUsageRequirementsMap( + std::string const& config) const +{ + return this + ->LinkImplUsageRequirementsOnlyMap[cmSystemTools::UpperCase(config)]; +} + bool cmGeneratorTarget::GetConfigCommonSourceFilesForXcode( std::vector<cmSourceFile*>& files) const { @@ -7956,7 +7981,7 @@ bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const return true; } if (cmLinkImplementationLibraries const* impl = - this->GetLinkImplementationLibraries(config)) { + this->GetLinkImplementationLibraries(config, LinkInterfaceFor::Link)) { return !impl->Libraries.empty(); } return false; @@ -7964,14 +7989,15 @@ bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const cmLinkImplementationLibraries const* cmGeneratorTarget::GetLinkImplementationLibraries( - const std::string& config) const + const std::string& config, LinkInterfaceFor implFor) const { - return this->GetLinkImplementationLibrariesInternal(config, this); + return this->GetLinkImplementationLibrariesInternal(config, this, implFor); } cmLinkImplementationLibraries const* cmGeneratorTarget::GetLinkImplementationLibrariesInternal( - const std::string& config, cmGeneratorTarget const* head) const + const std::string& config, cmGeneratorTarget const* head, + LinkInterfaceFor implFor) const { // There is no link implementation for targets that cannot compile sources. if (!this->CanCompileSources()) { @@ -7980,7 +8006,9 @@ cmGeneratorTarget::GetLinkImplementationLibrariesInternal( // Populate the link implementation libraries for this configuration. HeadToLinkImplementationMap& hm = - this->LinkImplMap[cmSystemTools::UpperCase(config)]; + (implFor == LinkInterfaceFor::Usage + ? this->GetHeadToLinkImplementationUsageRequirementsMap(config) + : this->GetHeadToLinkImplementationMap(config)); // If the link implementation does not depend on the head target // then re-use the one from the head we computed first. @@ -7991,7 +8019,7 @@ cmGeneratorTarget::GetLinkImplementationLibrariesInternal( cmOptionalLinkImplementation& impl = hm[head]; if (!impl.LibrariesDone) { impl.LibrariesDone = true; - this->ComputeLinkImplementationLibraries(config, impl, head); + this->ComputeLinkImplementationLibraries(config, impl, head, implFor); } return &impl; } @@ -8007,6 +8035,7 @@ class TransitiveLinkImpl { cmGeneratorTarget const* Self; std::string const& Config; + LinkInterfaceFor ImplFor; cmLinkImplementation& Impl; std::set<cmLinkItem> Emitted; @@ -8017,9 +8046,10 @@ class TransitiveLinkImpl public: TransitiveLinkImpl(cmGeneratorTarget const* self, std::string const& config, - cmLinkImplementation& impl) + LinkInterfaceFor implFor, cmLinkImplementation& impl) : Self(self) , Config(config) + , ImplFor(implFor) , Impl(impl) { } @@ -8036,8 +8066,8 @@ void TransitiveLinkImpl::Follow(cmGeneratorTarget const* target) } // Get this target's usage requirements. - cmLinkInterfaceLibraries const* iface = target->GetLinkInterfaceLibraries( - this->Config, this->Self, LinkInterfaceFor::Usage); + cmLinkInterfaceLibraries const* iface = + target->GetLinkInterfaceLibraries(this->Config, this->Self, this->ImplFor); if (!iface) { return; } @@ -8101,16 +8131,17 @@ void TransitiveLinkImpl::Compute() void ComputeLinkImplTransitive(cmGeneratorTarget const* self, std::string const& config, + LinkInterfaceFor implFor, cmLinkImplementation& impl) { - TransitiveLinkImpl transitiveLinkImpl(self, config, impl); + TransitiveLinkImpl transitiveLinkImpl(self, config, implFor, impl); transitiveLinkImpl.Compute(); } } void cmGeneratorTarget::ComputeLinkImplementationLibraries( const std::string& config, cmOptionalLinkImplementation& impl, - cmGeneratorTarget const* head) const + cmGeneratorTarget const* head, LinkInterfaceFor implFor) const { cmLocalGenerator const* lg = this->LocalGenerator; cmMakefile const* mf = lg->GetMakefile(); @@ -8121,6 +8152,20 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( // Keep this logic in sync with ExpandLinkItems. cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_LIBRARIES", nullptr, nullptr); + // The $<LINK_ONLY> expression may be used to specify link dependencies + // that are otherwise excluded from usage requirements. + if (implFor == LinkInterfaceFor::Usage) { + switch (this->GetPolicyStatusCMP0131()) { + case cmPolicies::WARN: + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + dagChecker.SetTransitivePropertiesOnly(); + break; + } + } cmGeneratorExpression ge(entry.Backtrace); std::unique_ptr<cmCompiledGeneratorExpression> const cge = ge.Parse(entry.Value); @@ -8216,7 +8261,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( // Update the list of direct link dependencies from usage requirements. if (head == this) { - ComputeLinkImplTransitive(this, config, impl); + ComputeLinkImplTransitive(this, config, implFor, impl); } // Get the list of configurations considered to be DEBUG. diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3e30913..96e48a4 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -399,17 +399,18 @@ public: LinkClosure const* GetLinkClosure(const std::string& config) const; cmLinkImplementation const* GetLinkImplementation( - const std::string& config) const; + const std::string& config, LinkInterfaceFor implFor) const; void ComputeLinkImplementationLanguages( const std::string& config, cmOptionalLinkImplementation& impl) const; cmLinkImplementationLibraries const* GetLinkImplementationLibraries( - const std::string& config) const; + const std::string& config, LinkInterfaceFor implFor) const; void ComputeLinkImplementationLibraries(const std::string& config, cmOptionalLinkImplementation& impl, - const cmGeneratorTarget* head) const; + const cmGeneratorTarget* head, + LinkInterfaceFor implFor) const; struct TargetOrString { @@ -984,6 +985,7 @@ private: const cmGeneratorTarget* head, bool secondPass) const; cmLinkImplementation const* GetLinkImplementation(const std::string& config, + LinkInterfaceFor implFor, bool secondPass) const; enum class LinkItemRole @@ -1108,9 +1110,16 @@ private: }; using LinkImplMapType = std::map<std::string, HeadToLinkImplementationMap>; mutable LinkImplMapType LinkImplMap; + mutable LinkImplMapType LinkImplUsageRequirementsOnlyMap; + + HeadToLinkImplementationMap& GetHeadToLinkImplementationMap( + std::string const& config) const; + HeadToLinkImplementationMap& GetHeadToLinkImplementationUsageRequirementsMap( + std::string const& config) const; cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal( - const std::string& config, const cmGeneratorTarget* head) const; + const std::string& config, const cmGeneratorTarget* head, + LinkInterfaceFor implFor) const; bool ComputeOutputDir(const std::string& config, cmStateEnums::ArtifactType artifact, std::string& out) const; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index baa54e5..fb84cd1 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -759,7 +759,9 @@ void cmGlobalGenerator::EnableLanguage( needTestLanguage[lang] = true; // Some generators like visual studio should not use the env variables // So the global generator can specify that in this variable - if (!mf->GetDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV")) { + if ((mf->GetPolicyStatus(cmPolicies::CMP0132) == cmPolicies::OLD || + mf->GetPolicyStatus(cmPolicies::CMP0132) == cmPolicies::WARN) && + !mf->GetDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV")) { // put ${CMake_(LANG)_COMPILER_ENV_VAR}=${CMAKE_(LANG)_COMPILER // into the environment, in case user scripts want to run // configure, or sub cmakes diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 1e6624e..f01b36c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1627,7 +1627,10 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt) // If the language is compiled as a source trust Xcode to link with it. for (auto const& Language : - gtgt->GetLinkImplementation("NOCONFIG")->Languages) { + gtgt + ->GetLinkImplementation("NOCONFIG", + cmGeneratorTarget::LinkInterfaceFor::Link) + ->Languages) { if (Language == llang) { return; } diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 55f6453..9cd1943 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -73,11 +73,11 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions, } // watch for our state change if (scopeDepth == 0 && func.LowerCaseName() == "else") { + cmListFileBacktrace elseBT = mf.GetBacktrace().Push( + cmListFileContext{ func.OriginalName(), + this->GetStartingContext().FilePath, func.Line() }); if (this->ElseSeen) { - cmListFileBacktrace elseBT = mf.GetBacktrace().Push(cmListFileContext{ - func.OriginalName(), this->GetStartingContext().FilePath, - func.Line() }); mf.GetCMakeInstance()->IssueMessage( MessageType::FATAL_ERROR, "A duplicate ELSE command was found inside an IF block.", elseBT); @@ -92,7 +92,8 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions, // if trace is enabled, print a (trivially) evaluated "else" // statement if (!this->IsBlocking && mf.GetCMakeInstance()->GetTrace()) { - mf.PrintCommandTrace(func); + mf.PrintCommandTrace(func, elseBT, + cmMakefile::CommandMissingFromStack::Yes); } } else if (scopeDepth == 0 && func.LowerCaseName() == "elseif") { cmListFileBacktrace elseifBT = mf.GetBacktrace().Push( @@ -111,7 +112,8 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions, } else { // if trace is enabled, print the evaluated "elseif" statement if (mf.GetCMakeInstance()->GetTrace()) { - mf.PrintCommandTrace(func); + mf.PrintCommandTrace(func, elseifBT, + cmMakefile::CommandMissingFromStack::Yes); } std::string errorString; diff --git a/Source/cmLinkItemGraphVisitor.cxx b/Source/cmLinkItemGraphVisitor.cxx index d87d183..0ad846b 100644 --- a/Source/cmLinkItemGraphVisitor.cxx +++ b/Source/cmLinkItemGraphVisitor.cxx @@ -98,8 +98,8 @@ void cmLinkItemGraphVisitor::GetDependencies(cmGeneratorTarget const& target, std::string const& config, DependencyMap& dependencies) { - const auto* implementationLibraries = - target.GetLinkImplementationLibraries(config); + const auto* implementationLibraries = target.GetLinkImplementationLibraries( + config, cmGeneratorTarget::LinkInterfaceFor::Link); if (implementationLibraries != nullptr) { for (auto const& lib : implementationLibraries->Libraries) { auto const& name = lib.AsStr(); diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index 71f9f80..43f1b8e 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -136,7 +136,8 @@ void cmLinkLineDeviceComputer::ComputeLinkLibraries( linkLib.Value += " "; const cmLinkImplementation* linkImpl = - cli.GetTarget()->GetLinkImplementation(cli.GetConfig()); + cli.GetTarget()->GetLinkImplementation( + cli.GetConfig(), cmGeneratorTarget::LinkInterfaceFor::Link); for (const cmLinkImplItem& iter : linkImpl->Libraries) { if (iter.Target != nullptr && diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f0a96a8..a781d59 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -241,14 +241,14 @@ cmListFileBacktrace cmMakefile::GetBacktrace() const return this->Backtrace; } -void cmMakefile::PrintCommandTrace( - cmListFileFunction const& lff, - cm::optional<std::string> const& deferId) const +void cmMakefile::PrintCommandTrace(cmListFileFunction const& lff, + cmListFileBacktrace const& bt, + CommandMissingFromStack missing) const { // Check if current file in the list of requested to trace... std::vector<std::string> const& trace_only_this_files = this->GetCMakeInstance()->GetTraceSources(); - std::string const& full_path = this->GetBacktrace().Top().FilePath; + std::string const& full_path = bt.Top().FilePath; std::string const& only_filename = cmSystemTools::GetFilenameName(full_path); bool trace = trace_only_this_files.empty(); if (!trace) { @@ -282,6 +282,7 @@ void cmMakefile::PrintCommandTrace( args.push_back(arg.Value); } } + cm::optional<std::string> const& deferId = bt.Top().DeferId; switch (this->GetCMakeInstance()->GetTraceFormat()) { case cmake::TraceFormat::TRACE_JSON_V1: { @@ -303,9 +304,9 @@ void cmMakefile::PrintCommandTrace( val["args"].append(arg); } val["time"] = cmSystemTools::GetTime(); - val["frame"] = + val["frame"] = (missing == CommandMissingFromStack::Yes ? 1 : 0) + static_cast<Json::Value::UInt64>(this->ExecutionStatusStack.size()); - val["global_frame"] = + val["global_frame"] = (missing == CommandMissingFromStack::Yes ? 1 : 0) + static_cast<Json::Value::UInt64>(this->RecursionDepth); msg << Json::writeString(builder, val); #endif @@ -427,7 +428,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, if (!cmSystemTools::GetFatalErrorOccured()) { // if trace is enabled, print out invoke information if (this->GetCMakeInstance()->GetTrace()) { - this->PrintCommandTrace(lff, this->Backtrace.Top().DeferId); + this->PrintCommandTrace(lff, this->Backtrace); } // Try invoking the command. bool invokeSucceeded = command(lff.Arguments(), status); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 6d44e79..c8e1e83 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -674,11 +674,18 @@ public: bool copyonly, bool atOnly, bool escapeQuotes, mode_t permissions = 0, cmNewLineStyle = cmNewLineStyle()); + enum class CommandMissingFromStack + { + No, + Yes, + }; + /** * Print a command's invocation */ - void PrintCommandTrace(cmListFileFunction const& lff, - cm::optional<std::string> const& deferId = {}) const; + void PrintCommandTrace( + cmListFileFunction const& lff, cmListFileBacktrace const& bt, + CommandMissingFromStack missing = CommandMissingFromStack::No) const; /** * Set a callback that is invoked whenever ExecuteCommand is called. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index e41ed8c..244f56e 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -191,8 +191,6 @@ void cmMakefileExecutableTargetGenerator::WriteNvidiaDeviceExecutableRule( this->CreateObjectLists(useLinkScript, false, useResponseFileForObjects, buildObjs, depends, false); - std::string const& aixExports = this->GetAIXExports(this->GetConfigName()); - cmRulePlaceholderExpander::RuleVariables vars; std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); @@ -211,7 +209,6 @@ void cmMakefileExecutableTargetGenerator::WriteNvidiaDeviceExecutableRule( cmOutputConverter::SHELL); vars.Language = linkLanguage.c_str(); - vars.AIXExports = aixExports.c_str(); vars.Objects = buildObjs.c_str(); vars.ObjectDir = objectDir.c_str(); vars.Target = target.c_str(); @@ -521,11 +518,14 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string manifests = this->GetManifests(this->GetConfigName()); + std::string const& aixExports = this->GetAIXExports(this->GetConfigName()); + cmRulePlaceholderExpander::RuleVariables vars; vars.CMTargetName = this->GeneratorTarget->GetName().c_str(); vars.CMTargetType = cmState::GetTargetTypeName(this->GeneratorTarget->GetType()).c_str(); vars.Language = linkLanguage.c_str(); + vars.AIXExports = aixExports.c_str(); vars.Objects = buildObjs.c_str(); std::string objectDir = this->GeneratorTarget->GetSupportDirectory(); diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 7d4012d..434c51c 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -390,7 +390,13 @@ class cmMakefile; "Compiler id for MCST LCC compilers is now LCC, not GNU.", 3, 23, 0, \ cmPolicies::WARN) \ SELECT(POLICY, CMP0130, "while() diagnoses condition evaluation errors.", \ - 3, 24, 0, cmPolicies::WARN) + 3, 24, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0131, \ + "LINK_LIBRARIES supports the LINK_ONLY generator expression.", 3, \ + 24, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0132, \ + "Do not set compiler environment variables on first run", 3, 24, 0, \ + cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ @@ -426,7 +432,8 @@ class cmMakefile; F(CMP0108) \ F(CMP0112) \ F(CMP0113) \ - F(CMP0119) + F(CMP0119) \ + F(CMP0131) /** \class cmPolicies * \brief Handles changes in CMake behavior and policies diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index a01e6ae..a47b3c0 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -114,7 +114,8 @@ bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin, } // Collect all static_library dependencies from the test target cmLinkImplementationLibraries const* libs = - testTarget->GetLinkImplementationLibraries(config); + testTarget->GetLinkImplementationLibraries( + config, cmGeneratorTarget::LinkInterfaceFor::Link); if (libs) { for (cmLinkItem const& item : libs->Libraries) { cmGeneratorTarget const* depTarget = item.Target; @@ -1266,7 +1267,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() std::map<cmGeneratorTarget const*, std::size_t> commonTargets; for (std::string const& config : this->ConfigsList) { cmLinkImplementationLibraries const* libs = - this->GenTarget->GetLinkImplementationLibraries(config); + this->GenTarget->GetLinkImplementationLibraries( + config, cmGeneratorTarget::LinkInterfaceFor::Link); if (libs) { for (cmLinkItem const& item : libs->Libraries) { cmGeneratorTarget const* libTarget = item.Target; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index a5dfa4c..cb32172 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1821,6 +1821,7 @@ bool copy_data(struct archive* ar, struct archive* aw) bool extract_tar(const std::string& outFileName, const std::vector<std::string>& files, bool verbose, + cmSystemTools::cmTarExtractTimestamps extractTimestamps, bool extract) { cmLocaleRAII localeRAII; @@ -1879,10 +1880,12 @@ bool extract_tar(const std::string& outFileName, cmSystemTools::Stdout("\n"); } if (extract) { - r = archive_write_disk_set_options(ext, ARCHIVE_EXTRACT_TIME); - if (r != ARCHIVE_OK) { - ArchiveError("Problem with archive_write_disk_set_options(): ", ext); - break; + if (extractTimestamps == cmSystemTools::cmTarExtractTimestamps::Yes) { + r = archive_write_disk_set_options(ext, ARCHIVE_EXTRACT_TIME); + if (r != ARCHIVE_OK) { + ArchiveError("Problem with archive_write_disk_set_options(): ", ext); + break; + } } r = archive_write_header(ext, entry); @@ -1942,13 +1945,15 @@ bool extract_tar(const std::string& outFileName, bool cmSystemTools::ExtractTar(const std::string& outFileName, const std::vector<std::string>& files, + cmTarExtractTimestamps extractTimestamps, bool verbose) { #if !defined(CMAKE_BOOTSTRAP) - return extract_tar(outFileName, files, verbose, true); + return extract_tar(outFileName, files, verbose, extractTimestamps, true); #else (void)outFileName; (void)files; + (void)extractTimestamps; (void)verbose; return false; #endif @@ -1959,7 +1964,8 @@ bool cmSystemTools::ListTar(const std::string& outFileName, bool verbose) { #if !defined(CMAKE_BOOTSTRAP) - return extract_tar(outFileName, files, verbose, false); + return extract_tar(outFileName, files, verbose, cmTarExtractTimestamps::Yes, + false); #else (void)outFileName; (void)files; diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 19dabe8..c17ecbd 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -417,6 +417,12 @@ public: TarCompressNone }; + enum class cmTarExtractTimestamps + { + Yes, + No + }; + static bool ListTar(const std::string& outFileName, const std::vector<std::string>& files, bool verbose); static bool CreateTar(const std::string& outFileName, @@ -426,7 +432,9 @@ public: std::string const& format = std::string(), int compressionLevel = 0); static bool ExtractTar(const std::string& inFileName, - const std::vector<std::string>& files, bool verbose); + const std::vector<std::string>& files, + cmTarExtractTimestamps extractTimestamps, + bool verbose); // This should be called first thing in main // it will keep child processes from inheriting the // stdin and stdout of this process. This is important diff --git a/Source/cmake.cxx b/Source/cmake.cxx index a602458..5bfc4c8 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -868,6 +868,11 @@ void cmake::SetArgs(const std::vector<std::string>& args) CommandArgument{ "-B", "No build directory specified for -B", CommandArgument::Values::One, CommandArgument::RequiresSeparator::No, BuildArgLambda }, + CommandArgument{ "--fresh", CommandArgument::Values::Zero, + [](std::string const&, cmake* cm) -> bool { + cm->FreshCache = true; + return true; + } }, CommandArgument{ "-P", "-P must be followed by a file name.", CommandArgument::Values::One, CommandArgument::RequiresSeparator::No, @@ -2404,12 +2409,19 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) } if (this->GetWorkingMode() == NORMAL_MODE) { + if (this->FreshCache) { + this->DeleteCache(this->GetHomeOutputDirectory()); + } // load the cache if (this->LoadCache() < 0) { cmSystemTools::Error("Error executing cmake::LoadCache(). Aborting.\n"); return -1; } } else { + if (this->FreshCache) { + cmSystemTools::Error("--fresh allowed only when configuring a project"); + return -1; + } this->AddCMakePaths(); } diff --git a/Source/cmake.h b/Source/cmake.h index 3c2a36c..c2bbff7 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -703,6 +703,7 @@ private: FileExtensions HipFileExtensions; bool ClearBuildSystem = false; bool DebugTryCompile = false; + bool FreshCache = false; bool RegenerateDuringBuild = false; std::unique_ptr<cmFileTimeCache> FileTimeCache; std::string GraphVizFile; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 0554c3e..96bf845 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -73,6 +73,8 @@ const char* cmDocumentationOptions[][2] = { { "--list-presets", "List available presets." }, { "-E", "CMake command mode." }, { "-L[A][H]", "List non-advanced cached variables." }, + { "--fresh", + "Configure a fresh build tree, removing any existing cache file." }, { "--build <dir>", "Build a CMake-generated project binary tree." }, { "--install <dir>", "Install a CMake-generated project binary tree." }, { "--open <dir>", "Open generated project in the associated application." }, diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index f1c1bdc..df740c9 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1368,6 +1368,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args, std::vector<std::string> files; std::string mtime; std::string format; + cmSystemTools::cmTarExtractTimestamps extractTimestamps = + cmSystemTools::cmTarExtractTimestamps::Yes; cmSystemTools::cmTarCompression compress = cmSystemTools::TarCompressNone; int nCompress = 0; @@ -1393,6 +1395,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args, format); return 1; } + } else if (arg == "--touch") { + extractTimestamps = cmSystemTools::cmTarExtractTimestamps::No; } else { cmSystemTools::Error("Unknown option to -E tar: " + arg); return 1; @@ -1464,7 +1468,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args, return 1; } } else if (action == cmSystemTools::TarActionExtract) { - if (!cmSystemTools::ExtractTar(outFile, files, verbose)) { + if (!cmSystemTools::ExtractTar(outFile, files, extractTimestamps, + verbose)) { cmSystemTools::Error("Problem extracting tar: " + outFile); return 1; } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index e39cdaf..3ce9b48 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1542,16 +1542,22 @@ if(BUILD_TESTING) endif() set(FindMatlab.basic_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.basic_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.basic_checks APPEND PROPERTY LABELS "Matlab") set(FindMatlab.versions_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.versions_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.versions_checks APPEND PROPERTY LABELS "Matlab") set(FindMatlab.components_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.components_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.components_checks APPEND PROPERTY LABELS "Matlab") set(FindMatlab.failure_reports_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.failure_reports ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.failure_reports APPEND PROPERTY LABELS "Matlab") set(FindMatlab.r2018a_check_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.r2018a_check ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.r2018a_check APPEND PROPERTY LABELS "Matlab") set(FindMatlab.targets_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options}) ADD_TEST_MACRO(FindMatlab.targets_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>) + set_property(TEST FindMatlab.targets_checks APPEND PROPERTY LABELS "Matlab") endif() set(ExternalProject_BUILD_OPTIONS "") diff --git a/Tests/InterfaceLinkLibraries/CMakeLists.txt b/Tests/InterfaceLinkLibraries/CMakeLists.txt index 9e14c44..07a747b 100644 --- a/Tests/InterfaceLinkLibraries/CMakeLists.txt +++ b/Tests/InterfaceLinkLibraries/CMakeLists.txt @@ -59,3 +59,12 @@ set_property(TARGET bar_static_private APPEND PROPERTY INTERFACE_LINK_LIBRARIES add_executable(InterfaceLinkLibraries main_vs6_4.cpp) set_property(TARGET InterfaceLinkLibraries APPEND PROPERTY LINK_LIBRARIES bar_static_private) + +add_library(foo_link_only STATIC foo_link_only.c) +target_compile_definitions(foo_link_only PUBLIC FOO_LINK_ONLY) +add_executable(use_foo_link_only_CMP0131_OLD use_foo_link_only.c) +target_link_libraries(use_foo_link_only_CMP0131_OLD PRIVATE "$<LINK_ONLY:foo_link_only>") +target_compile_definitions(use_foo_link_only_CMP0131_OLD PRIVATE EXPECT_FOO_LINK_ONLY) +cmake_policy(SET CMP0131 NEW) +add_executable(use_foo_link_only_CMP0131_NEW use_foo_link_only.c) +target_link_libraries(use_foo_link_only_CMP0131_NEW PRIVATE "$<LINK_ONLY:foo_link_only>") diff --git a/Tests/InterfaceLinkLibraries/foo_link_only.c b/Tests/InterfaceLinkLibraries/foo_link_only.c new file mode 100644 index 0000000..9ca1c01 --- /dev/null +++ b/Tests/InterfaceLinkLibraries/foo_link_only.c @@ -0,0 +1,8 @@ +#ifndef FOO_LINK_ONLY +# error "FOO_LINK_ONLY incorrectly not defined" +#endif + +int foo_link_only(void) +{ + return 0; +} diff --git a/Tests/InterfaceLinkLibraries/use_foo_link_only.c b/Tests/InterfaceLinkLibraries/use_foo_link_only.c new file mode 100644 index 0000000..e975c1b --- /dev/null +++ b/Tests/InterfaceLinkLibraries/use_foo_link_only.c @@ -0,0 +1,16 @@ +#ifdef EXPECT_FOO_LINK_ONLY +# ifndef FOO_LINK_ONLY +# error "FOO_LINK_ONLY incorrectly not defined" +# endif +#else +# ifdef FOO_LINK_ONLY +# error "FOO_LINK_ONLY incorrectly defined" +# endif +#endif + +extern int foo_link_only(void); + +int main(void) +{ + return foo_link_only(); +} diff --git a/Tests/InterfaceLinkLibrariesDirect/CMakeLists.txt b/Tests/InterfaceLinkLibrariesDirect/CMakeLists.txt index b06a2fb..dec131d 100644 --- a/Tests/InterfaceLinkLibrariesDirect/CMakeLists.txt +++ b/Tests/InterfaceLinkLibrariesDirect/CMakeLists.txt @@ -52,7 +52,7 @@ set_property(TARGET A APPEND PROPERTY INTERFACE_LINK_LIBRARIES_DIRECT add_library(static_A_public STATIC static_A_public.c) target_link_libraries(static_A_public PUBLIC A) -# Uses A's usage requirements, but does not propagate them. +# Uses A's usage requirements, but propagates only the linking requirements. # Does not use the exe-only usage requirement. Does use the optional one. add_library(static_A_private STATIC static_A_private.c) target_link_libraries(static_A_private PRIVATE A) @@ -63,10 +63,15 @@ add_executable(exe_use_static_A_public exe_use_static_A_public.c) target_link_libraries(exe_use_static_A_public PRIVATE static_A_public) set_property(TARGET exe_use_static_A_public PROPERTY A_LINK_OPTIONAL 1) -# Does not use A's usage requirements. +# Does not use A's usage requirements, but does use its non-optional linking requirements. add_executable(exe_use_static_A_private exe_use_static_A_private.c) target_link_libraries(exe_use_static_A_private PRIVATE static_A_private) +# Uses A's usage requirements, including an optional one, but overrides the link ordering. +add_executable(exe_use_static_A_public_explicit exe_use_static_A_public_explicit.c) +target_link_libraries(exe_use_static_A_public_explicit PRIVATE static_A_public A direct_from_A direct_from_A_for_exe direct_from_A_optional) +set_property(TARGET exe_use_static_A_public_explicit PROPERTY A_LINK_OPTIONAL 1) + #---------------------------------------------------------------------------- # Test how original and injected dependencies get ordered. diff --git a/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_private.c b/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_private.c index 024e96e..12cf309 100644 --- a/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_private.c +++ b/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_private.c @@ -9,15 +9,15 @@ #endif extern void static_A_private(void); -extern void not_direct_from_A(void); -extern void not_direct_from_A_for_exe(void); +extern void direct_from_A(void); +extern void direct_from_A_for_exe(void); extern void not_direct_from_A_optional(void); int main(void) { static_A_private(); - not_direct_from_A(); - not_direct_from_A_for_exe(); + direct_from_A(); + direct_from_A_for_exe(); not_direct_from_A_optional(); return 0; } diff --git a/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_public_explicit.c b/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_public_explicit.c new file mode 100644 index 0000000..f698a24 --- /dev/null +++ b/Tests/InterfaceLinkLibrariesDirect/exe_use_static_A_public_explicit.c @@ -0,0 +1,23 @@ +#ifndef DEF_DIRECT_FROM_A +# error "DEF_DIRECT_FROM_A incorrectly not defined" +#endif +#ifndef DEF_DIRECT_FROM_A_FOR_EXE +# error "DEF_DIRECT_FROM_A_FOR_EXE incorrectly not defined" +#endif +#ifndef DEF_DIRECT_FROM_A_OPTIONAL +# error "DEF_DIRECT_FROM_A_OPTIONAL incorrectly not defined" +#endif + +extern void static_A_public(void); +extern void not_direct_from_A(void); +extern void not_direct_from_A_for_exe(void); +extern void not_direct_from_A_optional(void); + +int main(void) +{ + static_A_public(); + not_direct_from_A(); + not_direct_from_A_for_exe(); + not_direct_from_A_optional(); + return 0; +} diff --git a/Tests/RunCMake/CMP0132/CMP0132-Common.cmake b/Tests/RunCMake/CMP0132/CMP0132-Common.cmake new file mode 100644 index 0000000..796f61c --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-Common.cmake @@ -0,0 +1,15 @@ +if(NOT "$ENV{CC}" STREQUAL "") + message(STATUS "Test environment already sets CC, test being SKIPPED") + return() +elseif(CMAKE_GENERATOR MATCHES "Xcode|Visual Studio") + message(STATUS "This generator never sets CC, test being SKIPPED") + return() +endif() + +enable_language(C) + +if("$ENV{CC}" STREQUAL "") + message(STATUS "CC was left unset") +else() + message(STATUS "CC was set to $ENV{CC}") +endif() diff --git a/Tests/RunCMake/CMP0132/CMP0132-NEW-stdout.txt b/Tests/RunCMake/CMP0132/CMP0132-NEW-stdout.txt new file mode 100644 index 0000000..8056c2c --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-NEW-stdout.txt @@ -0,0 +1 @@ +SKIPPED|CC was left unset diff --git a/Tests/RunCMake/CMP0132/CMP0132-NEW.cmake b/Tests/RunCMake/CMP0132/CMP0132-NEW.cmake new file mode 100644 index 0000000..fabb419 --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0132 NEW) +include(CMP0132-Common.cmake) diff --git a/Tests/RunCMake/CMP0132/CMP0132-OLD-stdout.txt b/Tests/RunCMake/CMP0132/CMP0132-OLD-stdout.txt new file mode 100644 index 0000000..c131428 --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-OLD-stdout.txt @@ -0,0 +1 @@ +SKIPPED|CC was set diff --git a/Tests/RunCMake/CMP0132/CMP0132-OLD.cmake b/Tests/RunCMake/CMP0132/CMP0132-OLD.cmake new file mode 100644 index 0000000..aae4f2a --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0132 OLD) +include(CMP0132-Common.cmake) diff --git a/Tests/RunCMake/CMP0132/CMP0132-WARN-stdout.txt b/Tests/RunCMake/CMP0132/CMP0132-WARN-stdout.txt new file mode 100644 index 0000000..c131428 --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-WARN-stdout.txt @@ -0,0 +1 @@ +SKIPPED|CC was set diff --git a/Tests/RunCMake/CMP0132/CMP0132-WARN.cmake b/Tests/RunCMake/CMP0132/CMP0132-WARN.cmake new file mode 100644 index 0000000..c07e5db --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMP0132-WARN.cmake @@ -0,0 +1,2 @@ + +include(CMP0132-Common.cmake) diff --git a/Tests/RunCMake/CMP0132/CMakeLists.txt b/Tests/RunCMake/CMP0132/CMakeLists.txt new file mode 100644 index 0000000..5ff8d3e --- /dev/null +++ b/Tests/RunCMake/CMP0132/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.23) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0132/RunCMakeTest.cmake b/Tests/RunCMake/CMP0132/RunCMakeTest.cmake new file mode 100644 index 0000000..db599ce --- /dev/null +++ b/Tests/RunCMake/CMP0132/RunCMakeTest.cmake @@ -0,0 +1,7 @@ +include(RunCMake) + +if(NOT CMAKE_GENERATOR_NO_COMPILER_ENV) + run_cmake(CMP0132-WARN) + run_cmake(CMP0132-OLD) + run_cmake(CMP0132-NEW) +endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 1deb75f..e695844 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -142,6 +142,14 @@ if (CMAKE_SYSTEM_NAME MATCHES "(Linux|Darwin)") endif() add_RunCMake_test(CMP0126) +if("${CMAKE_C_COMPILER_ID}" STREQUAL "LCC" OR + "${CMAKE_CXX_COMPILER_ID}" STREQUAL "LCC" OR + "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "LCC") + add_RunCMake_test("CMP0129") +endif() + +add_RunCMake_test(CMP0132) + # The test for Policy 65 requires the use of the # CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode # generators ignore. The policy will have no effect on those generators. @@ -803,6 +811,7 @@ if(CMake_TEST_FindMatlab OR CMake_TEST_FindMatlab_MCR OR (NOT "${CMake_TEST_Find endif() add_RunCMake_test(FindMatlab ${FindMatlab_additional_test_options}) + set_property(TEST RunCMake.FindMatlab APPEND PROPERTY LABELS "Matlab") endif() add_executable(pseudo_emulator pseudo_emulator.c) @@ -976,7 +985,3 @@ endif() if(WIN32) add_RunCMake_test(Win32GenEx) endif() - -if("${CMAKE_C_COMPILER_ID}" STREQUAL "LCC" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "LCC" OR "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "LCC") - add_RunCMake_test("CMP0129") -endif() diff --git a/Tests/RunCMake/CommandLine/Fresh-stdout.txt b/Tests/RunCMake/CommandLine/Fresh-stdout.txt new file mode 100644 index 0000000..b5cece9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Fresh-stdout.txt @@ -0,0 +1,4 @@ +-- CMAKE_SOURCE_DIR='[^']*/Tests/RunCMake/CommandLine' +-- CMAKE_BINARY_DIR='[^']*/Tests/RunCMake/CommandLine/Fresh-build' +-- OLD CACHED_VAR_1='' +-- NEW CACHED_VAR_1='CACHED-VALUE-1' diff --git a/Tests/RunCMake/CommandLine/Fresh.cmake b/Tests/RunCMake/CommandLine/Fresh.cmake new file mode 100644 index 0000000..9b1695c --- /dev/null +++ b/Tests/RunCMake/CommandLine/Fresh.cmake @@ -0,0 +1,18 @@ +message(STATUS "CMAKE_SOURCE_DIR='${CMAKE_SOURCE_DIR}'") +message(STATUS "CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}'") +message(STATUS "OLD CACHED_VAR_1='${CACHED_VAR_1}'") +set(CACHED_VAR_1 "CACHED-VALUE-1" CACHE STRING "") +message(STATUS "NEW CACHED_VAR_1='${CACHED_VAR_1}'") +set(kept "${CMAKE_BINARY_DIR}/kept") +set(removed "${CMAKE_BINARY_DIR}/CMakeFiles/removed") +if(FIRST) + file(WRITE "${kept}" "") + file(WRITE "${removed}" "") +else() + if(NOT EXISTS "${kept}") + message(FATAL_ERROR "File was not kept:\n ${kept}") + endif() + if(EXISTS "${removed}") + message(FATAL_ERROR "File was not removed:\n ${removed}") + endif() +endif() diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt index c0f96f3..c94c19d 100644 --- a/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt +++ b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt @@ -1,8 +1,9 @@ -^-- CMAKE_ARGC='7' +^-- CMAKE_ARGC='8' -- CMAKE_ARGV1='-P' -- CMAKE_ARGV2='[^']*/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake' -- CMAKE_ARGV3='--' -- CMAKE_ARGV4='-DFOO' -- CMAKE_ARGV5='-S' -- CMAKE_ARGV6='-B' --- CMAKE_ARGV7=''$ +-- CMAKE_ARGV7='--fresh' +-- CMAKE_ARGV8=''$ diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake index d0a4859..8dca990 100644 --- a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake +++ b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake @@ -6,3 +6,4 @@ message(STATUS "CMAKE_ARGV4='${CMAKE_ARGV4}'") message(STATUS "CMAKE_ARGV5='${CMAKE_ARGV5}'") message(STATUS "CMAKE_ARGV6='${CMAKE_ARGV6}'") message(STATUS "CMAKE_ARGV7='${CMAKE_ARGV7}'") +message(STATUS "CMAKE_ARGV8='${CMAKE_ARGV8}'") diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-result.txt b/Tests/RunCMake/CommandLine/P_fresh-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-result.txt +++ b/Tests/RunCMake/CommandLine/P_fresh-result.txt diff --git a/Tests/RunCMake/CommandLine/P_fresh-stderr.txt b/Tests/RunCMake/CommandLine/P_fresh-stderr.txt new file mode 100644 index 0000000..0c5b035 --- /dev/null +++ b/Tests/RunCMake/CommandLine/P_fresh-stderr.txt @@ -0,0 +1 @@ +^CMake Error: --fresh allowed only when configuring a project$ diff --git a/Tests/RunCMake/CommandLine/P_fresh.cmake b/Tests/RunCMake/CommandLine/P_fresh.cmake new file mode 100644 index 0000000..dfedce1 --- /dev/null +++ b/Tests/RunCMake/CommandLine/P_fresh.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This code should not be reached.") diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 22a59f2..c8234ec 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -52,7 +52,8 @@ run_cmake_command(G_no-arg ${CMAKE_COMMAND} -B DummyBuildDir -G) run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -B DummyBuildDir -G NoSuchGenerator) run_cmake_command(P_no-arg ${CMAKE_COMMAND} -P) run_cmake_command(P_no-file ${CMAKE_COMMAND} -P nosuchscriptfile.cmake) -run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO -S -B) +run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO -S -B --fresh) +run_cmake_command(P_fresh ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_fresh.cmake" --fresh) run_cmake_command(build-no-dir ${CMAKE_COMMAND} --build) @@ -212,6 +213,22 @@ message(STATUS "CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}'") endfunction() run_ExplicitDirs() +function(run_Fresh) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/Fresh-build") + + set(RunCMake_TEST_VARIANT_DESCRIPTION "-empty") + run_cmake_with_options(Fresh --fresh -DFIRST=ON) + set(RunCMake_TEST_NO_CLEAN 1) + + set(RunCMake_TEST_VARIANT_DESCRIPTION "-reconfig") + run_cmake_with_options(Fresh --fresh) + + set(RunCMake_TEST_VARIANT_DESCRIPTION "-src-from-cache") + set(RunCMake_TEST_NO_SOURCE_DIR 1) + run_cmake_with_options(Fresh --fresh "${RunCMake_TEST_BINARY_DIR}") +endfunction() +run_Fresh() + function(run_Toolchain) set(RunCMake_TEST_NO_SOURCE_DIR 1) set(source_dir ${RunCMake_SOURCE_DIR}/Toolchain) diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-check.py b/Tests/RunCMake/CommandLine/trace-json-v1-check.py index 2ef1495..c4b95dc 100755 --- a/Tests/RunCMake/CommandLine/trace-json-v1-check.py +++ b/Tests/RunCMake/CommandLine/trace-json-v1-check.py @@ -56,6 +56,11 @@ required_traces = [ 'cmd': 'message', 'frame': 3, 'global_frame': 6 if expand else 5 + }, + { + 'cmd': 'else', + 'global_frame': 4 if expand else 3, + 'line': 3 } ] @@ -98,4 +103,7 @@ with open(trace_file, 'r') as fp: if subset == j: required_traces.remove(j) -assert not required_traces +assert not required_traces, ( + "The following traces were expected to be part of the " + "output but weren't", required_traces +) diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt b/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt index 089a960..743f6de 100644 --- a/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt +++ b/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt @@ -1,3 +1,8 @@ +function(function_that_uses_else) + if(FALSE) + else() + endif() +endfunction() function(f) message(STATUS "nested global_frame") endfunction() diff --git a/Tests/RunCMake/CommandLine/trace-json-v1.cmake b/Tests/RunCMake/CommandLine/trace-json-v1.cmake index 4ed6160..464eb1f 100644 --- a/Tests/RunCMake/CommandLine/trace-json-v1.cmake +++ b/Tests/RunCMake/CommandLine/trace-json-v1.cmake @@ -8,3 +8,4 @@ set(FOO 42) set(BAR " space in string!") message(STATUS fff ${ASDF} " ${FOO} ${BAR}" " SPACES !!! ") add_subdirectory(trace-json-v1-nested) +function_that_uses_else() diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake index a64af95..a487f37 100644 --- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake @@ -34,3 +34,9 @@ run_cmake(zip) # Extracting only selected files or directories run_cmake(zip-filtered) + +# Use the --mtime option to set the mtime when creating archive +run_cmake(set-mtime) + +# Use the --touch option to avoid extracting the mtime +run_cmake(touch-mtime) diff --git a/Tests/RunCMake/CommandLineTar/mtime-tests.cmake b/Tests/RunCMake/CommandLineTar/mtime-tests.cmake new file mode 100644 index 0000000..8b4f098 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/mtime-tests.cmake @@ -0,0 +1,9 @@ +set(OUTPUT_NAME "test.tar") + +set(ARCHIVE_MTIME "1970-01-01UTC") +set(ARCHIVE_MTIME_RFC3339 "1970-01-01T00:00:00Z") + +set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_OPTIONS --mtime=${ARCHIVE_MTIME}) + +set(DECOMPRESSION_FLAGS xvf) diff --git a/Tests/RunCMake/CommandLineTar/set-mtime.cmake b/Tests/RunCMake/CommandLineTar/set-mtime.cmake new file mode 100644 index 0000000..333cc88 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/set-mtime.cmake @@ -0,0 +1,11 @@ +include(${CMAKE_CURRENT_LIST_DIR}/mtime-tests.cmake) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +foreach(file ${CHECK_FILES}) + file(TIMESTAMP ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file} MTIME UTC) + if(NOT MTIME STREQUAL ARCHIVE_MTIME_RFC3339) + message(FATAL_ERROR + "Extracted timestamp ${MTIME} does not match expected ${ARCHIVE_MTIME_RFC3339}") + endif() +endforeach() diff --git a/Tests/RunCMake/CommandLineTar/touch-mtime.cmake b/Tests/RunCMake/CommandLineTar/touch-mtime.cmake new file mode 100644 index 0000000..c9e3524 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/touch-mtime.cmake @@ -0,0 +1,13 @@ +include(${CMAKE_CURRENT_LIST_DIR}/mtime-tests.cmake) + +set(DECOMPRESSION_OPTIONS --touch) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +foreach(file ${CHECK_FILES}) + file(TIMESTAMP ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file} MTIME UTC) + if(MTIME STREQUAL ARCHIVE_MTIME_RFC3339) + message(FATAL_ERROR + "File has unexpected timestamp ${MTIME}") + endif() +endforeach() diff --git a/Tests/RunCMake/CompilerArgs/C-stdout.txt b/Tests/RunCMake/CompilerArgs/C-stdout.txt new file mode 100644 index 0000000..e553cbb --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/C-stdout.txt @@ -0,0 +1 @@ +-- CMAKE_C_COMPILER_ARG1=' ?-DFOO1 -DFOO2' diff --git a/Tests/RunCMake/CompilerArgs/C.cmake b/Tests/RunCMake/CompilerArgs/C.cmake index 96b004b..0fbfdd2 100644 --- a/Tests/RunCMake/CompilerArgs/C.cmake +++ b/Tests/RunCMake/CompilerArgs/C.cmake @@ -1,3 +1,4 @@ enable_language(C) set(CMAKE_VERBOSE_MAKEFILE TRUE) +message(STATUS "CMAKE_C_COMPILER_ARG1='${CMAKE_C_COMPILER_ARG1}'") add_executable(main main.c) diff --git a/Tests/RunCMake/CompilerArgs/CXX-stdout.txt b/Tests/RunCMake/CompilerArgs/CXX-stdout.txt new file mode 100644 index 0000000..c543d3b --- /dev/null +++ b/Tests/RunCMake/CompilerArgs/CXX-stdout.txt @@ -0,0 +1 @@ +-- CMAKE_CXX_COMPILER_ARG1=' ?-DFOO1 -DFOO2' diff --git a/Tests/RunCMake/CompilerArgs/CXX.cmake b/Tests/RunCMake/CompilerArgs/CXX.cmake index 3d2ee00..b6cf87e 100644 --- a/Tests/RunCMake/CompilerArgs/CXX.cmake +++ b/Tests/RunCMake/CompilerArgs/CXX.cmake @@ -1,3 +1,4 @@ enable_language(CXX) set(CMAKE_VERBOSE_MAKEFILE TRUE) +message(STATUS "CMAKE_CXX_COMPILER_ARG1='${CMAKE_CXX_COMPILER_ARG1}'") add_executable(main main.cxx) diff --git a/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake b/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake index 9e5a18a..62294cd 100644 --- a/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerArgs/RunCMakeTest.cmake @@ -19,12 +19,6 @@ function(run_compiler_env lang) # Use the correct compiler include(${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/${lang}_comp.cmake) - # Use a single build tree for tests without cleaning. - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-env-build) - set(RunCMake_TEST_NO_CLEAN 1) - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - # Set the compiler if(lang STREQUAL "C") set(ENV{CC} "'${temp_CMAKE_${lang}_COMPILER}' -DFOO1 -DFOO2") @@ -32,19 +26,30 @@ function(run_compiler_env lang) set(ENV{${lang}} "'${temp_CMAKE_${lang}_COMPILER}' -DFOO1 -DFOO2") endif() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-env-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-env") + run_cmake(${lang}) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/CMakeFiles") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-env-cached") run_cmake(${lang}) run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) endfunction() function(run_compiler_tc lang) - # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_OPTIONS + -DCMAKE_TOOLCHAIN_FILE=${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/toolchain_${lang}_comp.cmake) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${lang}-tc-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-tc") + run_cmake(${lang}) set(RunCMake_TEST_NO_CLEAN 1) - file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") - file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) - set(RunCMake_TEST_OPTIONS - -DCMAKE_TOOLCHAIN_FILE=${RunCMake_BINARY_DIR}/Find${lang}Compiler-build/toolchain_${lang}_comp.cmake) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/CMakeFiles") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-tc-cached") run_cmake(${lang}) run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args}) endfunction() diff --git a/Tests/RunCMake/Framework/FrameworkConsumption.cmake b/Tests/RunCMake/Framework/FrameworkConsumption.cmake new file mode 100644 index 0000000..4663166 --- /dev/null +++ b/Tests/RunCMake/Framework/FrameworkConsumption.cmake @@ -0,0 +1,15 @@ + +cmake_minimum_required(VERSION 3.22...3.24) +enable_language(C) + +# Create framework and ensure header is placed in Headers +set(input_header "${CMAKE_SOURCE_DIR}/Gui.h") +add_library(Gui SHARED Gui.c "${input_header}") +set_target_properties(Gui PROPERTIES + PUBLIC_HEADER "${input_header}" + FRAMEWORK TRUE +) + +add_executable(app main.c) + +target_link_libraries(app PRIVATE Gui) diff --git a/Tests/RunCMake/Framework/Gui.c b/Tests/RunCMake/Framework/Gui.c new file mode 100644 index 0000000..f669327 --- /dev/null +++ b/Tests/RunCMake/Framework/Gui.c @@ -0,0 +1,5 @@ + +int foo(void) +{ + return 0; +} diff --git a/Tests/RunCMake/Framework/Gui.h b/Tests/RunCMake/Framework/Gui.h new file mode 100644 index 0000000..5beae6d --- /dev/null +++ b/Tests/RunCMake/Framework/Gui.h @@ -0,0 +1,2 @@ + +int foo(void); diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake index 2f8fdc7..a767130 100644 --- a/Tests/RunCMake/Framework/RunCMakeTest.cmake +++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake @@ -105,3 +105,15 @@ function(framework_system_include_test) endfunction() framework_system_include_test() + +function(framework_consumption) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/FrameworkConsumption-build") + set(RunCMake_TEST_NO_CLEAN 1) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(FrameworkConsumption) + run_cmake_command(FrameworkConsumption-build ${CMAKE_COMMAND} --build .) +endfunction() + +framework_consumption() diff --git a/Tests/RunCMake/Framework/main.c b/Tests/RunCMake/Framework/main.c new file mode 100644 index 0000000..fc09922 --- /dev/null +++ b/Tests/RunCMake/Framework/main.c @@ -0,0 +1,9 @@ + +#include <Gui/Gui.h> + +int main() +{ + foo(); + + return 0; +} diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake index 98eef35..f20d225 100644 --- a/Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake @@ -11,6 +11,7 @@ run_cmake(empty-arguments) run_cmake(forbidden-arguments) run_cmake(nested-incompatible-genex) run_cmake(invalid-feature) +run_cmake(multiple-definitions) run_cmake(bad-feature1) run_cmake(bad-feature2) run_cmake(bad-feature3) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-stderr.txt new file mode 100644 index 0000000..995f363 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at multiple-definitions.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified through generator-expression '\$<LINK_GROUP>' to + link target 'lib', is not supported for the 'C' link language. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions.cmake new file mode 100644 index 0000000..a021d44 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_GROUP/multiple-definitions.cmake @@ -0,0 +1,12 @@ +enable_language(C) + +# Language specific definition takes precedence over more generic one +set(CMAKE_C_LINK_GROUP_USING_feat "-BEFORE" "-AFTER") +set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED FALSE) +set(CMAKE_LINK_GROUP_USING_feat "-BEFORE" "-AFTER") +set(CMAKE_LINK_GROUP_USING_feat_SUPPORTED TRUE) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake index 9c266fe..3fb68d6 100644 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake @@ -10,6 +10,7 @@ run_cmake(no-arguments) run_cmake(empty-arguments) run_cmake(forbidden-arguments) run_cmake(invalid-feature) +run_cmake(multiple-definitions) run_cmake(bad-feature1) run_cmake(bad-feature2) run_cmake(bad-feature3) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-stderr.txt new file mode 100644 index 0000000..26b0bac --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at multiple-definitions.cmake:[0-9]+ \(add_library\): + Feature 'feat', specified through generator-expression '\$<LINK_LIBRARY>' to + link target 'lib', is not supported for the 'C' link language. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions.cmake new file mode 100644 index 0000000..1bd1888 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-definitions.cmake @@ -0,0 +1,12 @@ +enable_language(C) + +# Language specific definition takes precedence over more generic one +set(CMAKE_C_LINK_LIBRARY_USING_feat "<LIBRARY>") +set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED FALSE) +set(CMAKE_LINK_LIBRARY_USING_feat "<LIBRARY>") +set(CMAKE_LINK_LIBRARY_USING_feat_SUPPORTED TRUE) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>") diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt index 3846d7c..97c3394 100644 --- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -35,6 +35,7 @@ \* CMP0112 \* CMP0113 \* CMP0119 + \* CMP0131 Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/define_property/RunCMakeTest.cmake b/Tests/RunCMake/define_property/RunCMakeTest.cmake index 7d7c75b..93eaf1b 100644 --- a/Tests/RunCMake/define_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/define_property/RunCMakeTest.cmake @@ -6,4 +6,4 @@ run_cmake(define_property-INITIALIZE_FROM_VARIABLE-invalid_1) run_cmake(define_property-INITIALIZE_FROM_VARIABLE-invalid_2) run_cmake(define_property-INITIALIZE_FROM_VARIABLE-non_target) run_cmake(define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix) -run_cmake(define_property-INITIALIZE_FROM_VARIABLE-no_prefix) +run_cmake(define_property-INITIALIZE_FROM_VARIABLE-no_underscore) diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-stderr.txt index a7903c9..c5ae467 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-stderr.txt +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-invalid_1\.cmake:[0-9]+ \(define_property\): - define_property variable name "CMAKE_PROP1" is reserved + define_property variable name "CMAKE_Test_PROP1" is reserved Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1.cmake index 873263a..edb8852 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1.cmake +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1.cmake @@ -1,3 +1,3 @@ -define_property(TARGET PROPERTY PROP1 - INITIALIZE_FROM_VARIABLE CMAKE_PROP1 +define_property(TARGET PROPERTY Test_PROP1 + INITIALIZE_FROM_VARIABLE CMAKE_Test_PROP1 ) diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-stderr.txt index ea6bc86..3dbee34 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-stderr.txt +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-invalid_2\.cmake:[0-9]+ \(define_property\): - define_property variable name "_CMAKE_PROP1" is reserved + define_property variable name "_CMAKE_Test_PROP1" is reserved Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2.cmake index 95945a3..e1c3ca5 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2.cmake +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2.cmake @@ -1,3 +1,3 @@ -define_property(TARGET PROPERTY PROP1 - INITIALIZE_FROM_VARIABLE _CMAKE_PROP1 +define_property(TARGET PROPERTY Test_PROP1 + INITIALIZE_FROM_VARIABLE _CMAKE_Test_PROP1 ) diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-stderr.txt deleted file mode 100644 index fc9099c..0000000 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-no_prefix\.cmake:[0-9]+ \(define_property\): - define_property Variable name must have a non-empty prefix before property - name "PROP1" -Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore-result.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore-stderr.txt new file mode 100644 index 0000000..9bbdd8b --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-no_underscore\.cmake:[0-9]+ \(define_property\): + define_property Property name "PROP1" defined with INITIALIZE_FROM_VARIABLE + does not contain underscore +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore.cmake index cc39b57..cc39b57 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix.cmake +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore.cmake diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-subdirectory/CMakeLists.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-subdirectory/CMakeLists.txt index 67c186d..ee128ec 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-subdirectory/CMakeLists.txt +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-subdirectory/CMakeLists.txt @@ -1,11 +1,11 @@ -define_property(TARGET PROPERTY PROP2 +define_property(TARGET PROPERTY Test_PROP2 INITIALIZE_FROM_VARIABLE Test_PROP2 ) -define_property(TARGET PROPERTY PROP3 - INITIALIZE_FROM_VARIABLE Test_PROP3 +define_property(TARGET PROPERTY Test_PROP3 + INITIALIZE_FROM_VARIABLE MyTest_PROP3 ) add_executable(sub_exe ../main.c) -assert_prop_eq(sub_exe PROP1 "Hello") -assert_prop_eq(sub_exe PROP2 "world") -assert_prop_eq(sub_exe PROP3 "!") +assert_prop_eq(sub_exe Test_PROP1 "Hello") +assert_prop_eq(sub_exe Test_PROP2 "world") +assert_prop_eq(sub_exe Test_PROP3 "!") diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE.cmake index d866fc9..5014c74 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE.cmake +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE.cmake @@ -16,14 +16,14 @@ endfunction() set(Test_PROP1 "Hello") set(Test_PROP2 "world") -set(Test_PROP3 "!") -define_property(TARGET PROPERTY PROP1 +set(MyTest_PROP3 "!") +define_property(TARGET PROPERTY Test_PROP1 INITIALIZE_FROM_VARIABLE Test_PROP1 ) add_subdirectory(define_property-INITIALIZE_FROM_VARIABLE-subdirectory) add_executable(top_exe main.c) -assert_prop_eq(top_exe PROP1 "Hello") -assert_prop_eq(top_exe PROP2 "world") -assert_prop_eq(top_exe PROP3 "!") +assert_prop_eq(top_exe Test_PROP1 "Hello") +assert_prop_eq(top_exe Test_PROP2 "world") +assert_prop_eq(top_exe Test_PROP3 "!") diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-definitions-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-definitions-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-definitions-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-mutiple-definitions-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-mutiple-definitions-check.cmake new file mode 100644 index 0000000..3e53d26 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-mutiple-definitions-check.cmake @@ -0,0 +1,4 @@ + +if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP") + set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base1> <base2> --END_GROUP'.") +endif() diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake index d08db16..31eb7e2 100644 --- a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake @@ -20,6 +20,9 @@ set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE) set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--LIBFLAG<LIBRARY>") set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) +set(CMAKE_C_LINK_GROUP_USING_feat2 "--START_GROUP" "--END_GROUP") +set(CMAKE_LINK_GROUP_USING_feat2 "--START_GROUP" "--END_GROUP") +set(CMAKE_LINK_GROUP_USING_feat2_SUPPORTED TRUE) add_library(LinkGroup_simple1 SHARED lib.c) target_link_libraries(LinkGroup_simple1 PRIVATE "$<LINK_GROUP:feat1,base1,base2>") @@ -31,6 +34,10 @@ add_library(LinkGroup_simple2 SHARED lib.c) target_link_libraries(LinkGroup_simple2 PRIVATE "$<LINK_GROUP:feat1,base2,base3>") +add_library(LinkGroup_multiple-definitions SHARED lib.c) +target_link_libraries(LinkGroup_multiple-definitions PRIVATE "$<LINK_GROUP:feat2,base1,base2>") + + add_library(base4 SHARED base.c) target_link_libraries(base4 INTERFACE "$<LINK_GROUP:feat1,base1,base2>") add_library(LinkGroup_multiple-groups SHARED lib.c) diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake index 8307bb2..c1d74d0 100644 --- a/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake @@ -42,6 +42,7 @@ if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode" run_cmake_target(LINK_GROUP simple1 LinkGroup_simple1) run_cmake_target(LINK_GROUP simple2 LinkGroup_simple2) + run_cmake_target(LINK_GROUP multiple-definitions LinkGroup_multiple-definitions) run_cmake_target(LINK_GROUP multiple-groups LinkGroup_multiple-groups) run_cmake_target(LINK_GROUP group-and-single LinkGroup_group-and-single) run_cmake_target(LINK_GROUP with-LINK_LIBRARY LinkGroup_with-LINK_LIBRARY) @@ -63,7 +64,7 @@ if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode" endif() # Feature RESCAN -if (CMAKE_SYSTEM_NAME STREQUAL "Linux" +if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD" OR (CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND (NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro" OR CMAKE_C_COMPILER_VERSION VERSION_GREATER "5.9")) OR (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "GNU")) run_cmake(rescan) diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake index 1581611..f19112a 100644 --- a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake +++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake @@ -16,7 +16,6 @@ set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--LIBFLAG<LIBRARY>") set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE) set(CMAKE_C_LINK_LIBRARY_USING_feat1_1 "--LIBFLAG_C<LIBRARY>") -set(CMAKE_C_LINK_LIBRARY_USING_feat1_1_SUPPORTED FALSE) set(CMAKE_LINK_LIBRARY_USING_feat1_1 "--LIBFLAG<LIBRARY>") set(CMAKE_LINK_LIBRARY_USING_feat1_1_SUPPORTED TRUE) |