From e36e455b7cdb50beb7c9cd16db8e27ecc1eaca70 Mon Sep 17 00:00:00 2001 From: CheesyNacho10 <67198608+CheesyNacho10@users.noreply.github.com> Date: Tue, 7 Mar 2023 12:40:27 +0100 Subject: FindwxWidgets: Add an imported target --- .gitlab/ci/configure_debian10_aarch64_ninja.cmake | 1 + .gitlab/ci/configure_debian10_ninja.cmake | 1 + .gitlab/ci/configure_fedora37_makefiles.cmake | 1 + Help/release/dev/FindwxWidgets-imported-target.rst | 4 ++++ Modules/FindwxWidgets.cmake | 21 +++++++++++++++++++++ Tests/CMakeLists.txt | 1 + Tests/FindwxWidgets/CMakeLists.txt | 10 ++++++++++ Tests/FindwxWidgets/Test/CMakeLists.txt | 17 +++++++++++++++++ Tests/FindwxWidgets/Test/main.cpp | 7 +++++++ 9 files changed, 63 insertions(+) create mode 100644 Help/release/dev/FindwxWidgets-imported-target.rst create mode 100644 Tests/FindwxWidgets/CMakeLists.txt create mode 100644 Tests/FindwxWidgets/Test/CMakeLists.txt create mode 100644 Tests/FindwxWidgets/Test/main.cpp diff --git a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake index 7407959..16282b6 100644 --- a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake +++ b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake @@ -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 "") diff --git a/.gitlab/ci/configure_debian10_ninja.cmake b/.gitlab/ci/configure_debian10_ninja.cmake index e8d6d55..327c1c5 100644 --- a/.gitlab/ci/configure_debian10_ninja.cmake +++ b/.gitlab/ci/configure_debian10_ninja.cmake @@ -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 "") diff --git a/.gitlab/ci/configure_fedora37_makefiles.cmake b/.gitlab/ci/configure_fedora37_makefiles.cmake index 725cc46..f5676aa 100644 --- a/.gitlab/ci/configure_fedora37_makefiles.cmake +++ b/.gitlab/ci/configure_fedora37_makefiles.cmake @@ -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 "") diff --git a/Help/release/dev/FindwxWidgets-imported-target.rst b/Help/release/dev/FindwxWidgets-imported-target.rst new file mode 100644 index 0000000..c04e0ac --- /dev/null +++ b/Help/release/dev/FindwxWidgets-imported-target.rst @@ -0,0 +1,4 @@ +FindwxWidgets-imported-target +----------------------------- + +* The :module:`FindwxWidgets` module now provides an imported target. diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 3159ff7..cc76b35 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -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( ${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 "$<$:${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 diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index d913e93..446e400 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1484,6 +1484,7 @@ if(BUILD_TESTING) SQLite3 TIFF Vulkan + wxWidgets X11 XalanC XercesC diff --git a/Tests/FindwxWidgets/CMakeLists.txt b/Tests/FindwxWidgets/CMakeLists.txt new file mode 100644 index 0000000..b66f838 --- /dev/null +++ b/Tests/FindwxWidgets/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindwxWidgets.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --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 $ + ) diff --git a/Tests/FindwxWidgets/Test/CMakeLists.txt b/Tests/FindwxWidgets/Test/CMakeLists.txt new file mode 100644 index 0000000..ecc9c36 --- /dev/null +++ b/Tests/FindwxWidgets/Test/CMakeLists.txt @@ -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) diff --git a/Tests/FindwxWidgets/Test/main.cpp b/Tests/FindwxWidgets/Test/main.cpp new file mode 100644 index 0000000..0e576cf --- /dev/null +++ b/Tests/FindwxWidgets/Test/main.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + wxGetCwd(); + return 0; +} -- cgit v0.12