From 9487fe5cd271a4bee96ab590509ef38f6972887a Mon Sep 17 00:00:00 2001
From: Kai Kang <kai.kang@windriver.com>
Date: Sat, 12 Oct 2024 18:43:25 +0800
Subject: [PATCH] fix libdir for multilib

wxWidgets hardcodes libdir with 'lib' and does not support multilib
which will change it. Respect variable wxPLATFORM_LIB_DIR to support
libdir be configurable.

Upstream-Status: Pending

Signed-off-by: Kai Kang <kai.kang@windriver.com>

Rebase for wxWidgets 3.2.1. Replace wxPLATFORM_LIB_DIR with LIB_SUFFIX
in this patch that LIB_SUFFIX has been passed to cmake in cmake.bbclass.

Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
 CMakeLists.txt              |  2 +-
 build/cmake/config.cmake    |  2 +-
 build/cmake/functions.cmake |  4 ++--
 build/cmake/install.cmake   | 12 ++++++------
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f6ae7f6210..2a13e448db 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,7 +45,7 @@ include(build/cmake/policies.cmake NO_POLICY_SCOPE)
 # Initialize variables for quick access to wx root dir in sub dirs
 set(wxSOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(wxBINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
-set(wxOUTPUT_DIR ${wxBINARY_DIR}/lib)
+set(wxOUTPUT_DIR ${wxBINARY_DIR}/lib${LIB_SUFFIX})
 
 # parse the version number from wx/version.h and include in wxMAJOR_VERSION and wxMINOR_VERSION
 file(READ "${wxSOURCE_DIR}/include/wx/version.h" WX_VERSION_H_CONTENTS)
diff --git a/build/cmake/config.cmake b/build/cmake/config.cmake
index addd8d6b81..9ec677534b 100644
--- a/build/cmake/config.cmake
+++ b/build/cmake/config.cmake
@@ -100,7 +100,7 @@ function(wx_write_config_inplace)
     execute_process(
         COMMAND
         "${CMAKE_COMMAND}" -E ${COPY_CMD}
-        "${wxBINARY_DIR}/lib/wx/config/inplace-${TOOLCHAIN_FULLNAME}"
+        "${wxBINARY_DIR}/lib${LIB_SUFFIX}/wx/config/inplace-${TOOLCHAIN_FULLNAME}"
         "${wxBINARY_DIR}/wx-config"
         )
 endfunction()
diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake
index 72a34f0b4f..81ede7d8ae 100644
--- a/build/cmake/functions.cmake
+++ b/build/cmake/functions.cmake
@@ -462,8 +462,8 @@ macro(wx_add_library name)
         endif()
         wx_install(TARGETS ${name}
             EXPORT wxWidgetsTargets
-            LIBRARY DESTINATION "lib${GEN_EXPR_DIR}${wxPLATFORM_LIB_DIR}"
-            ARCHIVE DESTINATION "lib${GEN_EXPR_DIR}${wxPLATFORM_LIB_DIR}"
+            LIBRARY DESTINATION "lib${LIB_SUFFIX}${GEN_EXPR_DIR}${wxPLATFORM_LIB_DIR}"
+            ARCHIVE DESTINATION "lib${LIB_SUFFIX}${GEN_EXPR_DIR}${wxPLATFORM_LIB_DIR}"
             RUNTIME DESTINATION "${runtime_dir}${GEN_EXPR_DIR}${wxPLATFORM_LIB_DIR}"
             BUNDLE DESTINATION Applications/wxWidgets
             )
diff --git a/build/cmake/install.cmake b/build/cmake/install.cmake
index 384c6837b8..d3303faabb 100644
--- a/build/cmake/install.cmake
+++ b/build/cmake/install.cmake
@@ -29,11 +29,11 @@ if(WIN32_MSVC_NAMING)
 else()
     install(
         DIRECTORY "${wxSETUP_HEADER_PATH}"
-        DESTINATION "lib/wx/include")
+        DESTINATION "lib${LIB_SUFFIX}/wx/include")
 
     install(
         FILES "${wxOUTPUT_DIR}/wx/config/${wxBUILD_FILE_ID}"
-        DESTINATION "lib/wx/config"
+        DESTINATION "lib${LIB_SUFFIX}/wx/config"
         PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
                     GROUP_EXECUTE GROUP_READ
                     WORLD_EXECUTE WORLD_READ
@@ -42,13 +42,13 @@ else()
     install(DIRECTORY DESTINATION "bin")
     install(CODE "execute_process( \
         COMMAND ${CMAKE_COMMAND} -E create_symlink \
-        \"${CMAKE_INSTALL_PREFIX}/lib/wx/config/${wxBUILD_FILE_ID}\" \
+        \"${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/wx/config/${wxBUILD_FILE_ID}\" \
         \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/wx-config\" \
         )"
     )
 endif()
 
-install(EXPORT wxWidgetsTargets NAMESPACE wx:: DESTINATION "lib/cmake/wxWidgets/${wxPLATFORM_LIB_DIR}")
+install(EXPORT wxWidgetsTargets NAMESPACE wx:: DESTINATION "lib${LIB_SUFFIX}/cmake/wxWidgets/${wxPLATFORM_LIB_DIR}")
 
 # find_package config file
 include(CMakePackageConfigHelpers)
@@ -71,11 +71,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 "lib${LIB_SUFFIX}/cmake/wxWidgets"
 )
 install(
     FILES "${projectConfig}" "${versionConfig}"
-    DESTINATION "lib/cmake/wxWidgets"
+    DESTINATION "lib${LIB_SUFFIX}/cmake/wxWidgets"
 )
 
 # uninstall target
-- 
2.25.1

