summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-10-02 12:01:02 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-10-02 12:01:21 (GMT)
commit275b4a53eef8d10af069fbcb0d1d9bc4d0b5f6d5 (patch)
tree1863a4e43cd68b578996eade2522c55c0d90e0e9
parent9288c291cb56f75ad0ed8a86b0882d1998c8b79d (diff)
parent6bbc1e775d46cbe1ad97ecea0862d030680b332a (diff)
downloadCMake-275b4a53eef8d10af069fbcb0d1d9bc4d0b5f6d5.zip
CMake-275b4a53eef8d10af069fbcb0d1d9bc4d0b5f6d5.tar.gz
CMake-275b4a53eef8d10af069fbcb0d1d9bc4d0b5f6d5.tar.bz2
Merge topic 'autogen-predefs'
6bbc1e77 Autogen: Add release notes for (CMAKE_)AUTOMOC_COMPILER_PREDEFINES 75c98b5e Autogen: Doc: Add documentation for (CMAKE_)AUTOMOC_COMPILER_PREDEFINES 1d7f099d Autogen: Add (CMAKE_)AUTOMOC_COMPILER_PREDEFINES Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1328
-rw-r--r--Help/manual/cmake-properties.7.rst1
-rw-r--r--Help/manual/cmake-variables.7.rst2
-rw-r--r--Help/prop_tgt/AUTOMOC.rst3
-rw-r--r--Help/prop_tgt/AUTOMOC_COMPILER_PREDEFINES.rst24
-rw-r--r--Help/release/dev/autogen-predefs.rst11
-rw-r--r--Help/variable/CMAKE_AUTOMOC_COMPILER_PREDEFINES.rst8
-rw-r--r--Help/variable/CMAKE_LANG_COMPILER_PREDEFINES_COMMAND.rst8
-rw-r--r--Modules/CMakeGenericSystem.cmake1
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx13
-rw-r--r--Source/cmTarget.cxx1
10 files changed, 67 insertions, 5 deletions
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 0adfff6..dd59a00 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -122,6 +122,7 @@ Properties on Targets
/prop_tgt/ARCHIVE_OUTPUT_NAME
/prop_tgt/AUTOGEN_BUILD_DIR
/prop_tgt/AUTOGEN_TARGET_DEPENDS
+ /prop_tgt/AUTOMOC_COMPILER_PREDEFINES
/prop_tgt/AUTOMOC_DEPEND_FILTERS
/prop_tgt/AUTOMOC_MACRO_NAMES
/prop_tgt/AUTOMOC_MOC_OPTIONS
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index cba81e5..66d3049 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -270,6 +270,7 @@ Variables that Control the Build
/variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY
/variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY_CONFIG
/variable/CMAKE_AUTOMOC
+ /variable/CMAKE_AUTOMOC_COMPILER_PREDEFINES
/variable/CMAKE_AUTOMOC_DEPEND_FILTERS
/variable/CMAKE_AUTOMOC_MACRO_NAMES
/variable/CMAKE_AUTOMOC_MOC_OPTIONS
@@ -398,6 +399,7 @@ Variables for Languages
/variable/CMAKE_LANG_COMPILER_LOADED
/variable/CMAKE_LANG_COMPILER_TARGET
/variable/CMAKE_LANG_COMPILER_VERSION
+ /variable/CMAKE_LANG_COMPILER_PREDEFINES_COMMAND
/variable/CMAKE_LANG_COMPILE_OBJECT
/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY
/variable/CMAKE_LANG_CREATE_SHARED_MODULE
diff --git a/Help/prop_tgt/AUTOMOC.rst b/Help/prop_tgt/AUTOMOC.rst
index 641ac09..9e5261f 100644
--- a/Help/prop_tgt/AUTOMOC.rst
+++ b/Help/prop_tgt/AUTOMOC.rst
@@ -76,6 +76,9 @@ Additional macro names to search for can be added to :prop_tgt:`AUTOMOC_MACRO_NA
Additional ``moc`` dependency file names can be extracted from source code
by using :prop_tgt:`AUTOMOC_DEPEND_FILTERS`.
+Compiler pre definitions for ``moc`` are written to a ``moc_predefs.h`` file
+which is controlled by :prop_tgt:`AUTOMOC_COMPILER_PREDEFINES`.
+
Source C++ files can be excluded from :prop_tgt:`AUTOMOC` processing by
enabling :prop_sf:`SKIP_AUTOMOC` or the broader :prop_sf:`SKIP_AUTOGEN`.
diff --git a/Help/prop_tgt/AUTOMOC_COMPILER_PREDEFINES.rst b/Help/prop_tgt/AUTOMOC_COMPILER_PREDEFINES.rst
new file mode 100644
index 0000000..57a647f
--- /dev/null
+++ b/Help/prop_tgt/AUTOMOC_COMPILER_PREDEFINES.rst
@@ -0,0 +1,24 @@
+AUTOMOC_COMPILER_PREDEFINES
+---------------------------
+
+Boolean value used by :prop_tgt:`AUTOMOC` to determine if the
+compiler pre definitions file ``moc_predefs.h`` should be generated.
+
+CMake generates a ``moc_predefs.h`` file with compiler pre definitions
+from the output of the command defined in
+:variable:`CMAKE_CXX_COMPILER_PREDEFINES_COMMAND <CMAKE_<LANG>_COMPILER_PREDEFINES_COMMAND>`
+when
+
+- :prop_tgt:`AUTOMOC` is enabled,
+- :prop_tgt:`AUTOMOC_COMPILER_PREDEFINES` is enabled,
+- :variable:`CMAKE_CXX_COMPILER_PREDEFINES_COMMAND <CMAKE_<LANG>_COMPILER_PREDEFINES_COMMAND>` isn't empty and
+- the Qt version is greater or equal 5.8.
+
+The ``moc_predefs.h`` file, which is generated in :prop_tgt:`AUTOGEN_BUILD_DIR`,
+is passed to ``moc`` as the argument to the ``--include`` option.
+
+By default :prop_tgt:`AUTOMOC_COMPILER_PREDEFINES` is initialized from
+:variable:`CMAKE_AUTOMOC_COMPILER_PREDEFINES`, which is ON by default.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
diff --git a/Help/release/dev/autogen-predefs.rst b/Help/release/dev/autogen-predefs.rst
new file mode 100644
index 0000000..c390e2a
--- /dev/null
+++ b/Help/release/dev/autogen-predefs.rst
@@ -0,0 +1,11 @@
+autogen-predefs
+---------------
+
+* When using :prop_tgt:`AUTOMOC`, the new variable
+ :variable:`CMAKE_AUTOMOC_COMPILER_PREDEFINES` allows to default
+ enable or disable the generation of the compiler pre definitions file
+ ``moc_predefs.h``.
+
+* When using :prop_tgt:`AUTOMOC`, the new boolean target property
+ :prop_tgt:`AUTOMOC_COMPILER_PREDEFINES` allows to enable or disable the
+ generation of the compiler pre definitions file ``moc_predefs.h``.
diff --git a/Help/variable/CMAKE_AUTOMOC_COMPILER_PREDEFINES.rst b/Help/variable/CMAKE_AUTOMOC_COMPILER_PREDEFINES.rst
new file mode 100644
index 0000000..7e1c53d
--- /dev/null
+++ b/Help/variable/CMAKE_AUTOMOC_COMPILER_PREDEFINES.rst
@@ -0,0 +1,8 @@
+CMAKE_AUTOMOC_COMPILER_PREDEFINES
+---------------------------------
+
+This variable is used to initialize the :prop_tgt:`AUTOMOC_COMPILER_PREDEFINES`
+property on all the targets. See that target property for additional
+information.
+
+By default it is ON.
diff --git a/Help/variable/CMAKE_LANG_COMPILER_PREDEFINES_COMMAND.rst b/Help/variable/CMAKE_LANG_COMPILER_PREDEFINES_COMMAND.rst
new file mode 100644
index 0000000..e050f43
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_COMPILER_PREDEFINES_COMMAND.rst
@@ -0,0 +1,8 @@
+CMAKE_<LANG>_COMPILER_PREDEFINES_COMMAND
+----------------------------------------
+
+Command that outputs the compiler pre definitions.
+
+See :prop_tgt:`AUTOMOC` which uses
+:variable:`CMAKE_CXX_COMPILER_PREDEFINES_COMMAND <CMAKE_<LANG>_COMPILER_PREDEFINES_COMMAND>`
+to generate the :prop_tgt:`AUTOMOC_COMPILER_PREDEFINES`.
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake
index 3951b2c..324a279 100644
--- a/Modules/CMakeGenericSystem.cmake
+++ b/Modules/CMakeGenericSystem.cmake
@@ -23,6 +23,7 @@ set(CMAKE_DL_LIBS "dl")
set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
+set(CMAKE_AUTOMOC_COMPILER_PREDEFINES ON)
set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_NAMESPACE")
# basically all general purpose OSs support shared libs
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index c6f0a51..217865b 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -363,11 +363,14 @@ static void SetupAutoTargetMoc(cmQtAutoGenDigest const& digest,
AddDefinitionEscaped(makefile, "_moc_depend_filters",
GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS"));
- if (QtVersionGreaterOrEqual(digest.QtVersionMajor, digest.QtVersionMinor, 5,
- 8)) {
- AddDefinitionEscaped(
- makefile, "_moc_predefs_cmd",
- makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND"));
+ // Compiler predefines
+ if (target->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES")) {
+ if (QtVersionGreaterOrEqual(digest.QtVersionMajor, digest.QtVersionMinor,
+ 5, 8)) {
+ AddDefinitionEscaped(
+ makefile, "_moc_predefs_cmd",
+ makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND"));
+ }
}
// Moc includes and compile definitions
{
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 49b0664..7a3cc76 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -244,6 +244,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
this->SetPropertyDefault("AUTOMOC", nullptr);
this->SetPropertyDefault("AUTOUIC", nullptr);
this->SetPropertyDefault("AUTORCC", nullptr);
+ this->SetPropertyDefault("AUTOMOC_COMPILER_PREDEFINES", nullptr);
this->SetPropertyDefault("AUTOMOC_DEPEND_FILTERS", nullptr);
this->SetPropertyDefault("AUTOMOC_MACRO_NAMES", nullptr);
this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", nullptr);