diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2022-11-16 09:28:45 (GMT) |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2022-11-16 09:38:53 (GMT) |
commit | 70c721befb52c2b4b718656a80df00f50dc689c7 (patch) | |
tree | c575e10645d87720058376e313447be6c1876f52 | |
parent | b7ab39bf59c1b68140f1884676a2cfdaee2f7b41 (diff) | |
download | CMake-70c721befb52c2b4b718656a80df00f50dc689c7.zip CMake-70c721befb52c2b4b718656a80df00f50dc689c7.tar.gz CMake-70c721befb52c2b4b718656a80df00f50dc689c7.tar.bz2 |
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
-rw-r--r-- | Modules/CMakeGenericSystem.cmake | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index e2925dc..77c1780 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) |