wxWidgets/build/cmake/wxWidgetsConfig.cmake.in
Tobias Taschner 77db8b7d54 Fix MSW lib names for ARM64 with CMake build
Any 64 platform had the added _x64 suffix. This will now be _arm64
when building for ARM64.

See #23347, #23355.

(cherry picked from commit 1edb38b54892273f2f932339d49b91f7b60fd3a4)
2023-07-03 02:56:23 +02:00

130 lines
5.5 KiB
CMake

@PACKAGE_INIT@
# determine target from compiler, platform and library type
if(WIN32 AND NOT CYGWIN AND NOT MSYS)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
set(wxCOMPILER_PREFIX "vc")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
set(wxCOMPILER_PREFIX "gcc")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
set(wxCOMPILER_PREFIX "clang")
endif()
set(wxPLATFORM_ARCH)
if(CMAKE_GENERATOR_PLATFORM)
if (CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
set(wxPLATFORM_ARCH "x64")
elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
set(wxPLATFORM_ARCH "arm64")
endif()
elseif(CMAKE_VS_PLATFORM_NAME)
if (CMAKE_VS_PLATFORM_NAME STREQUAL "x64")
set(wxPLATFORM_ARCH "x64")
elseif(CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64")
set(wxPLATFORM_ARCH "arm64")
endif()
else()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(wxPLATFORM_ARCH "x64")
endif()
endif()
if(wxPLATFORM_ARCH)
set(wxARCH_SUFFIX "_${wxPLATFORM_ARCH}")
endif()
# use wxWidgets_USE_STATIC to force static libraries, otherwise shared is searched first
if(NOT wxWidgets_USE_STATIC AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/${wxCOMPILER_PREFIX}${wxARCH_SUFFIX}_dll/@PROJECT_NAME@Targets.cmake")
set(wxPLATFORM_LIB_DIR "/${wxCOMPILER_PREFIX}${wxARCH_SUFFIX}_dll")
elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${wxCOMPILER_PREFIX}${wxARCH_SUFFIX}_lib/@PROJECT_NAME@Targets.cmake")
set(wxPLATFORM_LIB_DIR "/${wxCOMPILER_PREFIX}${wxARCH_SUFFIX}_lib")
endif()
endif()
include("${CMAKE_CURRENT_LIST_DIR}${wxPLATFORM_LIB_DIR}/@PROJECT_NAME@Targets.cmake")
macro(wx_inherit_property source dest name)
# property name without _<CONFIG>
get_target_property(prop ${source} ${name})
if(prop)
set_target_properties(${dest} PROPERTIES ${name} "${prop}")
endif()
# property name with _<CONFIG>
get_target_property(configs ${source} IMPORTED_CONFIGURATIONS)
foreach(cfg ${configs})
set(name_cfg "${name}_${cfg}")
get_target_property(prop ${source} ${name_cfg})
if(prop)
set_target_properties(${dest} PROPERTIES ${name_cfg} "${prop}")
endif()
endforeach()
endmacro()
# for compatibility with FindwxWidgets
set(wxWidgets_LIBRARIES)
# list all available components
set(@PROJECT_NAME@_COMPONENTS)
foreach(libname @wxLIB_TARGETS@)
if(TARGET wx::${libname})
# remove wx prefix from component name
string(SUBSTRING ${libname} 2 -1 name)
# set variables used in check_required_components
list(APPEND @PROJECT_NAME@_COMPONENTS ${name})
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)
list(FIND configs "RELEASE" idxSrc)
if(idxSrc GREATER -1)
list(FIND configs "MINSIZEREL" idxSrc)
list(FIND CMAKE_CONFIGURATION_TYPES "MinSizeRel" idxDst)
if(idxSrc EQUAL -1 AND (idxDst GREATER -1 OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel"))
set_target_properties(wx::${libname} PROPERTIES MAP_IMPORTED_CONFIG_MINSIZEREL "Release")
endif()
list(FIND configs "RELWITHDEBINFO" idxSrc)
list(FIND CMAKE_CONFIGURATION_TYPES "RelWithDebInfo" idxDst)
if(idxSrc EQUAL -1 AND (idxDst GREATER -1 OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
set_target_properties(wx::${libname} PROPERTIES MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Release")
endif()
endif()
# add an alias from wx::<lib> to wx::wx<lib>
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
get_target_property(target_type wx::${libname} TYPE)
if(target_type STREQUAL STATIC_LIBRARY)
add_library(wx::${name} STATIC IMPORTED)
else()
add_library(wx::${name} SHARED IMPORTED)
endif()
wx_inherit_property(wx::${libname} wx::${name} IMPORTED_CONFIGURATIONS)
wx_inherit_property(wx::${libname} wx::${name} INTERFACE_COMPILE_DEFINITIONS)
wx_inherit_property(wx::${libname} wx::${name} INTERFACE_INCLUDE_DIRECTORIES)
wx_inherit_property(wx::${libname} wx::${name} INTERFACE_LINK_LIBRARIES)
wx_inherit_property(wx::${libname} wx::${name} IMPORTED_LINK_INTERFACE_LANGUAGES)
wx_inherit_property(wx::${libname} wx::${name} IMPORTED_LOCATION)
wx_inherit_property(wx::${libname} wx::${name} IMPORTED_IMPLIB)
wx_inherit_property(wx::${libname} wx::${name} IMPORTED_LINK_DEPENDENT_LIBRARIES)
else()
add_library(wx::${name} ALIAS wx::${libname})
endif()
# add to FindwxWidgets variable
list(FIND @PROJECT_NAME@_FIND_COMPONENTS ${name} idx)
if(NOT @PROJECT_NAME@_FIND_COMPONENTS OR idx GREATER -1)
list(APPEND wxWidgets_LIBRARIES wx::${name})
endif()
endif()
endforeach()
# if no components are specified in find_package, check all of them
if(NOT @PROJECT_NAME@_FIND_COMPONENTS)
set(@PROJECT_NAME@_FIND_COMPONENTS ${@PROJECT_NAME@_COMPONENTS})
endif()
check_required_components("@PROJECT_NAME@")