Bug 500106

Summary: Breeze fails to build with Qt 6.8.2 due to double definition of a CMake target during configuration
Product: [Plasma] Breeze Reporter: Hernan Martinez <hernan.c.martinez>
Component: generalAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED FIXED    
Severity: major CC: georgefb899, julius.kuenzel, nate, uhhadd
Priority: NOR    
Version First Reported In: 6.3.0   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Hernan Martinez 2025-02-15 04:47:05 UTC
STEPS TO REPRODUCE
1. Using MSYS2's UCRT64 environment configure Breeze for building with CMake

OBSERVED RESULT
  -- The C compiler identification is Clang 19.1.7
  -- The CXX compiler identification is Clang 19.1.7
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: D:/M/msys64/clang64/bin/clang.exe - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: D:/M/msys64/clang64/bin/clang++.exe - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Looking for __GLIBC__
  -- Looking for __GLIBC__ - not found
  -- Performing Test HAVE_DATE_TIME
  -- Performing Test HAVE_DATE_TIME - Success
  -- Check if compiler accepts -pthread
  -- Check if compiler accepts -pthread - yes
  Installing in /clang64. Run C:/_/B/src/build-CLANG64/prefix.sh to set the environment for breeze.
  -- Performing Test HAVE_STDATOMIC
  -- Performing Test HAVE_STDATOMIC - Success
  -- Found WrapAtomic: TRUE
  -- Found WrapVulkanHeaders: D:/M/msys64/clang64/include
  -- Found KF6CoreAddons: D:/M/msys64/clang64/lib/cmake/KF6CoreAddons/KF6CoreAddonsConfig.cmake (found version "6.10.0")
  -- Found KF6ColorScheme: D:/M/msys64/clang64/lib/cmake/KF6ColorScheme/KF6ColorSchemeConfig.cmake (found version "6.10.0")
  -- Found KF6Config: D:/M/msys64/clang64/lib/cmake/KF6Config/KF6ConfigConfig.cmake (found version "6.10.0")
  -- Found KF6GuiAddons: D:/M/msys64/clang64/lib/cmake/KF6GuiAddons/KF6GuiAddonsConfig.cmake (found version "6.10.0")
  -- Found Gettext: D:/M/msys64/clang64/bin/msgmerge.exe (found version "0.23.1")
  -- Found KF6I18n: D:/M/msys64/clang64/lib/cmake/KF6I18n/KF6I18nConfig.cmake (found version "6.10.0")
  -- Found KF6IconThemes: D:/M/msys64/clang64/lib/cmake/KF6IconThemes/KF6IconThemesConfig.cmake (found version "6.10.0")
  -- Found KF6WindowSystem: D:/M/msys64/clang64/lib/cmake/KF6WindowSystem/KF6WindowSystemConfig.cmake (found version "6.10.0")
  -- Found KF6: success (found suitable version "6.10.0", minimum required is "6.10.0") found components: CoreAddons ColorScheme Config GuiAddons I18n IconThemes WindowSystem
  Installing in /clang64. Run C:/_/B/src/build-CLANG64/prefix.sh to set the environment for breeze.
  CMake Error at D:/M/msys64/clang64/lib/cmake/Qt6EntryPointPrivate/Qt6EntryPointMinGW32Target.cmake:4 (add_library):
    add_library cannot create imported target "EntryPointMinGW32" because
    another target with the same name already exists.
  Call Stack (most recent call first):
    D:/M/msys64/clang64/lib/cmake/Qt6EntryPointPrivate/Qt6EntryPointPrivateConfig.cmake:140 (include)
    D:/M/msys64/clang64/share/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
    D:/M/msys64/clang64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:145 (find_dependency)
    D:/M/msys64/clang64/lib/cmake/Qt6Core/Qt6CoreDependencies.cmake:46 (_qt_internal_find_qt_dependencies)
    D:/M/msys64/clang64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake:45 (include)
    D:/M/msys64/clang64/lib/cmake/Qt6/Qt6Config.cmake:190 (find_package)
    cursors/src/kcursorgen/CMakeLists.txt:2 (find_package)
  
  
  CMake Error at D:/M/msys64/clang64/lib/cmake/Qt6EntryPointPrivate/Qt6EntryPointMinGW32Target.cmake:6 (target_link_libraries):
    Cannot specify link libraries for target "EntryPointMinGW32" which is not
    built by this project.
  Call Stack (most recent call first):
    D:/M/msys64/clang64/lib/cmake/Qt6EntryPointPrivate/Qt6EntryPointPrivateConfig.cmake:140 (include)
    D:/M/msys64/clang64/share/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
    D:/M/msys64/clang64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:145 (find_dependency)
    D:/M/msys64/clang64/lib/cmake/Qt6Core/Qt6CoreDependencies.cmake:46 (_qt_internal_find_qt_dependencies)
    D:/M/msys64/clang64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake:45 (include)
    D:/M/msys64/clang64/lib/cmake/Qt6/Qt6Config.cmake:190 (find_package)
    cursors/src/kcursorgen/CMakeLists.txt:2 (find_package)
  
  
  CMake Warning at D:/M/msys64/clang64/lib/cmake/Qt6/Qt6Config.cmake:190 (find_package):
    Found package configuration file:
  
      D:/M/msys64/clang64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
  
    but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
    NOT FOUND.
  Call Stack (most recent call first):
    cursors/src/kcursorgen/CMakeLists.txt:2 (find_package)
  
  
  -- Configuring incomplete, errors occurred!
 -- The C compiler identification is Clang 19.1.7
  -- The CXX compiler identification is Clang 19.1.7
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: D:/M/msys64/clang64/bin/clang.exe - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: D:/M/msys64/clang64/bin/clang++.exe - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Looking for __GLIBC__
  -- Looking for __GLIBC__ - not found
  -- Performing Test HAVE_DATE_TIME
  -- Performing Test HAVE_DATE_TIME - Success
  -- Check if compiler accepts -pthread
  -- Check if compiler accepts -pthread - yes
  Installing in /clang64. Run C:/_/B/src/build-CLANG64/prefix.sh to set the environment for breeze.
  -- Performing Test HAVE_STDATOMIC
  -- Performing Test HAVE_STDATOMIC - Success
  -- Found WrapAtomic: TRUE
  -- Found WrapVulkanHeaders: D:/M/msys64/clang64/include
  -- Found KF6CoreAddons: D:/M/msys64/clang64/lib/cmake/KF6CoreAddons/KF6CoreAddonsConfig.cmake (found version "6.10.0")
  -- Found KF6ColorScheme: D:/M/msys64/clang64/lib/cmake/KF6ColorScheme/KF6ColorSchemeConfig.cmake (found version "6.10.0")
  -- Found KF6Config: D:/M/msys64/clang64/lib/cmake/KF6Config/KF6ConfigConfig.cmake (found version "6.10.0")
  -- Found KF6GuiAddons: D:/M/msys64/clang64/lib/cmake/KF6GuiAddons/KF6GuiAddonsConfig.cmake (found version "6.10.0")
  -- Found Gettext: D:/M/msys64/clang64/bin/msgmerge.exe (found version "0.23.1")
  -- Found KF6I18n: D:/M/msys64/clang64/lib/cmake/KF6I18n/KF6I18nConfig.cmake (found version "6.10.0")
  -- Found KF6IconThemes: D:/M/msys64/clang64/lib/cmake/KF6IconThemes/KF6IconThemesConfig.cmake (found version "6.10.0")
  -- Found KF6WindowSystem: D:/M/msys64/clang64/lib/cmake/KF6WindowSystem/KF6WindowSystemConfig.cmake (found version "6.10.0")
  -- Found KF6: success (found suitable version "6.10.0", minimum required is "6.10.0") found components: CoreAddons ColorScheme Config GuiAddons I18n IconThemes WindowSystem
  Installing in /clang64. Run C:/_/B/src/build-CLANG64/prefix.sh to set the environment for breeze.
  CMake Error at D:/M/msys64/clang64/lib/cmake/Qt6EntryPointPrivate/Qt6EntryPointMinGW32Target.cmake:4 (add_library):
    add_library cannot create imported target "EntryPointMinGW32" because
    another target with the same name already exists.
  Call Stack (most recent call first):
    D:/M/msys64/clang64/lib/cmake/Qt6EntryPointPrivate/Qt6EntryPointPrivateConfig.cmake:140 (include)
    D:/M/msys64/clang64/share/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
    D:/M/msys64/clang64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:145 (find_dependency)
    D:/M/msys64/clang64/lib/cmake/Qt6Core/Qt6CoreDependencies.cmake:46 (_qt_internal_find_qt_dependencies)
    D:/M/msys64/clang64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake:45 (include)
    D:/M/msys64/clang64/lib/cmake/Qt6/Qt6Config.cmake:190 (find_package)
    cursors/src/kcursorgen/CMakeLists.txt:2 (find_package)
  
  
  CMake Error at D:/M/msys64/clang64/lib/cmake/Qt6EntryPointPrivate/Qt6EntryPointMinGW32Target.cmake:6 (target_link_libraries):
    Cannot specify link libraries for target "EntryPointMinGW32" which is not
    built by this project.
  Call Stack (most recent call first):
    D:/M/msys64/clang64/lib/cmake/Qt6EntryPointPrivate/Qt6EntryPointPrivateConfig.cmake:140 (include)
    D:/M/msys64/clang64/share/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
    D:/M/msys64/clang64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:145 (find_dependency)
    D:/M/msys64/clang64/lib/cmake/Qt6Core/Qt6CoreDependencies.cmake:46 (_qt_internal_find_qt_dependencies)
    D:/M/msys64/clang64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake:45 (include)
    D:/M/msys64/clang64/lib/cmake/Qt6/Qt6Config.cmake:190 (find_package)
    cursors/src/kcursorgen/CMakeLists.txt:2 (find_package)
  
  
  CMake Warning at D:/M/msys64/clang64/lib/cmake/Qt6/Qt6Config.cmake:190 (find_package):
    Found package configuration file:
  
      D:/M/msys64/clang64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
  
    but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
    NOT FOUND.
  Call Stack (most recent call first):
    cursors/src/kcursorgen/CMakeLists.txt:2 (find_package)
  
  
  -- Configuring incomplete, errors occurred!

