Skip to content

AutoMoc: Don't initialize already defined CMAKE_AUTOMOC_ variables

Jörg Bornemann requested to merge jobor/cmake:fix-24069 into master

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 (closed)
Topic-rename: automoc-var-init

Edited by Brad King

Merge request reports