From 502a8393575f6ec977778b5f9a2a3c6e2a8d8da7 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Tue, 2 Sep 2025 19:27:49 +0100 Subject: [PATCH 1/3] CMake: Install cmake files into a versioned directory Under wxBUILD_INSTALL_LIBRARY_DIR. --- build/cmake/install.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build/cmake/install.cmake b/build/cmake/install.cmake index a373983043..3551095401 100644 --- a/build/cmake/install.cmake +++ b/build/cmake/install.cmake @@ -70,7 +70,10 @@ else() ) endif() -install(EXPORT wxWidgetsTargets NAMESPACE wx:: DESTINATION "lib/cmake/wxWidgets/${wxPLATFORM_LIB_DIR}") +wx_get_install_dir(library "lib") +set(wx_cmake_dir "${library_dir}/cmake/wxWidgets-${wxMAJOR_VERSION}.${wxMINOR_VERSION}") + +install(EXPORT wxWidgetsTargets NAMESPACE wx:: DESTINATION "${wx_cmake_dir}/${wxPLATFORM_LIB_DIR}") # find_package config file include(CMakePackageConfigHelpers) @@ -93,11 +96,11 @@ write_basic_package_version_file( configure_package_config_file( "${wxSOURCE_DIR}/build/cmake/wxWidgetsConfig.cmake.in" "${projectConfig}" - INSTALL_DESTINATION "lib/cmake/wxWidgets" + INSTALL_DESTINATION "${wx_cmake_dir}" ) install( FILES "${projectConfig}" "${versionConfig}" - DESTINATION "lib/cmake/wxWidgets" + DESTINATION "${wx_cmake_dir}" ) # uninstall target From 3d2185bbe94af10f04416400819d0f6a60479458 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Wed, 3 Sep 2025 19:34:47 +0100 Subject: [PATCH 2/3] CMake: Fix wx_get_install_dir on MS Windows On installation: CMake Error at cmake_install.cmake:3338 (file): file cannot create directory: C:/Program Files (x86)/wxWidgets/$clang_x64_dll/cmake/wxWidgets-3.3/clang_x64_dll>. Also prevents a trailing "/" being added to the wxBUILD_INSTALL_*_DIR on other platforms. Suggested-by: Maarten Bent --- build/cmake/functions.cmake | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 20241a5a42..5bee4e7848 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -433,11 +433,8 @@ macro(wx_get_install_dir artifact default) else() set(${artifact}_dir ${default}) endif() - if(wxBUILD_INSTALL_PLATFORM_SUBDIR) - if(${artifact}_dir) - wx_string_append(${artifact}_dir ${GEN_EXPR_DIR}) - endif() - wx_string_append(${artifact}_dir "${wxPLATFORM_LIB_DIR}") + if(wxBUILD_INSTALL_PLATFORM_SUBDIR AND wxPLATFORM_LIB_DIR) + wx_string_append(${artifact}_dir "/${wxPLATFORM_LIB_DIR}") endif() endmacro() From b4b3fa65d1b3bf3cb11c43a4114c45c1dab78afb Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Thu, 4 Sep 2025 19:22:15 +0100 Subject: [PATCH 3/3] 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. --- build/cmake/functions.cmake | 10 +++++++--- build/cmake/install.cmake | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 5bee4e7848..e9e9e0b5e3 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -427,15 +427,19 @@ function(wx_set_target_properties target_name) endfunction() macro(wx_get_install_dir artifact default) + wx_get_build_install_dir(${artifact} ${default}) + if(wxBUILD_INSTALL_PLATFORM_SUBDIR AND wxPLATFORM_LIB_DIR) + wx_string_append(${artifact}_dir "/${wxPLATFORM_LIB_DIR}") + endif() +endmacro() + +macro(wx_get_build_install_dir artifact default) string(TOUPPER ${artifact} artifact_upper) if(wxBUILD_INSTALL_${artifact_upper}_DIR) set(${artifact}_dir "${wxBUILD_INSTALL_${artifact_upper}_DIR}") else() set(${artifact}_dir ${default}) endif() - if(wxBUILD_INSTALL_PLATFORM_SUBDIR AND wxPLATFORM_LIB_DIR) - wx_string_append(${artifact}_dir "/${wxPLATFORM_LIB_DIR}") - endif() endmacro() diff --git a/build/cmake/install.cmake b/build/cmake/install.cmake index 3551095401..8d061d2ef2 100644 --- a/build/cmake/install.cmake +++ b/build/cmake/install.cmake @@ -70,7 +70,7 @@ else() ) endif() -wx_get_install_dir(library "lib") +wx_get_build_install_dir(library "lib") set(wx_cmake_dir "${library_dir}/cmake/wxWidgets-${wxMAJOR_VERSION}.${wxMINOR_VERSION}") install(EXPORT wxWidgetsTargets NAMESPACE wx:: DESTINATION "${wx_cmake_dir}/${wxPLATFORM_LIB_DIR}")