EXPECTED RESULT
The project is correctly configured for building.

SOFTWARE/OS VERSIONS
Windows: 11
KDE Plasma Version: 6.3.0
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.2

ADDITIONAL INFORMATION
This is my suspcion:
-----------------------------------------------------------------------------------------------------
    unset(QUERY_EXECUTABLE CACHE)
endfunction()   < ----  #1 Once we get here, Qt6Core_FOUND is set to 1, but this line clears it
if(BUILD_QT6)
    build_Qt6()
endif()

function(build_colors_and_cursors)
    # While it is technically not 100% correct to use versionless
    # KDEInstallDirs while (maybe) building for both Qt versions,
    # it doesn't really matter at the end, because colors and cursors
    # only use ICONDIR and DATADIR which both do not depend on the version
    include(KDEInstallDirs)
    add_subdirectory(colors)
    add_subdirectory(cursors) < --- #3 This looks for Qt6:Core again, with an unset `Qt6Core_FOUND` which in turn gets to that point where Qt6EntryPointPrivateConfig.cmake is called again.
endfunction()

build_colors_and_cursors() <----- #2 this is called
Comment 1 Hernan Martinez 2025-02-15 04:48:05 UTC
This is reproducible with both CLANG64 and UCRT64 envitonments.
Comment 2 george fb 2025-02-22 14:36:56 UTC
https://stackoverflow.com/questions/36724768/cmake-weird-side-effects-when-find-package-is-called-from-function-as-opposed

