From b17a03da7f8ada0433dac4bb80d867b1b1a7b4ce Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Thu, 12 Mar 2026 19:33:35 +0100 Subject: [PATCH 1/9] CMake: Import install properties of static libraries When installing static libraries, the built-in libraries also need import mappings for MinSizeRel and RelWithDebInfo configurations. Otherwise they will default to using Debug libraries. --- build/cmake/functions.cmake | 5 ++++ build/cmake/lib/CMakeLists.txt | 1 + build/cmake/lib/webp.cmake | 2 ++ build/cmake/wxWidgetsConfig.cmake.in | 41 +++++++++++++++++----------- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 55bfd7ac14..4e39f96a05 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -14,6 +14,8 @@ include(GNUInstallDirs) # List of libraries added via wx_add_library() to use for wx-config set(wxLIB_TARGETS) +# List of the (static) builtin libraries to use in wxWidgetsConfig.cmake +set(wxLIB_BUILTIN_TARGETS) # List of headers added via wx_append_sources() to use for install set(wxINSTALL_HEADERS) # List of files not included in the install manifest @@ -719,6 +721,9 @@ endfunction() # Add a third party builtin library function(wx_add_builtin_library name) + list(APPEND wxLIB_BUILTIN_TARGETS ${name}) + set(wxLIB_BUILTIN_TARGETS ${wxLIB_BUILTIN_TARGETS} PARENT_SCOPE) + wx_list_add_prefix(src_list "${wxSOURCE_DIR}/" ${ARGN}) list(GET src_list 0 src_file) diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt index 2901361ac5..993944baaa 100644 --- a/build/cmake/lib/CMakeLists.txt +++ b/build/cmake/lib/CMakeLists.txt @@ -122,4 +122,5 @@ endif() # Propagate variable(s) to parent scope set(wxLIB_TARGETS ${wxLIB_TARGETS} PARENT_SCOPE) +set(wxLIB_BUILTIN_TARGETS ${wxLIB_BUILTIN_TARGETS} PARENT_SCOPE) set(wxINSTALL_HEADERS ${wxINSTALL_HEADERS} PARENT_SCOPE) diff --git a/build/cmake/lib/webp.cmake b/build/cmake/lib/webp.cmake index 18a8da8359..4ce6b0580f 100644 --- a/build/cmake/lib/webp.cmake +++ b/build/cmake/lib/webp.cmake @@ -71,6 +71,8 @@ if(wxUSE_LIBWEBP STREQUAL "builtin") endforeach() set(WebP_LIBRARIES webp webpdemux sharpyuv) + list(APPEND wxLIB_BUILTIN_TARGETS ${WebP_LIBRARIES}) + if(NOT wxBUILD_SHARED) wx_get_install_platform_dir(archive) wx_install(TARGETS ${WebP_LIBRARIES} diff --git a/build/cmake/wxWidgetsConfig.cmake.in b/build/cmake/wxWidgetsConfig.cmake.in index 2f3a735d92..60621b10d8 100644 --- a/build/cmake/wxWidgetsConfig.cmake.in +++ b/build/cmake/wxWidgetsConfig.cmake.in @@ -94,6 +94,24 @@ macro(wx_copy_target ns name libname) wx_inherit_property(wx::${libname} ${ns}::${name} IMPORTED_LINK_DEPENDENT_LIBRARIES) endmacro() +macro(wx_map_release libname) + # use the Release configuration for MinSizeRel and RelWithDebInfo configurations + # only when Release target exists, and MinSizeRel/RelWithDebInfo doesn't exist + get_target_property(configs wx::${libname} IMPORTED_CONFIGURATIONS) + if("RELEASE" IN_LIST configs) + if(NOT "MINSIZEREL" IN_LIST configs) + if("MinSizeRel" IN_LIST CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") + set_target_properties(wx::${libname} PROPERTIES MAP_IMPORTED_CONFIG_MINSIZEREL "Release") + endif() + endif() + if(NOT "RELWITHDEBINFO" IN_LIST configs) + if("RelWithDebInfo" IN_LIST CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + set_target_properties(wx::${libname} PROPERTIES MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Release") + endif() + endif() + endif() +endmacro() + # for compatibility with FindwxWidgets set(wxWidgets_LIBRARIES) @@ -108,6 +126,8 @@ endif() set(@PROJECT_NAME@_COMPONENTS) foreach(libname @wxLIB_TARGETS@) if(TARGET wx::${libname}) + wx_map_release(${libname}) + # remove wx prefix from component name string(SUBSTRING ${libname} 2 -1 name) @@ -116,22 +136,6 @@ foreach(libname @wxLIB_TARGETS@) set(@PROJECT_NAME@_${name}_FOUND 1) set(@PROJECT_NAME@_FIND_REQUIRED_${name} 1) - # use the Release configuration for MinSizeRel and RelWithDebInfo configurations - # only when Release target exists, and MinSizeRel/RelWithDebInfo doesn't exist - get_target_property(configs wx::${libname} IMPORTED_CONFIGURATIONS) - if("RELEASE" IN_LIST configs) - if(NOT "MINSIZEREL" IN_LIST configs) - if("MinSizeRel" IN_LIST CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") - set_target_properties(wx::${libname} PROPERTIES MAP_IMPORTED_CONFIG_MINSIZEREL "Release") - endif() - endif() - if(NOT "RELWITHDEBINFO" IN_LIST configs) - if("RelWithDebInfo" IN_LIST CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - set_target_properties(wx::${libname} PROPERTIES MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Release") - endif() - endif() - endif() - # add an alias from wx:: to wx::wx if(NOT TARGET wx::${name}) if(CMAKE_VERSION VERSION_LESS "3.18") @@ -153,6 +157,11 @@ foreach(libname @wxLIB_TARGETS@) endif() endif() endforeach() +foreach(libname @wxLIB_BUILTIN_TARGETS@) + if(TARGET wx::${libname}) + wx_map_release(${libname}) + endif() +endforeach() include(CMakeFindDependencyMacro) From 764d775076f8c2b05c5b3d8cb64cae863ffd2368 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Thu, 12 Mar 2026 19:48:53 +0100 Subject: [PATCH 2/9] CMake: Allow to override wx_option_auto --- build/cmake/functions.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 4e39f96a05..3eecba3443 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -1119,7 +1119,13 @@ endfunction() # just a warning otherwise, while ON means that an error is given if it can't # be enabled. function(wx_option_auto name desc) - wx_option(${name} ${desc} AUTO STRINGS ON OFF AUTO) + cmake_parse_arguments(OPTION "" "" "STRINGS" ${ARGN}) + if(ARGC EQUAL 2) + set(default AUTO) + else() + set(default ${OPTION_UNPARSED_ARGUMENTS}) + endif() + wx_option(${name} ${desc} ${default} STRINGS ON OFF AUTO) endfunction() # Force a new value for an option created with wx_option From 7f293e41943a6e13e11c513aa4d8e40f702f7318 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Thu, 12 Mar 2026 19:49:42 +0100 Subject: [PATCH 3/9] CMake: Refactor applying toolkit properties Group them together in base and not-base. --- build/cmake/functions.cmake | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 3eecba3443..67e2dd22e0 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -400,11 +400,6 @@ function(wx_set_target_properties target_name) $ ) - if(wxTOOLKIT_INCLUDE_DIRS AND NOT wxTARGET_IS_BASE) - target_include_directories(${target_name} - PRIVATE ${wxTOOLKIT_INCLUDE_DIRS}) - endif() - if (WIN32) set(WIN32_LIBRARIES kernel32 @@ -433,25 +428,27 @@ function(wx_set_target_properties target_name) PUBLIC ${WIN32_LIBRARIES}) endif() - if(wxTOOLKIT_LIBRARY_DIRS AND NOT wxTARGET_IS_BASE) - target_link_directories(${target_name} - PUBLIC ${wxTOOLKIT_LIBRARY_DIRS}) - endif() - if(wxTOOLKIT_LIBRARIES AND NOT wxTARGET_IS_BASE) - target_link_libraries(${target_name} - PUBLIC ${wxTOOLKIT_LIBRARIES}) - endif() - if(wxTARGET_IS_BASE) # Currently base libraries still use toolkit definitions internally. # This is wrong and should, ideally, be fixed, but for now keep # defining them. However we don't need to define this for the targets # using the base library. - target_compile_definitions(${target_name} - PRIVATE ${wxTOOLKIT_DEFINITIONS}) + if(wxTOOLKIT_DEFINITIONS) + target_compile_definitions(${target_name} PRIVATE ${wxTOOLKIT_DEFINITIONS}) + endif() else() - target_compile_definitions(${target_name} - PUBLIC ${wxTOOLKIT_DEFINITIONS}) + if(wxTOOLKIT_INCLUDE_DIRS) + target_include_directories(${target_name} PRIVATE ${wxTOOLKIT_INCLUDE_DIRS}) + endif() + if(wxTOOLKIT_LIBRARY_DIRS) + target_link_directories(${target_name} PUBLIC ${wxTOOLKIT_LIBRARY_DIRS}) + endif() + if(wxTOOLKIT_LIBRARIES) + target_link_libraries(${target_name} PUBLIC ${wxTOOLKIT_LIBRARIES}) + endif() + if(wxTOOLKIT_DEFINITIONS) + target_compile_definitions(${target_name} PUBLIC ${wxTOOLKIT_DEFINITIONS}) + endif() endif() if(wxBUILD_SHARED) From 48092f29cbdc30397a00fafeaf6dbba94c85a06a Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 15 Mar 2026 18:58:02 +0100 Subject: [PATCH 4/9] CMake: Set the wx-config RESCOMP value --- build/cmake/config.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cmake/config.cmake b/build/cmake/config.cmake index f2a4446f76..b28b501482 100644 --- a/build/cmake/config.cmake +++ b/build/cmake/config.cmake @@ -200,7 +200,7 @@ function(wx_write_config) set(WXCONFIG_RESFLAGS) set(WXCONFIG_RPATH "-Wl,-rpath,\$libdir") set(LDFLAGS_GL) - set(RESCOMP) + get_filename_component(RESCOMP "${CMAKE_RC_COMPILER}" NAME_WE) wx_configure_script( "wx-config.in" From 54bbd316def346c2b3f61ad0eb4310ed8bbd834c Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 15 Mar 2026 19:04:46 +0100 Subject: [PATCH 5/9] CMake: Get rid of macro to link sample libraries And check if widgets sample targets are valid before using it. --- build/cmake/functions.cmake | 7 ------- build/cmake/samples/CMakeLists.txt | 12 +++++++++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 67e2dd22e0..1aa226ad7c 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -1063,13 +1063,6 @@ function(wx_add name group) endif() endfunction() -# Link libraries to a sample -function(wx_link_sample_libraries name) - if(TARGET ${name}) - target_link_libraries(${name} PUBLIC ${ARGN}) - endif() -endfunction() - # Add a option and mark is as advanced if it starts with wxUSE_ # wx_option( [default] [STRINGS strings]) # The default is ON if not third parameter is specified diff --git a/build/cmake/samples/CMakeLists.txt b/build/cmake/samples/CMakeLists.txt index 5d1ca08f4d..8f835991e0 100644 --- a/build/cmake/samples/CMakeLists.txt +++ b/build/cmake/samples/CMakeLists.txt @@ -216,7 +216,9 @@ wx_add_sample(widgets IMPORTANT ${SAMPLE_WIDGETS_SRC} DATA ${WIDGETS_RC_FILES} textctrl.cpp ../image/toucan.png:toucan.png ) # includes needed by the native widget (like gtk.h) -target_include_directories(widgets PRIVATE ${wxTOOLKIT_INCLUDE_DIRS}) +if(TARGET widgets) + target_include_directories(widgets PRIVATE ${wxTOOLKIT_INCLUDE_DIRS}) +endif() wx_add_sample(wizard DATA wiztest.svg wiztest2.svg DEPENDS wxUSE_WIZARDDLG) wx_add_sample(wrapsizer) @@ -265,11 +267,15 @@ if(WIN32) # this test only makes sense with statically built wx, otherwise # the same copy of wx would be used wx_add_sample(dll wx_exe.cpp my_dll.h NAME wx_exe FOLDER dll) - wx_link_sample_libraries(wx_exe my_dll) + if(TARGET wx_exe AND TARGET my_dll) + target_link_libraries(wx_exe PRIVATE my_dll) + endif() endif() wx_add_sample(dll sdk_exe.cpp my_dll.h NAME sdk_exe FOLDER dll) - wx_link_sample_libraries(sdk_exe my_dll) + if(TARGET sdk_exe AND TARGET my_dll) + target_link_libraries(sdk_exe PRIVATE my_dll) + endif() endif() wx_add_sample(regtest RES regtest.rc DEPENDS wxUSE_REGKEY) From 24571ab89db0fda94a77fc56398b146af58f36c0 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 29 Mar 2026 16:17:44 +0200 Subject: [PATCH 6/9] CMake: Install with relative symlinks Try to install using 'ln -s --relative' first, before falling back to 'ln -s' and 'cmake -E create_symlink'. If all fail, use 'cmake -E copy'. Also add an option to disable using symlinks and always copy. Correctly use and (not) escape DESTDIR and CMAKE_INSTALL_PREFIX in install and uninstall variables. Fixes #26247 --- build/cmake/config.cmake | 2 +- build/cmake/functions.cmake | 36 ++++++++++++++++++++++++++++++++ build/cmake/install.cmake | 13 ++++++------ build/cmake/options.cmake | 2 ++ build/cmake/utils/CMakeLists.txt | 14 ++++++------- 5 files changed, 51 insertions(+), 16 deletions(-) diff --git a/build/cmake/config.cmake b/build/cmake/config.cmake index b28b501482..20aa6c699d 100644 --- a/build/cmake/config.cmake +++ b/build/cmake/config.cmake @@ -92,7 +92,7 @@ function(wx_write_config_inplace) "wx-config-inplace.in" "inplace-${TOOLCHAIN_FULLNAME}" ) - if(WIN32_MSVC_NAMING) + if(WIN32_MSVC_NAMING OR NOT wxBUILD_INSTALL_USE_SYMLINK) set(COPY_CMD copy) else() set(COPY_CMD create_symlink) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 1aa226ad7c..c178015099 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -92,6 +92,42 @@ macro(wx_install) endif() endmacro() +# wx_install_symlink(...) +# Create symlink dst pointing to src +# try different symlink and copy methods until one succeeds +macro(wx_install_symlink src dst) + if(wxBUILD_INSTALL) + install(CODE " + set(SYMLINK_SRC \"${src}\") + set(SYMLINK_DST \"${dst}\") + message(STATUS \"Installing: \${SYMLINK_DST}\") + + if(CMAKE_VERSION GREATER_EQUAL \"3.17\") + execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E rm -f \"\${SYMLINK_DST}\") + else() + execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E remove -f \"\${SYMLINK_DST}\") + endif() + + set(SYMLINK_RES 1) + set(wxBUILD_INSTALL_USE_SYMLINK ${wxBUILD_INSTALL_USE_SYMLINK}) + if(wxBUILD_INSTALL_USE_SYMLINK) + if(SYMLINK_RES) + execute_process(COMMAND ln -s --relative \"\${SYMLINK_SRC}\" \"\${SYMLINK_DST}\" RESULT_VARIABLE SYMLINK_RES OUTPUT_QUIET ERROR_QUIET) + endif() + if(SYMLINK_RES) + execute_process(COMMAND ln -s \"\${SYMLINK_SRC}\" \"\${SYMLINK_DST}\" RESULT_VARIABLE SYMLINK_RES OUTPUT_QUIET ERROR_QUIET) + endif() + if(SYMLINK_RES) + execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink \"\${SYMLINK_SRC}\" \"\${SYMLINK_DST}\" RESULT_VARIABLE SYMLINK_RES) + endif() + endif() + if(SYMLINK_RES) + execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"\${SYMLINK_SRC}\" \"\${SYMLINK_DST}\" RESULT_VARIABLE SYMLINK_RES) + endif() + ") + endif() +endmacro() + # Get a valid flavour name with optional prefix macro(wx_get_flavour flavour prefix) if(wxBUILD_FLAVOUR) diff --git a/build/cmake/install.cmake b/build/cmake/install.cmake index 88591a8c05..0ce80419e7 100644 --- a/build/cmake/install.cmake +++ b/build/cmake/install.cmake @@ -67,13 +67,12 @@ else() wx_get_install_platform_dir(runtime) install(DIRECTORY DESTINATION "${runtime_dir}") - install(CODE "execute_process( \ - COMMAND ${CMAKE_COMMAND} -E create_symlink \ - \"${CMAKE_INSTALL_PREFIX}/${library_dir}/wx/config/${wxBUILD_FILE_ID}\" \ - \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${runtime_dir}/wx-config\" \ - )" - ) - list(APPEND WX_EXTRA_UNINSTALL_FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${runtime_dir}/wx-config") + set(CONFIG_DIR "\\\$ENV{DESTDIR}\\\${CMAKE_INSTALL_PREFIX}") + set(CONFIG_SRC "${CONFIG_DIR}/${library_dir}/wx/config/${wxBUILD_FILE_ID}") + set(CONFIG_DST "${CONFIG_DIR}/${runtime_dir}/wx-config") + wx_install_symlink(${CONFIG_SRC} ${CONFIG_DST}) + + list(APPEND WX_EXTRA_UNINSTALL_FILES "\"${CMAKE_INSTALL_PREFIX}/${runtime_dir}/wx-config\"") endif() wx_get_install_dir(library) diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 3056d37613..50e9e30a77 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -92,6 +92,8 @@ wx_option(wxBUILD_INSTALL_PLATFORM_SUBDIR "use platform specific sub-directory ( mark_as_advanced(wxBUILD_INSTALL_PLATFORM_SUBDIR) wx_option(wxBUILD_INSTALL_PDB "install pdb files in the runtime directory (MSVC-naming)" OFF) mark_as_advanced(wxBUILD_INSTALL_PDB) +wx_option(wxBUILD_INSTALL_USE_SYMLINK "use symlinks when possible, disable to always use copy" ON) +mark_as_advanced(wxBUILD_INSTALL_USE_SYMLINK) # Use the MSVC/makefile naming convention, or the configure naming convention, # this is the same check as used in FindwxWidgets. diff --git a/build/cmake/utils/CMakeLists.txt b/build/cmake/utils/CMakeLists.txt index 608351ac42..dd2d82beb0 100644 --- a/build/cmake/utils/CMakeLists.txt +++ b/build/cmake/utils/CMakeLists.txt @@ -38,14 +38,12 @@ if(wxUSE_XRC) set(EXE_SUFFIX ${CMAKE_EXECUTABLE_SUFFIX}) endif() - # Don't use wx_install() here to preserve escaping. - install(CODE "execute_process( \ - COMMAND ${CMAKE_COMMAND} -E create_symlink \ - \"${CMAKE_INSTALL_PREFIX}/${runtime_dir}/${wxrc_output_name}${EXE_SUFFIX}\" \ - \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${runtime_dir}/wxrc${EXE_SUFFIX}\" \ - )" - ) - list(APPEND WX_EXTRA_UNINSTALL_FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${runtime_dir}/wxrc${EXE_SUFFIX}") + set(WXRC_DIR "\\\$ENV{DESTDIR}\\\${CMAKE_INSTALL_PREFIX}") + set(WXRC_SRC "${WXRC_DIR}/${runtime_dir}/${wxrc_output_name}${EXE_SUFFIX}") + set(WXRC_DST "${WXRC_DIR}/${runtime_dir}/wxrc${EXE_SUFFIX}") + wx_install_symlink(${WXRC_SRC} ${WXRC_DST}) + + list(APPEND WX_EXTRA_UNINSTALL_FILES "\"${CMAKE_INSTALL_PREFIX}/${runtime_dir}/wxrc${EXE_SUFFIX}\"") set(WX_EXTRA_UNINSTALL_FILES ${WX_EXTRA_UNINSTALL_FILES} PARENT_SCOPE) endif() endif() From 62403ce1e04b4efa50dfb7a4c749a54fc23d09d9 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 11 Apr 2026 20:16:55 +0200 Subject: [PATCH 7/9] CMake: Add wxbase_only target Can be used by console applications, it links with wx::base with wxUSE_GUI=0. Update wx_copy_target in wxWidgetsConfig.cmake to handle INTERFACE libraries correctly. See #26285 --- build/cmake/functions.cmake | 11 +++++------ build/cmake/lib/base/CMakeLists.txt | 10 ++++++++++ build/cmake/wxWidgetsConfig.cmake.in | 25 ++++++++++++++++++------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index c178015099..5a4ee8cee6 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -1008,17 +1008,16 @@ function(wx_add name group) endif() # All applications use at least the base library other libraries - # will have to be added with wx_link_sample_libraries() - wx_exe_link_libraries(${target_name} wxbase) - if(NOT APP_CONSOLE) - # UI applications always require core - wx_exe_link_libraries(${target_name} wxcore) + if(APP_CONSOLE) + wx_exe_link_libraries(${target_name} wxbase_only) else() - target_compile_definitions(${target_name} PRIVATE wxUSE_GUI=0 wxUSE_BASE=1) + wx_exe_link_libraries(${target_name} wxcore) endif() + if(APP_LIBRARIES) wx_exe_link_libraries(${target_name} ${APP_LIBRARIES}) endif() + if(APP_DEFINITIONS) target_compile_definitions(${target_name} PRIVATE ${APP_DEFINITIONS}) endif() diff --git a/build/cmake/lib/base/CMakeLists.txt b/build/cmake/lib/base/CMakeLists.txt index a09d239540..476642c1ca 100644 --- a/build/cmake/lib/base/CMakeLists.txt +++ b/build/cmake/lib/base/CMakeLists.txt @@ -82,3 +82,13 @@ if(APPLE) elseif(UNIX) wx_lib_link_libraries(wxbase PRIVATE ${CMAKE_DL_LIBS}) endif() + + +add_library(wxbase_only INTERFACE) +add_library(wx::base_only ALIAS wxbase_only) +add_library(wxWidgets::base_only ALIAS wxbase_only) +target_link_libraries(wxbase_only INTERFACE wxbase) +target_compile_definitions(wxbase_only INTERFACE wxUSE_GUI=0) +wx_install(TARGETS wxbase_only EXPORT wxWidgetsTargets) +list(APPEND wxLIB_TARGETS wxbase_only) +set(wxLIB_TARGETS ${wxLIB_TARGETS} PARENT_SCOPE) diff --git a/build/cmake/wxWidgetsConfig.cmake.in b/build/cmake/wxWidgetsConfig.cmake.in index 60621b10d8..ab5de5e390 100644 --- a/build/cmake/wxWidgetsConfig.cmake.in +++ b/build/cmake/wxWidgetsConfig.cmake.in @@ -81,17 +81,23 @@ macro(wx_copy_target ns name libname) get_target_property(target_type wx::${libname} TYPE) if(target_type STREQUAL STATIC_LIBRARY) add_library(${ns}::${name} STATIC IMPORTED) - else() + elseif(target_type STREQUAL SHARED_LIBRARY) add_library(${ns}::${name} SHARED IMPORTED) + elseif(target_type STREQUAL INTERFACE_LIBRARY) + add_library(${ns}::${name} INTERFACE IMPORTED) + else() + message(FATAL_ERROR "Unsupported library type: ${target_type}") endif() - wx_inherit_property(wx::${libname} ${ns}::${name} IMPORTED_CONFIGURATIONS) wx_inherit_property(wx::${libname} ${ns}::${name} INTERFACE_COMPILE_DEFINITIONS) wx_inherit_property(wx::${libname} ${ns}::${name} INTERFACE_INCLUDE_DIRECTORIES) wx_inherit_property(wx::${libname} ${ns}::${name} INTERFACE_LINK_LIBRARIES) - wx_inherit_property(wx::${libname} ${ns}::${name} IMPORTED_LINK_INTERFACE_LANGUAGES) - wx_inherit_property(wx::${libname} ${ns}::${name} IMPORTED_LOCATION) - wx_inherit_property(wx::${libname} ${ns}::${name} IMPORTED_IMPLIB) - wx_inherit_property(wx::${libname} ${ns}::${name} IMPORTED_LINK_DEPENDENT_LIBRARIES) + if(target_type STREQUAL STATIC_LIBRARY OR target_type STREQUAL SHARED_LIBRARY) + wx_inherit_property(wx::${libname} ${ns}::${name} IMPORTED_CONFIGURATIONS) + wx_inherit_property(wx::${libname} ${ns}::${name} IMPORTED_LINK_INTERFACE_LANGUAGES) + wx_inherit_property(wx::${libname} ${ns}::${name} IMPORTED_LOCATION) + wx_inherit_property(wx::${libname} ${ns}::${name} IMPORTED_IMPLIB) + wx_inherit_property(wx::${libname} ${ns}::${name} IMPORTED_LINK_DEPENDENT_LIBRARIES) + endif() endmacro() macro(wx_map_release libname) @@ -136,7 +142,7 @@ foreach(libname @wxLIB_TARGETS@) set(@PROJECT_NAME@_${name}_FOUND 1) set(@PROJECT_NAME@_FIND_REQUIRED_${name} 1) - # add an alias from wx:: to wx::wx + # add aliases from wx:: and wxWidgets::${lib} to wx::wx if(NOT TARGET wx::${name}) if(CMAKE_VERSION VERSION_LESS "3.18") # CMake <3.18 does not support alias to non-global imported target, create a copy of the library @@ -148,6 +154,11 @@ foreach(libname @wxLIB_TARGETS@) endif() endif() + # don't include 'wxbase_only' in wxWidgets_LIBRARIES and wxWidgets::wxWidgets + if(${libname} STREQUAL "wxbase_only") + continue() + endif() + # add to FindwxWidgets variable if(NOT @PROJECT_NAME@_FIND_COMPONENTS OR ${name} IN_LIST @PROJECT_NAME@_FIND_COMPONENTS) list(APPEND wxWidgets_LIBRARIES wx::${name}) From 8c1ede66075ccfca8edfcfe87950e89ebc4c64d5 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 11 Apr 2026 20:18:14 +0200 Subject: [PATCH 8/9] CMake: Don't install release PDBs when stripped releases is enabled See #26338 --- build/cmake/functions.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 5a4ee8cee6..33e0351674 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -588,7 +588,11 @@ macro(wx_add_library name) ) if(wxBUILD_SHARED AND MSVC AND wxBUILD_INSTALL_PDB) - wx_install(FILES $ DESTINATION "${runtime_dir}") + if(wxBUILD_STRIPPED_RELEASE) + wx_install(FILES $ DESTINATION "${runtime_dir}" CONFIGURATIONS Debug RelWithDebInfo) + else() + wx_install(FILES $ DESTINATION "${runtime_dir}") + endif() endif() wx_target_enable_precomp(${name} "${wxSOURCE_DIR}/include/wx/wxprec.h") From 8ade35509a36d57cf649e8272dfd7a6eefeb50d6 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 11 Apr 2026 20:18:36 +0200 Subject: [PATCH 9/9] CMake: Show check_symbol_exists messages only once Same behaviour as the built-in check functions. --- build/cmake/setup.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build/cmake/setup.cmake b/build/cmake/setup.cmake index 828ecf6999..b8f25b0de7 100644 --- a/build/cmake/setup.cmake +++ b/build/cmake/setup.cmake @@ -183,13 +183,17 @@ else() function(wx_check_symbols_exist_if_not_linux header) foreach(func ${ARGN}) string(TOUPPER "HAVE_${func}" var) - message(STATUS "Looking for ${func} in ${header}") + set(MSG_TYPE STATUS) + if(DEFINED ${var}) + set(MSG_TYPE DEBUG) + endif() + message(${MSG_TYPE} "Looking for ${func} in ${header}") check_symbol_exists(${func} ${header} ${var}) if(${var}) - message(STATUS "Looking for ${func} in ${header} - found") + message(${MSG_TYPE} "Looking for ${func} in ${header} - found") set(${var} 1 PARENT_SCOPE) else() - message(STATUS "Looking for ${func} in ${header} - not found") + message(${MSG_TYPE} "Looking for ${func} in ${header} - not found") endif() endforeach() endfunction()