CMake: Create wxWidgets::wxWidgets imported target

Use the same name as the target from the official FindwxWidgets module,
so it can be used interchangeable.
This commit is contained in:
Maarten Bent 2024-01-28 14:05:38 +01:00
parent 966c39802e
commit a63ba1cc04
No known key found for this signature in database
GPG key ID: 58AAEE3F4A4FD070

View file

@ -59,6 +59,13 @@ endmacro()
# for compatibility with FindwxWidgets
set(wxWidgets_LIBRARIES)
# create one target with all libraries, same as FindwxWidgets
set(CREATE_WX_TARGET OFF)
if(NOT TARGET wxWidgets::wxWidgets)
add_library(wxWidgets::wxWidgets INTERFACE IMPORTED)
set(CREATE_WX_TARGET ON)
endif()
# list all available components
set(@PROJECT_NAME@_COMPONENTS)
foreach(libname @wxLIB_TARGETS@)
@ -113,6 +120,9 @@ foreach(libname @wxLIB_TARGETS@)
list(FIND @PROJECT_NAME@_FIND_COMPONENTS ${name} idx)
if(NOT @PROJECT_NAME@_FIND_COMPONENTS OR idx GREATER -1)
list(APPEND wxWidgets_LIBRARIES wx::${name})
if(CREATE_WX_TARGET)
target_link_libraries(wxWidgets::wxWidgets INTERFACE wx::${name})
endif()
endif()
endif()
endforeach()