It builds when changing build_Qt6 function to a macro.
Comment 3 Julius Künzel 2025-02-24 20:41:57 UTC
See https://invent.kde.org/plasma/breeze/-/merge_requests/526
Comment 4 Julius Künzel 2025-02-26 09:05:35 UTC
Git commit cd3c4778a881bf66800542213da51806a9a4f3b0 by Julius Künzel.
Committed on 24/02/2025 at 19:39.
Pushed by jlskuz into branch 'master'.

Fix Qt6 build regression with MinGW

!476 introduced a find_package call for Qt6 in subdir while it was already found previously in the toplevel CMakeLists.txt (implicitely via eg. QtWidgets). With MinGW this failed:

```
CMake Error at C:/gitlab/craft/windows-mingw_64-gcc/lib/cmake/Qt6EntryPointPrivate/Qt6EntryPointMinGW32Target.cmake:4 (add_library):
add_library cannot create imported target "EntryPointMinGW32" because
another target with the same name already exists.
[...]
Cannot specify link libraries for target "EntryPointMinGW32" which is not
built by this project.
[...]
CMake Warning at C:/gitlab/craft/windows-mingw_64-gcc/lib/cmake/Qt6/Qt6Config.cmake:181 (find_package):
Found package configuration file:
C:/gitlab/craft/windows-mingw_64-gcc/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
NOT FOUND.
Call Stack (most recent call first):
cursors/src/kcursorgen/CMakeLists.txt:2 (find_package)
```

M  +1    -1    CMakeLists.txt
M  +0    -1    cursors/src/kcursorgen/CMakeLists.txt

https://invent.kde.org/plasma/breeze/-/commit/cd3c4778a881bf66800542213da51806a9a4f3b0
Comment 5 Julius Künzel 2025-02-28 07:59:52 UTC
Git commit 58cebc1b298d4491ae4862fa59af5059616ed0e4 by Julius Künzel.
Committed on 28/02/2025 at 07:59.
Pushed by jlskuz into branch 'Plasma/6.3'.

Fix Qt6 build regression with MinGW

!476 introduced a find_package call for Qt6 in subdir while it was already found previously in the toplevel CMakeLists.txt (implicitely via eg. QtWidgets). With MinGW this failed:

```
CMake Error at C:/gitlab/craft/windows-mingw_64-gcc/lib/cmake/Qt6EntryPointPrivate/Qt6EntryPointMinGW32Target.cmake:4 (add_library):
add_library cannot create imported target "EntryPointMinGW32" because
another target with the same name already exists.
[...]
Cannot specify link libraries for target "EntryPointMinGW32" which is not
built by this project.
[...]
CMake Warning at C:/gitlab/craft/windows-mingw_64-gcc/lib/cmake/Qt6/Qt6Config.cmake:181 (find_package):
Found package configuration file:
C:/gitlab/craft/windows-mingw_64-gcc/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
NOT FOUND.
Call Stack (most recent call first):
cursors/src/kcursorgen/CMakeLists.txt:2 (find_package)
```

M  +1    -1    CMakeLists.txt
M  +0    -1    cursors/src/kcursorgen/CMakeLists.txt

https://invent.kde.org/plasma/breeze/-/commit/58cebc1b298d4491ae4862fa59af5059616ed0e4