--- src/CMakeLists.txt.orig	2021-06-01 04:32:31 UTC
+++ src/CMakeLists.txt
@@ -16,7 +16,11 @@ if (UNIX OR MINGW)
 set( CL_WX_CONFIG wx-config )
 
 if (UNIX OR MINGW)
-    execute_process(COMMAND which ${CL_WX_CONFIG} OUTPUT_VARIABLE WX_TOOL OUTPUT_STRIP_TRAILING_WHITESPACE)
+    if(NOT wxWidgets_CONFIG_EXECUTABLE)
+        execute_process(COMMAND which ${CL_WX_CONFIG} OUTPUT_VARIABLE WX_TOOL OUTPUT_STRIP_TRAILING_WHITESPACE)
+    else()
+        set(WX_TOOL ${wxWidgets_CONFIG_EXECUTABLE})
+    endif()
     if (NOT WX_TOOL)
         message(FATAL_ERROR
 "\nNo functional wx_config script was found in your PATH.\nIs the wxWidgets development package installed?\nIf you built wxWidgets yourself, you can specify the path to your built wx-config executable via WITH_WXPATH\neg. -DWITH_WXPATH=\"/path/to/wx-config/\""
@@ -52,7 +56,16 @@ endif (WX_GTK3)
 	set(wxWidgets_CONFIG_OPTIONS --toolkit=gtk3)
 endif (WX_GTK3)
 
-SET(WX_LIBS std aui gl stc richtext propgrid media)
+# Work around find_package(wxWidgets...) inability to detect absence of some
+# optional components (e.g., media)
+find_library(WX_MEDIA wx_gtk${GTK_VERSION}u_media-3.0)
+if (NOT WX_MEDIA)
+	message(STATUS "wx_gtk${GTK_VERSION}u_media-3.0 not found, building without MP3 playback support.")
+else (WX_MEDIA)
+	SET(WX_LIBS ${WX_LIBS} media)
+endif ()
+
+SET(WX_LIBS std aui gl stc richtext propgrid ${WX_LIBS})
 if (NO_WEBVIEW)
 	SET(WX_LIBS ${WX_LIBS} html)
 else (NO_WEBVIEW)
@@ -159,8 +172,10 @@ endif(APPLE)
 	set_source_files_properties(${OSX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
 endif(APPLE)
 
+if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "i386")
 # enable SSE instructions for dumb library
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_USE_SSE -msse")
+endif()
 
 if(USE_SANITIZER)
 	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
