Fix Wx OpenGL and ABI checks for MSYS2 CLANG64.

Probably fixes this in other environments as well, or breaks it.

Move the wxWidgets_LIBRARIES paths conversion to the already existing
normalize_wx_paths() function that was using a different method that no
longer works. This converts the variable to the right format before the
tests run, fixing the Wx OpenGL test.

For the ABI checks, wrap the function pointers for the minhook
trampoline API in reinterpret_cast<LPVOID>(&fp), why this is necessary I
don't know, and it may break on other compilers. The trampoline is used
to catch message boxes opened by Wx for fatal errors.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2022-02-05 01:00:25 +00:00
parent 87e41300f1
commit 796dfe78f9
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
2 changed files with 20 additions and 36 deletions

View File

@ -15,21 +15,26 @@ function(JOIN VALUES GLUE OUTPUT)
set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE)
endfunction()
# convert msys paths like /c/foo to windows paths like c:/foo
# for variables set by FindWxWidgets
# On MSYS2 transform wx lib paths to native paths for Ninja.
function(normalize_wx_paths)
if(MSYS)
unset(new_paths)
foreach(p ${wxWidgets_LIBRARY_DIRS})
execute_process(COMMAND cygpath -m "${p}" OUTPUT_VARIABLE p_win OUTPUT_STRIP_TRAILING_WHITESPACE)
list(APPEND new_paths "${p_win}")
set(libs "")
foreach(lib ${wxWidgets_LIBRARIES})
if(NOT lib MATCHES "^(-Wl,|-mwindows$|-pipe$)")
if(lib MATCHES "^/")
cygpath(lib "${lib}")
endif()
if(VBAM_STATIC AND lib MATCHES "^-l(wx.*|jpeg|tiff|jbig|lzma|expat)$")
cygpath(lib "$ENV{MSYSTEM_PREFIX}/lib/lib${CMAKE_MATCH_1}.a")
endif()
list(APPEND libs "${lib}")
endif()
endforeach()
set(wxWidgets_LIBRARY_DIRS ${new_paths} PARENT_SCOPE)
string(REGEX REPLACE "((^| )[^/]*)/([a-zA-Z])/" "\\1\\3:/" new_libs "${wxWidgets_LIBRARIES}")
set(wxWidgets_LIBRARIES ${new_libs} PARENT_SCOPE)
set(wxWidgets_LIBRARIES "${libs}" PARENT_SCOPE)
endif()
endfunction()

View File

@ -352,13 +352,13 @@ int main(int argc, char** argv)
if (MH_Initialize() != MH_OK) return 1;
// Create a hook for MessageBoxW and MessageBoxA
if (MH_CreateHook(&MessageBoxW, &DetourMessageBoxW, reinterpret_cast<LPVOID*>(&fpMessageBoxW)) != MH_OK)
if (MH_CreateHook(reinterpret_cast<LPVOID>(&MessageBoxW), reinterpret_cast<LPVOID>(&DetourMessageBoxW), reinterpret_cast<LPVOID*>(&fpMessageBoxW)) != MH_OK)
return 1;
if (MH_CreateHook(&MessageBoxA, &DetourMessageBoxA, reinterpret_cast<LPVOID*>(&fpMessageBoxA)) != MH_OK)
if (MH_CreateHook(reinterpret_cast<LPVOID>(&MessageBoxA), reinterpret_cast<LPVOID>(&DetourMessageBoxA), reinterpret_cast<LPVOID*>(&fpMessageBoxA)) != MH_OK)
return 1;
if (MH_EnableHook(&MessageBoxW) != MH_OK) return 1;
if (MH_EnableHook(&MessageBoxA) != MH_OK) return 1;
if (MH_EnableHook(reinterpret_cast<LPVOID>(&MessageBoxW)) != MH_OK) return 1;
if (MH_EnableHook(reinterpret_cast<LPVOID>(&MessageBoxA)) != MH_OK) return 1;
#endif
wxEntry(argc, argv);
@ -950,27 +950,6 @@ if(NOT TRANSLATIONS_ONLY)
TARGET_LINK_LIBRARIES(visualboyadvance-m ${SPARKLE_FRAMEWORK})
endif()
# On MSYS2 transform wx lib paths to native paths for Ninja.
if(MSYS)
set(libs "")
foreach(lib ${wxWidgets_LIBRARIES})
if(NOT lib MATCHES "^(-Wl,|-mwindows$|-pipe$)")
if(lib MATCHES "^/")
cygpath(lib "${lib}")
endif()
if(VBAM_STATIC AND lib MATCHES "^-l(wx.*|jpeg|tiff|jbig|lzma|expat)$")
cygpath(lib "$ENV{MSYSTEM_PREFIX}/lib/lib${CMAKE_MATCH_1}.a")
endif()
list(APPEND libs "${lib}")
endif()
endforeach()
set(wxWidgets_LIBRARIES "${libs}")
endif()
target_link_libraries(
visualboyadvance-m
${wxWidgets_LIBRARIES}