diff --git a/Help/release/dev/find-modules.rst b/Help/release/dev/find-modules.rst index 6b92227148..2e851baa29 100644 --- a/Help/release/dev/find-modules.rst +++ b/Help/release/dev/find-modules.rst @@ -94,3 +94,7 @@ Find Modules * The :module:`FindTIFF` module now provides a ``TIFF_VERSION`` result variable. The ``TIFF_VERSION_STRING`` result variable is deprecated. + +* The :module:`FindwxWidgets` module now provides a ``wxWidgets_VERSION`` + result variable. The ``wxWidgets_VERSION_STRING`` result variable is + deprecated. diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index ddcbdf6ba8..27e830159d 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -92,8 +92,8 @@ This module defines the following variables: Boolean indicating whether (the requested version of) wxWidgets and all its requested components are found. -``wxWidgets_VERSION_STRING`` - .. versionadded:: 3.4 +``wxWidgets_VERSION`` + .. versionadded:: 4.2 The version of the wxWidgets found. @@ -190,6 +190,19 @@ ON/OFF the following variables: set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr) +Deprecated Variables +^^^^^^^^^^^^^^^^^^^^ + +The following variables are provided for backward compatibility: + +``wxWidgets_VERSION_STRING`` + .. deprecated:: 4.2 + Use ``wxWidgets_VERSION``, which has the same value. + + .. versionadded:: 3.4 + + The version of the wxWidgets found. + Examples ^^^^^^^^ @@ -365,12 +378,12 @@ macro(wx_extract_version) string(REGEX REPLACE "^(.*\n)?#define +wxSUBRELEASE_NUMBER +([0-9]+).*" "\\2" wxWidgets_VERSION_TWEAK "${_wx_version_h}" ) - set(wxWidgets_VERSION_STRING - "${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}.${wxWidgets_VERSION_PATCH}" ) + set(wxWidgets_VERSION + "${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}.${wxWidgets_VERSION_PATCH}") if(${wxWidgets_VERSION_TWEAK} GREATER 0) - string(APPEND wxWidgets_VERSION_STRING ".${wxWidgets_VERSION_TWEAK}") + string(APPEND wxWidgets_VERSION ".${wxWidgets_VERSION_TWEAK}") endif() - dbg_msg("wxWidgets_VERSION_STRING: ${wxWidgets_VERSION_STRING}") + set(wxWidgets_VERSION_STRING "${wxWidgets_VERSION}") endmacro() #===================================================================== @@ -1132,7 +1145,7 @@ endif() find_package_handle_standard_args(wxWidgets REQUIRED_VARS wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS - VERSION_VAR wxWidgets_VERSION_STRING + VERSION_VAR wxWidgets_VERSION ${wxWidgets_HANDLE_COMPONENTS} ) unset(wxWidgets_HANDLE_COMPONENTS) diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt index c2b510e2f4..40c076877a 100644 --- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -105,6 +105,7 @@ foreach( PERL PKG_CONFIG PNG PostgreSQL SDL TIFF + wxWidgets ZLIB ) check_version_string(${VTEST} ${VTEST}_VERSION_STRING) @@ -127,6 +128,7 @@ foreach( Ruby RUBY SDL SWIG TIFF + wxWidgets ZLIB ) check_version_string(${VTEST} ${VTEST}_VERSION) diff --git a/Tests/FindwxWidgets/Test/CMakeLists.txt b/Tests/FindwxWidgets/Test/CMakeLists.txt index ecc9c369cc..9c40217e4d 100644 --- a/Tests/FindwxWidgets/Test/CMakeLists.txt +++ b/Tests/FindwxWidgets/Test/CMakeLists.txt @@ -4,6 +4,8 @@ include(CTest) find_package(wxWidgets REQUIRED) +add_compile_definitions(CMAKE_EXPECTED_WXWIDGETS_VERSION="${wxWidgets_VERSION}") + add_executable(test_tgt main.cpp) target_link_libraries(test_tgt wxWidgets::wxWidgets) add_test(NAME test_tgt COMMAND test_tgt) diff --git a/Tests/FindwxWidgets/Test/main.cpp b/Tests/FindwxWidgets/Test/main.cpp index 0e576cfede..c990d93a8a 100644 --- a/Tests/FindwxWidgets/Test/main.cpp +++ b/Tests/FindwxWidgets/Test/main.cpp @@ -1,7 +1,24 @@ +#include +#include +#include + #include +#include int main() { wxGetCwd(); - return 0; + + std::string found_version = std::to_string(wxMAJOR_VERSION) + "." + + std::to_string(wxMINOR_VERSION) + "." + std::to_string(wxRELEASE_NUMBER); + +#if wxSUBRELEASE_NUMBER > 0 + found_version += "." + std::to_string(wxSUBRELEASE_NUMBER); +#endif + + std::cout << "Found wxWidgets version " << found_version + << ", expected version " << CMAKE_EXPECTED_WXWIDGETS_VERSION + << "\n"; + + return std::strcmp(found_version.c_str(), CMAKE_EXPECTED_WXWIDGETS_VERSION); }