diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt
index a2885b73..f0248b1b 100644
--- a/src/wx/CMakeLists.txt
+++ b/src/wx/CMakeLists.txt
@@ -65,6 +65,14 @@ function(normalize_wx_paths)
     endif()
 endfunction()
 
+function(clear_wx_vars)
+    unset(wxWidgets_FOUND        PARENT_SCOPE CACHE FORCE)
+    unset(wxWidgets_INCLUDE_DIRS PARENT_SCOPE CACHE FORCE)
+    unset(wxWidgets_LIBRARIES    PARENT_SCOPE CACHE FORCE)
+    unset(wxWidgets_LIBRARY_DIRS PARENT_SCOPE CACHE FORCE)
+    unset(wxWidgets_CXX_FLAGS    PARENT_SCOPE CACHE FORCE)
+endfunction()
+
 if(CMAKE_PREFIX_PATH)
     set(wxWidgets_CONFIG_OPTIONS "--prefix=${CMAKE_PREFIX_PATH}")
 endif()
@@ -87,6 +95,7 @@ if("$ENV{WX_CONFIG}" STREQUAL "")
         if(wxWidgets_FOUND)
             break()
         endif()
+        clear_wx_vars()
     endforeach()
 
     if(NOT wxWidgets_FOUND)