Merge topic 'patch-UsewxWidgets'

c827016b10 UsewxWidgets, Use_wxWindows: Update documentation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10437
This commit is contained in:
Brad King 2025-03-10 14:25:08 +00:00 committed by Kitware Robot
commit 7c55e2a698
2 changed files with 47 additions and 38 deletions

View File

@ -7,39 +7,41 @@ Use_wxWindows
.. deprecated:: 2.8.10 .. deprecated:: 2.8.10
Use ``find_package(wxWidgets)`` and ``include(${wxWidgets_USE_FILE})`` instead. Use :module:`find_package(wxWidgets) <FindwxWidgets>` instead.
This convenience include finds if wxWindows is installed and set the This convenience include finds if wxWindows library is installed and sets the
appropriate libs, incdirs, flags etc. author Jan Woetzel <jw -at- appropriate libraries, include directories, flags, etc.
mip.informatik.uni-kiel.de> (07/2003)
USAGE: Examples
^^^^^^^^
:: Include ``Use_wxWindows`` module in project's ``CMakeLists.txt``:
just include Use_wxWindows.cmake .. code-block:: cmake
in your projects CMakeLists.txt
include( ${CMAKE_MODULE_PATH}/Use_wxWindows.cmake) # CMakeLists.txt
include(Use_wxWindows)
:: When the GL support is required, set ``WXWINDOWS_USE_GL`` *before* including
this module:
if you are sure you need GL then .. code-block:: cmake
set(WXWINDOWS_USE_GL 1) set(WXWINDOWS_USE_GL ON)
include(Use_wxWindows)
::
*before* you include this file.
#]=======================================================================] #]=======================================================================]
# Author: Jan Woetzel <jw -at- mip.informatik.uni-kiel.de> (07/2003)
# ----------------------------------------------------- # -----------------------------------------------------
# 16.Feb.2004: changed INCLUDE to FIND_PACKAGE to read from users own non-system CMAKE_MODULE_PATH (Jan Woetzel JW) # 16.Feb.2004: changed INCLUDE to FIND_PACKAGE to read from users own non-system CMAKE_MODULE_PATH (Jan Woetzel JW)
# 07/2006: rewrite as FindwxWidgets.cmake, kept for backward compatibility JW # 07/2006: rewrite as FindwxWidgets.cmake, kept for backward compatibility JW
message(STATUS "Use_wxWindows.cmake is DEPRECATED. \n" message(
"Please use find_package(wxWidgets) and include(${wxWidgets_USE_FILE}) instead. (JW)") DEPRECATION
"Use_wxWindows module is DEPRECATED.\n"
"Please use find_package(wxWidgets) instead. (JW)"
)
# ------------------------ # ------------------------

View File

@ -5,39 +5,46 @@
UsewxWidgets UsewxWidgets
------------ ------------
Convenience include for using wxWidgets library. This module calls :command:`include_directories` and
:command:`link_directories`, sets compile definitions for the current directory
and appends some compile flags to use wxWidgets library after calling the
:module:`find_package(wxWidgets) <FindwxWidgets>`.
Determines if wxWidgets was FOUND and sets the appropriate libs, Examples
incdirs, flags, etc. INCLUDE_DIRECTORIES and LINK_DIRECTORIES are ^^^^^^^^
called.
USAGE Include ``UsewxWidgets`` module in project's ``CMakeLists.txt``:
.. code-block:: cmake .. code-block:: cmake
# Note that for MinGW users the order of libs is important! # Note that for MinGW users the order of libraries is important.
find_package(wxWidgets REQUIRED net gl core base) find_package(wxWidgets REQUIRED net gl core base)
# Above also sets the wxWidgets_USE_FILE variable that points to this module.
include(${wxWidgets_USE_FILE}) include(${wxWidgets_USE_FILE})
# and for each of your dependent executable/library targets:
target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
# Link wxWidgets libraries for each dependent executable/library target.
target_link_libraries(<ProjectTarget> ${wxWidgets_LIBRARIES})
As of CMake 3.27, a better approach is to link only the
:module:`wxWidgets::wxWidgets <FindwxWidgets>` ``IMPORTED`` target to specific
targets that require it, rather than including this module. Imported targets
provide better control of the package usage properties, such as include
directories and compile flags, by applying them only to the targets they are
linked to, avoiding unnecessary propagation to all targets in the current
directory.
DEPRECATED .. code-block:: cmake
:: # CMakeLists.txt
find_package(wxWidgets)
LINK_LIBRARIES is not called in favor of adding dependencies per target. # Link the imported target for each dependent executable/library target.
target_link_libraries(<ProjectTarget> wxWidgets::wxWidgets)
AUTHOR
::
Jan Woetzel <jw -at- mip.informatik.uni-kiel.de>
#]=======================================================================] #]=======================================================================]
# Author: Jan Woetzel <jw -at- mip.informatik.uni-kiel.de>
if (wxWidgets_FOUND) if (wxWidgets_FOUND)
if (wxWidgets_INCLUDE_DIRS) if (wxWidgets_INCLUDE_DIRS)
if(wxWidgets_INCLUDE_DIRS_NO_SYSTEM) if(wxWidgets_INCLUDE_DIRS_NO_SYSTEM)