diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst index dc301ba47..376ec783a 100644 --- a/Help/manual/cmake-packages.7.rst +++ b/Help/manual/cmake-packages.7.rst @@ -131,7 +131,9 @@ It may also provide a CMake package configuration file:: /lib/cmake/foo-1.2/FooConfig.cmake with content defining :prop_tgt:`IMPORTED` targets, or defining variables, such -as:: +as: + +.. code-block:: cmake # ... # (compute PREFIX relative to file location) diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index d467c36ab..91386605c 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -22,7 +22,9 @@ The :command:`cmake_minimum_required` command does more than report an error if a too-old version of CMake is used to build a project. It also sets all policies introduced in that CMake version or earlier to NEW behavior. To manage policies without increasing the minimum required -CMake version, the :command:`if(POLICY)` command may be used:: +CMake version, the :command:`if(POLICY)` command may be used: + +.. code-block:: cmake if(POLICY CMP0990) cmake_policy(SET CMP0990 NEW) diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst index fbe546eae..97cd6504c 100644 --- a/Help/manual/cmake-toolchains.7.rst +++ b/Help/manual/cmake-toolchains.7.rst @@ -22,17 +22,23 @@ Languages Languages are enabled by the :command:`project` command. If no project command is in the top-level CMakeLists file, one will be implicitly generated. By default -the enabled languages are C and CXX:: +the enabled languages are C and CXX: + +.. code-block:: cmake project(C_Only C) A special value of NONE can also be used with the :command:`project` command -to enable no languages:: +to enable no languages: + +.. code-block:: cmake project(MyProject NONE) The :command:`enable_language` command can be used to enable languages after the -:command:`project` command:: +:command:`project` command: + +.. code-block:: cmake enable_language(CXX) @@ -86,7 +92,9 @@ Cross Compiling If :manual:`cmake(1)` is invoked with the command line parameter ``-DCMAKE_TOOLCHAIN_FILE=path/to/file``, the file will be loaded early to set values for the compilers. A typical cross-compiling toolchain has content such -as:: +as: + +.. code-block:: cmake set(CMAKE_SYSTEM_NAME Linux) @@ -127,7 +135,9 @@ the ``CMAKE_FIND_ROOT_PATH_MODE_*`` variables. Some compilers are inherently cross compilers, such as Clang and the QNX QCC compiler. The :variable:`CMAKE__COMPILER_TARGET` can be set to pass a -value to those supported compilers when compiling:: +value to those supported compilers when compiling: + +.. code-block:: cmake set(CMAKE_SYSTEM_NAME Linux) @@ -138,7 +148,9 @@ value to those supported compilers when compiling:: set(CMAKE_CXX_COMPILER clang++) set(CMAKE_CXX_COMPILER_TARGET ${triple}) -Or, for QCC:: +Or, for QCC: + +.. code-block:: cmake set(CMAKE_SYSTEM_NAME QNX) diff --git a/Help/prop_gbl/AUTOGEN_TARGETS_FOLDER.rst b/Help/prop_gbl/AUTOGEN_TARGETS_FOLDER.rst index 48cc8a117..5a69ef31d 100644 --- a/Help/prop_gbl/AUTOGEN_TARGETS_FOLDER.rst +++ b/Help/prop_gbl/AUTOGEN_TARGETS_FOLDER.rst @@ -1,8 +1,9 @@ AUTOGEN_TARGETS_FOLDER ---------------------- -Name of FOLDER for ``*_automoc`` targets that are added automatically by CMake for targets for which AUTOMOC is enabled. +Name of :prop_tgt:`FOLDER` for ``*_automoc`` targets that are added automatically by +CMake for targets for which :prop_tgt:`AUTOMOC` is enabled. -If not set, CMake uses the FOLDER property of the parent target as a +If not set, CMake uses the :prop_tgt:`FOLDER` property of the parent target as a default value for this property. See also the documentation for the -FOLDER target property and the AUTOMOC target property. +:prop_tgt:`FOLDER` target property and the :prop_tgt:`AUTOMOC` target property. diff --git a/Help/prop_gbl/AUTOMOC_TARGETS_FOLDER.rst b/Help/prop_gbl/AUTOMOC_TARGETS_FOLDER.rst index 185e0ecf4..671f86a85 100644 --- a/Help/prop_gbl/AUTOMOC_TARGETS_FOLDER.rst +++ b/Help/prop_gbl/AUTOMOC_TARGETS_FOLDER.rst @@ -1,10 +1,11 @@ AUTOMOC_TARGETS_FOLDER ---------------------- -Name of FOLDER for ``*_automoc`` targets that are added automatically by CMake for targets for which AUTOMOC is enabled. +Name of :prop_tgt:`FOLDER` for ``*_automoc`` targets that are added automatically by +CMake for targets for which :prop_tgt:`AUTOMOC` is enabled. -This property is obsolete. Use AUTOGEN_TARGETS_FOLDER instead. +This property is obsolete. Use :prop_gbl:`AUTOGEN_TARGETS_FOLDER` instead. -If not set, CMake uses the FOLDER property of the parent target as a +If not set, CMake uses the :prop_tgt:`FOLDER` property of the parent target as a default value for this property. See also the documentation for the -FOLDER target property and the AUTOMOC target property. +:prop_tgt:`FOLDER` target property and the :prop_tgt:`AUTOMOC` target property. diff --git a/Help/prop_sf/AUTORCC_OPTIONS.rst b/Help/prop_sf/AUTORCC_OPTIONS.rst index 4b6bb1084..d9dc4d33e 100644 --- a/Help/prop_sf/AUTORCC_OPTIONS.rst +++ b/Help/prop_sf/AUTORCC_OPTIONS.rst @@ -1,14 +1,13 @@ AUTORCC_OPTIONS --------------- -Additional options for rcc when using autorcc (see the :prop_tgt:`AUTORCC` target -property) +Additional options for ``rcc`` when using :prop_tgt:`AUTORCC` This property holds additional command line options which will be used when -rcc is executed during the build via autorcc, i.e. it is equivalent to the -optional OPTIONS argument of the qt4_add_resources() macro. +``rcc`` is executed during the build via :prop_tgt:`AUTORCC`, i.e. it is equivalent to the +optional ``OPTIONS`` argument of the :module:`qt4_add_resources() ` macro. By default it is empty. -The options set on the .qrc source file may override :prop_tgt:`AUTORCC_OPTIONS` set +The options set on the ``.qrc`` source file may override :prop_tgt:`AUTORCC_OPTIONS` set on the target. diff --git a/Help/prop_sf/AUTOUIC_OPTIONS.rst b/Help/prop_sf/AUTOUIC_OPTIONS.rst index a38b2f88c..6dfabb078 100644 --- a/Help/prop_sf/AUTOUIC_OPTIONS.rst +++ b/Help/prop_sf/AUTOUIC_OPTIONS.rst @@ -1,14 +1,14 @@ AUTOUIC_OPTIONS --------------- -Additional options for uic when using autouic (see the :prop_tgt:`AUTOUIC` target property) +Additional options for ``uic`` when using :prop_tgt:`AUTOUIC` This property holds additional command line options -which will be used when uic is executed during the build via autouic, -i.e. it is equivalent to the optional OPTIONS argument of the -qt4_wrap_ui() macro. +which will be used when ``uic`` is executed during the build via :prop_tgt:`AUTOUIC`, +i.e. it is equivalent to the optional ``OPTIONS`` argument of the +:module:`qt4_wrap_ui()` macro. By default it is empty. -The options set on the .ui source file may override :prop_tgt:`AUTOUIC_OPTIONS` set +The options set on the ``.ui`` source file may override :prop_tgt:`AUTOUIC_OPTIONS` set on the target. diff --git a/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst b/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst index 006c83a98..2bc18818c 100644 --- a/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst +++ b/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst @@ -3,10 +3,10 @@ AUTOGEN_TARGET_DEPENDS Target dependencies of the corresponding ``_automoc`` target. -Targets which have their :prop_tgt:`AUTOMOC` target set to true have a +Targets which have their :prop_tgt:`AUTOMOC` target set to ``TRUE`` have a corresponding ``_automoc`` target which is used to autogenerate generate moc files. As this ``_automoc`` target is created at generate-time, it is not -possible to define dependencies of it, such as to create inputs for the moc +possible to define dependencies of it, such as to create inputs for the ``moc`` executable. The ``AUTOGEN_TARGET_DEPENDS`` target can be set instead to a list of dependencies diff --git a/Help/prop_tgt/AUTOMOC.rst b/Help/prop_tgt/AUTOMOC.rst index 8af11160c..16094c781 100644 --- a/Help/prop_tgt/AUTOMOC.rst +++ b/Help/prop_tgt/AUTOMOC.rst @@ -3,29 +3,29 @@ AUTOMOC Should the target be processed with automoc (for Qt projects). -AUTOMOC is a boolean specifying whether CMake will handle the Qt moc +AUTOMOC is a boolean specifying whether CMake will handle the Qt ``moc`` preprocessor automatically, i.e. without having to use the -QT4_WRAP_CPP() or QT5_WRAP_CPP() macro. Currently Qt4 and Qt5 are -supported. When this property is set to TRUE, CMake will scan the -source files at build time and invoke moc accordingly. If an #include -statement like #include "moc_foo.cpp" is found, the Q_OBJECT class -declaration is expected in the header, and moc is run on the header -file. If an #include statement like #include "foo.moc" is found, then -a Q_OBJECT is expected in the current source file and moc is run on +:module:`QT4_WRAP_CPP() ` or QT5_WRAP_CPP() macro. Currently Qt4 and Qt5 are +supported. When this property is set to ``TRUE``, CMake will scan the +source files at build time and invoke moc accordingly. If an ``#include`` +statement like ``#include "moc_foo.cpp"`` is found, the ``Q_OBJECT`` class +declaration is expected in the header, and ``moc`` is run on the header +file. If an ``#include`` statement like ``#include "foo.moc"`` is found, then +a ``Q_OBJECT`` is expected in the current source file and ``moc`` is run on the file itself. Additionally, all header files are parsed for -Q_OBJECT macros, and if found, moc is also executed on those files. +``Q_OBJECT`` macros, and if found, ``moc`` is also executed on those files. The resulting moc files, which are not included as shown above in any of the source files are included in a generated -_automoc.cpp file, which is compiled as part of the -target.This property is initialized by the value of the variable -CMAKE_AUTOMOC if it is set when a target is created. +``_automoc.cpp`` file, which is compiled as part of the +target. This property is initialized by the value of the variable +:variable:`CMAKE_AUTOMOC` if it is set when a target is created. Additional command line options for moc can be set via the -AUTOMOC_MOC_OPTIONS property. +:prop_tgt:`AUTOMOC_MOC_OPTIONS` property. -By setting the CMAKE_AUTOMOC_RELAXED_MODE variable to TRUE the rules -for searching the files which will be processed by moc can be relaxed. +By setting the :variable:`CMAKE_AUTOMOC_RELAXED_MODE` variable to ``TRUE`` the +rules for searching the files which will be processed by moc can be relaxed. See the documentation for this variable for more details. -The global property AUTOMOC_TARGETS_FOLDER can be used to group the +The global property :prop_gbl:`AUTOMOC_TARGETS_FOLDER` can be used to group the automoc targets together in an IDE, e.g. in MSVS. diff --git a/Help/prop_tgt/AUTOMOC_MOC_OPTIONS.rst b/Help/prop_tgt/AUTOMOC_MOC_OPTIONS.rst index 6ab5c85f6..d086bf5e1 100644 --- a/Help/prop_tgt/AUTOMOC_MOC_OPTIONS.rst +++ b/Help/prop_tgt/AUTOMOC_MOC_OPTIONS.rst @@ -1,12 +1,12 @@ AUTOMOC_MOC_OPTIONS ------------------- -Additional options for moc when using automoc (see the AUTOMOC property) +Additional options for moc when using :prop_tgt:`AUTOMOC` -This property is only used if the AUTOMOC property is set to TRUE for -this target. In this case, it holds additional command line options -which will be used when moc is executed during the build, i.e. it is -equivalent to the optional OPTIONS argument of the qt4_wrap_cpp() +This property is only used if the :prop_tgt:`AUTOMOC` property is set to ``TRUE`` +for this target. In this case, it holds additional command line options +which will be used when ``moc`` is executed during the build, i.e. it is +equivalent to the optional ``OPTIONS`` argument of the :module:`qt4_wrap_cpp() ` macro. By default it is empty. diff --git a/Help/prop_tgt/AUTORCC.rst b/Help/prop_tgt/AUTORCC.rst index ef2c9c8b6..f6409ea94 100644 --- a/Help/prop_tgt/AUTORCC.rst +++ b/Help/prop_tgt/AUTORCC.rst @@ -4,18 +4,18 @@ AUTORCC Should the target be processed with autorcc (for Qt projects). -AUTORCC is a boolean specifying whether CMake will handle -the Qt rcc code generator automatically, i.e. without having to use -the QT4_ADD_RESOURCES() or QT5_ADD_RESOURCES() macro. Currently Qt4 and Qt5 are -supported. +``AUTORCC`` is a boolean specifying whether CMake will handle +the Qt ``rcc`` code generator automatically, i.e. without having to use +the :module:`QT4_ADD_RESOURCES() ` or QT5_ADD_RESOURCES() macro. +Currently Qt4 and Qt5 are supported. -When this property is set to TRUE, CMake will handle .qrc files added -as target sources at build time and invoke rcc accordingly. +When this property is set to ``TRUE``, CMake will handle ``.qrc`` files added +as target sources at build time and invoke ``rcc`` accordingly. This property is initialized by the value of the :variable:`CMAKE_AUTORCC` variable if it is set when a target is created. Additional command line options for rcc can be set via the -:prop_sf:`AUTORCC_OPTIONS` source file property on the .qrc file. +:prop_sf:`AUTORCC_OPTIONS` source file property on the ``.qrc`` file. The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group the autouic targets together in an IDE, e.g. in MSVS. diff --git a/Help/prop_tgt/AUTORCC_OPTIONS.rst b/Help/prop_tgt/AUTORCC_OPTIONS.rst index 489e277d6..1dd82ee38 100644 --- a/Help/prop_tgt/AUTORCC_OPTIONS.rst +++ b/Help/prop_tgt/AUTORCC_OPTIONS.rst @@ -1,12 +1,12 @@ AUTORCC_OPTIONS --------------- -Additional options for rcc when using autorcc (see the :prop_tgt:`AUTORCC` target property) +Additional options for ``rcc`` when using :prop_tgt:`AUTORCC` This property holds additional command line options -which will be used when rcc is executed during the build via autorcc, -i.e. it is equivalent to the optional OPTIONS argument of the -qt4_add_resources() macro. +which will be used when ``rcc`` is executed during the build via :prop_tgt:`AUTORCC`, +i.e. it is equivalent to the optional ``OPTIONS`` argument of the +:module:`qt4_add_resources() ` macro. By default it is empty. @@ -14,4 +14,4 @@ This property is initialized by the value of the variable :variable:`CMAKE_AUTORCC` if it is set when a target is created. The options set on the target may be overridden by :prop_sf:`AUTORCC_OPTIONS` set -on the .qrc source file. +on the ``.qrc`` source file. diff --git a/Help/prop_tgt/AUTOUIC.rst b/Help/prop_tgt/AUTOUIC.rst index 548c2598d..010c0277a 100644 --- a/Help/prop_tgt/AUTOUIC.rst +++ b/Help/prop_tgt/AUTOUIC.rst @@ -3,20 +3,20 @@ AUTOUIC Should the target be processed with autouic (for Qt projects). -AUTOUIC is a boolean specifying whether CMake will handle -the Qt uic code generator automatically, i.e. without having to use -the QT4_WRAP_UI() or QT5_WRAP_UI() macro. Currently Qt4 and Qt5 are -supported. +``AUTOUIC`` is a boolean specifying whether CMake will handle +the Qt ``uic`` code generator automatically, i.e. without having to use +the :module:`QT4_WRAP_UI() ` or QT5_WRAP_UI() macro. Currently Qt4 +and Qt5 are supported. -When this property is set to TRUE, CMake will scan the source files -at build time and invoke uic accordingly. -If an #include statement like #include "ui_foo.h" is found in -foo.cpp, a foo.ui file is expected next to foo.cpp, and uic is -run on the foo.ui file. +When this property is set to ``TRUE``, CMake will scan the source files +at build time and invoke ``uic`` accordingly. +If an ``#include`` statement like ``#include "ui_foo.h"`` is found in +``foo.cpp``, a ``foo.ui`` file is expected next to ``foo.cpp``, and ``uic`` is +run on the ``foo.ui`` file. This property is initialized by the value of the :variable:`CMAKE_AUTOUIC` variable if it is set when a target is created. Additional command line options for uic can be set via the -:prop_sf:`AUTOUIC_OPTIONS` source file property on the foo.ui file. +:prop_sf:`AUTOUIC_OPTIONS` source file property on the ``foo.ui`` file. The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group the autouic targets together in an IDE, e.g. in MSVS. diff --git a/Help/prop_tgt/AUTOUIC_OPTIONS.rst b/Help/prop_tgt/AUTOUIC_OPTIONS.rst index aeec38baa..d0f865c82 100644 --- a/Help/prop_tgt/AUTOUIC_OPTIONS.rst +++ b/Help/prop_tgt/AUTOUIC_OPTIONS.rst @@ -1,12 +1,12 @@ AUTOUIC_OPTIONS --------------- -Additional options for uic when using autouic (see the :prop_tgt:`AUTOUIC` target property) +Additional options for uic when using :prop_tgt:`AUTOUIC` This property holds additional command line options -which will be used when uic is executed during the build via autouic, -i.e. it is equivalent to the optional OPTIONS argument of the -qt4_wrap_ui() macro. +which will be used when ``uic`` is executed during the build via :prop_tgt:`AUTOUIC`, +i.e. it is equivalent to the optional ``OPTIONS`` argument of the +:module:`qt4_wrap_ui() ` macro. By default it is empty. @@ -14,7 +14,7 @@ This property is initialized by the value of the variable :variable:`CMAKE_AUTOUIC` if it is set when a target is created. The options set on the target may be overridden by :prop_sf:`AUTOUIC_OPTIONS` set -on the .ui source file. +on the ``.ui`` source file. This property may use "generator expressions" with the syntax "$<...>". See the :manual:`cmake-generator-expressions(7)` manual for available diff --git a/Help/variable/CMAKE_AUTOMOC.rst b/Help/variable/CMAKE_AUTOMOC.rst index 87e8a9bec..02e5eb57a 100644 --- a/Help/variable/CMAKE_AUTOMOC.rst +++ b/Help/variable/CMAKE_AUTOMOC.rst @@ -1,7 +1,7 @@ CMAKE_AUTOMOC ------------- -Whether to handle moc automatically for Qt targets. +Whether to handle ``moc`` automatically for Qt targets. -This variable is used to initialize the AUTOMOC property on all the +This variable is used to initialize the :prop_tgt:`AUTOMOC` property on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_AUTOMOC_MOC_OPTIONS.rst b/Help/variable/CMAKE_AUTOMOC_MOC_OPTIONS.rst index bdbed859a..09bf5cd2f 100644 --- a/Help/variable/CMAKE_AUTOMOC_MOC_OPTIONS.rst +++ b/Help/variable/CMAKE_AUTOMOC_MOC_OPTIONS.rst @@ -1,8 +1,7 @@ CMAKE_AUTOMOC_MOC_OPTIONS ------------------------- -Additional options for moc when using automoc (see CMAKE_AUTOMOC). +Additional options for ``moc`` when using :variable:`CMAKE_AUTOMOC`. -This variable is used to initialize the AUTOMOC_MOC_OPTIONS property -on all the targets. See that target property for additional -information. +This variable is used to initialize the :prop_tgt:`AUTOMOC_MOC_OPTIONS` property +on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst b/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst index 885841015..a814d408b 100644 --- a/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst +++ b/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst @@ -3,11 +3,11 @@ CMAKE_AUTOMOC_RELAXED_MODE Switch between strict and relaxed automoc mode. -By default, automoc behaves exactly as described in the documentation -of the AUTOMOC target property. When set to TRUE, it accepts more -input and tries to find the correct input file for moc even if it +By default, :prop_tgt:`AUTOMOC` behaves exactly as described in the documentation +of the :prop_tgt:`AUTOMOC` target property. When set to ``TRUE``, it accepts more +input and tries to find the correct input file for ``moc`` even if it differs from the documented behaviour. In this mode it e.g. also checks whether a header file is intended to be processed by moc when a -"foo.moc" file has been included. +``"foo.moc"`` file has been included. Relaxed mode has to be enabled for KDE4 compatibility. diff --git a/Help/variable/CMAKE_AUTORCC.rst b/Help/variable/CMAKE_AUTORCC.rst index d2139939d..067f76611 100644 --- a/Help/variable/CMAKE_AUTORCC.rst +++ b/Help/variable/CMAKE_AUTORCC.rst @@ -1,7 +1,7 @@ CMAKE_AUTORCC ------------- -Whether to handle rcc automatically for Qt targets. +Whether to handle ``rcc`` automatically for Qt targets. This variable is used to initialize the :prop_tgt:`AUTORCC` property on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_AUTORCC_OPTIONS.rst b/Help/variable/CMAKE_AUTORCC_OPTIONS.rst index 5efbfa378..298cb6be7 100644 --- a/Help/variable/CMAKE_AUTORCC_OPTIONS.rst +++ b/Help/variable/CMAKE_AUTORCC_OPTIONS.rst @@ -1,7 +1,7 @@ CMAKE_AUTORCC_OPTIONS --------------------- -Whether to handle rcc automatically for Qt targets. +Whether to handle ``rcc`` automatically for Qt targets. This variable is used to initialize the :prop_tgt:`AUTORCC_OPTIONS` property on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_AUTOUIC.rst b/Help/variable/CMAKE_AUTOUIC.rst index 3b016b02e..0beb55590 100644 --- a/Help/variable/CMAKE_AUTOUIC.rst +++ b/Help/variable/CMAKE_AUTOUIC.rst @@ -1,7 +1,7 @@ CMAKE_AUTOUIC ------------- -Whether to handle uic automatically for Qt targets. +Whether to handle ``uic`` automatically for Qt targets. This variable is used to initialize the :prop_tgt:`AUTOUIC` property on all the targets. See that target property for additional information. diff --git a/Help/variable/CMAKE_AUTOUIC_OPTIONS.rst b/Help/variable/CMAKE_AUTOUIC_OPTIONS.rst index 6a88669c0..3c9b8c4f5 100644 --- a/Help/variable/CMAKE_AUTOUIC_OPTIONS.rst +++ b/Help/variable/CMAKE_AUTOUIC_OPTIONS.rst @@ -1,7 +1,7 @@ CMAKE_AUTOUIC_OPTIONS --------------------- -Whether to handle uic automatically for Qt targets. +Whether to handle ``uic`` automatically for Qt targets. This variable is used to initialize the :prop_tgt:`AUTOUIC_OPTIONS` property on all the targets. See that target property for additional information. diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index 5baf9e02d..f83f992cd 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -6,14 +6,11 @@ # # This module provides the function GENERATE_EXPORT_HEADER(). # -# The GENERATE_EXPORT_HEADER function can be used to generate a file +# The ``GENERATE_EXPORT_HEADER`` function can be used to generate a file # suitable for preprocessor inclusion which contains EXPORT macros to be -# used in library classes. -# -# GENERATE_EXPORT_HEADER( LIBRARY_TARGET -# -# :: +# used in library classes:: # +# GENERATE_EXPORT_HEADER( LIBRARY_TARGET # [BASE_NAME ] # [EXPORT_MACRO_NAME ] # [EXPORT_FILE_NAME ] @@ -23,20 +20,21 @@ # [NO_DEPRECATED_MACRO_NAME ] # [DEFINE_NO_DEPRECATED] # [PREFIX_NAME ] +# ) # -# ) # -# The target properties CXX_VISIBILITY_PRESET and -# VISIBILITY_INLINES_HIDDEN can be used to add the appropriate compile -# flags for targets. See the documentation of those target properties, -# and the convenience variables CMAKE_CXX_VISIBILITY_PRESET and -# CMAKE_VISIBILITY_INLINES_HIDDEN. +# The target properties :prop_tgt:`CXX_VISIBILITY_PRESET <_VISIBILITY_PRESET>` +# and :prop_tgt:`VISIBILITY_INLINES_HIDDEN` can be used to add the appropriate +# compile flags for targets. See the documentation of those target properties, +# and the convenience variables +# :variable:`CMAKE_CXX_VISIBILITY_PRESET _VISIBILITY_PRESET>` and +# :variable:`CMAKE_VISIBILITY_INLINES_HIDDEN`. # -# By default GENERATE_EXPORT_HEADER() generates macro names in a file +# By default ``GENERATE_EXPORT_HEADER()`` generates macro names in a file # name determined by the name of the library. This means that in the -# simplest case, users of generate_export_header will be equivalent to: +# simplest case, users of ``GenerateExportHeader`` will be equivalent to: # -# :: +# .. code-block:: cmake # # set(CMAKE_CXX_VISIBILITY_PRESET hidden) # set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) @@ -49,10 +47,9 @@ # ) # # -# # And in the ABI header files: # -# :: +# .. code-block:: c++ # # #include "somelib_export.h" # class SOMELIB_EXPORT SomeClass { @@ -60,17 +57,16 @@ # }; # # -# # The CMake fragment will generate a file in the -# ${CMAKE_CURRENT_BINARY_DIR} called somelib_export.h containing the -# macros SOMELIB_EXPORT, SOMELIB_NO_EXPORT, SOMELIB_DEPRECATED, -# SOMELIB_DEPRECATED_EXPORT and SOMELIB_DEPRECATED_NO_EXPORT. The +# ``${CMAKE_CURRENT_BINARY_DIR}`` called ``somelib_export.h`` containing the +# macros ``SOMELIB_EXPORT``, ``SOMELIB_NO_EXPORT``, ``SOMELIB_DEPRECATED``, +# ``SOMELIB_DEPRECATED_EXPORT`` and ``SOMELIB_DEPRECATED_NO_EXPORT``. The # resulting file should be installed with other headers in the library. # -# The BASE_NAME argument can be used to override the file name and the -# names used for the macros +# The ``BASE_NAME`` argument can be used to override the file name and the +# names used for the macros: # -# :: +# .. code-block:: cmake # # add_library(somelib someclass.cpp) # generate_export_header(somelib @@ -78,14 +74,14 @@ # ) # # +# Generates a file called ``other_name_export.h`` containing the macros +# ``OTHER_NAME_EXPORT``, ``OTHER_NAME_NO_EXPORT`` and ``OTHER_NAME_DEPRECATED`` +# etc. # -# Generates a file called other_name_export.h containing the macros -# OTHER_NAME_EXPORT, OTHER_NAME_NO_EXPORT and OTHER_NAME_DEPRECATED etc. -# -# The BASE_NAME may be overridden by specifiying other options in the +# The ``BASE_NAME`` may be overridden by specifiying other options in the # function. For example: # -# :: +# .. code-block:: cmake # # add_library(somelib someclass.cpp) # generate_export_header(somelib @@ -93,11 +89,10 @@ # ) # # +# creates the macro ``OTHER_NAME_EXPORT`` instead of ``SOMELIB_EXPORT``, but +# other macros and the generated file name is as default: # -# creates the macro OTHER_NAME_EXPORT instead of SOMELIB_EXPORT, but -# other macros and the generated file name is as default. -# -# :: +# .. code-block:: cmake # # add_library(somelib someclass.cpp) # generate_export_header(somelib @@ -105,17 +100,16 @@ # ) # # +# creates the macro ``KDE_DEPRECATED`` instead of ``SOMELIB_DEPRECATED``. # -# creates the macro KDE_DEPRECATED instead of SOMELIB_DEPRECATED. -# -# If LIBRARY_TARGET is a static library, macros are defined without +# If ``LIBRARY_TARGET`` is a static library, macros are defined without # values. # # If the same sources are used to create both a shared and a static -# library, the uppercased symbol ${BASE_NAME}_STATIC_DEFINE should be -# used when building the static library +# library, the uppercased symbol ``${BASE_NAME}_STATIC_DEFINE`` should be +# used when building the static library: # -# :: +# .. code-block:: cmake # # add_library(shared_variant SHARED ${lib_SRCS}) # add_library(static_variant ${lib_SRCS}) @@ -123,16 +117,14 @@ # set_target_properties(static_variant PROPERTIES # COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) # -# -# # This will cause the export macros to expand to nothing when building # the static library. # -# If DEFINE_NO_DEPRECATED is specified, then a macro -# ${BASE_NAME}_NO_DEPRECATED will be defined This macro can be used to -# remove deprecated code from preprocessor output. +# If ``DEFINE_NO_DEPRECATED`` is specified, then a macro +# ``${BASE_NAME}_NO_DEPRECATED`` will be defined This macro can be used to +# remove deprecated code from preprocessor output: # -# :: +# .. code-block:: cmake # # option(EXCLUDE_DEPRECATED "Exclude deprecated parts of the library" FALSE) # if (EXCLUDE_DEPRECATED) @@ -141,10 +133,9 @@ # generate_export_header(somelib ${NO_BUILD_DEPRECATED}) # # -# # And then in somelib: # -# :: +# .. code-block:: c++ # # class SOMELIB_EXPORT SomeClass # { @@ -154,42 +145,38 @@ # #endif # }; # -# -# -# :: +# .. code-block:: c++ # # #ifndef SOMELIB_NO_DEPRECATED # void SomeClass::oldMethod() { } # #endif # # -# -# If PREFIX_NAME is specified, the argument will be used as a prefix to +# If ``PREFIX_NAME`` is specified, the argument will be used as a prefix to # all generated macros. # # For example: # -# :: +# .. code-block:: cmake # # generate_export_header(somelib PREFIX_NAME VTK_) # +# Generates the macros ``VTK_SOMELIB_EXPORT`` etc. # +# :: # -# Generates the macros VTK_SOMELIB_EXPORT etc. +# ADD_COMPILER_EXPORT_FLAGS( [] ) # -# -# -# ADD_COMPILER_EXPORT_FLAGS( [] ) -# -# The ADD_COMPILER_EXPORT_FLAGS function adds -fvisibility=hidden to -# CMAKE_CXX_FLAGS if supported, and is a no-op on Windows which does not -# need extra compiler flags for exporting support. You may optionally -# pass a single argument to ADD_COMPILER_EXPORT_FLAGS that will be -# populated with the required CXX_FLAGS required to enable visibility +# The ``ADD_COMPILER_EXPORT_FLAGS`` function adds ``-fvisibility=hidden`` to +# :variable:`CMAKE_CXX_FLAGS _FLAGS>` if supported, and is a no-op +# on Windows which does not need extra compiler flags for exporting support. +# You may optionally pass a single argument to ``ADD_COMPILER_EXPORT_FLAGS`` +# that will be populated with the ``CXX_FLAGS`` required to enable visibility # support for the compiler/architecture in use. # # This function is deprecated. Set the target properties -# CXX_VISIBILITY_PRESET and VISIBILITY_INLINES_HIDDEN instead. +# :prop_tgt:`CXX_VISIBILITY_PRESET <_VISIBILITY_PRESET>` and +# :prop_tgt:`VISIBILITY_INLINES_HIDDEN` instead. #============================================================================= # Copyright 2011 Stephen Kelly diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index e4d7f7f1e..87bfb3cc1 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -33,6 +33,15 @@ bool cmAddDependenciesCommand } if(cmTarget* target = this->Makefile->FindTargetToUse(target_name.c_str())) { + if (target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + cmOStringStream e; + e << "Cannot add target-level dependencies to INTERFACE library " + "target \"" << target_name << "\".\n"; + this->SetError(e.str().c_str()); + return false; + } + std::vector::const_iterator s = args.begin(); ++s; // skip over target_name for (; s != args.end(); ++s) diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 1025dc0d1..73e9b319e 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -114,13 +114,18 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) std::vector missingTargets; bool require2_8_12 = false; - bool require2_8_13 = false; + bool require3_0_0 = false; + bool requiresConfigFiles = false; // Create all the imported targets. for(std::vector::const_iterator tei = allTargets.begin(); tei != allTargets.end(); ++tei) { cmTarget* te = (*tei)->Target; + + requiresConfigFiles = requiresConfigFiles + || te->GetType() != cmTarget::INTERFACE_LIBRARY; + this->GenerateImportTargetCode(os, te); ImportPropertyMap properties; @@ -160,7 +165,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) } if (te->GetType() == cmTarget::INTERFACE_LIBRARY) { - require2_8_13 = true; + require3_0_0 = true; } this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); @@ -169,7 +174,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->GenerateInterfaceProperties(te, os, properties); } - if (require2_8_13) + if (require3_0_0) { this->GenerateRequiredCMakeVersion(os, "2.8.12.20131007"); } @@ -197,15 +202,19 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) } this->GenerateImportedFileCheckLoop(os); - // Generate an import file for each configuration. bool result = true; - for(std::vector::const_iterator - ci = this->Configurations.begin(); - ci != this->Configurations.end(); ++ci) + // Generate an import file for each configuration. + // Don't do this if we only export INTERFACE_LIBRARY targets. + if (requiresConfigFiles) { - if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets)) + for(std::vector::const_iterator + ci = this->Configurations.begin(); + ci != this->Configurations.end(); ++ci) { - result = false; + if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets)) + { + result = false; + } } } diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index faba7cd35..a1454a32d 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -298,7 +298,7 @@ bool cmGetPropertyCommand::HandleTargetMode() return this->StoreResult(target->GetName()); } } - return false; + return this->StoreResult((this->Variable + "-NOTFOUND").c_str()); } if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name.c_str())) { diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index 30c174375..e20fe022d 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -55,7 +55,7 @@ bool cmIncludeDirectoryCommand std::vector includes; - GetIncludes(*i, includes); + this->GetIncludes(*i, includes); if (before) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 30a155783..6883f57ef 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4045,8 +4045,8 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type, // Create the target. cmsys::auto_ptr target(new cmTarget); target->SetType(type, name); - target->SetMakefile(this); target->MarkAsImported(); + target->SetMakefile(this); // Add to the set of available imported targets. this->ImportedTargets[name] = target.get(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9faf0d9e2..ead48b9d6 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -136,7 +136,7 @@ public: std::vector IncludeDirectoriesEntries; std::vector CompileOptionsEntries; std::vector CompileDefinitionsEntries; - std::vector LinkInterfacePropertyEntries; + std::vector LinkImplementationPropertyEntries; mutable std::map > CachedLinkInterfaceIncludeDirectoriesEntries; @@ -330,34 +330,36 @@ void cmTarget::SetMakefile(cmMakefile* mf) // Save the backtrace of target construction. this->Makefile->GetBacktrace(this->Internal->Backtrace); - // Initialize the INCLUDE_DIRECTORIES property based on the current value - // of the same directory property: - const std::vector parentIncludes = - this->Makefile->GetIncludeDirectoriesEntries(); - - for (std::vector::const_iterator it - = parentIncludes.begin(); it != parentIncludes.end(); ++it) + if (!this->IsImported()) { - this->InsertInclude(*it); - } + // Initialize the INCLUDE_DIRECTORIES property based on the current value + // of the same directory property: + const std::vector parentIncludes = + this->Makefile->GetIncludeDirectoriesEntries(); - const std::set parentSystemIncludes = - this->Makefile->GetSystemIncludeDirectories(); + for (std::vector::const_iterator it + = parentIncludes.begin(); it != parentIncludes.end(); ++it) + { + this->InsertInclude(*it); + } + const std::set parentSystemIncludes = + this->Makefile->GetSystemIncludeDirectories(); - for (std::set::const_iterator it - = parentSystemIncludes.begin(); - it != parentSystemIncludes.end(); ++it) - { - this->SystemIncludeDirectories.insert(*it); - } + for (std::set::const_iterator it + = parentSystemIncludes.begin(); + it != parentSystemIncludes.end(); ++it) + { + this->SystemIncludeDirectories.insert(*it); + } - const std::vector parentOptions = - this->Makefile->GetCompileOptionsEntries(); + const std::vector parentOptions = + this->Makefile->GetCompileOptionsEntries(); - for (std::vector::const_iterator it - = parentOptions.begin(); it != parentOptions.end(); ++it) - { - this->InsertCompileOption(*it); + for (std::vector::const_iterator it + = parentOptions.begin(); it != parentOptions.end(); ++it) + { + this->InsertCompileOption(*it); + } } if (this->GetType() != INTERFACE_LIBRARY) @@ -1042,8 +1044,8 @@ cmTarget::AddSystemIncludeDirectories(const std::vector &incs) void cmTarget::FinalizeSystemIncludeDirectories() { for (std::vector::const_iterator - it = this->Internal->LinkInterfacePropertyEntries.begin(), - end = this->Internal->LinkInterfacePropertyEntries.end(); + it = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); it != end; ++it) { if (!cmGeneratorExpression::IsValidTargetName(it->Value) @@ -1495,11 +1497,11 @@ void cmTarget::SetProperty(const char* prop, const char* value) } if (strcmp(prop, "LINK_LIBRARIES") == 0) { - this->Internal->LinkInterfacePropertyEntries.clear(); + this->Internal->LinkImplementationPropertyEntries.clear(); cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); cmValueWithOrigin entry(value, lfbt); - this->Internal->LinkInterfacePropertyEntries.push_back(entry); + this->Internal->LinkImplementationPropertyEntries.push_back(entry); return; } this->Properties.SetProperty(prop, value, cmProperty::TARGET); @@ -1570,7 +1572,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value, cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); cmValueWithOrigin entry(value, lfbt); - this->Internal->LinkInterfacePropertyEntries.push_back(entry); + this->Internal->LinkImplementationPropertyEntries.push_back(entry); return; } this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString); @@ -1882,8 +1884,8 @@ cmTarget::GetIncludeDirectories(const char *config) const if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString]) { for (std::vector::const_iterator - it = this->Internal->LinkInterfacePropertyEntries.begin(), - end = this->Internal->LinkInterfacePropertyEntries.end(); + it = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); it != end; ++it) { if (!cmGeneratorExpression::IsValidTargetName(it->Value) @@ -2111,8 +2113,8 @@ void cmTarget::GetCompileOptions(std::vector &result, if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[configString]) { for (std::vector::const_iterator - it = this->Internal->LinkInterfacePropertyEntries.begin(), - end = this->Internal->LinkInterfacePropertyEntries.end(); + it = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); it != end; ++it) { if (!cmGeneratorExpression::IsValidTargetName(it->Value) @@ -2224,8 +2226,8 @@ void cmTarget::GetCompileDefinitions(std::vector &list, if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString]) { for (std::vector::const_iterator - it = this->Internal->LinkInterfacePropertyEntries.begin(), - end = this->Internal->LinkInterfacePropertyEntries.end(); + it = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); it != end; ++it) { if (!cmGeneratorExpression::IsValidTargetName(it->Value) @@ -2720,25 +2722,6 @@ const char *cmTarget::GetProperty(const char* prop, this->GetLocation(configName.c_str()), cmProperty::TARGET); } - else - { - // Support "_LOCATION" for compatibility. - int len = static_cast(strlen(prop)); - if(len > 9 && strcmp(prop+len-9, "_LOCATION") == 0) - { - std::string configName(prop, len-9); - if(configName != "IMPORTED") - { - if (!this->HandleLocationPropertyPolicy()) - { - return 0; - } - this->Properties.SetProperty(prop, - this->GetLocation(configName.c_str()), - cmProperty::TARGET); - } - } - } } if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0) { @@ -2800,8 +2783,8 @@ const char *cmTarget::GetProperty(const char* prop, output = ""; std::string sep; for (std::vector::const_iterator - it = this->Internal->LinkInterfacePropertyEntries.begin(), - end = this->Internal->LinkInterfacePropertyEntries.end(); + it = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); it != end; ++it) { output += sep; @@ -4257,20 +4240,23 @@ enum CompatibleType //---------------------------------------------------------------------------- template -PropertyType consistentProperty(PropertyType lhs, PropertyType rhs, - CompatibleType t); +std::pair consistentProperty(PropertyType lhs, + PropertyType rhs, + CompatibleType t); //---------------------------------------------------------------------------- template<> -bool consistentProperty(bool lhs, bool rhs, CompatibleType) +std::pair consistentProperty(bool lhs, bool rhs, CompatibleType) { - return lhs == rhs; + return std::make_pair(lhs == rhs, lhs); } //---------------------------------------------------------------------------- -const char * consistentStringProperty(const char *lhs, const char *rhs) +std::pair consistentStringProperty(const char *lhs, + const char *rhs) { - return strcmp(lhs, rhs) == 0 ? lhs : 0; + const bool b = strcmp(lhs, rhs) == 0; + return std::make_pair(b, b ? lhs : 0); } #if defined(_MSC_VER) && _MSC_VER <= 1200 @@ -4284,49 +4270,69 @@ cmMinimum(const T& l, const T& r) {return l < r ? l : r;} #endif //---------------------------------------------------------------------------- -const char * consistentNumberProperty(const char *lhs, const char *rhs, - CompatibleType t) +std::pair consistentNumberProperty(const char *lhs, + const char *rhs, + CompatibleType t) { + +#if defined(_MSC_VER) + static const char* const null_ptr = 0; +#else +# define null_ptr 0 +#endif + double lnum; double rnum; if(sscanf(lhs, "%lg", &lnum) != 1 || sscanf(rhs, "%lg", &rnum) != 1) { - return 0; + return std::pair(false, null_ptr); } +#if !defined(_MSC_VER) +#undef null_ptr +#endif + if (t == NumberMaxType) { - return cmMaximum(lnum, rnum) == lnum ? lhs : rhs; + return std::make_pair(true, cmMaximum(lnum, rnum) == lnum ? lhs : rhs); } else { - return cmMinimum(lnum, rnum) == lnum ? lhs : rhs; + return std::make_pair(true, cmMinimum(lnum, rnum) == lnum ? lhs : rhs); } } //---------------------------------------------------------------------------- template<> -const char* consistentProperty(const char *lhs, const char *rhs, - CompatibleType t) +std::pair consistentProperty(const char *lhs, + const char *rhs, + CompatibleType t) { if (!lhs && !rhs) { - return ""; + return std::make_pair(true, lhs); } if (!lhs) { - return rhs ? rhs : ""; + return std::make_pair(true, rhs); } if (!rhs) { - return lhs ? lhs : ""; + return std::make_pair(true, lhs); } + +#if defined(_MSC_VER) + static const char* const null_ptr = 0; +#else +# define null_ptr 0 +#endif + switch(t) { case BoolType: assert(!"consistentProperty for strings called with BoolType"); - return 0; + return std::pair(false, null_ptr); case StringType: return consistentStringProperty(lhs, rhs); case NumberMinType: @@ -4334,7 +4340,12 @@ const char* consistentProperty(const char *lhs, const char *rhs, return consistentNumberProperty(lhs, rhs, t); } assert(!"Unreachable!"); - return 0; + return std::pair(false, null_ptr); + +#if !defined(_MSC_VER) +#undef null_ptr +#endif + } template @@ -4506,7 +4517,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, ("INTERFACE_" + p).c_str(), 0); std::string reportEntry; - if (ifacePropContent) + if (ifaceIsSet) { reportEntry += " * Target \""; reportEntry += li->Target->GetName(); @@ -4519,11 +4530,12 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, { if (ifaceIsSet) { - PropertyType consistent = consistentProperty(propContent, + std::pair consistent = + consistentProperty(propContent, ifacePropContent, t); report += reportEntry; - report += compatibilityAgree(t, propContent != consistent); - if (!consistent) + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) { cmOStringStream e; e << "Property " << p << " on target \"" @@ -4535,7 +4547,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, } else { - propContent = consistent; + propContent = consistent.second; continue; } } @@ -4549,19 +4561,14 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, { propContent = impliedValue(propContent); - reportEntry += " * Target \""; - reportEntry += li->Target->GetName(); - reportEntry += "\" property value \""; - reportEntry += valueAsString(propContent); - reportEntry += "\" "; - if (ifaceIsSet) { - PropertyType consistent = consistentProperty(propContent, + std::pair consistent = + consistentProperty(propContent, ifacePropContent, t); report += reportEntry; - report += compatibilityAgree(t, propContent != consistent); - if (!consistent) + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) { cmOStringStream e; e << "Property " << p << " on target \"" @@ -4574,7 +4581,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, } else { - propContent = consistent; + propContent = consistent.second; continue; } } @@ -4590,11 +4597,12 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, { if (propInitialized) { - PropertyType consistent = consistentProperty(propContent, + std::pair consistent = + consistentProperty(propContent, ifacePropContent, t); report += reportEntry; - report += compatibilityAgree(t, propContent != consistent); - if (!consistent) + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) { cmOStringStream e; e << "The INTERFACE_" << p << " property of \"" @@ -4606,7 +4614,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, } else { - propContent = consistent; + propContent = consistent.second; continue; } } @@ -6003,7 +6011,8 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, << propsString << " property in the dependencies of target \"" << this->GetName() << "\". This is not allowed. A property may only require compatibility " - "in a boolean interpretation or a string interpretation, but not both."; + "in a boolean interpretation, a numeric minimum, a numeric maximum or a " + "string interpretation, but not a mixture."; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } } diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt index fdb163840..9467faed3 100644 --- a/Tests/AliasTarget/CMakeLists.txt +++ b/Tests/AliasTarget/CMakeLists.txt @@ -48,3 +48,25 @@ endif() add_library(iface INTERFACE) add_library(Alias::Iface ALIAS iface) + +get_target_property(_notAlias1 foo ALIASED_TARGET) +if (NOT DEFINED _notAlias1) + message(SEND_ERROR "_notAlias1 is not defined") +endif() +if (_notAlias1) + message(SEND_ERROR "_notAlias1 is defined, but foo is not an ALIAS") +endif() +if (NOT _notAlias1 STREQUAL _notAlias1-NOTFOUND) + message(SEND_ERROR "_notAlias1 not defined to a -NOTFOUND variant") +endif() + +get_property(_notAlias2 TARGET foo PROPERTY ALIASED_TARGET) +if (NOT DEFINED _notAlias2) + message(SEND_ERROR "_notAlias2 is not defined") +endif() +if (_notAlias2) + message(SEND_ERROR "_notAlias2 is defined, but foo is not an ALIAS") +endif() +if (NOT _notAlias2 STREQUAL _notAlias2-NOTFOUND) + message(SEND_ERROR "_notAlias2 not defined to a -NOTFOUND variant") +endif() diff --git a/Tests/CMakeCommands/add_compile_options/CMakeLists.txt b/Tests/CMakeCommands/add_compile_options/CMakeLists.txt index 1652cf665..995b32c28 100644 --- a/Tests/CMakeCommands/add_compile_options/CMakeLists.txt +++ b/Tests/CMakeCommands/add_compile_options/CMakeLists.txt @@ -12,3 +12,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") "DO_GNU_TESTS" ) endif() + +add_compile_options(-rtti) +add_library(imp UNKNOWN IMPORTED) +get_target_property(_res imp COMPILE_OPTIONS) +if (_res) + message(SEND_ERROR "add_compile_options populated the COMPILE_OPTIONS target property") +endif() diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index 900dbd028..14d40aa54 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -25,3 +25,10 @@ target_compile_definitions(consumer target_compile_definitions(consumer PRIVATE ) + +add_definitions(-DSOME_DEF) +add_library(imp UNKNOWN IMPORTED) +get_target_property(_res imp COMPILE_DEFINITIONS) +if (_res) + message(SEND_ERROR "add_definitions populated the COMPILE_DEFINITIONS target property") +endif() diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index 8a564c702..661bbaab6 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -62,3 +62,10 @@ target_include_directories(consumer target_include_directories(consumer SYSTEM PRIVATE ) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +add_library(imp UNKNOWN IMPORTED) +get_target_property(_res imp INCLUDE_DIRECTORIES) +if (_res) + message(SEND_ERROR "include_directories populated the INCLUDE_DIRECTORIES target property") +endif() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 063bd2da2..78dddd341 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2168,6 +2168,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestConfig/ScriptWithArgs.log" ) + ADD_TEST_MACRO(CMakeCommands.add_compile_options add_compile_options) ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries) ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories) ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions) diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt index f400f1335..9d4793d06 100644 --- a/Tests/ExportImport/Export/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt @@ -23,7 +23,10 @@ set_property(TARGET sharedlib PROPERTY INTERFACE_COMPILE_DEFINITIONS "SHAREDLIB_ add_library(sharediface INTERFACE) target_link_libraries(sharediface INTERFACE sharedlib) -install(TARGETS headeronly sharediface sharedlib +install(TARGETS headeronly sharediface + EXPORT expInterface +) +install(TARGETS sharedlib EXPORT expInterface RUNTIME DESTINATION bin LIBRARY DESTINATION lib NAMELINK_SKIP diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 9dd528919..7b99395bd 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -47,7 +47,6 @@ add_custom_target(generate_moc_input COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}" COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h" ) -# set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/myinterface.h" PROPERTIES GENERATED TRUE) add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp gadget.cpp $ diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt index 00445645c..e3efe2884 100644 --- a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt +++ b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt @@ -24,6 +24,28 @@ CMake Debug Log: \* Target "CompatibleInterface" property not set. + +CMake Debug Log: + Boolean compatibility of property "BOOL_PROP5" for target + "CompatibleInterface" \(result: "FALSE"\): + + \* Target "CompatibleInterface" property not set. + \* Target "iface1" property value "FALSE" \(Interface set\) ++ +CMake Debug Log: + Boolean compatibility of property "BOOL_PROP6" for target + "CompatibleInterface" \(result: "FALSE"\): + + \* Target "CompatibleInterface" property not set. + \* Target "iface1" property value "FALSE" \(Interface set\) + \* Target "iface2" property value "FALSE" \(Agree\) ++ +CMake Debug Log: + Boolean compatibility of property "BOOL_PROP7" for target + "CompatibleInterface" \(result: "FALSE"\): + + \* Target "CompatibleInterface" property is implied by use. + \* Target "iface1" property value "FALSE" \(Agree\) ++ CMake Debug Log: String compatibility of property "STRING_PROP1" for target "CompatibleInterface" \(result: "prop1"\): diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake b/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake index 3214d8eef..42a3af21d 100644 --- a/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake +++ b/Tests/RunCMake/CompatibleInterface/DebugProperties.cmake @@ -13,6 +13,9 @@ set_property(TARGET iface1 APPEND PROPERTY BOOL_PROP2 BOOL_PROP3 BOOL_PROP4 + BOOL_PROP5 + BOOL_PROP6 + BOOL_PROP7 ) set_property(TARGET iface1 APPEND PROPERTY COMPATIBLE_INTERFACE_STRING @@ -32,7 +35,7 @@ set_property(TARGET iface1 APPEND PROPERTY ) set(CMAKE_DEBUG_TARGET_PROPERTIES - BOOL_PROP1 BOOL_PROP2 BOOL_PROP3 BOOL_PROP4 + BOOL_PROP1 BOOL_PROP2 BOOL_PROP3 BOOL_PROP4 BOOL_PROP5 BOOL_PROP6 BOOL_PROP7 STRING_PROP1 STRING_PROP2 STRING_PROP3 NUMBER_MIN_PROP1 NUMBER_MIN_PROP2 NUMBER_MAX_PROP1 NUMBER_MAX_PROP2 @@ -40,6 +43,9 @@ set(CMAKE_DEBUG_TARGET_PROPERTIES set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP1 ON) set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP2 ON) +set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP5 OFF) +set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP6 OFF) +set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP7 OFF) set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP1 prop1) set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP2 prop2) set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MIN_PROP1 100) @@ -47,8 +53,15 @@ set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MIN_PROP2 200) set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MAX_PROP1 100) set_property(TARGET iface1 PROPERTY INTERFACE_NUMBER_MAX_PROP2 200) +add_library(iface2 INTERFACE) +set_property(TARGET iface2 PROPERTY INTERFACE_BOOL_PROP6 OFF) + +add_library(iface3 INTERFACE) + add_executable(CompatibleInterface empty.cpp) -target_link_libraries(CompatibleInterface iface1) +target_link_libraries(CompatibleInterface iface1 iface2 + $<$>:iface3> +) set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP2 ON) set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP3 ON) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceNumber-mismatched-use-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceNumber-mismatched-use-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceNumber-mismatched-use-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceNumber-mismatched-use-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceNumber-mismatched-use-stderr.txt new file mode 100644 index 000000000..723daec09 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceNumber-mismatched-use-stderr.txt @@ -0,0 +1,4 @@ +CMake Error: Property SOMEPROP on target "user" is +implied to be empty because it was used to determine the link libraries +already. The INTERFACE_SOMEPROP property on +dependency "foo" is in conflict. diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceNumber-mismatched-use.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceNumber-mismatched-use.cmake new file mode 100644 index 000000000..a064d7683 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceNumber-mismatched-use.cmake @@ -0,0 +1,9 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_NUMBER_MIN SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP 42) + +add_executable(user main.cpp) +target_link_libraries(user foo $<$,42>:bar>) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict-stderr.txt index 5a8f99df2..900e3f89e 100644 --- a/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict-stderr.txt +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict-stderr.txt @@ -2,4 +2,5 @@ CMake Error in CMakeLists.txt: Property "SOMETHING" appears in both the COMPATIBLE_INTERFACE_BOOL and the COMPATIBLE_INTERFACE_STRING property in the dependencies of target "user". This is not allowed. A property may only require compatibility in a - boolean interpretation or a string interpretation, but not both. + boolean interpretation, a numeric minimum, a numeric maximum or a string + interpretation, but not a mixture. diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict.cmake index 711368a80..4bae8042d 100644 --- a/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict.cmake +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Conflict.cmake @@ -1,9 +1,8 @@ add_library(foo UNKNOWN IMPORTED) -add_library(bar UNKNOWN IMPORTED) set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SOMETHING) set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING SOMETHING) add_executable(user main.cpp) -target_link_libraries(user foo bar) +target_link_libraries(user foo) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Min-Conflict-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Min-Conflict-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Min-Conflict-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Min-Conflict-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Min-Conflict-stderr.txt new file mode 100644 index 000000000..2cfbae476 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Min-Conflict-stderr.txt @@ -0,0 +1,7 @@ +CMake Error in CMakeLists.txt: + Property "OTHER" appears in both the COMPATIBLE_INTERFACE_BOOL, + COMPATIBLE_INTERFACE_NUMBER_MIN and the COMPATIBLE_INTERFACE_STRING + property in the dependencies of target "user". This is not allowed. A + property may only require compatibility in a boolean interpretation, a + numeric minimum, a numeric maximum or a string interpretation, but not a + mixture. diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Min-Conflict.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Min-Conflict.cmake new file mode 100644 index 000000000..164ffd9fc --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-Bool-Min-Conflict.cmake @@ -0,0 +1,9 @@ + +add_library(foo UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL OTHER) +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING OTHER) +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_NUMBER_MIN OTHER) + +add_executable(user main.cpp) +target_link_libraries(user foo) diff --git a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake index b87adc89f..0b9729bf2 100644 --- a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake @@ -7,8 +7,10 @@ run_cmake(InterfaceBool-builtin-prop) run_cmake(InterfaceString-mismatch-depends) run_cmake(InterfaceString-mismatch-depend-self) run_cmake(InterfaceString-mismatched-use) +run_cmake(InterfaceNumber-mismatched-use) run_cmake(InterfaceString-builtin-prop) run_cmake(InterfaceString-Bool-Conflict) +run_cmake(InterfaceString-Bool-Min-Conflict) run_cmake(DebugProperties) if (QT_QMAKE_EXECUTABLE}) diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake index 0d00b71c5..d76600c35 100644 --- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake @@ -5,3 +5,4 @@ run_cmake(target_commands) run_cmake(no_shared_libs) run_cmake(whitelist) run_cmake(genex_link) +run_cmake(add_dependencies) diff --git a/Tests/RunCMake/interface_library/add_dependencies-result.txt b/Tests/RunCMake/interface_library/add_dependencies-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/interface_library/add_dependencies-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/add_dependencies-stderr.txt b/Tests/RunCMake/interface_library/add_dependencies-stderr.txt new file mode 100644 index 000000000..c550b6869 --- /dev/null +++ b/Tests/RunCMake/interface_library/add_dependencies-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at add_dependencies.cmake:4 \(add_dependencies\): + add_dependencies Cannot add target-level dependencies to INTERFACE library + target "iface". + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/interface_library/add_dependencies.cmake b/Tests/RunCMake/interface_library/add_dependencies.cmake new file mode 100644 index 000000000..12cdfb4ff --- /dev/null +++ b/Tests/RunCMake/interface_library/add_dependencies.cmake @@ -0,0 +1,4 @@ + +add_library(foo empty.cpp) +add_library(iface INTERFACE) +add_dependencies(iface foo) diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index 5e0ef8777..aa9735eb3 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -11,8 +11,7 @@ #============================================================================= if(NOT CMake_SOURCE_DIR) set(CMakeHelp_STANDALONE 1) - cmake_minimum_required(VERSION 2.8.2 FATAL_ERROR) - set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required + cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR) get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH) get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH) include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake) diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py index 1955e4295..336c74aa3 100644 --- a/Utilities/Sphinx/cmake.py +++ b/Utilities/Sphinx/cmake.py @@ -12,6 +12,16 @@ import os import re +# Monkey patch for pygments reporting an error when generator expressions are +# used. +# https://bitbucket.org/birkenfeld/pygments-main/issue/942/cmake-generator-expressions-not-handled +from pygments.lexers import CMakeLexer +from pygments.token import Name, Operator +from pygments.lexer import bygroups +CMakeLexer.tokens["args"].append(('(\\$<)(.+?)(>)', + bygroups(Operator, Name.Variable, Operator))) + + from docutils.parsers.rst import Directive, directives from docutils.transforms import Transform try: