CMake: Install cmake files into a versioned directory (PR #25757)

35 views
Skip to first unread message

Chris Mayo

unread,
Sep 2, 2025, 2:29:56 PM (6 days ago) Sep 2
to wx-...@googlegroups.com, Subscribed

Under wxBUILD_INSTALL_LIBRARY_DIR.


To allow both wxWidgets 3.2 and 3.3 to be installed at the same time. That seems like it is going to be useful - I tried compiling 2 applications against 3.3 and both failed, although I could force one to complete using -DwxNO_REQUIRE_LITERAL_MSGIDS.

CMake can handle this, including finding a specific version e.g.:

cmake_minimum_required(VERSION 3.10)
project(test-wx-cmake)
find_package(wxWidgets 3.3 REQUIRED COMPONENTS net core base CONFIG)
message("wxWidgets_VERSION " ${wxWidgets_VERSION})

You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/25757

Commit Summary

  • 502a839 CMake: Install cmake files into a versioned directory

File Changes

(1 file)

Patch Links:


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/pull/25757@github.com>

VZ

unread,
Sep 2, 2025, 5:32:16 PM (6 days ago) Sep 2
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25757)

Just in case you didn't notice it, these changes result in many CI errors.


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/pull/25757/c3246863200@github.com>

Chris Mayo

unread,
Sep 3, 2025, 2:35:28 PM (5 days ago) Sep 3
to wx-...@googlegroups.com, Push

@cjmayo pushed 1 commit.

  • 3d2185b CMake: Fix wx_get_install_dir on MS Windows


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25757/before/502a8393575f6ec977778b5f9a2a3c6e2a8d8da7/after/3d2185bbe94af10f04416400819d0f6a60479458@github.com>

Chris Mayo

