CMake CONFIG Search Mode Resulting in CMP0107 Error (Issue #25671)

19 views
Skip to first unread message

woopelderly

unread,
Jul 30, 2025, 10:28:37 AMJul 30
to wx-...@googlegroups.com, Subscribed
woopelderly created an issue (wxWidgets/wxWidgets#25671)

Build System Used

I build wxWidgets and/or my application using:

  • [ x ] CMake
  • configure
  • mingw32-make with makefile.gcc
  • [ x ] MSBuild (Microsoft Visual Studio solution file)
  • nmake with makefile.vc
  • Xcode

Full powershell commandline: rm -r -Force cmake ; cmake -B cmake ; cmake --build cmake --parallel

Full log for CMake configure step:
cmake-configure-log.txt

Description

The Error

In the CMake configure step, I get an error from CMake Policy CMP0107.

CMake Error at .../vcpkg/scripts/buildsystems/vcpkg.cmake:639 (_add_library):
  _add_library cannot create ALIAS target "wx::base" because another target
  with the same name already exists.

I use vcpkg to get wxWidget's sources.

In the build/cmake/wxWidgetsConfig.cmake.in file, line 129, with CMP0107 set to NEW my project errors.

Minimal Example that duplicates the problem

This zip folder contains a minimal project example that creates the error (assuming you have an environment variable called VCPKG_ROOT set to where vcpkg is at on your system).

minimal_example.zip

The problem occurs when wxWidgets was found with find_package's CONFIG search mode and then target_link_libraries is called from within a call from add_subdirectory and also called in the top level CMakeLists.txt.

Possible Solution

One work-around I found is to check if the TARGET exists before attempting to create an alias, like this (from build/cmake/wxWidgetsConfig.cmake.in file, line 129-ish):

...
        else()
            if( NOT TARGET wx::${name})
                add_library(wx::${name} ALIAS wx::${libname})
            endif()
        endif()
...

Would that be a fix you would consider making to deal with CMP0107? Or maybe there is a better solution? I am by no means a CMake expert.

Platform and version information

  • wxWidgets version you are building: 3.2.6
  • wxWidgets port you are building: wxMSW
  • OS and its version: Windows 11 Enterprise 10.0.22631 Build 22631
  • Compiler being used: Visual C++ 2022 00476-80000-00000-AA078, Visual Studio 17.14.6
  • Non-default compiler options, if any : n/a
  • CMake version: 3.31.2


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25671@github.com>

woopelderly

unread,
Sep 24, 2025, 12:07:37 PM (18 hours ago) Sep 24
to wx-...@googlegroups.com, Subscribed
woopelderly left a comment (wxWidgets/wxWidgets#25671)

Looks like this was fixed recently in PR #25796
Thank you @MaartenBent !
Though I'm not sure how to see which version of wxWidgets this will be available in....


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25671/3329697827@github.com>

woopelderly

unread,
Sep 24, 2025, 12:08:59 PM (18 hours ago) Sep 24
to wx-...@googlegroups.com, Subscribed

Closed #25671 as completed.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/25671/issue_event/19896730208@github.com>

Maarten

unread,
Sep 24, 2025, 1:10:56 PM (17 hours ago) Sep 24
to wx-...@googlegroups.com, Subscribed
MaartenBent left a comment (wxWidgets/wxWidgets#25671)

Indeed, for now it is only fixed in the development branch for wx3.3(.2).
But I'll backport CMake improvements to 3.2 as well, before 3.2.9 gets released.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25671/3329908830@github.com>

Reply all
Reply to author
Forward
0 new messages