diff options
66 files changed, 536 insertions, 310 deletions
diff --git a/Help/cpack_gen/deb.rst b/Help/cpack_gen/deb.rst index 26021cc..fdde654 100644 --- a/Help/cpack_gen/deb.rst +++ b/Help/cpack_gen/deb.rst @@ -1,20 +1,20 @@ -CPack Deb Generator +CPack DEB Generator ------------------- -The built in (binary) CPack Deb generator (Unix only) +The built in (binary) CPack DEB generator (Unix only) Variables specific to CPack Debian (DEB) generator ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The CPack Deb generator may be used to create Deb package using :module:`CPack`. -The CPack Deb generator is a :module:`CPack` generator thus it uses the +The CPack DEB generator may be used to create DEB package using :module:`CPack`. +The CPack DEB generator is a :module:`CPack` generator thus it uses the ``CPACK_XXX`` variables used by :module:`CPack`. -The CPack Deb generator should work on any Linux host but it will produce +The CPack DEB generator should work on any Linux host but it will produce better deb package when Debian specific tools ``dpkg-xxx`` are usable on the build system. -The CPack Deb generator has specific features which are controlled by the +The CPack DEB generator has specific features which are controlled by the specifics :code:`CPACK_DEBIAN_XXX` variables. :code:`CPACK_DEBIAN_<COMPONENT>_XXXX` variables may be used in order to have @@ -22,13 +22,13 @@ specifics :code:`CPACK_DEBIAN_XXX` variables. the **grouping name** written in upper case. It may be either a component name or a component GROUP name. -Here are some CPack Deb generator wiki resources that are here for historic +Here are some CPack DEB generator wiki resources that are here for historic reasons and are no longer maintained but may still prove useful: - https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/Configuration - https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/PackageGenerators#deb-unix-only -List of CPack Deb generator specific variables: +List of CPack DEB generator specific variables: .. variable:: CPACK_DEB_COMPONENT_INSTALL @@ -64,7 +64,7 @@ List of CPack Deb generator specific variables: * Mandatory : YES * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].deb`` - This may be set to ``DEB-DEFAULT`` to allow the CPack Deb generator to generate + This may be set to ``DEB-DEFAULT`` to allow the CPack DEB generator to generate package file name by itself in deb format:: <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb @@ -75,7 +75,7 @@ List of CPack Deb generator specific variables: .. note:: Preferred setting of this variable is ``DEB-DEFAULT`` but for backward - compatibility with the CPack Deb generator in CMake prior to version 3.6 this + compatibility with the CPack DEB generator in CMake prior to version 3.6 this feature is disabled by default. .. note:: @@ -279,7 +279,7 @@ List of CPack Deb generator specific variables: .. variable:: CPACK_DEBIAN_PACKAGE_DEBUG May be set when invoking cpack in order to trace debug information - during the CPack Deb generator run. + during the CPack DEB generator run. * Mandatory : NO * Default : - @@ -553,5 +553,5 @@ Reproducible packages The environment variable ``SOURCE_DATE_EPOCH`` may be set to a UNIX timestamp, defined as the number of seconds, excluding leap seconds, -since 01 Jan 1970 00:00:00 UTC. If set, the CPack Deb generator will +since 01 Jan 1970 00:00:00 UTC. If set, the CPack DEB generator will use its value for timestamps in the package. diff --git a/Help/cpack_gen/dmg.rst b/Help/cpack_gen/dmg.rst index b7b3a0a..1e37889 100644 --- a/Help/cpack_gen/dmg.rst +++ b/Help/cpack_gen/dmg.rst @@ -1,7 +1,7 @@ -CPack DMG Generator -------------------- +CPack DragNDrop Generator +------------------------- -DragNDrop CPack generator (macOS). +The DragNDrop CPack generator (macOS) creates a DMG image. Variables specific to CPack DragNDrop generator ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Help/cpack_gen/freebsd.rst b/Help/cpack_gen/freebsd.rst index 2419057..b22ea9a 100644 --- a/Help/cpack_gen/freebsd.rst +++ b/Help/cpack_gen/freebsd.rst @@ -13,7 +13,7 @@ depending on the installed package-management tools -- using :module:`CPack`. The CPack FreeBSD generator is a :module:`CPack` generator and uses the ``CPACK_XXX`` variables used by :module:`CPack`. It tries to re-use packaging information that may already be specified for Debian packages for the -:cpack_gen:`CPack Deb Generator`. It also tries to re-use RPM packaging +:cpack_gen:`CPack DEB Generator`. It also tries to re-use RPM packaging information when Debian does not specify. The CPack FreeBSD generator should work on any host with libpkg installed. The diff --git a/Help/cpack_gen/wix.rst b/Help/cpack_gen/wix.rst index fc8a098..dde4943 100644 --- a/Help/cpack_gen/wix.rst +++ b/Help/cpack_gen/wix.rst @@ -1,9 +1,9 @@ -CPack WiX Generator +CPack WIX Generator ------------------- -CPack WiX generator specific options +CPack WIX generator specific options -Variables specific to CPack WiX generator +Variables specific to CPack WIX generator ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The following variables are specific to the installers built on @@ -50,11 +50,11 @@ Windows using WiX. If CPACK_RESOURCE_FILE_LICENSE has an .rtf extension it is used as-is. If CPACK_RESOURCE_FILE_LICENSE has an .txt extension it is implicitly - converted to RTF by the WiX Generator. + converted to RTF by the WIX Generator. The expected encoding of the .txt file is UTF-8. With CPACK_WIX_LICENSE_RTF you can override the license file used by the - WiX Generator in case CPACK_RESOURCE_FILE_LICENSE is in an unsupported + WIX Generator in case CPACK_RESOURCE_FILE_LICENSE is in an unsupported format or the .txt -> .rtf conversion does not work as expected. .. variable:: CPACK_WIX_PRODUCT_ICON @@ -122,10 +122,10 @@ Windows using WiX. generated WiX sources This optional variable can be used to specify an XML file that the - WiX generator will use to inject fragments into its generated + WIX generator will use to inject fragments into its generated source files. - Patch files understood by the CPack WiX generator + Patch files understood by the CPack WIX generator roughly follow this RELAX NG compact schema: .. code-block:: none @@ -155,7 +155,7 @@ Windows using WiX. The following example illustrates how this works. - Given that the WiX generator creates the following XML element: + Given that the WIX generator creates the following XML element: .. code-block:: xml diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst index f05c4b1..c3bbf28 100644 --- a/Help/manual/cmake-developer.7.rst +++ b/Help/manual/cmake-developer.7.rst @@ -13,6 +13,9 @@ Introduction This manual is intended for reference by developers modifying the CMake source tree itself, and by those authoring externally-maintained modules. +See https://cmake.org/get-involved/ to get involved in development of +CMake upstream. + Adding Compile Features ======================= diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index bddf827..63e43e1 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -20,63 +20,74 @@ commands to populate those properties, such as :command:`target_link_libraries`, :command:`target_include_directories`, :command:`target_compile_definitions` and others. -This means that they enable conditional linking, conditional -definitions used when compiling, and conditional include directories and -more. The conditions may be based on the build configuration, target -properties, platform information or any other queryable information. +They enable conditional linking, conditional definitions used when compiling, +conditional include directories, and more. The conditions may be based on +the build configuration, target properties, platform information or any other +queryable information. -Logical Expressions -=================== +Generator expressions have the form ``$<...>``. To avoid confusion, this page +deviates from most of the CMake documentation in that it omits angular brackets +``<...>`` around placeholders like ``condition``, ``string``, ``target``, +among others. -Logical expressions are used to create conditional output. The basic -expressions are the ``0`` and ``1`` expressions. Because other logical -expressions evaluate to either ``0`` or ``1``, they can be composed to -create conditional output: +Generator expressions can be nested, as shown in most of the examples below. -.. code-block:: cmake +.. _`Boolean Generator Expressions`: - $<$<CONFIG:Debug>:DEBUG_MODE> +Boolean Generator Expressions +============================= -expands to ``DEBUG_MODE`` when the ``Debug`` configuration is used, and -otherwise expands to nothing. - -Available logical expressions are: - -``$<BOOL:...>`` - ``1`` if the ``...`` is true, else ``0`` -``$<AND:?[,?]...>`` - ``1`` if all ``?`` are ``1``, else ``0`` - - The ``?`` must always be either ``0`` or ``1`` in boolean expressions. - -``$<OR:?[,?]...>`` - ``0`` if all ``?`` are ``0``, else ``1`` -``$<NOT:?>`` - ``0`` if ``?`` is ``1``, else ``1`` -``$<IF:?,true-value...,false-value...>`` - ``true-value...`` if ``?`` is ``1``, ``false-value...`` if ``?`` is ``0`` -``$<STREQUAL:a,b>`` - ``1`` if ``a`` is STREQUAL ``b``, else ``0`` -``$<EQUAL:a,b>`` - ``1`` if ``a`` is EQUAL ``b`` in a numeric comparison, else ``0`` -``$<IN_LIST:a,b>`` - ``1`` if ``a`` is IN_LIST ``b``, else ``0`` -``$<TARGET_EXISTS:tgt>`` - ``1`` if ``tgt`` is an existed target name, else ``0``. -``$<CONFIG:cfg>`` - ``1`` if config is ``cfg``, else ``0``. This is a case-insensitive comparison. - The mapping in :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` is also considered by - this expression when it is evaluated on a property on an :prop_tgt:`IMPORTED` - target. -``$<PLATFORM_ID:comp>`` - ``1`` if the CMake-id of the platform matches ``comp``, otherwise ``0``. - See also the :variable:`CMAKE_SYSTEM_NAME` variable. -``$<C_COMPILER_ID:comp>`` - ``1`` if the CMake-id of the C compiler matches ``comp``, otherwise ``0``. - See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable. -``$<CXX_COMPILER_ID:comp>`` - ``1`` if the CMake-id of the CXX compiler matches ``comp``, otherwise ``0``. - See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable. +Boolean expressions evaluate to either ``0`` or ``1``. +They are typically used to construct the condition in a :ref:`conditional +generator expression<Conditional Generator Expressions>`. + +Available boolean expressions are: + +Logical Operators +----------------- + +``$<BOOL:string>`` + Converts ``string`` to ``0`` or ``1`` according to the rules of the + :command:`if()` command. Evaluates to ``0`` if any of the following is true: + + * ``string`` is empty, + * ``string`` is a case-insensitive equal of + ``0``, ``FALSE``, ``OFF``, ``N``, ``NO``, ``IGNORE``, or ``NOTFOUND``, or + * ``string`` ends in the suffix ``-NOTFOUND`` (case-sensitive). + + Otherwise evaluates to ``1``. + +``$<AND:conditions>`` + where ``conditions`` is a comma-separated list of boolean expressions. + Evaluates to ``1`` if all conditions are ``1``. + Otherwise evaluates to ``0``. + +``$<OR:conditions>`` + where ``conditions`` is a comma-separated list of boolean expressions. + Evaluates to ``1`` if at least one of the conditions is ``1``. + Otherwise evaluates to ``0``. + +``$<NOT:condition>`` + ``0`` if ``condition`` is ``1``, else ``1``. + +String Comparisons +------------------ + +``$<STREQUAL:string1,string2>`` + ``1`` if ``string1`` and ``string2`` are equal, else ``0``. + The comparison is case-sensitive. For a case-insensitive comparison, + combine with a :ref:`string transforming generator expression + <String Transforming Generator Expressions>`, + + .. code-block:: cmake + + $<STREQUAL:$<UPPER_CASE:${foo}>,"BAR"> # "1" if ${foo} is any of "BAR", "Bar", "bar", ... + +``$<EQUAL:value1,value2>`` + ``1`` if ``value1`` and ``value2`` are numerically equal, else ``0``. +``$<IN_LIST:string,list>`` + ``1`` if ``string`` is member of the comma-separated ``list``, else ``0``. + Uses case-sensitive comparisons. ``$<VERSION_LESS:v1,v2>`` ``1`` if ``v1`` is a version less than ``v2``, else ``0``. ``$<VERSION_GREATER:v1,v2>`` @@ -87,27 +98,55 @@ Available logical expressions are: ``1`` if ``v1`` is a version less than or equal to ``v2``, else ``0``. ``$<VERSION_GREATER_EQUAL:v1,v2>`` ``1`` if ``v1`` is a version greater than or equal to ``v2``, else ``0``. -``$<C_COMPILER_VERSION:ver>`` - ``1`` if the version of the C compiler matches ``ver``, otherwise ``0``. + + +Variable Queries +---------------- + +``$<TARGET_EXISTS:target>`` + ``1`` if ``target`` exists, else ``0``. +``$<CONFIG:cfg>`` + ``1`` if config is ``cfg``, else ``0``. This is a case-insensitive comparison. + The mapping in :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` is also considered by + this expression when it is evaluated on a property on an :prop_tgt:`IMPORTED` + target. +``$<PLATFORM_ID:platform_id>`` + ``1`` if the CMake-id of the platform matches ``platform_id`` + otherwise ``0``. + See also the :variable:`CMAKE_SYSTEM_NAME` variable. +``$<C_COMPILER_ID:compiler_id>`` + ``1`` if the CMake-id of the C compiler matches ``compiler_id``, + otherwise ``0``. + See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable. +``$<CXX_COMPILER_ID:compiler_id>`` + ``1`` if the CMake-id of the CXX compiler matches ``compiler_id``, + otherwise ``0``. + See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable. +``$<C_COMPILER_VERSION:version>`` + ``1`` if the version of the C compiler matches ``version``, otherwise ``0``. See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. -``$<CXX_COMPILER_VERSION:ver>`` - ``1`` if the version of the CXX compiler matches ``ver``, otherwise ``0``. +``$<CXX_COMPILER_VERSION:version>`` + ``1`` if the version of the CXX compiler matches ``version``, otherwise ``0``. See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. -``$<TARGET_POLICY:pol>`` - ``1`` if the policy ``pol`` was NEW when the 'head' target was created, - else ``0``. If the policy was not set, the warning message for the policy +``$<TARGET_POLICY:policy>`` + ``1`` if the ``policy`` was NEW when the 'head' target was created, + else ``0``. If the ``policy`` was not set, the warning message for the policy will be emitted. This generator expression only works for a subset of policies. -``$<COMPILE_FEATURES:feature[,feature]...>`` - ``1`` if all of the ``feature`` features are available for the 'head' +``$<COMPILE_FEATURES:features>`` + where ``features`` is a comma-spearated list. + Evaluates to ``1`` if all of the ``features`` are available for the 'head' target, and ``0`` otherwise. If this expression is used while evaluating the link implementation of a target and if any dependency transitively increases the required :prop_tgt:`C_STANDARD` or :prop_tgt:`CXX_STANDARD` for the 'head' target, an error is reported. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. -``$<COMPILE_LANGUAGE:lang>`` - ``1`` when the language used for compilation unit matches ``lang``, + +.. _`Boolean COMPILE_LANGUAGE Generator Expression`: + +``$<COMPILE_LANGUAGE:language>`` + ``1`` when the language used for compilation unit matches ``language``, otherwise ``0``. This expression may be used to specify compile options, compile definitions, and include directories for source files of a particular language in a target. For example: @@ -149,20 +188,22 @@ Available logical expressions are: add_executable(myapp main.cpp) target_link_libraries(myapp myapp_c myapp_cxx) -Informational Expressions -========================= +String-Valued Generator Expressions +=================================== -These expressions expand to some information. The information may be used -directly, eg: +These expressions expand to some string. +For example, .. code-block:: cmake include_directories(/usr/include/$<CXX_COMPILER_ID>/) expands to ``/usr/include/GNU/`` or ``/usr/include/Clang/`` etc, depending on -the Id of the compiler. +the compiler identifier. -These expressions may also may be combined with logical expressions: +String-valued expressions may also be combined with other expressions. +Here an example for a string-valued expression within a boolean expressions +within a conditional expression: .. code-block:: cmake @@ -172,12 +213,123 @@ expands to ``OLD_COMPILER`` if the :variable:`CMAKE_CXX_COMPILER_VERSION <CMAKE_<LANG>_COMPILER_VERSION>` is less than 4.2.0. -Available informational expressions are: +And here two nested string-valued expressions: + +.. code-block:: cmake + + -I$<JOIN:$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>, -I> + +generates a string of the entries in the :prop_tgt:`INCLUDE_DIRECTORIES` target +property with each entry preceded by ``-I``. + +Expanding on the previous example, if one first wants to check if the +``INCLUDE_DIRECTORIES`` property is non-empty, then it is advisable to +introduce a helper variable to keep the code readable: + +.. code-block:: cmake + + set(prop "$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>") # helper variable + $<$<BOOL:${prop}>:-I$<JOIN:${prop}, -I>> + +The following string-valued generator expressions are available: + +Escaped Characters +------------------ + +String literals to escape the special meaning a character would otherwise have: + +``$<ANGLE-R>`` + A literal ``>``. Used for example to compare strings that contain a ``>``. +``$<COMMA>`` + A literal ``,``. Used for example to compare strings which contain a ``,``. +``$<SEMICOLON>`` + A literal ``;``. Used to prevent list expansion on an argument with ``;``. + +.. _`Conditional Generator Expressions`: + +Conditional Expressions +----------------------- + +Conditional generator expressions depend on a boolean condition +that must be ``0`` or ``1``. + +``$<condition:true_string>`` + Evaluates to ``true_string`` if ``condition`` is ``1``. + Otherwise evaluates to the empty string. + +``$<IF:condition,true_string,false_string>`` + Evaluates to ``true_string`` if ``condition`` is ``1``. + Otherwise evaluates to ``false_string``. + +Typically, the ``condition`` is a :ref:`boolean generator expression +<Boolean Generator Expressions>`. For instance, + +.. code-block:: cmake + + $<$<CONFIG:Debug>:DEBUG_MODE> + +expands to ``DEBUG_MODE`` when the ``Debug`` configuration is used, and +otherwise expands to the empty string. + +.. _`String Transforming Generator Expressions`: + +String Transformations +---------------------- + +``$<JOIN:list,string>`` + Joins the list with the content of ``string``. +``$<LOWER_CASE:string>`` + Content of ``string`` converted to lower case. +``$<UPPER_CASE:string>`` + Content of ``string`` converted to upper case. + +``$<GENEX_EVAL:expr>`` + Content of ``expr`` evaluated as a generator expression in the current + context. This enables consumption of generator expressions whose + evaluation results itself in generator expressions. +``$<TARGET_GENEX_EVAL:tgt,expr>`` + Content of ``expr`` evaluated as a generator expression in the context of + ``tgt`` target. This enables consumption of custom target properties that + themselves contain generator expressions. + + Having the capability to evaluate generator expressions is very useful when + you want to manage custom properties supporting generator expressions. + For example: + + .. code-block:: cmake + + add_library(foo ...) + + set_property(TARGET foo PROPERTY + CUSTOM_KEYS $<$<CONFIG:DEBUG>:FOO_EXTRA_THINGS> + ) + + add_custom_target(printFooKeys + COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_PROPERTY:foo,CUSTOM_KEYS> + ) + + This naive implementation of the ``printFooKeys`` custom command is wrong + because ``CUSTOM_KEYS`` target property is not evaluated and the content + is passed as is (i.e. ``$<$<CONFIG:DEBUG>:FOO_EXTRA_THINGS>``). + + To have the expected result (i.e. ``FOO_EXTRA_THINGS`` if config is + ``Debug``), it is required to evaluate the output of + ``$<TARGET_PROPERTY:foo,CUSTOM_KEYS>``: + + .. code-block:: cmake + + add_custom_target(printFooKeys + COMMAND ${CMAKE_COMMAND} -E + echo $<TARGET_GENEX_EVAL:foo,$<TARGET_PROPERTY:foo,CUSTOM_KEYS>> + ) + +Variable Queries +---------------- -``$<CONFIGURATION>`` - Configuration name. Deprecated. Use ``CONFIG`` instead. ``$<CONFIG>`` - Configuration name + Configuration name. +``$<CONFIGURATION>`` + Configuration name. Deprecated since CMake 3.0. Use ``CONFIG`` instead. ``$<PLATFORM_ID>`` The CMake-id of the platform. See also the :variable:`CMAKE_SYSTEM_NAME` variable. @@ -193,6 +345,19 @@ Available informational expressions are: ``$<CXX_COMPILER_VERSION>`` The version of the CXX compiler used. See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable. +``$<COMPILE_LANGUAGE>`` + The compile language of source files when evaluating compile options. + See :ref:`the related boolean expression + <Boolean COMPILE_LANGUAGE Generator Expression>` + ``$<COMPILE_LANGUAGE:language>`` + for notes about the portability of this generator expression. + +Target-Dependent Queries +------------------------ + +``$<TARGET_NAME_IF_EXISTS:tgt>`` + Expands to the ``tgt`` if the given target exists, an empty string + otherwise. ``$<TARGET_FILE:tgt>`` Full path to main file (.exe, .so.1.2, .a) where ``tgt`` is the name of a target. ``$<TARGET_FILE_NAME:tgt>`` @@ -245,58 +410,14 @@ Available informational expressions are: ``$<INSTALL_PREFIX>`` Content of the install prefix when the target is exported via :command:`install(EXPORT)` and empty otherwise. -``$<COMPILE_LANGUAGE>`` - The compile language of source files when evaluating compile options. See - the unary version for notes about portability of this generator - expression. - -Output Expressions -================== - -These expressions generate output, in some cases depending on an input. These -expressions may be combined with other expressions for information or logical -comparison: - -.. code-block:: cmake - - -I$<JOIN:$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>, -I> - -generates a string of the entries in the :prop_tgt:`INCLUDE_DIRECTORIES` target -property with each entry preceded by ``-I``. Note that a more-complete use -in this situation would require first checking if the INCLUDE_DIRECTORIES -property is non-empty: -.. code-block:: cmake - - $<$<BOOL:${prop}>:-I$<JOIN:${prop}, -I>> - -where ``${prop}`` refers to a helper variable: - -.. code-block:: cmake - - set(prop "$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>") - -Available output expressions are: +Output-Related Expressions +-------------------------- -``$<0:...>`` - Empty string (ignores ``...``) -``$<1:...>`` - Content of ``...`` -``$<JOIN:list,...>`` - Joins the list with the content of ``...`` -``$<ANGLE-R>`` - A literal ``>``. Used to compare strings which contain a ``>`` for example. -``$<COMMA>`` - A literal ``,``. Used to compare strings which contain a ``,`` for example. -``$<SEMICOLON>`` - A literal ``;``. Used to prevent list expansion on an argument with ``;``. ``$<TARGET_NAME:...>`` Marks ``...`` as being the name of a target. This is required if exporting targets to multiple dependent export sets. The ``...`` must be a literal name of a target- it may not contain generator expressions. -``$<TARGET_NAME_IF_EXISTS:...>`` - Expands to the ``...`` if the given target exists, an empty string - otherwise. ``$<LINK_ONLY:...>`` Content of ``...`` except when evaluated in a link interface while propagating :ref:`Target Usage Requirements`, in which case it is the @@ -311,10 +432,6 @@ Available output expressions are: Content of ``...`` when the property is exported using :command:`export`, or when the target is used by another target in the same buildsystem. Expands to the empty string otherwise. -``$<LOWER_CASE:...>`` - Content of ``...`` converted to lower case. -``$<UPPER_CASE:...>`` - Content of ``...`` converted to upper case. ``$<MAKE_C_IDENTIFIER:...>`` Content of ``...`` converted to a C identifier. The conversion follows the same behavior as :command:`string(MAKE_C_IDENTIFIER)`. @@ -325,42 +442,25 @@ Available output expressions are: Content of ``...`` converted to shell path style. For example, slashes are converted to backslashes in Windows shells and drive letters are converted to posix paths in MSYS shells. The ``...`` must be an absolute path. -``$<GENEX_EVAL:...>`` - Content of ``...`` evaluated as a generator expression in the current - context. This enables consumption of generator expressions - whose evaluation results itself in generator expressions. -``$<TARGET_GENEX_EVAL:tgt,...>`` - Content of ``...`` evaluated as a generator expression in the context of - ``tgt`` target. This enables consumption of custom target properties that - themselves contain generator expressions. - Having the capability to evaluate generator expressions is very useful when - you want to manage custom properties supporting generator expressions. - For example: +Debugging +========= - .. code-block:: cmake +Since generator expressions are evaluated during generation of the buildsystem, +and not during processing of ``CMakeLists.txt`` files, it is not possible to +inspect their result with the :command:`message()` command. - add_library(foo ...) +One possible way to generate debug messages is to add a custom target, - set_property(TARGET foo PROPERTY - CUSTOM_KEYS $<$<CONFIG:DEBUG>:FOO_EXTRA_THINGS> - ) +.. code-block:: cmake - add_custom_target(printFooKeys - COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_PROPERTY:foo,CUSTOM_KEYS> - ) + add_custom_target(genexdebug COMMAND ${CMAKE_COMMAND} -E echo "$<...>") - This naive implementation of the ``printFooKeys`` custom command is wrong - because ``CUSTOM_KEYS`` target property is not evaluated and the content - is passed as is (i.e. ``$<$<CONFIG:DEBUG>:FOO_EXTRA_THINGS>``). +The shell command ``make genexdebug`` (invoked after execution of ``cmake``) +would then print the result of ``$<...>``. - To have the expected result (i.e. ``FOO_EXTRA_THINGS`` if config is - ``Debug``), it is required to evaluate the output of - ``$<TARGET_PROPERTY:foo,CUSTOM_KEYS>``: +Another way is to write debug messages to a file: - .. code-block:: cmake +.. code-block:: cmake - add_custom_target(printFooKeys - COMMAND ${CMAKE_COMMAND} -E - echo $<TARGET_GENEX_EVAL:foo,$<TARGET_PROPERTY:foo,CUSTOM_KEYS>> - ) + file(GENERATE OUTPUT filename CONTENT "$<...>") diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index c0bef08..95744df 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -237,6 +237,7 @@ They are normally called through the :command:`find_package` command. /module/FindSDL_ttf /module/FindSelfPackers /module/FindSquish + /module/FindSQLite3 /module/FindSubversion /module/FindSWIG /module/FindTCL diff --git a/Help/module/CPackDMG.rst b/Help/module/CPackDMG.rst index a597002..e59dcbb 100644 --- a/Help/module/CPackDMG.rst +++ b/Help/module/CPackDMG.rst @@ -1,4 +1,4 @@ CPackDMG -------- -The documentation for the CPack DMG generator has moved here: :cpack_gen:`CPack DMG Generator` +The documentation for the CPack DragNDrop generator has moved here: :cpack_gen:`CPack DragNDrop Generator` diff --git a/Help/module/CPackDeb.rst b/Help/module/CPackDeb.rst index 73e59a2..cd7e5f3 100644 --- a/Help/module/CPackDeb.rst +++ b/Help/module/CPackDeb.rst @@ -1,4 +1,4 @@ CPackDeb -------- -The documentation for the CPack Deb generator has moved here: :cpack_gen:`CPack Deb Generator` +The documentation for the CPack DEB generator has moved here: :cpack_gen:`CPack DEB Generator` diff --git a/Help/module/CPackWIX.rst b/Help/module/CPackWIX.rst index e1d4a03..c88c723 100644 --- a/Help/module/CPackWIX.rst +++ b/Help/module/CPackWIX.rst @@ -1,4 +1,4 @@ CPackWIX -------- -The documentation for the CPack WiX generator has moved here: :cpack_gen:`CPack WiX Generator` +The documentation for the CPack WIX generator has moved here: :cpack_gen:`CPack WIX Generator` diff --git a/Help/module/FindSQLite3.rst b/Help/module/FindSQLite3.rst new file mode 100644 index 0000000..d1910e5 --- /dev/null +++ b/Help/module/FindSQLite3.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/FindSQLite3.cmake diff --git a/Help/release/3.1.rst b/Help/release/3.1.rst index 8278353..8bea28f 100644 --- a/Help/release/3.1.rst +++ b/Help/release/3.1.rst @@ -294,11 +294,11 @@ CPack * :manual:`cpack(1)` gained ``7Z`` and ``TXZ`` generators supporting lzma-compressed archives. -* The :cpack_gen:`CPack Deb Generator` learned a new +* The :cpack_gen:`CPack DEB Generator` learned a new :variable:`CPACK_DEBIAN_COMPRESSION_TYPE` variable to set the tarball compression type. -* The :manual:`cpack(1)` ``WiX`` generator learned to support +* The :cpack_gen:`CPack WIX Generator` learned to support a :prop_inst:`CPACK_WIX_ACL` installed file property to specify an Access Control List. diff --git a/Help/release/3.10.rst b/Help/release/3.10.rst index 66a1d09..03eda36 100644 --- a/Help/release/3.10.rst +++ b/Help/release/3.10.rst @@ -186,15 +186,15 @@ CPack * A :cpack_gen:`CPack FreeBSD Generator` was added for FreeBSD ``pkg(8)``. -* The :cpack_gen:`CPack Deb Generator` was enabled on Windows. While not +* The :cpack_gen:`CPack DEB Generator` was enabled on Windows. While not fully featured (due to the lack of external UNIX tools) this will allow building basic cross-platform Debian packages. -* The :cpack_gen:`CPack Deb Generator` learned to set package release +* The :cpack_gen:`CPack DEB Generator` learned to set package release version in ``Version`` info property. See the :variable:`CPACK_DEBIAN_PACKAGE_RELEASE` variable. -* The :cpack_gen:`CPack Deb Generator` learned more strict package +* The :cpack_gen:`CPack DEB Generator` learned more strict package version checking that complies with Debian rules. * The :module:`CPackIFW` module :command:`cpack_ifw_configure_component` and @@ -211,7 +211,7 @@ CPack repack dependent components. This feature is only available when using QtIFW 3.1 or later. -* The :cpack_gen:`CPack RPM Generator` and :cpack_gen:`CPack Deb Generator` +* The :cpack_gen:`CPack RPM Generator` and :cpack_gen:`CPack DEB Generator` learned to set the package epoch version. See :variable:`CPACK_RPM_PACKAGE_EPOCH` and :variable:`CPACK_DEBIAN_PACKAGE_EPOCH` variables. diff --git a/Help/release/3.13.rst b/Help/release/3.13.rst index 605122a..9f7e61f 100644 --- a/Help/release/3.13.rst +++ b/Help/release/3.13.rst @@ -181,11 +181,11 @@ CTest CPack ----- -* The :cpack_gen:`CPack Deb Generator` learned to split debug symbols into +* The :cpack_gen:`CPack DEB Generator` learned to split debug symbols into a corresponding .ddeb package when ``CPACK_DEBIAN_DEBUGINFO_PACKAGE`` is set. -* The :cpack_gen:`CPack Deb Generator` learned to honor the ``SOURCE_DATE_EPOCH`` +* The :cpack_gen:`CPack DEB Generator` learned to honor the ``SOURCE_DATE_EPOCH`` environment variable when packaging files. This is useful for generating reproducible packages. diff --git a/Help/release/3.3.rst b/Help/release/3.3.rst index 11f0c60..6657e8d 100644 --- a/Help/release/3.3.rst +++ b/Help/release/3.3.rst @@ -172,11 +172,11 @@ CPack * The :cpack_gen:`CPack IFW Generator` learned to support Qt Framework Installer 2.0 tools. -* The :cpack_gen:`CPack Deb Generator` learned a new +* The :cpack_gen:`CPack DEB Generator` learned a new :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS` variable to specify per-component use of ``dpkg-shlibdeps``. -* The :cpack_gen:`CPack Deb Generator` learned a new +* The :cpack_gen:`CPack DEB Generator` learned a new :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` option to specify per-component dependencies. diff --git a/Help/release/3.4.rst b/Help/release/3.4.rst index 0a0e6df..943d267 100644 --- a/Help/release/3.4.rst +++ b/Help/release/3.4.rst @@ -197,7 +197,7 @@ CTest CPack ----- -* The :cpack_gen:`CPack Deb Generator` learned to set package dependencies +* The :cpack_gen:`CPack DEB Generator` learned to set package dependencies per component. See variables: * :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_BREAKS` @@ -249,10 +249,10 @@ Other Changes :module:`CheckSymbolExists`, and :module:`FindThreads` modules learned to work in environments where only CXX is enabled. -* The :cpack_gen:`CPack Deb Generator` now correctly excludes symlinks +* The :cpack_gen:`CPack DEB Generator` now correctly excludes symlinks during package checksum calculation. -* The :cpack_gen:`CPack Deb Generator` no longer uses fakeroot and +* The :cpack_gen:`CPack DEB Generator` no longer uses fakeroot and system tar program for packaging. * The :module:`CPack` module no longer mangles settings with CMake-special diff --git a/Help/release/3.5.rst b/Help/release/3.5.rst index f988908..58a5d4e 100644 --- a/Help/release/3.5.rst +++ b/Help/release/3.5.rst @@ -120,23 +120,23 @@ Platforms CPack ----- -* The :cpack_gen:`CPack DMG Generator` learned new variable to +* The :cpack_gen:`CPack DragNDrop Generator` learned new variable to specify AppleScript file run to customize appearance of ``DragNDrop`` installer folder, including background image setting using supplied PNG or multi-resolution TIFF file. See the :variable:`CPACK_DMG_DS_STORE_SETUP_SCRIPT` and :variable:`CPACK_DMG_BACKGROUND_IMAGE` variables. -* The :cpack_gen:`CPack Deb Generator` learned to set the optional config +* The :cpack_gen:`CPack DEB Generator` learned to set the optional config file ``Source`` field using a monolithic or per-component variable. See :variable:`CPACK_DEBIAN_PACKAGE_SOURCE`. -* The :cpack_gen:`CPack Deb Generator` learned to set Package, Section +* The :cpack_gen:`CPack DEB Generator` learned to set Package, Section and Priority control fields per-component. See variables :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION` and :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY`. -* The :cpack_gen:`CPack DMG Generator` learned to add +* The :cpack_gen:`CPack DragNDrop Generator` learned to add multi-lingual SLAs to a DMG which is presented to the user when they try to mount the DMG. See the :variable:`CPACK_DMG_SLA_LANGUAGES` and :variable:`CPACK_DMG_SLA_DIR` variables for details. diff --git a/Help/release/3.6.rst b/Help/release/3.6.rst index b2403cf..f0add07 100644 --- a/Help/release/3.6.rst +++ b/Help/release/3.6.rst @@ -165,24 +165,24 @@ CTest CPack ----- -* The :cpack_gen:`CPack Deb Generator` learned how to handle ``$ORIGIN`` +* The :cpack_gen:`CPack DEB Generator` learned how to handle ``$ORIGIN`` in ``CMAKE_INSTALL_RPATH`` when :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` is used for dependency auto detection. -* The :cpack_gen:`CPack Deb Generator` learned how to generate +* The :cpack_gen:`CPack DEB Generator` learned how to generate ``DEBIAN/shlibs`` contorl file when package contains shared libraries. -* The :cpack_gen:`CPack Deb Generator` learned how to generate +* The :cpack_gen:`CPack DEB Generator` learned how to generate ``DEBIAN/postinst`` and ``DEBIAN/postrm`` files if the package installs libraries in ldconfig-controlled locations (e.g. ``/lib/``, ``/usr/lib/``). -* The :cpack_gen:`CPack Deb Generator` learned how to generate dependencies +* The :cpack_gen:`CPack DEB Generator` learned how to generate dependencies between Debian packages if multi-component setup is used and :variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables are set. For backward compatibility this feature is disabled by default. See :variable:`CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS`. -* The :cpack_gen:`CPack Deb Generator` learned how to set custom package +* The :cpack_gen:`CPack DEB Generator` learned how to set custom package file names including how to generate properly-named Debian packages:: <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb @@ -191,17 +191,17 @@ CPack :variable:`CPACK_DEBIAN_FILE_NAME` and :variable:`CPACK_DEBIAN_<COMPONENT>_FILE_NAME`. -* The :cpack_gen:`CPack Deb Generator` learned how to set the package +* The :cpack_gen:`CPack DEB Generator` learned how to set the package release number (``DebianRevisionNumber`` in package file name when used in combination with ``DEB-DEFAULT`` value set by :variable:`CPACK_DEBIAN_FILE_NAME`). See :variable:`CPACK_DEBIAN_PACKAGE_RELEASE`. -* The :cpack_gen:`CPack Deb Generator` learned how to set the package +* The :cpack_gen:`CPack DEB Generator` learned how to set the package architecture per-component. See :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE`. -* The :cpack_gen:`CPack DMG Generator` learned a new option to skip the +* The :cpack_gen:`CPack DragNDrop Generator` learned a new option to skip the ``/Applications`` symlink. See the :variable:`CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK` variable. diff --git a/Help/release/3.7.rst b/Help/release/3.7.rst index fae10f5..345c056 100644 --- a/Help/release/3.7.rst +++ b/Help/release/3.7.rst @@ -226,7 +226,7 @@ CPack * CPack gained a new :variable:`CPACK_PACKAGE_CHECKSUM` variable to enable generation of a checksum file for each package file. -* The :cpack_gen:`CPack Deb Generator` learned to support long file names +* The :cpack_gen:`CPack DEB Generator` learned to support long file names when archive format is set to GNU tar. See :variable:`CPACK_DEBIAN_ARCHIVE_TYPE` @@ -252,19 +252,19 @@ CPack :variable:`CPACK_NSIS_<compName>_INSTALL_DIRECTORY`. This can be used to set component specific installation directories. -* The :cpack_gen:`CPack WiX Generator` now supports +* The :cpack_gen:`CPack WIX Generator` now supports :variable:`CPACK_WIX_SKIP_PROGRAM_FOLDER` to allow specification of a custom absolute installation prefix outside of the ProgramFiles folders. -* The :cpack_gen:`CPack WiX Generator` now supports +* The :cpack_gen:`CPack WIX Generator` now supports :variable:`CPACK_COMPONENT_<compName>_DISABLED`. This can be used to deselect a component from being installed by default. -* The :cpack_gen:`CPack WiX Generator` now supports +* The :cpack_gen:`CPack WIX Generator` now supports :variable:`CPACK_WIX_PATCH_FILE` fragments for Feature elements. -* The :cpack_gen:`CPack WiX Generator` now supports +* The :cpack_gen:`CPack WIX Generator` now supports :variable:`CPACK_WIX_ROOT_FEATURE_TITLE` and :variable:`CPACK_WIX_ROOT_FEATURE_DESCRIPTION` to allow the specification of a custom title and description for the root feature element. diff --git a/Help/release/3.9.rst b/Help/release/3.9.rst index 5001e90..ffa95aa 100644 --- a/Help/release/3.9.rst +++ b/Help/release/3.9.rst @@ -232,12 +232,12 @@ CPack * The :cpack_gen:`CPack RPM Generator` learned to modify the ``debuginfo`` package name. See the :variable:`CPACK_RPM_DEBUGINFO_FILE_NAME` variable. -* The :cpack_gen:`CPack WiX Generator` patching system now has the +* The :cpack_gen:`CPack WIX Generator` patching system now has the ability to set additional attributes. This can be done by specifying attributes with the ``CPackWiXFragment`` XML tag after the ``Id`` attribute. See the :variable:`CPACK_WIX_PATCH_FILE` variable. -* The :cpack_gen:`CPack WiX Generator` implemented a new +* The :cpack_gen:`CPack WIX Generator` implemented a new :variable:`CPACK_WIX_ROOT_FOLDER_ID` variable which allows using a custom root folder ID instead of the default ``ProgramFilesFolder`` / ``ProgramFiles64Folder``. diff --git a/Help/release/dev/FindSQLite3-module.rst b/Help/release/dev/FindSQLite3-module.rst new file mode 100644 index 0000000..733a4d3 --- /dev/null +++ b/Help/release/dev/FindSQLite3-module.rst @@ -0,0 +1,4 @@ +FindSQLite3-module +------------------ + +* The :module:`FindSQLite3` module was added to find the SQLite v3.x library. diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index af45d8e..7e37212 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -125,7 +125,7 @@ endfunction() set(OpenMP_C_CXX_TEST_SOURCE " #include <omp.h> -int main() { +int main(void) { #ifdef _OPENMP omp_get_max_threads(); return 0; @@ -271,6 +271,9 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) break() endif() endif() + else() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Detecting ${LANG} OpenMP failed with the following output:\n${OpenMP_TRY_COMPILE_OUTPUT}\n\n") endif() set("${OPENMP_LIB_NAMES_VAR}" "NOTFOUND" PARENT_SCOPE) set("${OPENMP_FLAG_VAR}" "NOTFOUND" PARENT_SCOPE) @@ -292,7 +295,7 @@ const char ompver_str[] = { 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'M', ('0' + ((_OPENMP/10)%10)), ('0' + ((_OPENMP/1)%10)), ']', '\\0' }; -int main() +int main(void) { puts(ompver_str); return 0; @@ -325,7 +328,8 @@ function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE) string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}") try_compile(OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG} "${CMAKE_BINARY_DIR}" "${_OPENMP_TEST_SRC}" CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}" - COPY_FILE ${BIN_FILE}) + COPY_FILE ${BIN_FILE} + OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT) if(${OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG}}) file(STRINGS ${BIN_FILE} specstr LIMIT_COUNT 1 REGEX "INFO:OpenMP-date") @@ -333,6 +337,9 @@ function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE) if("${specstr}" MATCHES "${regex_spec_date}") set(${SPEC_DATE} "${CMAKE_MATCH_1}" PARENT_SCOPE) endif() + else() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Detecting ${LANG} OpenMP version failed with the following output:\n${OpenMP_TRY_COMPILE_OUTPUT}\n\n") endif() endfunction() diff --git a/Modules/FindSQLite3.cmake b/Modules/FindSQLite3.cmake new file mode 100644 index 0000000..374d7af --- /dev/null +++ b/Modules/FindSQLite3.cmake @@ -0,0 +1,66 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindSQLite3 +----------- + +Find the SQLite libraries, v3 + +IMPORTED targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` target: + +``SQLite::SQLite3`` + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables if found: + +``SQLite3_INCLUDE_DIRS`` + where to find sqlite3.h, etc. +``SQLite3_LIBRARIES`` + the libraries to link against to use SQLite3. +``SQLite3_VERSION`` + version of the SQLite3 library found +``SQLite3_FOUND`` + TRUE if found + +#]=======================================================================] + +# Look for the necessary header +find_path(SQLite3_INCLUDE_DIR NAMES sqlite3.h) +mark_as_advanced(SQLite3_INCLUDE_DIR) + +# Look for the necessary library +find_library(SQLite3_LIBRARY NAMES sqlite3 sqlite) +mark_as_advanced(SQLite3_LIBRARY) + +# Extract version information from the header file +if(SQLite3_INCLUDE_DIR) + file(STRINGS ${SQLite3_INCLUDE_DIR}/sqlite3.h _ver_line + REGEX "^#define SQLITE_VERSION *\"[0-9]+\\.[0-9]+\\.[0-9]+\"" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" + SQLite3_VERSION "${_ver_line}") + unset(_ver_line) +endif() + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(SQLite3 + REQUIRED_VARS SQLite3_INCLUDE_DIR SQLite3_LIBRARY + VERSION_VAR SQLite3_VERSION) + +# Create the imported target +if(SQLite3_FOUND) + set(SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDE_DIR}) + set(SQLite3_LIBRARIES ${SQLite3_LIBRARY}) + if(NOT TARGET SQLite::SQLite3) + add_library(SQLite::SQLite3 UNKNOWN IMPORTED) + set_target_properties(SQLite::SQLite3 PROPERTIES + IMPORTED_LOCATION "${SQLite3_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}") + endif() +endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7918d80..5f7dd8a 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 13) -set(CMake_VERSION_PATCH 20181106) +set(CMake_VERSION_PATCH 20181108) #set(CMake_VERSION_RC 1) diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 75bd6fb..75e5aa4 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -20,7 +20,7 @@ bool cmAddSubDirectoryCommand::InitialPass( } // store the binpath - std::string const& srcArg = args[0]; + std::string const& srcArg = args.front(); std::string binArg; bool excludeFromAll = false; @@ -84,10 +84,10 @@ bool cmAddSubDirectoryCommand::InitialPass( const std::string& bin = this->Makefile->GetCurrentBinaryDirectory(); size_t srcLen = src.length(); size_t binLen = bin.length(); - if (srcLen > 0 && src[srcLen - 1] == '/') { + if (srcLen > 0 && src.back() == '/') { --srcLen; } - if (binLen > 0 && bin[binLen - 1] == '/') { + if (binLen > 0 && bin.back() == '/') { --binLen; } binPath = bin.substr(0, binLen) + srcPath.substr(srcLen); diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 6031781..3f2e784 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -178,7 +178,7 @@ bool cmArchiveWrite::Add(std::string path, size_t skip, const char* prefix, bool recursive) { if (this->Okay()) { - if (!path.empty() && path[path.size() - 1] == '/') { + if (!path.empty() && path.back() == '/') { path.erase(path.size() - 1); } this->AddPath(path.c_str(), skip, prefix, recursive); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index d0d5db6..9a046db 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -727,7 +727,7 @@ bool cmCTest::UpdateCTestConfiguration() if (line.empty()) { continue; } - while (fin && (line[line.size() - 1] == '\\')) { + while (fin && (line.back() == '\\')) { line = line.substr(0, line.size() - 1); buffer[0] = 0; fin.getline(buffer, 1023); @@ -2575,7 +2575,7 @@ std::string cmCTest::GetShortPathToFile(const char* cfname) cmSystemTools::ConvertToUnixSlashes(*res); path = "./" + *res; - if (path[path.size() - 1] == '/') { + if (path.back() == '/') { path = path.substr(0, path.size() - 1); } } diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index b391dc4..0305677 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -415,8 +415,7 @@ void cmCacheManager::OutputValueNoNewlines(std::ostream& fout, std::string const& value) { // if value has trailing space or tab, enclose it in single quotes - if (!value.empty() && - (value[value.size() - 1] == ' ' || value[value.size() - 1] == '\t')) { + if (!value.empty() && (value.back() == ' ' || value.back() == '\t')) { fout << '\'' << value << '\''; } else { fout << value; diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 34f58ad..87ee382 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -976,9 +976,9 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const lg->GetIndividualFileTargets(objectFileTargets); for (std::string const& f : objectFileTargets) { const char* prefix = "[obj] "; - if (f[f.length() - 1] == 's') { + if (f.back() == 's') { prefix = "[to asm] "; - } else if (f[f.length() - 1] == 'i') { + } else if (f.back() == 'i') { prefix = "[pre] "; } this->AppendTarget(xml, f, make, makeArgs, subdir, prefix); @@ -1035,8 +1035,7 @@ std::string cmExtraEclipseCDT4Generator::GetPathBasename( { std::string outputBasename = path; while (!outputBasename.empty() && - (outputBasename[outputBasename.size() - 1] == '/' || - outputBasename[outputBasename.size() - 1] == '\\')) { + (outputBasename.back() == '/' || outputBasename.back() == '\\')) { outputBasename.resize(outputBasename.size() - 1); } std::string::size_type loc = outputBasename.find_last_of("/\\"); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index f5c4c93..9410690 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -294,8 +294,7 @@ std::string cmExtraKateGenerator::GetPathBasename( { std::string outputBasename = path; while (!outputBasename.empty() && - (outputBasename[outputBasename.size() - 1] == '/' || - outputBasename[outputBasename.size() - 1] == '\\')) { + (outputBasename.back() == '/' || outputBasename.back() == '\\')) { outputBasename.resize(outputBasename.size() - 1); } std::string::size_type loc = outputBasename.find_last_of("/\\"); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 1f76703..f86e5e2 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2525,7 +2525,7 @@ bool cmFileCommand::HandleCMakePathCommand( // remove double quotes in the path std::string& s = *j; - if (s.size() > 1 && s[0] == '\"' && s[s.size() - 1] == '\"') { + if (s.size() > 1 && s.front() == '\"' && s.back() == '\"') { s = s.substr(1, s.size() - 2); } } diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 865595b..425546a 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -129,13 +129,13 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) this->VariableDocumentation += "the (unknown) library be found"; } else if (this->Names.size() == 1) { this->VariableDocumentation += - "the " + this->Names[0] + " library be found"; + "the " + this->Names.front() + " library be found"; } else { this->VariableDocumentation += "one of the "; this->VariableDocumentation += cmJoin(cmMakeRange(this->Names).retreat(1), ", "); this->VariableDocumentation += - " or " + this->Names[this->Names.size() - 1] + " libraries be found"; + " or " + this->Names.back() + " libraries be found"; } } diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index fbaacfc..009f0e3 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -293,13 +293,13 @@ void cmFindCommon::AddPathSuffix(std::string const& arg) if (suffix.empty()) { return; } - if (suffix[0] == '/') { + if (suffix.front() == '/') { suffix = suffix.substr(1); } if (suffix.empty()) { return; } - if (suffix[suffix.size() - 1] == '/') { + if (suffix.back() == '/') { suffix = suffix.substr(0, suffix.size() - 1); } if (suffix.empty()) { diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 96de6ad..97c1d7d 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1429,7 +1429,7 @@ void cmFindPackageCommand::FillPrefixesUserHints() bool cmFindPackageCommand::SearchDirectory(std::string const& dir) { - assert(!dir.empty() && dir[dir.size() - 1] == '/'); + assert(!dir.empty() && dir.back() == '/'); // Check each path suffix on this directory. for (std::string const& s : this->SearchPathSuffixes) { @@ -1447,7 +1447,7 @@ bool cmFindPackageCommand::SearchDirectory(std::string const& dir) bool cmFindPackageCommand::CheckDirectory(std::string const& dir) { - assert(!dir.empty() && dir[dir.size() - 1] == '/'); + assert(!dir.empty() && dir.back() == '/'); // Look for the file in this directory. std::string d = dir.substr(0, dir.size() - 1); @@ -2001,7 +2001,7 @@ private: bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) { - assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/'); + assert(!prefix_in.empty() && prefix_in.back() == '/'); if (this->DebugMode) { fprintf(stderr, "Checking prefix [%s]\n", prefix_in.c_str()); } @@ -2157,7 +2157,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) bool cmFindPackageCommand::SearchFrameworkPrefix(std::string const& prefix_in) { - assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/'); + assert(!prefix_in.empty() && prefix_in.back() == '/'); if (this->DebugMode) { fprintf(stderr, "Checking framework prefix [%s]\n", prefix_in.c_str()); } @@ -2218,7 +2218,7 @@ bool cmFindPackageCommand::SearchFrameworkPrefix(std::string const& prefix_in) bool cmFindPackageCommand::SearchAppBundlePrefix(std::string const& prefix_in) { - assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/'); + assert(!prefix_in.empty() && prefix_in.back() == '/'); if (this->DebugMode) { fprintf(stderr, "Checking bundle prefix [%s]\n", prefix_in.c_str()); } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 71947ea..1663400 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -953,7 +953,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths( cmSystemTools::ExpandListArgument(entry, items); for (std::string const& item : items) { if (cmHasLiteralPrefix(item, "$<TARGET_OBJECTS:") && - item[item.size() - 1] == '>') { + item.back() == '>') { continue; } files.push_back(item); @@ -5612,8 +5612,7 @@ void cmGeneratorTarget::GetObjectLibrariesCMP0026( std::vector<std::string> files; cmSystemTools::ExpandListArgument(entry, files); for (std::string const& li : files) { - if (cmHasLiteralPrefix(li, "$<TARGET_OBJECTS:") && - li[li.size() - 1] == '>') { + if (cmHasLiteralPrefix(li, "$<TARGET_OBJECTS:") && li.back() == '>') { std::string objLibName = li.substr(17, li.size() - 18); if (cmGeneratorExpression::Find(objLibName) != std::string::npos) { diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 1b358ab..ffb895e 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -19,8 +19,8 @@ bool cmGetFilenameComponentCommand::InitialPass( // Check and see if the value has been stored in the cache // already, if so use that value - if (args.size() >= 4 && args[args.size() - 1] == "CACHE") { - const char* cacheValue = this->Makefile->GetDefinition(args[0]); + if (args.size() >= 4 && args.back() == "CACHE") { + const char* cacheValue = this->Makefile->GetDefinition(args.front()); if (cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) { return true; } @@ -113,20 +113,20 @@ bool cmGetFilenameComponentCommand::InitialPass( return false; } - if (args.size() >= 4 && args[args.size() - 1] == "CACHE") { + if (args.size() >= 4 && args.back() == "CACHE") { if (!programArgs.empty() && !storeArgs.empty()) { this->Makefile->AddCacheDefinition( storeArgs, programArgs.c_str(), "", args[2] == "PATH" ? cmStateEnums::FILEPATH : cmStateEnums::STRING); } this->Makefile->AddCacheDefinition( - args[0], result.c_str(), "", + args.front(), result.c_str(), "", args[2] == "PATH" ? cmStateEnums::FILEPATH : cmStateEnums::STRING); } else { if (!programArgs.empty() && !storeArgs.empty()) { this->Makefile->AddDefinition(storeArgs, programArgs.c_str()); } - this->Makefile->AddDefinition(args[0], result.c_str()); + this->Makefile->AddDefinition(args.front(), result.c_str()); } return true; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 71e844e..cf85473 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2265,7 +2265,7 @@ bool cmGlobalGenerator::NameResolvesToFramework( inline std::string removeQuotes(const std::string& s) { - if (s[0] == '\"' && s[s.size() - 1] == '\"') { + if (s.front() == '\"' && s.back() == '\"') { return s.substr(1, s.size() - 2); } return s; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 8c69f42..fbc756c 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -838,7 +838,7 @@ static void EnsureTrailingSlash(std::string& path) if (path.empty()) { return; } - std::string::value_type last = path[path.size() - 1]; + std::string::value_type last = path.back(); #ifdef _WIN32 if (last != '\\') { path += '\\'; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 596bc6b..b7a361e 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -546,7 +546,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets( target->GetType() == cmStateEnums::STATIC_LIBRARY || target->GetType() == cmStateEnums::SHARED_LIBRARY || target->GetType() == cmStateEnums::MODULE_LIBRARY))) { - makeHelper[makeHelper.size() - 1] = // fill placeholder + makeHelper.back() = // fill placeholder this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)"); cmCustomCommandLines commandLines; commandLines.push_back(makeHelper); diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index b2acb90..9b63d24 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -152,7 +152,7 @@ bool cmListCommand::HandleLengthCommand(std::vector<std::string> const& args) } const std::string& listName = args[1]; - const std::string& variableName = args[args.size() - 1]; + const std::string& variableName = args.back(); std::vector<std::string> varArgsExpanded; // do not check the return value here // if the list var is not found varArgsExpanded will have size 0 @@ -174,7 +174,7 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args) } const std::string& listName = args[1]; - const std::string& variableName = args[args.size() - 1]; + const std::string& variableName = args.back(); // expand the variable std::vector<std::string> varArgsExpanded; if (!this->GetList(varArgsExpanded, listName)) { @@ -243,7 +243,7 @@ bool cmListCommand::HandleFindCommand(std::vector<std::string> const& args) } const std::string& listName = args[1]; - const std::string& variableName = args[args.size() - 1]; + const std::string& variableName = args.back(); // expand the variable std::vector<std::string> varArgsExpanded; if (!this->GetList(varArgsExpanded, listName)) { @@ -1176,7 +1176,7 @@ bool cmListCommand::HandleSublistCommand(std::vector<std::string> const& args) } const std::string& listName = args[1]; - const std::string& variableName = args[args.size() - 1]; + const std::string& variableName = args.back(); // expand the variable std::vector<std::string> varArgsExpanded; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a065408..a703f4d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -807,19 +807,19 @@ std::string cmLocalGenerator::GetIncludeFlags( } std::string includePath = this->ConvertToIncludeReference(i, shellFormat, forceFullPaths); - if (quotePaths && !includePath.empty() && includePath[0] != '\"') { + if (quotePaths && !includePath.empty() && includePath.front() != '\"') { includeFlags << "\""; } includeFlags << includePath; - if (quotePaths && !includePath.empty() && includePath[0] != '\"') { + if (quotePaths && !includePath.empty() && includePath.front() != '\"') { includeFlags << "\""; } includeFlags << sep; } std::string flags = includeFlags.str(); // remove trailing separators - if ((sep[0] != ' ') && !flags.empty() && flags[flags.size() - 1] == sep[0]) { - flags[flags.size() - 1] = ' '; + if ((sep[0] != ' ') && !flags.empty() && flags.back() == sep[0]) { + flags.back() = ' '; } return flags; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 1da077e..7630691 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1347,7 +1347,7 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories( d != dirs.end(); ++d) { // Remove any trailing slash and skip empty paths. std::string dir = *d; - if (dir[dir.size() - 1] == '/') { + if (dir.back() == '/') { dir = dir.substr(0, dir.size() - 1); } if (dir.empty()) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 0a69d09..0d42fb0 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -67,7 +67,7 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused(); this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); - this->SuppressWatches = false; + this->SuppressSideEffects = false; // Setup the default include complaint regular expression (match nothing). this->ComplainFileRegularExpression = "^$"; @@ -2421,7 +2421,7 @@ const std::string* cmMakefile::GetDef(const std::string& name) const } #ifdef CMAKE_BUILD_WITH_CMAKE cmVariableWatch* vv = this->GetVariableWatch(); - if (vv && !this->SuppressWatches) { + if (vv && !this->SuppressSideEffects) { bool const watch_function_executed = vv->VariableAccessed(name, def ? cmVariableWatch::VARIABLE_READ_ACCESS @@ -2508,11 +2508,11 @@ const std::string& cmMakefile::ExpandVariablesInString( compareResults = true; // Suppress variable watches to avoid calling hooks twice. Suppress new // dereferences since the OLD behavior is still what is actually used. - this->SuppressWatches = true; + this->SuppressSideEffects = true; newError = ExpandVariablesInStringNew( newErrorstr, newResult, escapeQuotes, noEscapes, atOnly, filename, line, removeEmpty, replaceAt); - this->SuppressWatches = false; + this->SuppressSideEffects = false; CM_FALLTHROUGH; } case cmPolicies::OLD: @@ -2766,7 +2766,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew( } else { varresult = value; } - } else if (!removeEmpty) { + } else if (!removeEmpty && !this->SuppressSideEffects) { // check to see if we need to print a warning // if strict mode is on and the variable has // not been "cleared"/initialized with a set(foo ) call diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index b30f281..d8176d9 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -1025,7 +1025,7 @@ private: bool CheckCMP0000; std::set<std::string> WarnedCMP0074; bool IsSourceFileTryCompile; - mutable bool SuppressWatches; + mutable bool SuppressSideEffects; }; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f423560..3c46784 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -590,7 +590,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( // mingw32-make incorrectly interprets 'a\ b c' as 'a b' and 'c' // (but 'a\ b "c"' as 'a\', 'b', and 'c'!). Workaround this by // avoiding a trailing backslash in the argument. - targetOutPathCompilePDB[targetOutPathCompilePDB.size() - 1] = '/'; + targetOutPathCompilePDB.back() = '/'; } } cmRulePlaceholderExpander::RuleVariables vars; diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 04a9318..7fd7732 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -186,7 +186,7 @@ bool cmOrderDirectoriesConstraintSOName::FindConflict(std::string const& dir) // file name. Usually the soname starts with the library name. std::string base = this->FileName; std::set<std::string>::const_iterator first = files.lower_bound(base); - ++base[base.size() - 1]; + ++base.back(); std::set<std::string>::const_iterator last = files.upper_bound(base); if (first != last) { return true; diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index dbe6fa1..43a0107 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -118,11 +118,11 @@ std::string cmOutputConverter::ForceToRelativePath( std::string const& local_path, std::string const& remote_path) { // The paths should never be quoted. - assert(local_path[0] != '\"'); - assert(remote_path[0] != '\"'); + assert(local_path.front() != '\"'); + assert(remote_path.front() != '\"'); // The local path should never have a trailing slash. - assert(local_path.empty() || local_path[local_path.size() - 1] != '/'); + assert(local_path.empty() || local_path.back() != '/'); // If the path is already relative then just return the path. if (!cmSystemTools::FileIsFullPath(remote_path)) { diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index e2de3f9..87c1ec0 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -340,7 +340,7 @@ protected: } else { // try to guess which include path to use for (std::string incpath : this->IncludeDirectories) { - if (!incpath.empty() && incpath[incpath.size() - 1] != '/') { + if (!incpath.empty() && incpath.back() != '/') { incpath = incpath + "/"; } incpath = incpath + path; @@ -421,7 +421,7 @@ protected: } for (std::string path : this->IncludeDirectories) { - if (!path.empty() && path[path.size() - 1] != '/') { + if (!path.empty() && path.back() != '/') { path = path + "/"; } path = path + fname; @@ -435,7 +435,7 @@ protected: if (extraPath) { std::string path = extraPath; - if (!path.empty() && path[path.size() - 1] != '/') { + if (!path.empty() && path.back() != '/') { path = path + "/"; } path = path + fname; diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index 32ad0b0..8a04c1f 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -228,8 +228,7 @@ void cmRST::ProcessLine(std::string const& line) else { this->NormalLine(line); this->LastLineEndedInColonColon = - (line.size() >= 2 && line[line.size() - 2] == ':' && - line[line.size() - 1] == ':'); + (line.size() >= 2 && line[line.size() - 2] == ':' && line.back() == ':'); } } diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index a71861a..0dfb797 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -110,7 +110,7 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( if (replaceValues.Target) { if (variable == "TARGET_QUOTED") { std::string targetQuoted = replaceValues.Target; - if (!targetQuoted.empty() && targetQuoted[0] != '\"') { + if (!targetQuoted.empty() && targetQuoted.front() != '\"') { targetQuoted = '\"'; targetQuoted += replaceValues.Target; targetQuoted += '\"'; @@ -120,7 +120,7 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( if (variable == "TARGET_UNQUOTED") { std::string unquoted = replaceValues.Target; std::string::size_type sz = unquoted.size(); - if (sz > 2 && unquoted[0] == '\"' && unquoted[sz - 1] == '\"') { + if (sz > 2 && unquoted.front() == '\"' && unquoted.back() == '\"') { unquoted = unquoted.substr(1, sz - 2); } return unquoted; diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 985aac8..1a2d1c6 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -54,7 +54,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, } // SET (VAR PARENT_SCOPE) // Removes the definition of VAR // in the parent scope. - if (args.size() == 2 && args[args.size() - 1] == "PARENT_SCOPE") { + if (args.size() == 2 && args.back() == "PARENT_SCOPE") { this->Makefile->RaiseScope(variable, nullptr); return true; } @@ -74,12 +74,12 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, unsigned int ignoreLastArgs = 0; // look for PARENT_SCOPE argument - if (args.size() > 1 && args[args.size() - 1] == "PARENT_SCOPE") { + if (args.size() > 1 && args.back() == "PARENT_SCOPE") { parentScope = true; ignoreLastArgs++; } else { // look for FORCE argument - if (args.size() > 4 && args[args.size() - 1] == "FORCE") { + if (args.size() > 4 && args.back() == "FORCE") { force = true; ignoreLastArgs++; } @@ -103,7 +103,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, // we should be nice and try to catch some simple screwups if the last or // next to last args are CACHE then they screwed up. If they used FORCE // without CACHE they screwed up - if ((args[args.size() - 1] == "CACHE") || + if ((args.back() == "CACHE") || (args.size() > 1 && args[args.size() - 2] == "CACHE") || (force && !cache)) { this->SetError("given invalid arguments for CACHE mode."); diff --git a/Source/cmState.cxx b/Source/cmState.cxx index a2008a0..4bbd2e0 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -867,8 +867,8 @@ static bool ParseEntryWithoutType(const std::string& entry, std::string& var, // if value is enclosed in single quotes ('foo') then remove them // it is used to enclose trailing space or tab - if (flag && value.size() >= 2 && value[0] == '\'' && - value[value.size() - 1] == '\'') { + if (flag && value.size() >= 2 && value.front() == '\'' && + value.back() == '\'') { value = value.substr(1, value.size() - 2); } @@ -900,8 +900,8 @@ bool cmState::ParseCacheEntry(const std::string& entry, std::string& var, // if value is enclosed in single quotes ('foo') then remove them // it is used to enclose trailing space or tab - if (flag && value.size() >= 2 && value[0] == '\'' && - value[value.size() - 1] == '\'') { + if (flag && value.size() >= 2 && value.front() == '\'' && + value.back() == '\'') { value = value.substr(1, value.size() - 2); } diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 1605fd7..91d6190 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -156,7 +156,7 @@ bool cmStringCommand::HandleAsciiCommand(std::vector<std::string> const& args) return false; } std::string::size_type cc; - std::string const& outvar = args[args.size() - 1]; + std::string const& outvar = args.back(); std::string output; for (cc = 1; cc < args.size() - 1; cc++) { int ch = atoi(args[cc].c_str()); @@ -755,7 +755,7 @@ bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args) this->SetError("sub-command RANDOM invoked with bad length."); return false; } - const std::string& variableName = args[args.size() - 1]; + const std::string& variableName = args.back(); std::vector<char> result; @@ -765,8 +765,7 @@ bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args) } const char* alphaPtr = alphabet.c_str(); - int cc; - for (cc = 0; cc < length; cc++) { + for (int cc = 0; cc < length; cc++) { int idx = static_cast<int>(sizeofAlphabet * rand() / (RAND_MAX + 1.0)); result.push_back(*(alphaPtr + idx)); } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 568ee82..9866d13 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1301,7 +1301,7 @@ bool cmSystemTools::SimpleGlob(const std::string& glob, int type /* = 0 */) { files.clear(); - if (glob[glob.size() - 1] != '*') { + if (glob.back() != '*') { return false; } std::string path = cmSystemTools::GetFilenamePath(glob); @@ -1318,7 +1318,7 @@ bool cmSystemTools::SimpleGlob(const std::string& glob, if ((std::string(d.GetFile(i)) != ".") && (std::string(d.GetFile(i)) != "..")) { std::string fname = path; - if (path[path.size() - 1] != '/') { + if (path.back() != '/') { fname += "/"; } fname += d.GetFile(i); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 5d76a02..92d5505 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -87,7 +87,7 @@ const char* cmTargetPropertyComputer::GetSources<cmTarget>( cmSystemTools::ExpandListArgument(entry, files); for (std::string const& file : files) { if (cmHasLiteralPrefix(file, "$<TARGET_OBJECTS:") && - file[file.size() - 1] == '>') { + file.back() == '>') { std::string objLibName = file.substr(17, file.size() - 18); if (cmGeneratorExpression::Find(objLibName) != std::string::npos) { diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index a9acb3f..9353276 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -602,8 +602,8 @@ bool cmVisualStudioSlnParser::ParseTag(const std::string& fullTag, } const std::string& arg = cmSystemTools::TrimWhitespace( fullTag.substr(idxLeftParen + 1, idxRightParen - idxLeftParen - 1)); - if (arg[0] == '"') { - if (arg[arg.size() - 1] != '"') { + if (arg.front() == '"') { + if (arg.back() != '"') { this->LastResult.SetError(ResultErrorInputStructure, state.GetCurrentLine()); return false; @@ -620,7 +620,7 @@ bool cmVisualStudioSlnParser::ParseValue(const std::string& value, const std::string& trimmed = cmSystemTools::TrimWhitespace(value); if (trimmed.empty()) parsedLine.AddValue(trimmed); - else if (trimmed[0] == '"' && trimmed[trimmed.size() - 1] == '"') + else if (trimmed.front() == '"' && trimmed.back() == '"') parsedLine.AddQuotedValue(trimmed.substr(1, trimmed.size() - 2)); else parsedLine.AddValue(trimmed); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 79af3e7..35730b8 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2129,7 +2129,7 @@ void cmake::TruncateOutputLog(const char* fname) inline std::string removeQuotes(const std::string& s) { - if (s[0] == '\"' && s[s.size() - 1] == '\"') { + if (s.front() == '\"' && s.back() == '\"') { return s.substr(1, s.size() - 2); } return s; diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index 0c5bbe2..1a10666 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -221,7 +221,7 @@ static int process(const std::string& srcfilename, const std::string& dfile, while (std::getline(ss, line)) { if (startsWith(line, prefix)) { std::string inc = trimLeadingSpace(line.substr(prefix.size()).c_str()); - if (inc[inc.size() - 1] == '\r') // blech, stupid \r\n + if (inc.back() == '\r') // blech, stupid \r\n inc = inc.substr(0, inc.size() - 1); includes.push_back(inc); } else { diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 8a140e8..45881aa 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -468,18 +468,18 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // If multiple source files specified, // then destination must be directory if ((args.size() > 4) && - (!cmSystemTools::FileIsDirectory(args[args.size() - 1]))) { - std::cerr << "Error: Target (for copy command) \"" - << args[args.size() - 1] << "\" is not a directory.\n"; + (!cmSystemTools::FileIsDirectory(args.back()))) { + std::cerr << "Error: Target (for copy command) \"" << args.back() + << "\" is not a directory.\n"; return 1; } // If error occurs we want to continue copying next files. bool return_value = false; for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) { if (!cmSystemTools::cmCopyFile(args[cc].c_str(), - args[args.size() - 1].c_str())) { + args.back().c_str())) { std::cerr << "Error copying file \"" << args[cc] << "\" to \"" - << args[args.size() - 1] << "\".\n"; + << args.back() << "\".\n"; return_value = true; } } @@ -491,18 +491,18 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // If multiple source files specified, // then destination must be directory if ((args.size() > 4) && - (!cmSystemTools::FileIsDirectory(args[args.size() - 1]))) { + (!cmSystemTools::FileIsDirectory(args.back()))) { std::cerr << "Error: Target (for copy_if_different command) \"" - << args[args.size() - 1] << "\" is not a directory.\n"; + << args.back() << "\" is not a directory.\n"; return 1; } // If error occurs we want to continue copying next files. bool return_value = false; for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) { - if (!cmSystemTools::CopyFileIfDifferent( - args[cc].c_str(), args[args.size() - 1].c_str())) { + if (!cmSystemTools::CopyFileIfDifferent(args[cc].c_str(), + args.back().c_str())) { std::cerr << "Error copying file (if different) from \"" << args[cc] - << "\" to \"" << args[args.size() - 1] << "\".\n"; + << "\" to \"" << args.back() << "\".\n"; return_value = true; } } @@ -514,9 +514,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // If error occurs we want to continue copying next files. bool return_value = false; for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) { - if (!cmSystemTools::CopyADirectory(args[cc], args[args.size() - 1])) { + if (!cmSystemTools::CopyADirectory(args[cc], args.back())) { std::cerr << "Error copying directory from \"" << args[cc] - << "\" to \"" << args[args.size() - 1] << "\".\n"; + << "\" to \"" << args.back() << "\".\n"; return_value = true; } } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index fe27796..132855b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1473,6 +1473,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindProtobuf) endif() + if(CMake_TEST_FindSQLite3) + add_subdirectory(FindSQLite3) + endif() + if(CMake_TEST_FindTIFF) add_subdirectory(FindTIFF) endif() diff --git a/Tests/FindSQLite3/CMakeLists.txt b/Tests/FindSQLite3/CMakeLists.txt new file mode 100644 index 0000000..8bf170e --- /dev/null +++ b/Tests/FindSQLite3/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindSQLite3.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindSQLite3/Test" + "${CMake_BINARY_DIR}/Tests/FindSQLite3/Test" + ${build_generator_args} + --build-project TestFindSQLite3 + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindSQLite3/Test/CMakeLists.txt b/Tests/FindSQLite3/Test/CMakeLists.txt new file mode 100644 index 0000000..bcc6ebd --- /dev/null +++ b/Tests/FindSQLite3/Test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.4) +project(TestFindSQLite3 C) +include(CTest) + +find_package(SQLite3 REQUIRED) + +add_definitions(-DCMAKE_EXPECTED_SQLite3_VERSION="${SQLite3_VERSION}") + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt SQLite::SQLite3) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${SQLite3_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${SQLite3_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindSQLite3/Test/main.c b/Tests/FindSQLite3/Test/main.c new file mode 100644 index 0000000..aeb4940 --- /dev/null +++ b/Tests/FindSQLite3/Test/main.c @@ -0,0 +1,10 @@ +#include <string.h> + +#include <sqlite3.h> + +int main() +{ + char sqlite3_version[] = SQLITE_VERSION; + + return strcmp(sqlite3_version, CMAKE_EXPECTED_SQLite3_VERSION); +} diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index b47abfb..ef48852 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -348,6 +348,10 @@ set(RunCMake_TEST_OPTIONS --trace-expand --warn-uninitialized) run_cmake(trace-expand-warn-uninitialized) unset(RunCMake_TEST_OPTIONS) +set(RunCMake_TEST_OPTIONS --warn-uninitialized) +run_cmake(warn-uninitialized) +unset(RunCMake_TEST_OPTIONS) + set(RunCMake_TEST_OPTIONS --trace-source=trace-only-this-file.cmake) run_cmake(trace-source) unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt b/Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt new file mode 100644 index 0000000..a13402a --- /dev/null +++ b/Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt @@ -0,0 +1,5 @@ +^CMake Warning \(dev\) at warn-uninitialized.cmake:1 \(set\): + uninitialized variable 'WARN_FROM_NORMAL_CMAKE_FILE' +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CommandLine/warn-uninitialized.cmake b/Tests/RunCMake/CommandLine/warn-uninitialized.cmake new file mode 100644 index 0000000..f1a75c9 --- /dev/null +++ b/Tests/RunCMake/CommandLine/warn-uninitialized.cmake @@ -0,0 +1 @@ +set(FOO "${WARN_FROM_NORMAL_CMAKE_FILE}") |