unread,
Sep 3, 2025, 2:51:46 PM (5 days ago) Sep 3
to wx-...@googlegroups.com, Subscribed
cjmayo left a comment (wxWidgets/wxWidgets#25757)

Installation fixed on MS Windows.

Just MSW/MSVC wxMSW finding the files when testing now.


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/pull/25757/c3250381124@github.com>

Maarten

unread,
Sep 3, 2025, 4:22:52 PM (5 days ago) Sep 3
to wx-...@googlegroups.com, Subscribed
MaartenBent left a comment (wxWidgets/wxWidgets#25757)

I think it fails now because it installs the cmake files in lib/vc_x64_lib/cmake/wxWidgets-3.3. It should be in lib/cmake/wxWidgets-3.3. Otherwise the default search rules won't find it.

So in this case wx_get_install_dir should not append wxPLATFORM_LIB_DIR.

Maybe you can temporary disable wxBUILD_INSTALL_PLATFORM_SUBDIR so it doesn't get added.

set(install_subdir_temp ${wxBUILD_INSTALL_PLATFORM_SUBDIR})
set(wxBUILD_INSTALL_PLATFORM_SUBDIR OFF)
wx_get_install_dir(library "lib")
set(wxBUILD_INSTALL_PLATFORM_SUBDIR ${install_subdir_temp})

Or alternatively add a 3th parameter to wx_get_install_dir with TRUE/FALSE to indicate if it should be added.


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/pull/25757/c3250657361@github.com>

Chris Mayo

unread,
Sep 4, 2025, 2:23:30 PM (4 days ago) Sep 4
to wx-...@googlegroups.com, Push

@cjmayo pushed 1 commit.

  • b4b3fa6 CMake: Add a wx_get_build_install_dir macro


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25757/before/3d2185bbe94af10f04416400819d0f6a60479458/after/b4b3fa65d1b3bf3cb11c43a4114c45c1dab78afb@github.com>

Chris Mayo

unread,
Sep 4, 2025, 2:25:39 PM (4 days ago) Sep 4
to wx-...@googlegroups.com, Subscribed
cjmayo left a comment (wxWidgets/wxWidgets#25757)

As far as I can see you can't have default values for arguments. I suggest splitting into two macros instead, new commit:

CMake: Add a wx_get_build_install_dir macro

On MSW/MSVC with wxMSW .cmake files were being installed into:
C:/Program Files (x86)/wxWidgets/lib/vc_x64_dll/cmake/wxWidgets-3.3/

which is not in the search path.

Add a wx_get_build_install_dir macro which allows a directory to be
retrived without wxPLATFORM_LIB_DIR appeneded, even on platforms that
use it.


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/pull/25757/c3255009566@github.com>

VZ

unread,
Sep 6, 2025, 3:10:49 PM (2 days ago) Sep 6
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25757)

Thinking more about this, I don't know if we're really supposed to do this, shouldn't it be possible to use 3.3 CMake file to find both 3.3 and 3.2? And could this break something relying on finding the files in the directory without version in it? And which version will be used if there is 3.2 version of CMake files in the unversioned directory and 3.3 one in the versioned directory?

On an unrelated note, if you find any unintentional (i.e. not documented on the top of the change log) incompatible changes in 3.3, please open issues for them.


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/pull/25757/c3263060487@github.com>

Chris Mayo

unread,
Sep 7, 2025, 2:13:07 PM (18 hours ago) Sep 7
to wx-...@googlegroups.com, Subscribed
cjmayo left a comment (wxWidgets/wxWidgets#25757)

Thinking more about this, I don't know if we're really supposed to do this, shouldn't it be possible to use 3.3 CMake file to find both 3.3 and 3.2?

No, they are unique per version. Just wxWidgetsConfigVersion.cmake for example:

@@ -10,13 +10,13 @@
 # The variable CVF_VERSION must be set before calling configure_file().
 
 
-set(PACKAGE_VERSION "3.2.8")
+set(PACKAGE_VERSION "3.3.1")
 
 if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
   set(PACKAGE_VERSION_COMPATIBLE FALSE)
 else()
 
-  if("3.2.8" MATCHES "^([0-9]+)\\.([0-9]+)")
+  if("3.3.1" MATCHES "^([0-9]+)\\.([0-9]+)")
     set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
     set(CVF_VERSION_MINOR "${CMAKE_MATCH_2}")
 
@@ -27,7 +27,7 @@
       string(REGEX REPLACE "^0+" "" CVF_VERSION_MINOR "${CVF_VERSION_MINOR}")
     endif()
   else()
-    set(CVF_VERSION_MAJOR "3.2.8")
+    set(CVF_VERSION_MAJOR "3.3.1")
     set(CVF_VERSION_MINOR "")
   endif()

And could this break something relying on finding the files in the directory without version in it? And which version will be used if there is 3.2 version of CMake files in the unversioned directory and 3.3 one in the versioned directory?

For the directory name all that matters is that is starts wxWidgets. CMake looks for name*:
https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure
And as above it's all about the contents of the .cmake files.


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/pull/25757/c3263949757@github.com>

Maarten

unread,
Sep 7, 2025, 3:19:48 PM (17 hours ago) Sep 7
to wx-...@googlegroups.com, Subscribed
MaartenBent left a comment (wxWidgets/wxWidgets#25757)

Yes, in general finding wxWidgets like this should still work fine.

Only existing projects that have configured wxWidgets_DIR to point directly to wxinstalldir/lib/cmake/wxWidgets will not find it anymore. But normally it should just point to wxinstalldir and then it should find the new directory automatically.

I tested what happens when using find_package(wxWidgets CONFIG) when there are wxWidgets, wxWidgets-3.2 and wxWidgets-3.3 and it seems to always find unnumbered first, and then 3.2. So results are probably ordered alphanumeric, not by latest available version.
When specifying the desired version (find_package(wxWidgets 3.3 CONFIG)) it finds the desired one.

So this change should probably be in the changelog. Maybe even as an incompatible change?
Just to inform people that install/overwrite wxWidgets in the same directory, to remove the old non-versioned directory.


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/pull/25757/c3263985842@github.com>

Reply all
Reply to author
Forward
0 new messages