FindwxWidgets: Add an imported target

This commit is contained in:
CheesyNacho10
2023-03-07 12:40:27 +01:00
committed by Brad King
parent 42c84b1e2e
commit e36e455b7c
9 changed files with 63 additions and 0 deletions

View File

@@ -65,6 +65,7 @@ set(CMake_TEST_FindRuby "ON" CACHE BOOL "")
set(CMake_TEST_FindSDL "ON" CACHE BOOL "")
set(CMake_TEST_FindSQLite3 "ON" CACHE BOOL "")
set(CMake_TEST_FindTIFF "ON" CACHE BOOL "")
set(CMake_TEST_FindwxWidgets "ON" CACHE BOOL "")
set(CMake_TEST_FindX11 "ON" CACHE BOOL "")
set(CMake_TEST_FindXalanC "ON" CACHE BOOL "")
set(CMake_TEST_FindXercesC "ON" CACHE BOOL "")

View File

@@ -71,6 +71,7 @@ set(CMake_TEST_FindRuby_RVM "ON" CACHE BOOL "")
set(CMake_TEST_FindSDL "ON" CACHE BOOL "")
set(CMake_TEST_FindSQLite3 "ON" CACHE BOOL "")
set(CMake_TEST_FindTIFF "ON" CACHE BOOL "")
set(CMake_TEST_FindwxWidgets "ON" CACHE BOOL "")
set(CMake_TEST_FindX11 "ON" CACHE BOOL "")
set(CMake_TEST_FindXalanC "ON" CACHE BOOL "")
set(CMake_TEST_FindXercesC "ON" CACHE BOOL "")

View File

@@ -69,6 +69,7 @@ set(CMake_TEST_FindRuby_RVM "ON" CACHE BOOL "")
set(CMake_TEST_FindSDL "ON" CACHE BOOL "")
set(CMake_TEST_FindSQLite3 "ON" CACHE BOOL "")
set(CMake_TEST_FindTIFF "ON" CACHE BOOL "")
set(CMake_TEST_FindwxWidgets "ON" CACHE BOOL "")
set(CMake_TEST_FindX11 "ON" CACHE BOOL "")
set(CMake_TEST_FindXalanC "ON" CACHE BOOL "")
set(CMake_TEST_FindXercesC "ON" CACHE BOOL "")

View File

@@ -0,0 +1,4 @@
FindwxWidgets-imported-target
-----------------------------
* The :module:`FindwxWidgets` module now provides an imported target.

View File

@@ -113,6 +113,16 @@ If wxWidgets is required (i.e., not an optional part):
include(${wxWidgets_USE_FILE})
# and for each of your dependent executable/library targets:
target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
Imported targets
^^^^^^^^^^^^^^^^
.. versionadded:: 3.27
This module defines the following :prop_tgt:`IMPORTED` targets:
``wxWidgets::wxWidgets``
An interface library providing usage requirements for the found components.
#]=======================================================================]
#
@@ -981,6 +991,17 @@ find_package_handle_standard_args(wxWidgets
)
unset(wxWidgets_HANDLE_COMPONENTS)
if(wxWidgets_FOUND AND NOT TARGET wxWidgets::wxWidgets)
add_library(wxWidgets::wxWidgets INTERFACE IMPORTED)
target_link_libraries(wxWidgets::wxWidgets INTERFACE ${wxWidgets_LIBRARIES})
target_link_directories(wxWidgets::wxWidgets INTERFACE ${wxWidgets_LIBRARY_DIRS})
target_include_directories(wxWidgets::wxWidgets INTERFACE ${wxWidgets_INCLUDE_DIRS})
target_compile_options(wxWidgets::wxWidgets INTERFACE ${wxWidgets_CXX_FLAGS})
target_compile_definitions(wxWidgets::wxWidgets INTERFACE ${wxWidgets_DEFINITIONS})
# FIXME: Add "$<$<CONFIG:Debug>:${wxWidgets_DEFINITIONS_DEBUG}>"
# if the debug library variant is available.
endif()
#=====================================================================
# Macros for use in wxWidgets apps.
# - This module will not fail to find wxWidgets based on the code

View File

@@ -1484,6 +1484,7 @@ if(BUILD_TESTING)
SQLite3
TIFF
Vulkan
wxWidgets
X11
XalanC
XercesC

View File

@@ -0,0 +1,10 @@
add_test(NAME FindwxWidgets.Test COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
"${CMake_SOURCE_DIR}/Tests/FindwxWidgets/Test"
"${CMake_BINARY_DIR}/Tests/FindwxWidgets/Test"
${build_generator_args}
--build-project TestFindwxWidgets
--build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)

View File

@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.26)
project(TestFindwxWidgets CXX)
include(CTest)
find_package(wxWidgets REQUIRED)
add_executable(test_tgt main.cpp)
target_link_libraries(test_tgt wxWidgets::wxWidgets)
add_test(NAME test_tgt COMMAND test_tgt)
add_executable(test_var main.cpp)
target_link_libraries(test_var PRIVATE ${wxWidgets_LIBRARIES})
target_link_directories(test_var PRIVATE ${wxWidgets_LIBRARY_DIRS})
target_include_directories(test_var PRIVATE ${wxWidgets_INCLUDE_DIRS})
target_compile_options(test_var PRIVATE ${wxWidgets_CONFIG_OPTIONS})
target_compile_definitions(test_var PRIVATE ${wxWidgets_DEFINITIONS})
add_test(NAME test_var COMMAND test_var)

View File

@@ -0,0 +1,7 @@
#include <wx/filefn.h>
int main()
{
wxGetCwd();
return 0;
}