summaryrefslogtreecommitdiff
path: root/Modules/CMakeGenericSystem.cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2022-11-16 10:28:45 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2022-11-16 10:38:53 +0100
commit70c721befb52c2b4b718656a80df00f50dc689c7 (patch)
treec575e10645d87720058376e313447be6c1876f52 /Modules/CMakeGenericSystem.cmake
parentb7ab39bf59c1b68140f1884676a2cfdaee2f7b41 (diff)
downloadcmake-70c721befb52c2b4b718656a80df00f50dc689c7.tar.gz
AutoMoc: Don't initialize already defined CMAKE_AUTOMOC_ variables
Setting the variables CMAKE_AUTOGEN_ORIGIN_DEPENDS, CMAKE_AUTOMOC_COMPILER_PREDEFINES, and CMAKE_AUTOMOC_MACRO_NAMES on the cmake command line did not work as expected. CMakeGenericSystem.cmake initialized these variables even if they were defined by the user. This led to the confusing situation where the cache variant of a variable had one value (defined on the command line) and the non-cache variant of a variable had a different value (defined in CMakeGenericSystem.cmake). Fix this by checking whether the variables are defined before setting their default values. Fixes: #24069
Diffstat (limited to 'Modules/CMakeGenericSystem.cmake')
-rw-r--r--Modules/CMakeGenericSystem.cmake12
1 files changed, 9 insertions, 3 deletions
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake
index e2925dc98e..77c1780326 100644
--- a/Modules/CMakeGenericSystem.cmake
+++ b/Modules/CMakeGenericSystem.cmake
@@ -30,12 +30,18 @@ set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
# LINK_LIBRARY_OVERRIDE_<LIBRARY> target properties
set(CMAKE_LINK_LIBRARY_USING_DEFAULT_SUPPORTED TRUE)
-set(CMAKE_AUTOGEN_ORIGIN_DEPENDS ON)
-set(CMAKE_AUTOMOC_COMPILER_PREDEFINES ON)
+if(NOT DEFINED CMAKE_AUTOGEN_ORIGIN_DEPENDS)
+ set(CMAKE_AUTOGEN_ORIGIN_DEPENDS ON)
+endif()
+if(NOT DEFINED CMAKE_AUTOMOC_COMPILER_PREDEFINES)
+ set(CMAKE_AUTOMOC_COMPILER_PREDEFINES ON)
+endif()
if(NOT DEFINED CMAKE_AUTOMOC_PATH_PREFIX)
set(CMAKE_AUTOMOC_PATH_PREFIX OFF)
endif()
-set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_NAMESPACE" "Q_NAMESPACE_EXPORT")
+if(NOT DEFINED CMAKE_AUTOMOC_MACRO_NAMES)
+ set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_NAMESPACE" "Q_NAMESPACE_EXPORT")
+endif()
# basically all general purpose OSs support shared libs
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)