How find older version of library?

I have Mint 20.3 and install wxWidgets 3.0.4 by sudo apt install libwxgtk3.0-gtk3-dev
Now I install wxWidgeta 3.1.x from sources.
I have CMakeLists.txt :

cmake_minimum_required(VERSION 3.7)


find_package(wxWidgets 3.1 COMPONENTS core base net REQUIRED)

add_definitions("-Werror=return-type -H")

set(SOURCE_FILES main.cpp main.h)
add_executable(minimal_std ${SOURCE_FILES})

target_link_libraries(minimal_std ${wxWidgets_LIBRARIES})

First I call cmake with -DCMAKE_MODULE_PATH=/usr/local/include/wx-3.1
now I want test with older version, I changed
and find_package(wxWidgets 3.0.4 EXACT COMPONENTS core base net REQUIRED)
but have error

CMake Error at /home/andrzej/clion-2021.3.3/bin/cmake/linux/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find wxWidgets: Found unsuitable version "3.1.6", but required is
  exact version "3.0.4" (found

Did you remove CMakeCache.txt file before the second CMake generation? This file stores results of find_* commands to avoid multiple searches.
So, when you change your environment, it is required to remove this file to avoid unexpected results.

Additionally, include/wx-3.x seems like the wrong thing for CMAKE_MODULE_PATH (unless the FindwxWidgets.cmake file is there…which seems odd). For things like this, you can pass the --debug-find flag to get some insight into where CMake is actually looking.