From 6ac95d373ffd6d6b14665454a08b2a2aed988fb9 Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Sun, 17 Mar 2024 18:33:46 -0700 Subject: [PATCH] [Build] Rework wx/CMakeLists.txt * Bring the wx frontend more in-line with the rest of the codebase. * Always default to Unicode APIs on Windows. * Clean up all include guards and headers. --- CMakeLists.txt | 52 +- cmake/Toolchain-gcc-clang.cmake | 1 + cmake/Toolchain-msvc.cmake | 4 + cmake/VbamFunctions.cmake | 47 - po/CMakeLists.txt | 4 - po/wxvbam/CMakeLists.txt | 11 +- src/core/gba/gbaLink.cpp | 4 +- src/wx/CMakeLists.txt | 1829 +++++++---------- .../autoupdater/wxmsw/winsparkle-wrapper.cpp | 2 +- src/wx/background-input.cpp | 2 +- src/wx/background-input.h | 8 +- src/wx/cmdevents.cpp | 8 +- src/wx/config/game-control.cpp | 8 +- src/wx/config/game-control.h | 2 +- src/wx/config/internal/option-internal.cpp | 6 +- src/wx/config/internal/option-internal.h | 2 +- src/wx/config/internal/shortcuts-internal.cpp | 4 +- src/wx/config/internal/shortcuts-internal.h | 2 +- src/wx/config/option-observer.cpp | 4 +- src/wx/config/option-observer.h | 2 +- src/wx/config/option-proxy.h | 4 +- src/wx/config/option.cpp | 6 +- src/wx/config/option.h | 2 +- src/wx/config/shortcuts.cpp | 6 +- src/wx/config/shortcuts.h | 2 +- src/wx/config/user-input.cpp | 6 +- src/wx/config/user-input.h | 2 +- src/wx/copy-events.cmake | 2 +- src/wx/dialogs/accel-config.cpp | 14 +- src/wx/dialogs/accel-config.h | 4 +- src/wx/dialogs/directories-config.cpp | 6 +- src/wx/dialogs/directories-config.h | 2 +- src/wx/dialogs/display-config.cpp | 18 +- src/wx/dialogs/display-config.h | 4 +- src/wx/dialogs/game-boy-config.cpp | 10 +- src/wx/dialogs/game-boy-config.h | 4 +- src/wx/dialogs/game-maker.cpp | 2 +- src/wx/dialogs/gb-rom-info.cpp | 6 +- src/wx/dialogs/gb-rom-info.h | 2 +- src/wx/dialogs/joypad-config.cpp | 10 +- src/wx/dialogs/joypad-config.h | 2 +- src/wx/drawing.h | 8 +- src/wx/dsound.cpp | 2 +- src/wx/extra-translations.cpp | 3 +- src/wx/faudio.cpp | 2 +- src/wx/gfxviewers.cpp | 6 +- src/wx/guiinit.cpp | 28 +- src/wx/macsupport.mm | 4 +- src/wx/openal.cpp | 2 +- src/wx/opts.cpp | 16 +- src/wx/opts.h | 14 +- src/wx/panel.cpp | 18 +- src/wx/rpi.h | 7 +- src/wx/strutils.cpp | 2 +- src/wx/strutils.h | 6 +- src/wx/sys.cpp | 6 +- src/wx/tests/CMakeLists.txt | 6 + src/wx/tests/strutils.cpp | 2 +- src/wx/viewers.cpp | 6 +- src/wx/viewsupt.cpp | 8 +- src/wx/viewsupt.h | 6 +- src/wx/wayland.cpp | 2 +- src/wx/wayland.h | 6 +- src/wx/widgets/checkedlistctrl.cpp | 3 +- src/wx/widgets/{wx => }/checkedlistctrl.h | 8 +- src/wx/widgets/dpi-support-mac.mm | 2 +- src/wx/widgets/dpi-support.cpp | 2 +- src/wx/widgets/group-check-box.cpp | 2 +- src/wx/widgets/keep-on-top-styler.cpp | 5 +- src/wx/widgets/keep-on-top-styler.h | 2 +- src/wx/widgets/option-validator.cpp | 2 +- src/wx/widgets/option-validator.h | 2 +- src/wx/widgets/render-plugin.cpp | 2 +- src/wx/widgets/render-plugin.h | 3 +- src/wx/widgets/sdljoy.cpp | 5 +- src/wx/widgets/{wx => }/sdljoy.h | 9 +- src/wx/widgets/user-input-ctrl.cpp | 7 +- src/wx/widgets/user-input-ctrl.h | 6 +- src/wx/widgets/{wx => }/webupdatedef.h | 0 src/wx/widgets/wxmisc.cpp | 3 +- src/wx/widgets/{wx => }/wxmisc.h | 6 +- src/wx/wxhead.h | 8 +- src/wx/wxlogdebug.h | 6 +- src/wx/wxutil.cpp | 2 +- src/wx/wxutil.h | 6 +- src/wx/wxvbam.cpp | 24 +- src/wx/wxvbam.h | 28 +- src/wx/wxvbam.rc | 2 +- src/wx/xaudio2.cpp | 2 +- 89 files changed, 985 insertions(+), 1438 deletions(-) delete mode 100644 po/CMakeLists.txt rename src/wx/widgets/{wx => }/checkedlistctrl.h (96%) rename src/wx/widgets/{wx => }/sdljoy.h (97%) rename src/wx/widgets/{wx => }/webupdatedef.h (100%) rename src/wx/widgets/{wx => }/wxmisc.h (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2ab37ed..4572c769 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,28 +184,6 @@ if(X86_64 AND (ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS OR ENABLE_MMX)) message(FATAL_ERROR "The options ASM_CORE, ASM_SCALERS and MMX are not supported on X86_64 yet.") endif() -if(NOT WIN32) - find_library(PTHREAD_LIB pthread) - if(PTHREAD_LIB) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${PTHREAD_LIB}) - set(VBAM_PTHREAD_LIB ${PTHREAD_LIB}) - endif() -elseif(MINGW) - if(NOT VBAM_STATIC) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -lpthread) - set(VBAM_PTHREAD_LIB -lpthread) - else() - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,-Bstatic -lwinpthread -Wl,-Bdynamic") - set(VBAM_PTHREAD_LIB "-Wl,-Bstatic -lwinpthread -Wl,-Bdynamic") - endif() -else() - find_package(PThreads4W) - if(PThreads4W_FOUND) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} PThreads4W::PThreads4W) - set(VBAM_PTHREAD_LIB PThreads4W::PThreads4W) - endif() -endif() - # Look for some dependencies using CMake scripts find_package(ZLIB REQUIRED) @@ -240,17 +218,9 @@ endif() set(VBAM_SDL2_LIBS SDL2::SDL2 ${SDL2_LIBRARY_TEMP}) -# set the standard libraries all ports use -set( - VBAMCORE_LIBS - vbam-core - ${VBAM_SDL2_LIBS} - ${OPENGL_LIBRARIES} -) - set(VBAM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated) -# Set up "src" as a global include directory. +# Set up "src" and generated directory as a global include directory. include_directories( ${CMAKE_SOURCE_DIR}/src ${VBAM_GENERATED_DIR} @@ -262,10 +232,10 @@ if(ENABLE_FFMPEG) endif() if(APPLE) - set(FFMPEG_LDFLAGS ${FFMPEG_LDFLAGS} -framework CoreText -framework ApplicationServices) + list(APPEND FFMPEG_LDFLAGS "SHELL:-framework CoreText" "SHELL:-framework ApplicationServices") if(UPSTREAM_RELEASE) - set(FFMPEG_LDFLAGS ${FFMPEG_LDFLAGS} -lbz2 -ltiff -framework DiskArbitration -lfreetype -lfontconfig -llzma -lxml2 -lharfbuzz) + list(APPEND FFMPEG_LDFLAGS -lbz2 -ltiff "SHELL:-framework DiskArbitration" -lfreetype -lfontconfig -llzma -lxml2 -lharfbuzz) endif() elseif(WIN32) set(WIN32_MEDIA_FOUNDATION_LIBS dxva2 evr mf mfplat mfplay mfreadwrite mfuuid amstrmid) @@ -366,24 +336,10 @@ if(NOT TRANSLATIONS_ONLY) add_subdirectory(src/core) add_subdirectory(src/components) add_subdirectory(src/sdl) -endif() - -if(ENABLE_WX) add_subdirectory(src/wx) - - # Native Language Support - if(ENABLE_NLS) - add_subdirectory(po) - endif() endif() -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/vba-over.ini DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/vbam) -# manual pages -if(UNIX) - if(ENABLE_WX) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/debian/visualboyadvance-m.6 DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man6) - endif() -endif() +add_subdirectory(po/wxvbam) set(CPACK_GENERATOR "ZIP") set(CPACK_SOURCE_GENERATOR "TGZ") diff --git a/cmake/Toolchain-gcc-clang.cmake b/cmake/Toolchain-gcc-clang.cmake index b7a85726..f1ba3686 100644 --- a/cmake/Toolchain-gcc-clang.cmake +++ b/cmake/Toolchain-gcc-clang.cmake @@ -14,6 +14,7 @@ endif() add_compile_options( -pipe -Wno-unused-command-line-argument + -Wno-deprecated-copy -Wformat -Wformat-security -feliminate-unused-debug-types diff --git a/cmake/Toolchain-msvc.cmake b/cmake/Toolchain-msvc.cmake index 566f497e..7259460b 100644 --- a/cmake/Toolchain-msvc.cmake +++ b/cmake/Toolchain-msvc.cmake @@ -20,6 +20,10 @@ add_compile_definitions( __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS _CRT_SECURE_NO_WARNINGS + _UNICODE + UNICODE + WINVER=0x0A00 + NTDDI_VERSION=0x0A000007 NOMINMAX ) add_compile_options( diff --git a/cmake/VbamFunctions.cmake b/cmake/VbamFunctions.cmake index f254e9f0..6e1344c6 100644 --- a/cmake/VbamFunctions.cmake +++ b/cmake/VbamFunctions.cmake @@ -1,48 +1,3 @@ -# From: https://stackoverflow.com/a/41416298/262458 -function(REMOVE_DUPES ARG_STR OUTPUT) - set(ARG_LIST ${ARG_STR}) - separate_arguments(ARG_LIST) - list(REMOVE_DUPLICATES ARG_LIST) - string (REGEX REPLACE "([^\\]|^);" "\\1 " _TMP_STR "${ARG_LIST}") - string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping - set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE) -endfunction() - -# From: https://stackoverflow.com/a/7216542 -function(JOIN VALUES GLUE OUTPUT) - string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}") - string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping - set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE) -endfunction() - -# On MSYS2 transform wx lib paths to native paths for Ninja. -function(normalize_wx_paths) - 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}" PARENT_SCOPE) - endif() -endfunction() - -macro(cleanup_wx_vars) - if(wxWidgets_CXX_FLAGS) - list(REMOVE_ITEM wxWidgets_CXX_FLAGS -fpermissive) - endif() -endmacro() function(cygpath var path) execute_process( @@ -157,5 +112,3 @@ function(find_wx_util var util) set(${var} ${util} PARENT_SCOPE) endforeach() endfunction() - -# vim:sw=4 sts et: diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt deleted file mode 100644 index 99ceb39a..00000000 --- a/po/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -IF(ENABLE_WX) - add_subdirectory(wxvbam) -ENDIF(ENABLE_WX) - diff --git a/po/wxvbam/CMakeLists.txt b/po/wxvbam/CMakeLists.txt index 85eecaa7..aea4e583 100644 --- a/po/wxvbam/CMakeLists.txt +++ b/po/wxvbam/CMakeLists.txt @@ -1,8 +1,7 @@ +if(NOT ENABLE_WX OR NOT ENABLE_NLS) + return() +endif() + file(GLOB po_files "${CMAKE_CURRENT_SOURCE_DIR}/*.po") -gettext_create_translations( - wxvbam.pot - ${po_files} -) - -add_dependencies(visualboyadvance-m translations) +gettext_create_translations(wxvbam.pot ${po_files}) diff --git a/src/core/gba/gbaLink.cpp b/src/core/gba/gbaLink.cpp index c15f9823..f39fa3f8 100644 --- a/src/core/gba/gbaLink.cpp +++ b/src/core/gba/gbaLink.cpp @@ -2601,7 +2601,7 @@ static ConnectionState InitIPC() linkid = 0; #if (defined __WIN32__ || defined _WIN32) - if ((mmf = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(LINKDATA), LOCAL_LINK_NAME)) == NULL) { + if ((mmf = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(LINKDATA), LOCAL_LINK_NAME)) == NULL) { systemMessage(0, N_("Error creating file mapping")); return LINK_ERROR; } @@ -2672,7 +2672,7 @@ static ConnectionState InitIPC() for (int i = 0; i < 4; i++) { linkevent[sizeof(linkevent) - 2] = (char)i + '1'; #if (defined __WIN32__ || defined _WIN32) - linksync[i] = firstone ? CreateSemaphore(NULL, 0, 4, linkevent) : OpenSemaphore(SEMAPHORE_ALL_ACCESS, false, linkevent); + linksync[i] = firstone ? CreateSemaphoreA(NULL, 0, 4, linkevent) : OpenSemaphoreA(SEMAPHORE_ALL_ACCESS, false, linkevent); if (linksync[i] == NULL) { UnmapViewOfFile(linkmem); CloseHandle(mmf); diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index bd6d72f4..23da006d 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -1,35 +1,165 @@ # Do not use this file directly. Always use the top level CMakeLists.txt file include(VbamFunctions) -set(VBAM_LIBS ${VBAMCORE_LIBS}) +set(VBAM_WX_COMMON + background-input.cpp + background-input.h + cmdevents.cpp + config/game-control.cpp + config/game-control.h + config/internal/option-internal.cpp + config/internal/option-internal.h + config/internal/shortcuts-internal.cpp + config/internal/shortcuts-internal.h + config/option-id.h + config/option-observer.cpp + config/option-observer.h + config/option-proxy.h + config/option.cpp + config/option.h + config/shortcuts.cpp + config/shortcuts.h + config/user-input.cpp + config/user-input.h + dialogs/accel-config.cpp + dialogs/accel-config.h + dialogs/directories-config.cpp + dialogs/directories-config.h + dialogs/display-config.cpp + dialogs/display-config.h + dialogs/game-boy-config.cpp + dialogs/game-boy-config.h + dialogs/game-maker.cpp + dialogs/game-maker.h + dialogs/gb-rom-info.cpp + dialogs/gb-rom-info.h + dialogs/joypad-config.cpp + dialogs/joypad-config.h + dialogs/validated-child.h + drawing.h + extra-translations.cpp + gfxviewers.cpp + guiinit.cpp + ioregs.h + openal.cpp + openal.h + opts.cpp + opts.h + panel.cpp + rpi.h + strutils.cpp + strutils.h + sys.cpp + viewers.cpp + viewsupt.cpp + viewsupt.h + wayland.cpp + wayland.h + # from external source with minor modifications + widgets/checkedlistctrl.cpp + widgets/checkedlistctrl.h + widgets/dpi-support.h + widgets/group-check-box.cpp + widgets/group-check-box.h + widgets/keep-on-top-styler.cpp + widgets/keep-on-top-styler.h + widgets/option-validator.cpp + widgets/option-validator.h + widgets/render-plugin.cpp + widgets/render-plugin.h + widgets/user-input-ctrl.cpp + widgets/user-input-ctrl.h + widgets/sdljoy.cpp + widgets/sdljoy.h + widgets/webupdatedef.h + widgets/wxmisc.h + widgets/wxmisc.cpp + wxhead.h + wxlogdebug.h + wxutil.cpp + wxutil.h + wxvbam.cpp + wxvbam.h + x11keymap.h + xrc/visualboyadvance-m.xpm + # Generated files. + ${VBAM_GENERATED_DIR}/wx//builtin-xrc.h + ${VBAM_GENERATED_DIR}/wx//builtin-over.h + ${VBAM_GENERATED_DIR}/wx//cmdhandlers.h + ${VBAM_GENERATED_DIR}/wx//cmd-evtable.h + ${VBAM_GENERATED_DIR}/wx//cmdtab.cpp +) -find_package(OpenAL REQUIRED) +if(NOT ZIP_PROGRAM) + find_program(ZIP_PROGRAM zip DOC "zip compressor executable") + if(WIN32 AND NOT ZIP_PROGRAM AND NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/zip.exe) + if(NOT DEFINED POWERSHELL) + message(FATAL_ERROR "Powershell is required for extraction.") + endif() -include_directories(${OPENAL_INCLUDE_DIR}) + # Get zip binaries from wxrc. + file(DOWNLOAD "https://www.willus.com/archive/zip64/infozip_binaries_win32.zip" ${CMAKE_CURRENT_BINARY_DIR}/infozip_binaries_win32.zip) -if(OPENAL_STATIC OR (WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe))) - add_compile_definitions(AL_LIBTYPE_STATIC) + # Unzip it. + execute_process( + COMMAND "${POWERSHELL}" -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('${CMAKE_CURRENT_BINARY_DIR}/infozip_binaries_win32.zip', '${CMAKE_CURRENT_BINARY_DIR}'); }" + ) + + set(ZIP_PROGRAM ${CMAKE_CURRENT_BINARY_DIR}/zip.exe CACHE STRING "zip compressor executable" FORCE) + endif() + if(ZIP_PROGRAM) + set(ZIP_PROGRAM "${ZIP_PROGRAM}" CACHE STRING "zip compressor executable" FORCE) + else(NOT ZIP_PROGRAM) + message(FATAL_ERROR "The zip compressor program is required for building.") + endif() endif() -list(APPEND VBAM_LIBS ${OPENAL_LIBRARY}) +# Make the translations.zip +if(ENABLE_NLS OR TRANSLATIONS_ONLY) + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/translations.zip + COMMAND ${CMAKE_COMMAND} -D "ZIP_PROGRAM=${ZIP_PROGRAM}" -P ${CMAKE_CURRENT_SOURCE_DIR}/make-translations-zip.cmake + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + DEPENDS translations make-translations-zip.cmake + ) -if(APPLE) - add_compile_definitions(wxMAC_USE_CORE_GRAPHICS) + add_custom_target( + translations-zip + SOURCES ${CMAKE_BINARY_DIR}/translations.zip + ) endif() -if(NOT ENABLE_XAUDIO2) - add_compile_definitions(NO_XAUDIO2) +if(TRANSLATIONS_ONLY OR NOT ENABLE_WX) + return() endif() -if(NOT ENABLE_DIRECT3D) - add_compile_definitions(NO_D3D) -endif() +set(VBAM_ICON visualboyadvance-m.icns) +set(VBAM_ICON_PATH ${CMAKE_CURRENT_SOURCE_DIR}/icons/${VBAM_ICON}) -if(ENABLE_FAUDIO) - find_package(FAudio REQUIRED) - list(APPEND VBAM_LIBS FAudio::FAudio) -else() - add_compile_definitions(NO_FAUDIO) +add_executable( + visualboyadvance-m + WIN32 + MACOSX_BUNDLE +) + +target_sources(visualboyadvance-m PRIVATE ${VBAM_WX_COMMON} ${VBAM_ICON_PATH}) +target_include_directories(visualboyadvance-m PRIVATE ${NONSTD_INCLUDE_DIR}) + +target_link_libraries( + visualboyadvance-m + nonstd-lib + vbam-core + vbam-components-audio-sdl + vbam-components-draw-text + vbam-components-filters + vbam-components-filters-agb + vbam-components-filters-interframe + vbam-components-user-config + ${OPENGL_LIBRARIES} +) + +if(ENABLE_NLS) + add_dependencies(visualboyadvance-m translations-zip) endif() # on unix we have to check for X11 before we overwrite all the compile/link @@ -38,488 +168,235 @@ if(NOT WIN32 AND NOT APPLE) find_package(X11) if(X11_X11_LIB) - include_directories(${X11_INCLUDE_DIR}) - list(APPEND VBAM_LIBS ${X11_X11_LIB}) - add_compile_definitions(HAVE_X11) + target_include_directories(visualboyadvance-m PRIVATE ${X11_INCLUDE_DIR}) + target_link_libraries(visualboyadvance-m ${X11_X11_LIB}) + target_compile_definitions(visualboyadvance-m PRIVATE HAVE_X11) if(X11_Xscreensaver_LIB) - list(APPEND VBAM_LIBS ${X11_Xscreensaver_LIB}) - add_compile_definitions(HAVE_XSS) + target_link_libraries(visualboyadvance-m ${X11_Xscreensaver_LIB}) + target_compile_definitions(visualboyadvance-m PRIVATE HAVE_XSS) endif() endif() find_library(EGL_LIBRARY EGL) if(EGL_LIBRARY) - list(APPEND VBAM_LIBS ${EGL_LIBRARY}) - add_compile_definitions(HAVE_EGL) + target_link_libraries(visualboyadvance-m ${EGL_LIBRARY}) + target_compile_definitions(visualboyadvance-m PRIVATE HAVE_EGL) endif() find_library(WAYLAND_LIBRARY wayland-client) - if(WAYLAND_LIBRARY) - list(APPEND VBAM_LIBS ${WAYLAND_LIBRARY}) + target_link_libraries(visualboyadvance-m ${WAYLAND_LIBRARY}) endif() endif() -# Win32 definitions common to all toolchains. -if (WIN32) - add_compile_definitions(_UNICODE UNICODE wxUSE_GUI=1 __WXMSW__ WINVER=0x0A00 NTDDI_VERSION=0x0A000007) -endif() - -find_program(ZIP_PROGRAM zip) -if(ZIP_PROGRAM) - set(ZIP_PROGRAM "${ZIP_PROGRAM}" CACHE STRING "zip compressor executable" FORCE) -endif() - -# on VS with vcpkg we can't use FindwxWidgets, we have to set everything up -# manually because the package is broken -if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg") - # set up wxwidgets stuff - set(libtype u) - unset(arch_suffix) - unset(path_prefix) - set(build_suffix -rel) - - if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") - set(libtype ud) - set(path_prefix debug) - set(build_suffix -dbg) - - add_compile_definitions(_DEBUG) - endif() - - set(build_suffix_rel -rel) - set(build_suffix_dbg -dbg) - - if(VCPKG_TARGET_TRIPLET MATCHES -static) - set(arch_suffix -static) - - set(build_suffix_rel -static-rel) - set(build_suffix_dbg -static-dbg) - - set(build_suffix -static${build_suffix}) - else() - add_compile_definitions(WXUSINGDLL) - endif() - - set(common_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}) - set(dbg_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}/debug) - set(installed_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}/${path_prefix}) - - include_directories(${installed_prefix}/lib/msw${libtype}) - include_directories(${common_prefix}/include) - set(wxWidgets_LIB_DIR ${installed_prefix}/lib) - - foreach(wx_lib - ${wxWidgets_LIB_DIR}/wxbase*${libtype}_net.lib - ${wxWidgets_LIB_DIR}/wxbase*${libtype}_xml.lib - ${wxWidgets_LIB_DIR}/wxmsw*${libtype}_core.lib - ${wxWidgets_LIB_DIR}/wxmsw*${libtype}_gl.lib - ${wxWidgets_LIB_DIR}/wxmsw*${libtype}_xrc.lib - ${wxWidgets_LIB_DIR}/wxmsw*${libtype}_html.lib - ${wxWidgets_LIB_DIR}/wxbase*${libtype}.lib +if(WIN32) + target_sources(visualboyadvance-m + PRIVATE + dsound.cpp + wxvbam.rc ) - file(GLOB wx_lib_file "${wx_lib}") + target_link_libraries(visualboyadvance-m + dxguid dsound wsock32 ws2_32 imm32 version winmm) - if(wx_lib_file) - list(APPEND wxWidgets_LIBRARIES "${wx_lib_file}") - endif() - endforeach() + # Force a re-link when the manifest file is modified. + set_target_properties(visualboyadvance-m + PROPERTIES + LINK_DEPENDS + "${CMAKE_CURRENT_LIST_DIR}/visualboyadvance-m.manifest") - list( - APPEND wxWidgets_LIBRARIES - winmm comctl32 oleacc rpcrt4 shlwapi version wsock32 opengl32 - ) - - if(EXISTS ${wxWidgets_LIB_DIR}/wxregex${libtype}.lib) - list(APPEND wxWidgets_LIBRARIES ${wxWidgets_LIB_DIR}/wxregex${libtype}.lib) + if(MSVC) + # Disable the auto-generated manifest from CMake. + target_link_options(visualboyadvance-m PRIVATE "/MANIFEST:NO") endif() - if(VCPKG_TARGET_TRIPLET MATCHES -static) - unset(deb_suffix) - if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") - set(deb_suffix d) - endif() + # wxWidgets fails to bring in its dependency. + find_library(PCRE_LIB pcre2-16 REQUIRED) + target_link_libraries(visualboyadvance-m ${PCRE_LIB}) +endif() - foreach(lib_name libpng jpeg lzma tiff libexpat pcre2 nanosvg) - file( - GLOB lib_file - ${wxWidgets_LIB_DIR}/${lib_name}*.lib - ) - - if(lib_file) - list(APPEND wxWidgets_LIBRARIES ${lib_file}) - endif() - endforeach() - endif() - - set(WXRC ${common_prefix}/tools/wxwidgets/wxrc.exe) - - set(ENV{PATH} "${dbg_prefix}/bin;${common_prefix}/bin;$ENV{PATH}") - - if(NOT ZIP_PROGRAM AND NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/zip.exe) - if(NOT DEFINED POWERSHELL) - message(FATAL_ERROR "Powershell is required for extraction.") - endif() - # get zip binary for wxrc - file(DOWNLOAD "https://www.willus.com/archive/zip64/infozip_binaries_win32.zip" ${CMAKE_CURRENT_BINARY_DIR}/infozip_binaries_win32.zip) - # unzip it - execute_process( - COMMAND "${POWERSHELL}" -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('${CMAKE_CURRENT_BINARY_DIR}/infozip_binaries_win32.zip', '${CMAKE_CURRENT_BINARY_DIR}'); }" - ) - - set(ZIP_PROGRAM ${CMAKE_CURRENT_BINARY_DIR}/zip.exe CACHE STRING "zip compressor executable" FORCE) - endif() - - # SDL2.dll does not get copied to build dir - if(NOT VCPKG_TARGET_TRIPLET MATCHES -static) - unset(deb_suffix) - if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") - set(deb_suffix d) - endif() - - set(dll_path ${installed_prefix}/bin/SDL2${deb_suffix}.dll) - - if(NOT EXISTS ${CMAKE_BINARY_DIR}/SDL2${deb_suffix}.dll AND EXISTS ${dll_path}) - file(COPY ${dll_path} DESTINATION ${CMAKE_BINARY_DIR}) - endif() - endif() +if(APPLE) + target_sources(visualboyadvance-m PRIVATE + macsupport.mm + widgets/dpi-support-mac.mm + ) else() - if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") - set(wxWidgets_USE_DEBUG ON) # noop if wx is compiled with --disable-debug, like in Mac Homebrew atm - endif() + target_sources(visualboyadvance-m PRIVATE + widgets/dpi-support.cpp + ) +endif() - set(wxWidgets_USE_UNICODE ON) - - # Check for gtk4 then gtk3 packages first, some dists like arch rename the - # wx-config utility for these packages to e.g. wx-config-gtk3 - # - # Do not do the check if the WX_CONFIG env var is set or the cmake variable - # is set - if(NOT wxWidgets_CONFIG_EXECUTABLE) - if(DEFINED ENV{WX_CONFIG}) - if(NOT CMAKE_HOST_WIN32) - separate_arguments(wxWidgets_CONFIG_EXECUTABLE UNIX_COMMAND "$ENV{WX_CONFIG}") - else() - set(wxWidgets_CONFIG_EXECUTABLE "$ENV{WX_CONFIG}") - endif() - else() - find_wx_util(wxWidgets_CONFIG_EXECUTABLE wx-config) - endif() - endif() - - # adv is for wxAboutBox - # xml, html is for xrc - # the gl lib may not be available, and if it looks like it is we still have to - # do a compile test later - find_package(wxWidgets COMPONENTS xrc xml html adv net core base gl) - - if(NOT wxWidgets_FOUND) - set(WX_HAS_OPENGL FALSE) - find_package(wxWidgets COMPONENTS xrc xml html adv net core base REQUIRED) - endif() - - cleanup_wx_vars() - normalize_wx_paths() - - include_directories(${wxWidgets_INCLUDE_DIRS}) - - if(CMAKE_BUILD_TYPE STREQUAL Debug) - # tell wx to enable debug mode if possible, if the cmake module did not do it for us - execute_process(COMMAND "${wxWidgets_CONFIG_EXECUTABLE} --debug=yes" RESULT_VARIABLE WX_CONFIG_DEBUG OUTPUT_QUIET ERROR_QUIET) - - if(WX_CONFIG_DEBUG EQUAL 0) - add_compile_definitions(wxDEBUG_LEVEL=1) - endif() - - # this one should be safe in non-debug builds too - add_compile_definitions(WXDEBUG) - endif() - - foreach(DEF ${wxWidgets_DEFINITIONS}) - add_compile_definitions("${DEF}") - endforeach() - - foreach(CXX_COMPILE_FLAG ${wxWidgets_CXX_FLAGS}) - add_compile_options(${CXX_COMPILE_FLAG}) - endforeach() - - # Remove "-framework System" from libs on macOS, it's not necessary and nix doesn't have it. - if(APPLE) - unset(tmp_libs) - foreach(lib ${wxWidgets_LIBRARIES}) - if(NOT lib STREQUAL "-framework System") - list(APPEND tmp_libs "${lib}") - endif() - endforeach() - set(wxWidgets_LIBRARIES "${tmp_libs}") - endif() - - # set up variables for some compile/run checks for wxWidgets - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${MY_CXX_FLAGS} ${MY_C_FLAGS} ${MY_CXX_LINKER_FLAGS} ${MY_C_LINKER_FLAGS} ${wxWidgets_LIBRARIES}) - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} ${wxWidgets_CXX_FLAGS} ${MY_CXX_FLAGS} ${MY_C_FLAGS}) +# link libgcc/libstdc++ statically on mingw +# and adjust link command when making a static binary +if(CMAKE_COMPILER_IS_GNUCXX AND VBAM_STATIC) + # some dists don't have a static libpthread + set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread ") if(WIN32) - set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} "-Wl,--subsystem,console") - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,--subsystem,console") + add_custom_command( + TARGET visualboyadvance-m PRE_LINK + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/msys-link-static.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + else() + add_custom_command( + TARGET visualboyadvance-m PRE_LINK + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/link-static.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) endif() +endif() - set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${wxWidgets_INCLUDE_DIRS}) +# OpenAL. +find_package(OpenAL REQUIRED) +if(OPENAL_STATIC OR (WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe))) + target_compile_definitions(visualboyadvance-m PRIVATE AL_LIBTYPE_STATIC) +endif() +target_include_directories(visualboyadvance-m PRIVATE ${OPENAL_INCLUDE_DIR}) +target_link_libraries(visualboyadvance-m ${OPENAL_LIBRARY}) - foreach(DEF ${wxWidgets_DEFINITIONS}) - set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} "-D${DEF}") - endforeach() +# XAudio2. +if(ENABLE_XAUDIO2) + target_sources(visualboyadvance-m PRIVATE xaudio2.cpp) +else() + target_compile_definitions(visualboyadvance-m PRIVATE NO_XAUDIO2) +endif() - # CheckCXXSourceCompiles ignores compiler flags, so we have to stuff them into the definitions - set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_FLAGS} ${CMAKE_REQUIRED_DEFINITIONS}) +# Direct3D. +if(NOT ENABLE_DIRECT3D) + target_compile_definitions(visualboyadvance-m PRIVATE NO_D3D) +endif() - # find the right C++ ABI version for wxWidgets, this is also necessary for the OpenGL check following +# FAudio. +if(ENABLE_FAUDIO) + find_package(FAudio REQUIRED) + target_link_libraries(visualboyadvance-m FAudio::FAudio) +else() + target_compile_definitions(visualboyadvance-m PRIVATE NO_FAUDIO) +endif() - # on FreeBSD the ABI check segfaults and always fails, and we don't - # need it because everything is built with clang - set(ABI_CHECK FALSE) +# wxWidgets. +set(wxWidgets_USE_UNICODE ON) +if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") + set(wxWidgets_USE_DEBUG ON) # noop if wx is compiled with --disable-debug, like in Mac Homebrew atm +endif() +if(VBAM_STATIC) + set(wxWidgets_USE_STATIC ON) +endif() +find_package(wxWidgets COMPONENTS xrc xml html adv net core base gl) +if(NOT wxWidgets_FOUND) + set(WX_HAS_OPENGL FALSE) + find_package(wxWidgets COMPONENTS xrc xml html adv net core base REQUIRED) +endif() - if((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - AND NOT CMAKE_CROSSCOMPILING - AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" - AND NOT CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg" - AND NOT TRANSLATIONS_ONLY) +target_link_libraries(visualboyadvance-m ${wxWidgets_LIBRARIES}) +target_include_directories(visualboyadvance-m PRIVATE ${wxWidgets_INCLUDE_DIRS}) +target_compile_options(visualboyadvance-m PRIVATE ${wxWidgets_CXX_FLAGS}) +target_compile_definitions(visualboyadvance-m PRIVATE ${wxWidgets_DEFINITIONS}) +if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") + target_compile_definitions(visualboyadvance-m PRIVATE ${wxWidgets_DEFINITIONS_DEBUG}) +endif() - set(ABI_CHECK TRUE) - endif() +list(APPEND CMAKE_REQUIRED_LIBRARIES ${wxWidgets_LIBRARIES}) +list(APPEND CMAKE_REQUIRED_INCLUDES ${wxWidgets_INCLUDE_DIRS}) +list(APPEND CMAKE_REQUIRED_FLAGS ${wxWidgets_CXX_FLAGS}) +foreach(DEF ${wxWidgets_DEFINITIONS}) + list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D${DEF}") +endforeach() - if(ABI_CHECK) - set(WX_ABI_FOUND_MATCH FALSE) - - include(CheckCXXSourceRuns) - - set(WX_TEST_CONSOLE_APP " -#include -#include -#include - -#ifdef _WIN32 -#include -#include \"MinHook.h\" - -typedef int (WINAPI *MESSAGEBOXW)(HWND, LPCWSTR, LPCWSTR, UINT); -typedef int (WINAPI *MESSAGEBOXA)(HWND, LPCSTR, LPCSTR, UINT); - -// Pointers for calling original MessageBoxW/A. -MESSAGEBOXW fpMessageBoxW = NULL; -MESSAGEBOXA fpMessageBoxA = NULL; - -// Detour function which overrides MessageBoxW. -int WINAPI DetourMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType) -{ - std::wcerr << lpCaption << \": \" << lpText << std::endl; -} - -// Detour function which overrides MessageBoxA. -int WINAPI DetourMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) -{ - std::cerr << lpCaption << \": \" << lpText << std::endl; -} -#endif - -class MyApp : public wxAppConsole { -public: - virtual bool OnInit(); - // this is necessary for 2.8 to make the class non-abstract - virtual int OnRun() { return 0; } -}; - -bool MyApp::OnInit() { - exit(0); -} - -#if wxCHECK_VERSION(2, 9, 0) -wxIMPLEMENT_APP_NO_MAIN(MyApp); -#else -IMPLEMENT_APP_NO_MAIN(MyApp); -#endif - -int main(int argc, char** argv) -{ -#ifdef _WIN32 - // just in case (this does nothing though) - SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); - - // we need to install a trampoline for messageboxes, because Wx is - // hard-coded to show a messagebox on wxLogFatalError() - - // Initialize MinHook (for trampoline). - if (MH_Initialize() != MH_OK) return 1; - - // Create a hook for MessageBoxW and MessageBoxA - if (MH_CreateHook(reinterpret_cast(&MessageBoxW), reinterpret_cast(&DetourMessageBoxW), reinterpret_cast(&fpMessageBoxW)) != MH_OK) - return 1; - if (MH_CreateHook(reinterpret_cast(&MessageBoxA), reinterpret_cast(&DetourMessageBoxA), reinterpret_cast(&fpMessageBoxA)) != MH_OK) - return 1; - - if (MH_EnableHook(reinterpret_cast(&MessageBoxW)) != MH_OK) return 1; - if (MH_EnableHook(reinterpret_cast(&MessageBoxA)) != MH_OK) return 1; -#endif - - wxEntry(argc, argv); - wxEntryCleanup(); - return 0; -} -") - - # on windows we need the trampoline library from dependencies - if(WIN32) - # minhook requires -fpermissive unfortunately - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -fpermissive) - set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -fpermissive -w "-I${CMAKE_SOURCE_DIR}/dependencies/minhook/include") - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -Wl,--subsystem,console) - - if(X86_64) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "${CMAKE_SOURCE_DIR}/dependencies/minhook/libMinHook_64.a") - else() # assume 32 bit windows - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "${CMAKE_SOURCE_DIR}/dependencies/minhook/libMinHook.a") - endif() - endif() - - check_cxx_source_runs("${WX_TEST_CONSOLE_APP}" WX_DEFAULT_ABI_VERSION_COMPATIBLE) - - # remove -fpermissive set for minhook - list(REMOVE_ITEM CMAKE_REQUIRED_FLAGS -fpermissive) - list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -fpermissive) - - if(NOT WX_DEFAULT_ABI_VERSION_COMPATIBLE) - # currently goes up to 11 with gcc7, but we give it some room - set(WX_ABI_VERSION 15) - - set(CURRENT_DEFS ${CMAKE_REQUIRED_DEFINITIONS}) - set(CURRENT_LIBS ${CMAKE_REQUIRED_LIBRARIES}) - - while(NOT WX_ABI_VERSION EQUAL -1) - if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_DEFS} "-fabi-version=${WX_ABI_VERSION}") - set(CMAKE_REQUIRED_LIBRARIES ${CURRENT_LIBS} "-fabi-version=${WX_ABI_VERSION}") - elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) - set(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_DEFS} "-D__GXX_ABI_VERSION=10${WX_ABI_VERSION}") - set(CMAKE_REQUIRED_LIBRARIES ${CURRENT_LIBS} "-D__GXX_ABI_VERSION=10${WX_ABI_VERSION}") - endif() - - set(WX_ABI_VAR "WX_ABI_VERSION_${WX_ABI_VERSION}") - - check_cxx_source_runs("${WX_TEST_CONSOLE_APP}" ${WX_ABI_VAR}) - - if(${${WX_ABI_VAR}}) - set(WX_ABI_FOUND_MATCH TRUE) - break() - endif() - - math(EXPR WX_ABI_VERSION "${WX_ABI_VERSION} - 1") - endwhile() - - set(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_DEFS}) - set(CMAKE_REQUIRED_LIBRARIES ${CURRENT_LIBS}) - endif() - - if(WX_ABI_FOUND_MATCH) - # add C++ flags - if(CMAKE_COMPILER_IS_GNUCXX) - string(REGEX REPLACE "" " -fabi-version=${WX_ABI_VERSION} " CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}") - set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -fabi-version=${WX_ABI_VERSION}") - elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) - string(REGEX REPLACE "" " -D__GXX_ABI_VERSION=10${WX_ABI_VERSION} " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT}) - set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -D__GXX_ABI_VERSION=10${WX_ABI_VERSION}") - endif() - endif() - endif() - - # now check for OpenGL - include(CheckCXXSourceCompiles) - - if(NOT DEFINED WX_HAS_OPENGL) - check_cxx_source_compiles(" +# Check for OpenGL. +include(CheckCXXSourceCompiles) +if(NOT DEFINED WX_HAS_OPENGL) + check_cxx_source_compiles(" #include #include #include int main(int argc, char** argv) { - wxGLCanvas canvas(NULL, wxID_ANY, NULL, wxPoint(0, 0), wxSize(300, 300), 0); - return 0; +wxGLCanvas canvas(NULL, wxID_ANY, NULL, wxPoint(0, 0), wxSize(300, 300), 0); +return 0; }" WX_HAS_OPENGL) +endif() +if(NOT WX_HAS_OPENGL) + target_compile_definitions(visualboyadvance-m PRIVATE NO_OGL) +endif() + +# we make some direct gtk/gdk calls on linux and such +# so need to link the gtk that wx was built with +if(NOT WIN32 AND NOT APPLE) + find_package(PkgConfig REQUIRED) + + find_path(WX_CONFIG_H NAMES wx/config.h PATHS ${wxWidgets_INCLUDE_DIRS}) + if(NOT WX_CONFIG_H) + message(FATAL_ERROR "Could not find wx/config.h in ${wxWidgets_INCLUDE_DIRS}") endif() + set(WX_CONFIG_H "${WX_CONFIG_H}/wx/config.h") - if(NOT WX_HAS_OPENGL) - add_compile_definitions(NO_OGL) - endif() - - # end of wx compile checks - - # we make some direct gtk/gdk calls on linux and such - # so need to link the gtk that wx was built with - if(NOT WIN32 AND NOT APPLE) - find_package(PkgConfig REQUIRED) - - find_path(WX_CONFIG_H NAMES wx/config.h PATHS ${wxWidgets_INCLUDE_DIRS}) - if(NOT WX_CONFIG_H) - message(FATAL_ERROR "Could not find wx/config.h in ${wxWidgets_INCLUDE_DIRS}") + include(CheckCXXSymbolExists) + check_cxx_symbol_exists(__WXGTK4__ ${WX_CONFIG_H} WX_USING_GTK4) + check_cxx_symbol_exists(__WXGTK3__ ${WX_CONFIG_H} WX_USING_GTK3) + if(WX_USING_GTK4) + pkg_check_modules(GTK4 REQUIRED gtk+-4.0) + if(NOT GTK4_INCLUDE_DIRS) + message(FATAL_ERROR "Could not find gtk4") endif() - set(WX_CONFIG_H "${WX_CONFIG_H}/wx/config.h") - - include(CheckCXXSymbolExists) - check_cxx_symbol_exists(__WXGTK4__ ${WX_CONFIG_H} WX_USING_GTK4) - check_cxx_symbol_exists(__WXGTK3__ ${WX_CONFIG_H} WX_USING_GTK3) - if(WX_USING_GTK4) - pkg_check_modules(GTK4 REQUIRED gtk+-4.0) - if(NOT GTK4_INCLUDE_DIRS) - message(FATAL_ERROR "Could not find gtk4") - endif() - include_directories(${GTK4_INCLUDE_DIRS}) - link_directories(${GTK4_LIBRARY_DIRS}) - add_compile_options(${GTK4_CFLAGS_OTHER}) - list(APPEND VBAM_LIBS ${GTK4_LIBRARIES}) - elseif(WX_USING_GTK3) - pkg_check_modules(GTK3 REQUIRED gtk+-3.0) - if(NOT GTK3_INCLUDE_DIRS) - message(FATAL_ERROR "Could not find gtk3") - endif() - include_directories(${GTK3_INCLUDE_DIRS}) - link_directories(${GTK3_LIBRARY_DIRS}) - add_compile_options(${GTK3_CFLAGS_OTHER}) - list(APPEND VBAM_LIBS ${GTK3_LIBRARIES}) - else() - check_cxx_symbol_exists(__WXGTK20__ ${WX_CONFIG_H} WX_USING_GTK2) - if(WX_USING_GTK2) - # try to use pkg-config to find gtk2 first - pkg_check_modules(GTK2 REQUIRED gtk+-2.0) - if(GTK2_INCLUDE_DIRS) - include_directories(${GTK2_INCLUDE_DIRS}) - link_directories(${GTK2_LIBRARY_DIRS}) - add_compile_options(${GTK2_CFLAGS_OTHER}) - list(APPEND VBAM_LIBS ${GTK2_LIBRARIES}) - else() - # and if that fails, use the cmake module - find_package(GTK2 REQUIRED gtk) - if(NOT GTK2_INCLUDE_DIRS) - message(FATAL_ERROR "Could not find gtk2") - endif() - include_directories(${GTK2_INCLUDE_DIRS}) - add_compile_options(${GTK2_DEFINITIONS}) - list(APPEND VBAM_LIBS ${GTK2_LIBRARIES}) - endif() + target_include_directories(visualboyadvance-m PRIVATE ${GTK4_INCLUDE_DIRS}) + target_link_directories(visualboyadvance-m PRIVATE ${GTK4_LIBRARY_DIRS}) + target_compile_options(visualboyadvance-m PRIVATE ${GTK4_CFLAGS_OTHER}) + target_link_libraries(visualboyadvance-m ${GTK4_LIBRARIES}) + elseif(WX_USING_GTK3) + pkg_check_modules(GTK3 REQUIRED gtk+-3.0) + if(NOT GTK3_INCLUDE_DIRS) + message(FATAL_ERROR "Could not find gtk3") + endif() + target_include_directories(visualboyadvance-m PRIVATE ${GTK3_INCLUDE_DIRS}) + target_link_directories(visualboyadvance-m PRIVATE ${GTK3_LIBRARY_DIRS}) + target_compile_options(visualboyadvance-m PRIVATE ${GTK3_CFLAGS_OTHER}) + target_link_libraries(visualboyadvance-m ${GTK3_LIBRARIES}) + else() + check_cxx_symbol_exists(__WXGTK20__ ${WX_CONFIG_H} WX_USING_GTK2) + if(WX_USING_GTK2) + # try to use pkg-config to find gtk2 first + pkg_check_modules(GTK2 REQUIRED gtk+-2.0) + if(GTK2_INCLUDE_DIRS) + target_include_directories(visualboyadvance-m PRIVATE ${GTK2_INCLUDE_DIRS}) + target_link_directories(visualboyadvance-m PRIVATE ${GTK2_LIBRARY_DIRS}) + target_compile_options(visualboyadvance-m PRIVATE ${GTK2_CFLAGS_OTHER}) + target_link_libraries(visualboyadvance-m ${GTK2_LIBRARIES}) else() - find_package(GTK REQUIRED gtk) - if(NOT GTK_INCLUDE_DIRS) - message(FATAL_ERROR "Could not find gtk") + # and if that fails, use the cmake module + find_package(GTK2 REQUIRED gtk) + if(NOT GTK2_INCLUDE_DIRS) + message(FATAL_ERROR "Could not find gtk2") endif() - include_directories(${GTK_INCLUDE_DIRS}) - add_compile_options(${GTK_DEFINITIONS}) - list(APPEND VBAM_LIBS ${GTK_LIBRARIES}) + target_include_directories(visualboyadvance-m PRIVATE ${GTK2_INCLUDE_DIRS}) + target_compile_options(visualboyadvance-m PRIVATE ${GTK2_DEFINITIONS}) + target_link_libraries(visualboyadvance-m ${GTK2_LIBRARIES}) endif() + else() + find_package(GTK REQUIRED gtk) + if(NOT GTK_INCLUDE_DIRS) + message(FATAL_ERROR "Could not find gtk") + endif() + target_include_directories(visualboyadvance-m PRIVATE ${GTK_INCLUDE_DIRS}) + target_compile_options(visualboyadvance-m PRIVATE ${GTK_DEFINITIONS}) + target_link_libraries(visualboyadvance-m ${GTK_LIBRARIES}) endif() endif() +endif() - if(wxWidgets_USE_FILE) - include(${wxWidgets_USE_FILE}) +# FFMPeg. +if(ENABLE_FFMPEG) + target_link_libraries( + visualboyadvance-m + vbam-components-av-recording + ${FFMPEG_LIBRARIES} + ) + + if(FFMPEG_LDFLAGS) + target_link_options(visualboyadvance-m PRIVATE ${FFMPEG_LDFLAGS}) endif() -endif() # wxWidgets checks +endif() if(ENABLE_NLS) if(MSVC) @@ -551,7 +428,6 @@ if(ENABLE_NLS) endif() find_package(Gettext REQUIRED) - find_program(XGETTEXT xgettext) find_program(MSGINIT msginit) @@ -560,80 +436,18 @@ if(ENABLE_NLS) endif() endif() -# contrib widgets -include_directories(widgets) - -# for out-of-tree builds, grab includes from both target and source dirs -include_directories(${CMAKE_CURRENT_BINARY_DIR}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - -if(NOT ZIP_PROGRAM) - find_program(ZIP_PROGRAM zip DOC "zip compressor executable") - - if(NOT ZIP_PROGRAM) - message(FATAL_ERROR "The zip compressor program is required for building.") - endif() -endif() - -set( - XRC_SOURCES - xrc/AccelConfig.xrc - xrc/CheatAdd.xrc - xrc/CheatCreate.xrc - xrc/CheatEdit.xrc - xrc/CheatList.xrc - xrc/CodeSelect.xrc - xrc/DirectoriesConfig.xrc - xrc/Disassemble.xrc - xrc/DisplayConfig.xrc - xrc/ExportSPS.xrc - xrc/GBAROMInfo.xrc - xrc/GBColorPrefPanel.xrc - xrc/GBDisassemble.xrc - xrc/GBMapViewer.xrc - xrc/GBOAMViewer.xrc - xrc/GBPaletteViewer.xrc - xrc/GBPrinter.xrc - xrc/GBROMInfo.xrc - xrc/GBTileViewer.xrc - xrc/GameBoyAdvanceConfig.xrc - xrc/GameBoyConfig.xrc - xrc/GeneralConfig.xrc - xrc/IOViewer.xrc - xrc/JoyPanel.xrc - xrc/JoypadConfig.xrc - xrc/LinkConfig.xrc - xrc/Logging.xrc - xrc/MainFrame.xrc - xrc/MainIcon.xrc - xrc/MainMenu.xrc - xrc/MapViewer.xrc - xrc/MemSelRegion.xrc - xrc/MemViewer.xrc - xrc/NetLink.xrc - xrc/OAMViewer.xrc - xrc/PaletteViewer.xrc - xrc/SoundConfig.xrc - xrc/TileViewer.xrc - xrc/SpeedupConfig.xrc -) - # wxrc does not support xrs files in -c output (> 10x compression) -# we do it using the bin2c.c utility - -if(CMAKE_CROSSCOMPILING) - set(BIN2C ${CMAKE_BINARY_DIR}/bin2c) -else() - set(BIN2C bin2c) -endif() - +# we do it using the bin2c.c utility. +set(BIN2C ${CMAKE_BINARY_DIR}/bin2c) include(HostCompile) host_compile(${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c ${BIN2C}) +# Override wxrc when cross-compiling. if(CMAKE_HOST_WIN32 AND CMAKE_CROSSCOMPILING) set(WXRC ${CMAKE_SOURCE_DIR}/dependencies/wxrc/wxrc.exe) endif() +# Configure wxrc. if(WXRC AND NOT CMAKE_HOST_WIN32) separate_arguments(WXRC UNIX_COMMAND ${WXRC}) elseif(DEFINED ENV{WXRC}) @@ -684,668 +498,485 @@ endif() if(NOT WXRC) find_wx_util(WXRC wxrc) + if(NOT WXRC) + message(FATAL_ERROR "Could not find a wxrc executable.") + endif() endif() -if(NOT WXRC) - message(WARNING "could not find your wxrc executable") - set(WXRC wxrc) -endif() - -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/wxvbam.xrs - COMMAND ${CMAKE_COMMAND} -E env "PATH=$ENV{PATH}" ${WXRC} ${XRC_SOURCES} -o ${CMAKE_CURRENT_BINARY_DIR}/wxvbam.xrs - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${XRC_SOURCES} +# Build the resources. +set( + VBAM_XRC_FILES + xrc/AccelConfig.xrc + xrc/CheatAdd.xrc + xrc/CheatCreate.xrc + xrc/CheatEdit.xrc + xrc/CheatList.xrc + xrc/CodeSelect.xrc + xrc/DirectoriesConfig.xrc + xrc/Disassemble.xrc + xrc/DisplayConfig.xrc + xrc/ExportSPS.xrc + xrc/GBAROMInfo.xrc + xrc/GBColorPrefPanel.xrc + xrc/GBDisassemble.xrc + xrc/GBMapViewer.xrc + xrc/GBOAMViewer.xrc + xrc/GBPaletteViewer.xrc + xrc/GBPrinter.xrc + xrc/GBROMInfo.xrc + xrc/GBTileViewer.xrc + xrc/GameBoyAdvanceConfig.xrc + xrc/GameBoyConfig.xrc + xrc/GeneralConfig.xrc + xrc/IOViewer.xrc + xrc/JoyPanel.xrc + xrc/JoypadConfig.xrc + xrc/LinkConfig.xrc + xrc/Logging.xrc + xrc/MainFrame.xrc + xrc/MainIcon.xrc + xrc/MainMenu.xrc + xrc/MapViewer.xrc + xrc/MemSelRegion.xrc + xrc/MemViewer.xrc + xrc/NetLink.xrc + xrc/OAMViewer.xrc + xrc/PaletteViewer.xrc + xrc/SoundConfig.xrc + xrc/TileViewer.xrc + xrc/SpeedupConfig.xrc ) add_custom_command( - OUTPUT builtin-xrc.h - COMMAND ${BIN2C} wxvbam.xrs builtin-xrc.h builtin_xrs - DEPENDS wxvbam.xrs ${BIN2C} + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/wxvbam.xrs + COMMAND ${CMAKE_COMMAND} -E env "PATH=$ENV{PATH}" ${WXRC} ${VBAM_XRC_FILES} -o ${CMAKE_CURRENT_BINARY_DIR}/wxvbam.xrs + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${VBAM_XRC_FILES} +) + +add_custom_command( + OUTPUT ${VBAM_GENERATED_DIR}/wx/builtin-xrc.h + COMMAND ${BIN2C} ${CMAKE_CURRENT_BINARY_DIR}/wxvbam.xrs ${VBAM_GENERATED_DIR}/wx/builtin-xrc.h builtin_xrs + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/wxvbam.xrs ${BIN2C} ) # use a built-in vba-over.ini if no config file present add_custom_command( - OUTPUT builtin-over.h - COMMAND ${BIN2C} ${CMAKE_CURRENT_SOURCE_DIR}/../vba-over.ini builtin-over.h builtin_over - DEPENDS ../vba-over.ini ${BIN2C} + OUTPUT ${VBAM_GENERATED_DIR}/wx/builtin-over.h + COMMAND ${BIN2C} ${CMAKE_SOURCE_DIR}/src/vba-over.ini ${VBAM_GENERATED_DIR}/wx/builtin-over.h builtin_over + DEPENDS ${CMAKE_SOURCE_DIR}/src/vba-over.ini ${BIN2C} ) # I don't like duplicating/triplicating code, so I only declare # event handlers once, and copy them in other places they are needed # all using portable cmake code add_custom_command( - OUTPUT cmdtab.cpp cmdhandlers.h cmd-evtable.h - COMMAND ${CMAKE_COMMAND} -D OUTDIR=${CMAKE_CURRENT_BINARY_DIR} -P copy-events.cmake - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS cmdevents.cpp copy-events.cmake + OUTPUT + ${VBAM_GENERATED_DIR}/wx/cmdtab.cpp + ${VBAM_GENERATED_DIR}/wx/cmdhandlers.h + ${VBAM_GENERATED_DIR}/wx/cmd-evtable.h + COMMAND + ${CMAKE_COMMAND} -D OUTDIR=${VBAM_GENERATED_DIR}/wx/ -P copy-events.cmake + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS + cmdevents.cpp + copy-events.cmake ) +# # Win32 definitions common to all toolchains. +# if (WIN32) +# add_compile_definitions(wxUSE_GUI=1) +# endif() -# the following should be in the main file for consistency with -# other front ends, but can't due to cmake issues -# then again, the main file should be split up into separate dirs anyway - -set( - SRC_WX - wxvbam.cpp - background-input.cpp - guiinit.cpp - viewers.cpp - gfxviewers.cpp - cmdevents.cpp - extra-translations.cpp - opts.cpp - sys.cpp - panel.cpp - viewsupt.cpp - wayland.cpp - strutils.cpp - wxutil.cpp - config/game-control.cpp - config/internal/option-internal.cpp - config/internal/shortcuts-internal.cpp - config/option-observer.cpp - config/option.cpp - config/shortcuts.cpp - config/user-input.cpp - dialogs/accel-config.cpp - dialogs/directories-config.cpp - dialogs/display-config.cpp - dialogs/game-boy-config.cpp - dialogs/game-maker.cpp - dialogs/gb-rom-info.cpp - dialogs/joypad-config.cpp - widgets/group-check-box.cpp - widgets/keep-on-top-styler.cpp - widgets/option-validator.cpp - widgets/render-plugin.cpp - widgets/sdljoy.cpp - widgets/user-input-ctrl.cpp - widgets/wxmisc.cpp - # from external source with minor modifications - widgets/checkedlistctrl.cpp +set(VBAM_LOCALIZABLE_FILES ${VBAM_WX_COMMON}) +list(APPEND VBAM_LOCALIZABLE_FILES + autoupdater/autoupdater.h + autoupdater/macos/autoupdater.cpp + autoupdater/macos/sparkle-wrapper.h + autoupdater/wxmsw/autoupdater.cpp + autoupdater/wxmsw/winsparkle-rc.h + autoupdater/wxmsw/winsparkle-wrapper.cpp + autoupdater/wxmsw/winsparkle-wrapper.h + dsound.cpp + faudio.cpp + widgets/dpi-support.cpp + widgets/dpi-support-mac.mm + xaudio2.cpp + ${CMAKE_SOURCE_DIR}/src/core/gba/gbaLink.cpp ) -set(ALL_SRC_WX ${SRC_WX}) - -list(APPEND ALL_SRC_WX ${CMAKE_CURRENT_SOURCE_DIR}/widgets/dpi-support.cpp) - -if(APPLE) - list(APPEND SRC_WX macsupport.mm) - list(APPEND SRC_WX widgets/dpi-support-mac.mm) -else() - list(APPEND SRC_WX widgets/dpi-support.cpp) -endif() - -set( - HDR_WX - wxvbam.h - background-input.h - wxlogdebug.h - drawing.h - ioregs.h - opts.h - viewsupt.h - wxhead.h - wayland.h - wxutil.h - config/game-control.h - config/internal/option-internal.h - config/internal/shortcuts-internal.h - config/option-id.h - config/option-observer.h - config/option-proxy.h - config/option.h - config/shortcuts.h - config/user-input.h - dialogs/accel-config.h - dialogs/directories-config.h - dialogs/display-config.h - dialogs/game-boy-config.h - dialogs/game-maker.h - dialogs/gb-rom-info.h - dialogs/joypad-config.h - dialogs/validated-child.h - widgets/dpi-support.h - widgets/group-check-box.h - widgets/keep-on-top-styler.h - widgets/option-validator.h - widgets/render-plugin.h - widgets/user-input-ctrl.h - widgets/wx/sdljoy.h - widgets/wx/webupdatedef.h - widgets/wx/wxmisc.h - # from external source with minor modifications - widgets/wx/checkedlistctrl.h -) - -set(ALL_HDR_WX ${HDR_WX}) -# make files included for gettext pot generation -list(APPEND ALL_SRC_WX autoupdater/wxmsw/autoupdater.cpp) -list(APPEND ALL_HDR_WX autoupdater/autoupdater.h) -list(APPEND ALL_SRC_WX autoupdater/wxmsw/winsparkle-wrapper.cpp) -list(APPEND ALL_HDR_WX autoupdater/wxmsw/winsparkle-wrapper.h) -list(APPEND ALL_HDR_WX autoupdater/wxmsw/winsparkle-rc.h) - -if(WIN32 AND (X86_64 OR X86_32) AND ENABLE_ONLINEUPDATES) - list(APPEND SRC_WX autoupdater/wxmsw/autoupdater.cpp) - list(APPEND HDR_WX autoupdater/autoupdater.h) - list(APPEND SRC_WX autoupdater/wxmsw/winsparkle-wrapper.cpp) - list(APPEND HDR_WX autoupdater/wxmsw/winsparkle-wrapper.h) - list(APPEND HDR_WX autoupdater/wxmsw/winsparkle-rc.h) -endif() - -# make files included for gettext pot generation -list(APPEND ALL_HDR_WX autoupdater/autoupdater.h) -list(APPEND ALL_SRC_WX autoupdater/macos/autoupdater.cpp) -list(APPEND ALL_HDR_WX autoupdater/macos/sparkle-wrapper.h) - -if(APPLE AND ENABLE_ONLINEUPDATES) - list(APPEND HDR_WX autoupdater/autoupdater.h) - list(APPEND SRC_WX autoupdater/macos/autoupdater.cpp) - list(APPEND SRC_WX autoupdater/macos/sparkle-wrapper.mm) - list(APPEND HDR_WX autoupdater/macos/sparkle-wrapper.h) -endif() - -set( - RES_WX - ${XRC_SOURCES} - ../vba-over.ini - # icon File - xrc/visualboyadvance-m.xpm - # generated includes must be explicitly listed - ${CMAKE_CURRENT_BINARY_DIR}/builtin-xrc.h - ${CMAKE_CURRENT_BINARY_DIR}/builtin-over.h - ${CMAKE_CURRENT_BINARY_DIR}/cmdhandlers.h - ${CMAKE_CURRENT_BINARY_DIR}/cmd-evtable.h - # generated - ${CMAKE_CURRENT_BINARY_DIR}/cmdtab.cpp -) - -set( - CM_STUFF - copy-events.cmake -) - -list(APPEND ALL_SRC_WX openal.cpp) -list(APPEND ALL_HDR_WX openal.h) - -list(APPEND SRC_WX openal.cpp) -list(APPEND HDR_WX openal.h) - -list(APPEND ALL_SRC_WX xaudio2.cpp) - -if(ENABLE_XAUDIO2) - list(APPEND SRC_WX xaudio2.cpp) -endif() - -list(APPEND ALL_SRC_WX faudio.cpp) - -if(ENABLE_FAUDIO) - list(APPEND SRC_WX faudio.cpp) -endif() - -list(APPEND ALL_SRC_WX dsound.cpp) - -if(WIN32) - list(APPEND SRC_WX dsound.cpp) - - list(APPEND RES_WX wxvbam.rc) - - list(APPEND VBAM_LIBS dxguid dsound wsock32 ws2_32 imm32 version) -endif() - -link_directories(${CMAKE_BINARY_DIR}) - -set(VBAM_ICON visualboyadvance-m.icns) - -set(VBAM_ICON_PATH ${CMAKE_CURRENT_SOURCE_DIR}/icons/${VBAM_ICON}) - if(APPLE) set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) set(CMAKE_INSTALL_RPATH "@loader_path/../Frameworks") endif() -if(NOT TRANSLATIONS_ONLY) - add_executable( +if(WIN32 AND (X86_64 OR X86_32) AND ENABLE_ONLINEUPDATES) + if(NOT DEFINED WINSPARKLE_BIN_RELEASE_DIR) + set(WINSPARKLE_BIN_RELEASE_DIR ${CMAKE_SOURCE_DIR}/dependencies/WinSparkle-0.6.0) + endif() + + target_include_directories( visualboyadvance-m - WIN32 - MACOSX_BUNDLE - ${SRC_WX} - ${HDR_WX} - ${RES_WX} - ${VBAM_ICON_PATH} - ${CM_STUFF} + PRIVATE ${WINSPARKLE_BIN_RELEASE_DIR}/include ) - target_include_directories(visualboyadvance-m PRIVATE ${NONSTD_INCLUDE_DIR}) - - if(WIN32 AND (X86_64 OR X86_32) AND ENABLE_ONLINEUPDATES) - if(NOT DEFINED WINSPARKLE_BIN_RELEASE_DIR) - set(WINSPARKLE_BIN_RELEASE_DIR ${CMAKE_SOURCE_DIR}/dependencies/WinSparkle-0.6.0) - endif() - - target_include_directories( - visualboyadvance-m - PRIVATE ${WINSPARKLE_BIN_RELEASE_DIR}/include - ) - - if(X86_64) - set(WINSPARKLE_DLL ${CMAKE_SOURCE_DIR}/dependencies/WinSparkle-0.6.0/x64/Release/WinSparkle.dll) - else() - set(WINSPARKLE_DLL ${CMAKE_SOURCE_DIR}/dependencies/WinSparkle-0.6.0/Release/WinSparkle.dll) - endif() - - configure_file(autoupdater/wxmsw/winsparkle-path.h.in ${CMAKE_BINARY_DIR}/winsparkle-path.h) + if(X86_64) + set(WINSPARKLE_DLL ${CMAKE_SOURCE_DIR}/dependencies/WinSparkle-0.6.0/x64/Release/WinSparkle.dll) + else() + set(WINSPARKLE_DLL ${CMAKE_SOURCE_DIR}/dependencies/WinSparkle-0.6.0/Release/WinSparkle.dll) endif() - if(APPLE AND ENABLE_ONLINEUPDATES) - include(FetchContent) - FetchContent_Declare(Sparkle - URL "https://github.com/sparkle-project/Sparkle/releases/download/2.3.0-beta.2/Sparkle-2.3.0-beta.2.tar.xz" - URL_HASH SHA256=6875388aae23c1705c3956c62a9c967f4b788bc4f1dad93ab5645bc6096ef13b - DOWNLOAD_EXTRACT_TIMESTAMP TRUE - ) - FetchContent_MakeAvailable(Sparkle) - - find_library(SPARKLE_FRAMEWORK - NAMES Sparkle - HINTS ${sparkle_SOURCE_DIR} - ) - find_path(SPARKLE_INCLUDE_DIR Sparkle.h HINTS ${SPARKLE_FRAMEWORK}/Headers) - target_include_directories( - visualboyadvance-m - PRIVATE ${SPARKLE_INCLUDE_DIR} - ) - - set(APPCAST_URL "https://data.visualboyadvance-m.org/appcast.xml") - set(CCS1 rm -rf ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Frameworks/Sparkle.framework) - set(CCS2 mkdir -p ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Frameworks) - # The following commands *should* be run to make sure Sparkle is not going - # to bug randomly. - set(CCS3 cp -a ${SPARKLE_FRAMEWORK} ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Frameworks/Sparkle.framework) - set(CCS6 defaults write ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Info.plist SUEnableAutomaticChecks -bool YES) - #set(CCS7 defaults write ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Info.plist SUPublicEDKey -string "${PUBLIC_KEY}") - set(CCS8 defaults write ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Info.plist SUFeedURL -string "${APPCAST_URL}") - add_custom_command(TARGET visualboyadvance-m POST_BUILD - COMMAND ${CCS1} - COMMAND ${CCS2} - COMMAND ${CCS3} - COMMAND ${CCS6} - #COMMAND ${CCS7} - COMMAND ${CCS8} - ) - - TARGET_LINK_LIBRARIES(visualboyadvance-m ${SPARKLE_FRAMEWORK}) - endif() - - target_link_libraries( - visualboyadvance-m - ${wxWidgets_LIBRARIES} - ${VBAM_LIBS} - nonstd-lib - vbam-components-audio-sdl - vbam-components-draw-text - vbam-components-filters - vbam-components-filters-agb - vbam-components-filters-interframe - vbam-components-user-config - ) - - if(ENABLE_FFMPEG) - target_link_libraries( - visualboyadvance-m - vbam-components-av-recording - ${FFMPEG_LIBRARIES} - ) - - if(FFMPEG_LDFLAGS) - join("${FFMPEG_LDFLAGS}" " " FFMPEG_LDFLAGS_STR) - - set_target_properties( - visualboyadvance-m - PROPERTIES LINK_FLAGS ${FFMPEG_LDFLAGS_STR} - ) - endif() - endif() - - if(WIN32) - # Force a re-link when the manifest file is modified. - set_target_properties(visualboyadvance-m - PROPERTIES - LINK_DEPENDS - "${CMAKE_CURRENT_LIST_DIR}/visualboyadvance-m.manifest") - - if(MSVC) - # Disable the auto-generated manifest from CMake. - target_link_options(visualboyadvance-m PRIVATE "/MANIFEST:NO") - endif() - endif() - - # link libgcc/libstdc++ statically on mingw - # and adjust link command when making a static binary - if(CMAKE_COMPILER_IS_GNUCXX AND VBAM_STATIC) - # some dists don't have a static libpthread - set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread ") - - if(WIN32) - add_custom_command( - TARGET visualboyadvance-m PRE_LINK - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/msys-link-static.cmake - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - else() - add_custom_command( - TARGET visualboyadvance-m PRE_LINK - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/link-static.cmake - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - endif() - endif() - - if(NOT WIN32 AND NOT APPLE) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/visualboyadvance-m.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/visualboyadvance-m.metainfo.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo) - install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/icons/sizes/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor) - endif() + configure_file(autoupdater/wxmsw/winsparkle-path.h.in ${CMAKE_BINARY_DIR}/winsparkle-path.h) endif() -# Make the translations.zip -if(ENABLE_NLS) - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/translations.zip - COMMAND ${CMAKE_COMMAND} -D "ZIP_PROGRAM=${ZIP_PROGRAM}" -P ${CMAKE_CURRENT_SOURCE_DIR}/make-translations-zip.cmake - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - DEPENDS translations make-translations-zip.cmake +if(APPLE AND ENABLE_ONLINEUPDATES) + include(FetchContent) + FetchContent_Declare(Sparkle + URL "https://github.com/sparkle-project/Sparkle/releases/download/2.3.0-beta.2/Sparkle-2.3.0-beta.2.tar.xz" + URL_HASH SHA256=6875388aae23c1705c3956c62a9c967f4b788bc4f1dad93ab5645bc6096ef13b + DOWNLOAD_EXTRACT_TIMESTAMP TRUE + ) + FetchContent_MakeAvailable(Sparkle) + + find_library(SPARKLE_FRAMEWORK + NAMES Sparkle + HINTS ${sparkle_SOURCE_DIR} + ) + find_path(SPARKLE_INCLUDE_DIR Sparkle.h HINTS ${SPARKLE_FRAMEWORK}/Headers) + target_include_directories( + visualboyadvance-m + PRIVATE ${SPARKLE_INCLUDE_DIR} ) - add_custom_target( - translations-zip - SOURCES ${CMAKE_BINARY_DIR}/translations.zip + set(APPCAST_URL "https://data.visualboyadvance-m.org/appcast.xml") + set(CCS1 rm -rf ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Frameworks/Sparkle.framework) + set(CCS2 mkdir -p ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Frameworks) + # The following commands *should* be run to make sure Sparkle is not going + # to bug randomly. + set(CCS3 cp -a ${SPARKLE_FRAMEWORK} ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Frameworks/Sparkle.framework) + set(CCS6 defaults write ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Info.plist SUEnableAutomaticChecks -bool YES) + #set(CCS7 defaults write ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Info.plist SUPublicEDKey -string "${PUBLIC_KEY}") + set(CCS8 defaults write ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Info.plist SUFeedURL -string "${APPCAST_URL}") + add_custom_command(TARGET visualboyadvance-m POST_BUILD + COMMAND ${CCS1} + COMMAND ${CCS2} + COMMAND ${CCS3} + COMMAND ${CCS6} + #COMMAND ${CCS7} + COMMAND ${CCS8} ) - add_dependencies(visualboyadvance-m translations-zip) + TARGET_LINK_LIBRARIES(visualboyadvance-m ${SPARKLE_FRAMEWORK}) +endif() + +if(NOT WIN32 AND NOT APPLE) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/visualboyadvance-m.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/visualboyadvance-m.metainfo.xml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/icons/sizes/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor) endif() # Update the gettext pot source. # Do this automatically instead of manually to make sure we don't forget to update. if(ENABLE_NLS) - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/wx-xrc-strings.h - COMMAND ${CMAKE_COMMAND} -E env "PATH=$ENV{PATH}" ${WXRC} -g ${XRC_SOURCES} -o ${CMAKE_BINARY_DIR}/wx-xrc-strings.h - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${XRC_SOURCES} + add_custom_target( + vbam-wx-xrc-strings + COMMAND ${CMAKE_COMMAND} + -E env + "PATH=$ENV{PATH}" + ${WXRC} + -g ${VBAM_XRC_FILES} + -o ${CMAKE_BINARY_DIR}/wx-xrc-strings.h + BYPRODUCTS + ${CMAKE_BINARY_DIR}/wx-xrc-strings.h + WORKING_DIRECTORY + ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS + ${VBAM_XRC_FILES} ) - add_custom_target(xrc-strings DEPENDS ${CMAKE_BINARY_DIR}/wx-xrc-strings.h) - - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/wxvbam.pot - COMMAND ${XGETTEXT} -k_ -kN_ -o ${CMAKE_BINARY_DIR}/wxvbam.pot ${ALL_SRC_WX} ${ALL_HDR_WX} ${CMAKE_BINARY_DIR}/wx-xrc-strings.h - DEPENDS ${ALL_SRC_WX} ${ALL_HDR_WX} ${CMAKE_BINARY_DIR}/wx-xrc-strings.h + add_custom_target( + vbam-wx-pot + COMMAND ${XGETTEXT} + -k_ -kN_ + -o ${CMAKE_BINARY_DIR}/wxvbam.pot + ${VBAM_LOCALIZABLE_FILES} ${CMAKE_BINARY_DIR}/wx-xrc-strings.h + BYPRODUCTS + ${CMAKE_BINARY_DIR}/wxvbam.pot + DEPENDS + ${VBAM_LOCALIZABLE_FILES} ${CMAKE_BINARY_DIR}/wx-xrc-strings.h WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) - add_custom_target(gettext-pot ALL DEPENDS ${CMAKE_BINARY_DIR}/wxvbam.pot) - - add_dependencies(gettext-pot xrc-strings) - add_custom_command( - TARGET gettext-pot + TARGET vbam-wx-pot POST_BUILD - COMMAND ${CMAKE_COMMAND} -D SRC_DIR=${CMAKE_SOURCE_DIR}/po/wxvbam -D BIN_DIR=${CMAKE_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/check-pot-updated.cmake + COMMAND ${CMAKE_COMMAND} + -DSRC_DIR=${CMAKE_SOURCE_DIR}/po/wxvbam + -DBIN_DIR=${CMAKE_BINARY_DIR} + -P ${CMAKE_CURRENT_SOURCE_DIR}/check-pot-updated.cmake ) endif() -if(NOT TRANSLATIONS_ONLY) - find_program(GPG_PROGRAM gpg) +find_program(GPG_PROGRAM gpg) +if(GPG_PROGRAM) + execute_process( + COMMAND ${GPG_PROGRAM} -k + OUTPUT_VARIABLE GPG_KEYS + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) +endif() - if(GPG_PROGRAM) - execute_process( - COMMAND ${GPG_PROGRAM} -k - OUTPUT_VARIABLE GPG_KEYS - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET - ) +if(NOT ZIP_SUFFIX) + set(ZIP_SUFFIX "") +endif() + +if(UPSTREAM_RELEASE AND WIN32) + set(home "$ENV{HOME}") + + if((MSVC OR NOT CMAKE_CROSSCOMPILING) AND NOT DEFINED ENV{MSYSTEM_PREFIX}) + set(home "$ENV{USERPROFILE}") endif() - if(NOT ZIP_SUFFIX) - set(ZIP_SUFFIX "") - endif() + # rewrite backslashes to slashes, needed for msys osslsigncode + string(REGEX REPLACE "\\\\" "/" home "${home}") - if(UPSTREAM_RELEASE AND WIN32) - set(home "$ENV{HOME}") + set(cert "${home}/.codesign/windows_comodo.pkcs12") - if((MSVC OR NOT CMAKE_CROSSCOMPILING) AND NOT DEFINED ENV{MSYSTEM_PREFIX}) - set(home "$ENV{USERPROFILE}") - endif() - - # rewrite backslashes to slashes, needed for msys osslsigncode - string(REGEX REPLACE "\\\\" "/" home "${home}") - - set(cert "${home}/.codesign/windows_comodo.pkcs12") - - if(EXISTS "${cert}") - find_program(OSSLSIGNCODE_PROGRAM osslsigncode) - find_program(SIGNTOOL_PROGRAM signtool) - - if(OSSLSIGNCODE_PROGRAM) - add_custom_command( - TARGET visualboyadvance-m - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E rename visualboyadvance-m.exe visualboyadvance-m-unsigned.exe - COMMAND ${OSSLSIGNCODE_PROGRAM} sign -pkcs12 ${cert} -pass "vbam3!13" -t http://timestamp.digicert.com -n visualboyadvance-m -i https://github.com/visualboyadvance-m/visualboyadvance-m -in visualboyadvance-m-unsigned.exe -out visualboyadvance-m.exe - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - elseif(SIGNTOOL_PROGRAM) - add_custom_command( - TARGET visualboyadvance-m - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy visualboyadvance-m.exe visualboyadvance-m-unsigned.exe - COMMAND ${SIGNTOOL_PROGRAM} sign /f ${cert} /p "vbam3!13" /tr http://timestamp.digicert.com /du https://github.com/visualboyadvance-m/visualboyadvance-m /a visualboyadvance-m.exe - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - endif() - endif() - - if(CMAKE_BUILD_TYPE STREQUAL Debug) - set(exezip visualboyadvance-m-Win-${ARCH_NAME}-debug${ZIP_SUFFIX}.zip) - else() - set(exezip visualboyadvance-m-Win-${ARCH_NAME}${ZIP_SUFFIX}.zip) - endif() - - unset(pdb_file) - - if(MSVC AND CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") - set(pdb_file visualboyadvance-m.pdb) - endif() - - add_custom_command( - TARGET visualboyadvance-m - POST_BUILD - COMMAND ${ZIP_PROGRAM} -9 ${exezip} visualboyadvance-m.exe ${pdb_file} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - - if(GPG_KEYS) - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/translations.zip.asc - COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/translations.zip.asc - # COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/interactive-pause.cmake - COMMAND ${GPG_PROGRAM} --detach-sign -a ${CMAKE_BINARY_DIR}/translations.zip - DEPENDS ${CMAKE_BINARY_DIR}/translations.zip - ) - - add_custom_target(translations-zip-sig DEPENDS ${CMAKE_BINARY_DIR}/translations.zip.asc) - - add_dependencies(translations-zip translations-zip-sig) + if(EXISTS "${cert}") + find_program(OSSLSIGNCODE_PROGRAM osslsigncode) + find_program(SIGNTOOL_PROGRAM signtool) + if(OSSLSIGNCODE_PROGRAM) add_custom_command( TARGET visualboyadvance-m POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove ${exezip}.asc - # COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/interactive-pause.cmake - COMMAND ${GPG_PROGRAM} --detach-sign -a ${exezip} + COMMAND ${CMAKE_COMMAND} -E rename visualboyadvance-m.exe visualboyadvance-m-unsigned.exe + COMMAND ${OSSLSIGNCODE_PROGRAM} sign -pkcs12 ${cert} -pass "vbam3!13" -t http://timestamp.digicert.com -n visualboyadvance-m -i https://github.com/visualboyadvance-m/visualboyadvance-m -in visualboyadvance-m-unsigned.exe -out visualboyadvance-m.exe WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - endif() - - if(NOT MSVC AND CMAKE_BUILD_TYPE MATCHES "^(Release|MinSizeRel)$") - find_program(STRIP_PROGRAM strip) - - if(STRIP_PROGRAM) - add_custom_command( - TARGET visualboyadvance-m - POST_BUILD - COMMAND ${STRIP_PROGRAM} visualboyadvance-m.exe - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) - endif() - endif() - endif() - - if(APPLE) - # this should set ROM file types correctly - set_property(TARGET visualboyadvance-m APPEND PROPERTY MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/wxplist.in) - set(MACOSX_BUNDLE_ICON_FILE ${VBAM_ICON}) - set_source_files_properties(${VBAM_ICON_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) - - # bundle dylibs and relink them for releasing .app - # also install translations into the .app - # but only in Release mode - if(CMAKE_BUILD_TYPE MATCHES "^(Release|MinSizeRel)$") - add_custom_command( - TARGET visualboyadvance-m POST_BUILD - COMMAND ${CMAKE_SOURCE_DIR}/tools/macOS/third_party_libs_tool ./visualboyadvance-m.app - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - ) - endif() - - add_custom_command( - TARGET visualboyadvance-m POST_BUILD - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/mac-translations.cmake - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - - set(ver ${VBAM_VERSION}) - - if(NOT VBAM_VERSION_RELEASE) - set(ver "${ver}-${VBAM_REVISION}") - endif() - - add_custom_command( - TARGET visualboyadvance-m POST_BUILD - COMMAND defaults write ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Info.plist CFBundleVersion -string "${ver}" - COMMAND defaults write ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Info.plist CFBundleShortVersionString -string "${ver}" - COMMAND plutil -convert xml1 ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Info.plist - ) - endif() - - if(APPLE AND UPSTREAM_RELEASE) - if(CMAKE_BUILD_TYPE MATCHES "^(Release|MinSizeRel)$") - find_program(STRIP_PROGRAM strip) - - if(STRIP_PROGRAM) - add_custom_command( - TARGET visualboyadvance-m - POST_BUILD - COMMAND ${STRIP_PROGRAM} visualboyadvance-m.app/Contents/MacOS/visualboyadvance-m - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - endif() - endif() - - add_custom_command( - TARGET visualboyadvance-m - POST_BUILD - VERBATIM COMMAND sh -c [=[codesign --sign "Developer ID Application" --options runtime --timestamp --force --deep ./visualboyadvance-m.app || :]=] - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - - if(EXISTS ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Frameworks) - # Sign frameworks individually, like Xcode. - file(GLOB frameworks ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Frameworks/*) - foreach(framework ${frameworks}) - message(STATUS "Signing framework: " ${framework}) - add_custom_command( - TARGET visualboyadvance-m - POST_BUILD - VERBATIM COMMAND sh -c "codesign --sign 'Developer ID Application' --options runtime --timestamp --force --deep ${framework} || :" - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - endforeach() - endif() - - # Zip, notarize, staple to the .app and zip again - - if(CMAKE_BUILD_TYPE STREQUAL Debug) - set(appzip visualboyadvance-m-Mac-${ARCH_NAME}-debug${ZIP_SUFFIX}.zip) - else() - set(appzip visualboyadvance-m-Mac-${ARCH_NAME}${ZIP_SUFFIX}.zip) - endif() - - add_custom_command( - TARGET visualboyadvance-m - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove ${appzip} - COMMAND ${ZIP_PROGRAM} -9yr ${appzip} ./visualboyadvance-m.app - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - - add_custom_command( - TARGET visualboyadvance-m - POST_BUILD - COMMAND xcrun notarytool submit ${appzip} --keychain-profile AC_PASSWORD --wait - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - - add_custom_command( - TARGET visualboyadvance-m - POST_BUILD - COMMAND xcrun stapler staple ./visualboyadvance-m.app - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - - add_custom_command( - TARGET visualboyadvance-m - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove ${appzip} - COMMAND ${ZIP_PROGRAM} -9yr ${appzip} ./visualboyadvance-m.app - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) - - if(GPG_KEYS) + elseif(SIGNTOOL_PROGRAM) add_custom_command( TARGET visualboyadvance-m POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove ${appzip}.asc - COMMAND ${GPG_PROGRAM} --detach-sign -a ${appzip} + COMMAND ${CMAKE_COMMAND} -E copy visualboyadvance-m.exe visualboyadvance-m-unsigned.exe + COMMAND ${SIGNTOOL_PROGRAM} sign /f ${cert} /p "vbam3!13" /tr http://timestamp.digicert.com /du https://github.com/visualboyadvance-m/visualboyadvance-m /a visualboyadvance-m.exe WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - ) + ) endif() endif() - if(UPSTREAM_RELEASE AND NOT WIN32 AND NOT APPLE AND CMAKE_BUILD_TYPE MATCHES "^(Release|MinSizeRel)$") + if(CMAKE_BUILD_TYPE STREQUAL Debug) + set(exezip visualboyadvance-m-Win-${ARCH_NAME}-debug${ZIP_SUFFIX}.zip) + else() + set(exezip visualboyadvance-m-Win-${ARCH_NAME}${ZIP_SUFFIX}.zip) + endif() + + unset(pdb_file) + + if(MSVC AND CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") + set(pdb_file visualboyadvance-m.pdb) + endif() + + add_custom_command( + TARGET visualboyadvance-m + POST_BUILD + COMMAND ${ZIP_PROGRAM} -9 ${exezip} visualboyadvance-m.exe ${pdb_file} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + + if(GPG_KEYS) + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/translations.zip.asc + COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/translations.zip.asc +# COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/interactive-pause.cmake + COMMAND ${GPG_PROGRAM} --detach-sign -a ${CMAKE_BINARY_DIR}/translations.zip + DEPENDS ${CMAKE_BINARY_DIR}/translations.zip + ) + + add_custom_target(translations-zip-sig DEPENDS ${CMAKE_BINARY_DIR}/translations.zip.asc) + + add_dependencies(translations-zip translations-zip-sig) + + add_custom_command( + TARGET visualboyadvance-m + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E remove ${exezip}.asc +# COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/interactive-pause.cmake + COMMAND ${GPG_PROGRAM} --detach-sign -a ${exezip} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + endif() + + if(NOT MSVC AND CMAKE_BUILD_TYPE MATCHES "^(Release|MinSizeRel)$") find_program(STRIP_PROGRAM strip) if(STRIP_PROGRAM) add_custom_command( TARGET visualboyadvance-m POST_BUILD - COMMAND ${STRIP_PROGRAM} visualboyadvance-m + COMMAND ${STRIP_PROGRAM} visualboyadvance-m.exe + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + endif() + endif() +endif() + +if(APPLE) + # this should set ROM file types correctly + set(MACOSX_BUNDLE_ICON_FILE ${VBAM_ICON}) + set_property(TARGET visualboyadvance-m APPEND PROPERTY MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/wxplist.in) + set_source_files_properties(${VBAM_ICON_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + + # bundle dylibs and relink them for releasing .app + # also install translations into the .app + # but only in Release mode + if(CMAKE_BUILD_TYPE MATCHES "^(Release|MinSizeRel)$") + add_custom_command( + TARGET visualboyadvance-m POST_BUILD + COMMAND ${CMAKE_SOURCE_DIR}/tools/macOS/third_party_libs_tool ./visualboyadvance-m.app + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + ) + endif() + + add_custom_command( + TARGET visualboyadvance-m POST_BUILD + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/mac-translations.cmake + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + + set(ver ${VBAM_VERSION}) + + if(NOT VBAM_VERSION_RELEASE) + set(ver "${ver}-${VBAM_REVISION}") + endif() + + add_custom_command( + TARGET visualboyadvance-m POST_BUILD + COMMAND defaults write ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Info.plist CFBundleVersion -string "${ver}" + COMMAND defaults write ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Info.plist CFBundleShortVersionString -string "${ver}" + COMMAND plutil -convert xml1 ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Info.plist + ) +endif() + +if(APPLE AND UPSTREAM_RELEASE) + if(CMAKE_BUILD_TYPE MATCHES "^(Release|MinSizeRel)$") + find_program(STRIP_PROGRAM strip) + + if(STRIP_PROGRAM) + add_custom_command( + TARGET visualboyadvance-m + POST_BUILD + COMMAND ${STRIP_PROGRAM} visualboyadvance-m.app/Contents/MacOS/visualboyadvance-m WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) endif() endif() - install( - TARGETS visualboyadvance-m - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} + add_custom_command( + TARGET visualboyadvance-m + POST_BUILD + VERBATIM COMMAND sh -c [=[codesign --sign "Developer ID Application" --options runtime --timestamp --force --deep ./visualboyadvance-m.app || :]=] + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) - if(BUILD_TESTING AND (NOT CMAKE_CROSSCOMPILING)) - add_subdirectory(tests) + if(EXISTS ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Frameworks) + # Sign frameworks individually, like Xcode. + file(GLOB frameworks ${CMAKE_BINARY_DIR}/visualboyadvance-m.app/Contents/Frameworks/*) + foreach(framework ${frameworks}) + message(STATUS "Signing framework: " ${framework}) + add_custom_command( + TARGET visualboyadvance-m + POST_BUILD + VERBATIM COMMAND sh -c "codesign --sign 'Developer ID Application' --options runtime --timestamp --force --deep ${framework} || :" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + endforeach() + endif() + + # Zip, notarize, staple to the .app and zip again + + if(CMAKE_BUILD_TYPE STREQUAL Debug) + set(appzip visualboyadvance-m-Mac-${ARCH_NAME}-debug${ZIP_SUFFIX}.zip) + else() + set(appzip visualboyadvance-m-Mac-${ARCH_NAME}${ZIP_SUFFIX}.zip) + endif() + + add_custom_command( + TARGET visualboyadvance-m + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E remove ${appzip} + COMMAND ${ZIP_PROGRAM} -9yr ${appzip} ./visualboyadvance-m.app + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + + add_custom_command( + TARGET visualboyadvance-m + POST_BUILD + COMMAND xcrun notarytool submit ${appzip} --keychain-profile AC_PASSWORD --wait + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + + add_custom_command( + TARGET visualboyadvance-m + POST_BUILD + COMMAND xcrun stapler staple ./visualboyadvance-m.app + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + + add_custom_command( + TARGET visualboyadvance-m + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E remove ${appzip} + COMMAND ${ZIP_PROGRAM} -9yr ${appzip} ./visualboyadvance-m.app + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + + if(GPG_KEYS) + add_custom_command( + TARGET visualboyadvance-m + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E remove ${appzip}.asc + COMMAND ${GPG_PROGRAM} --detach-sign -a ${appzip} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) endif() endif() + +if(UPSTREAM_RELEASE AND NOT WIN32 AND NOT APPLE AND CMAKE_BUILD_TYPE MATCHES "^(Release|MinSizeRel)$") + find_program(STRIP_PROGRAM strip) + + if(STRIP_PROGRAM) + add_custom_command( + TARGET visualboyadvance-m + POST_BUILD + COMMAND ${STRIP_PROGRAM} visualboyadvance-m + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + endif() +endif() + +install( + TARGETS visualboyadvance-m + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} +) + +if(BUILD_TESTING AND (NOT CMAKE_CROSSCOMPILING)) + add_subdirectory(tests) +endif() + +# Installation scripts. +install( + PROGRAMS ${PROJECT_BINARY_DIR}/visualboyadvance-m${CMAKE_EXECUTABLE_SUFFIX} + DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} +) +install( + FILES ${CMAKE_SOURCE_DIR}/src/vba-over.ini + DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/vbam +) + +if (UNIX) + install(FILES ${CMAKE_SOURCE_DIR}/src/debian/visualboyadvance-m.6 DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man6) +endif() diff --git a/src/wx/autoupdater/wxmsw/winsparkle-wrapper.cpp b/src/wx/autoupdater/wxmsw/winsparkle-wrapper.cpp index 21655ab9..5de96086 100644 --- a/src/wx/autoupdater/wxmsw/winsparkle-wrapper.cpp +++ b/src/wx/autoupdater/wxmsw/winsparkle-wrapper.cpp @@ -3,7 +3,7 @@ #include #include -#include "wxvbam.h" +#include "wx/wxvbam.h" #include "winsparkle-wrapper.h" #include "wx/msw/private.h" diff --git a/src/wx/background-input.cpp b/src/wx/background-input.cpp index 916379ac..aa7fd52a 100644 --- a/src/wx/background-input.cpp +++ b/src/wx/background-input.cpp @@ -10,7 +10,7 @@ #include #include #include -#include "wayland.h" +#include "wx/wayland.h" #endif // defined(__WXMSW__) diff --git a/src/wx/background-input.h b/src/wx/background-input.h index d738c95d..94ee4d75 100644 --- a/src/wx/background-input.h +++ b/src/wx/background-input.h @@ -1,5 +1,5 @@ -#ifndef BACKGROUND_INPUT_H -#define BACKGROUND_INPUT_H +#ifndef VBAM_WX_BACKGROUND_INPUT_H_ +#define VBAM_WX_BACKGROUND_INPUT_H_ #include #include @@ -7,10 +7,8 @@ #include #include -#include - void enableKeyboardBackgroundInput(wxEvtHandler* handler); void disableKeyboardBackgroundInput(); -#endif // BACKGROUND_INPUT_H +#endif // VBAM_WX_BACKGROUND_INPUT_H_ diff --git a/src/wx/cmdevents.cpp b/src/wx/cmdevents.cpp index 8fe30b86..80a04349 100644 --- a/src/wx/cmdevents.cpp +++ b/src/wx/cmdevents.cpp @@ -1,4 +1,4 @@ -#include "wxvbam.h" +#include "wx/wxvbam.h" #include #include @@ -11,8 +11,6 @@ #include #include "components/filters_interframe/interframe.h" -#include "config/option-proxy.h" -#include "config/option.h" #include "core/base/version.h" #include "core/gb/gb.h" #include "core/gb/gbCheats.h" @@ -24,7 +22,9 @@ #include "core/gba/gbaGlobals.h" #include "core/gba/gbaPrint.h" #include "core/gba/gbaSound.h" -#include "dialogs/game-maker.h" +#include "wx/config/option-proxy.h" +#include "wx/config/option.h" +#include "wx/dialogs/game-maker.h" #define GetXRCDialog(n) \ wxStaticCast(wxGetApp().frame->FindWindowByName(n), wxDialog) diff --git a/src/wx/config/game-control.cpp b/src/wx/config/game-control.cpp index dae9a4b9..efd1e022 100644 --- a/src/wx/config/game-control.cpp +++ b/src/wx/config/game-control.cpp @@ -1,8 +1,8 @@ -#include "config/game-control.h" +#include "wx/config/game-control.h" -#include "../strutils.h" -#include "opts.h" -#include "wxlogdebug.h" +#include "wx/opts.h" +#include "wx/strutils.h" +#include "wx/wxlogdebug.h" namespace config { diff --git a/src/wx/config/game-control.h b/src/wx/config/game-control.h index 9d2473e6..10ef1c0d 100644 --- a/src/wx/config/game-control.h +++ b/src/wx/config/game-control.h @@ -9,7 +9,7 @@ #include -#include "config/user-input.h" +#include "wx/config/user-input.h" namespace config { diff --git a/src/wx/config/internal/option-internal.cpp b/src/wx/config/internal/option-internal.cpp index 8f71694d..cd44e15e 100644 --- a/src/wx/config/internal/option-internal.cpp +++ b/src/wx/config/internal/option-internal.cpp @@ -1,4 +1,4 @@ -#include "config/option.h" +#include "wx/config/option.h" // Helper implementation file to define and compile all of these huge constants // separately. These should not be updated very often, so having these in a @@ -13,10 +13,10 @@ #include "core/base/system.h" #include "core/gb/gbGlobals.h" #include "core/gba/gbaSound.h" -#include "opts.h" +#include "wx/opts.h" #define VBAM_OPTION_INTERNAL_INCLUDE -#include "config/internal/option-internal.h" +#include "wx/config/internal/option-internal.h" #undef VBAM_OPTION_INTERNAL_INCLUDE struct CoreOptions coreOptions; diff --git a/src/wx/config/internal/option-internal.h b/src/wx/config/internal/option-internal.h index aa87baa1..c1962ded 100644 --- a/src/wx/config/internal/option-internal.h +++ b/src/wx/config/internal/option-internal.h @@ -8,7 +8,7 @@ #include -#include "config/option.h" +#include "wx/config/option.h" namespace config { namespace internal { diff --git a/src/wx/config/internal/shortcuts-internal.cpp b/src/wx/config/internal/shortcuts-internal.cpp index 79892517..d77d0f82 100644 --- a/src/wx/config/internal/shortcuts-internal.cpp +++ b/src/wx/config/internal/shortcuts-internal.cpp @@ -1,9 +1,9 @@ -#include "config/shortcuts.h" +#include "wx/config/shortcuts.h" #include #define VBAM_SHORTCUTS_INTERNAL_INCLUDE -#include "config/internal/shortcuts-internal.h" +#include "wx/config/internal/shortcuts-internal.h" #undef VBAM_SHORTCUTS_INTERNAL_INCLUDE namespace config { diff --git a/src/wx/config/internal/shortcuts-internal.h b/src/wx/config/internal/shortcuts-internal.h index ddf38ea6..01b44820 100644 --- a/src/wx/config/internal/shortcuts-internal.h +++ b/src/wx/config/internal/shortcuts-internal.h @@ -5,7 +5,7 @@ #include #include -#include "config/user-input.h" +#include "wx/config/user-input.h" namespace config { namespace internal { diff --git a/src/wx/config/option-observer.cpp b/src/wx/config/option-observer.cpp index b8007412..cd802dfd 100644 --- a/src/wx/config/option-observer.cpp +++ b/src/wx/config/option-observer.cpp @@ -1,6 +1,6 @@ -#include "config/option-observer.h" +#include "wx/config/option-observer.h" -#include "config/option.h" +#include "wx/config/option.h" namespace config { diff --git a/src/wx/config/option-observer.h b/src/wx/config/option-observer.h index 4d467ac8..87c36a72 100644 --- a/src/wx/config/option-observer.h +++ b/src/wx/config/option-observer.h @@ -6,7 +6,7 @@ #include #include -#include "config/option-id.h" +#include "wx/config/option-id.h" namespace config { diff --git a/src/wx/config/option-proxy.h b/src/wx/config/option-proxy.h index 367162d4..3b132611 100644 --- a/src/wx/config/option-proxy.h +++ b/src/wx/config/option-proxy.h @@ -4,8 +4,8 @@ #include #include -#include "config/option-id.h" -#include "config/option.h" +#include "wx/config/option-id.h" +#include "wx/config/option.h" namespace config { diff --git a/src/wx/config/option.cpp b/src/wx/config/option.cpp index 6a98b08b..32db77f2 100644 --- a/src/wx/config/option.cpp +++ b/src/wx/config/option.cpp @@ -1,4 +1,4 @@ -#include "config/option.h" +#include "wx/config/option.h" #include @@ -8,10 +8,10 @@ #include #define VBAM_OPTION_INTERNAL_INCLUDE -#include "config/internal/option-internal.h" +#include "wx/config/internal/option-internal.h" #undef VBAM_OPTION_INTERNAL_INCLUDE -#include "config/option-proxy.h" +#include "wx/config/option-proxy.h" namespace config { diff --git a/src/wx/config/option.h b/src/wx/config/option.h index 2df13805..918e2c91 100644 --- a/src/wx/config/option.h +++ b/src/wx/config/option.h @@ -9,7 +9,7 @@ #include -#include "config/option-id.h" +#include "wx/config/option-id.h" using std::uint8_t; using std::uint16_t; diff --git a/src/wx/config/shortcuts.cpp b/src/wx/config/shortcuts.cpp index 62f05a71..ad240015 100644 --- a/src/wx/config/shortcuts.cpp +++ b/src/wx/config/shortcuts.cpp @@ -1,13 +1,13 @@ -#include "config/shortcuts.h" +#include "wx/config/shortcuts.h" #include #include #include -#include "config/user-input.h" +#include "wx/config/user-input.h" #define VBAM_SHORTCUTS_INTERNAL_INCLUDE -#include "config/internal/shortcuts-internal.h" +#include "wx/config/internal/shortcuts-internal.h" #undef VBAM_SHORTCUTS_INTERNAL_INCLUDE namespace config { diff --git a/src/wx/config/shortcuts.h b/src/wx/config/shortcuts.h index d55f9a25..8a54af10 100644 --- a/src/wx/config/shortcuts.h +++ b/src/wx/config/shortcuts.h @@ -7,7 +7,7 @@ #include #include -#include "config/user-input.h" +#include "wx/config/user-input.h" // by default, only 9 recent items #define wxID_FILE10 (wxID_FILE9 + 1) diff --git a/src/wx/config/user-input.cpp b/src/wx/config/user-input.cpp index da7cb3cc..b7480c3f 100644 --- a/src/wx/config/user-input.cpp +++ b/src/wx/config/user-input.cpp @@ -1,4 +1,4 @@ -#include "config/user-input.h" +#include "wx/config/user-input.h" #include @@ -7,8 +7,8 @@ #include #include -#include "strutils.h" -#include "wxutil.h" +#include "wx/strutils.h" +#include "wx/wxutil.h" namespace config { diff --git a/src/wx/config/user-input.h b/src/wx/config/user-input.h index bd39faac..2ce83d47 100644 --- a/src/wx/config/user-input.h +++ b/src/wx/config/user-input.h @@ -5,7 +5,7 @@ #include #include -#include "widgets/wx/sdljoy.h" +#include "wx/widgets/sdljoy.h" namespace config { diff --git a/src/wx/copy-events.cmake b/src/wx/copy-events.cmake index 59628b96..6794e7d5 100644 --- a/src/wx/copy-events.cmake +++ b/src/wx/copy-events.cmake @@ -13,7 +13,7 @@ STRING(REGEX MATCHALL "\nEVT_HANDLER([^\")]|\"[^\"]*\")*\\)" MW "${MW}") # cmdtab.cpp is a table of cmd-id-name/cmd-name pairs # sorted for binary searching -FILE(WRITE "${CMDTAB}" "// Generated from cmdevents.cpp; do not edit\n#include \n\n#include \"wxvbam.h\"\n#include \"wxhead.h\"\n\nstruct cmditem cmdtab[] = {\n") +FILE(WRITE "${CMDTAB}" "// Generated from cmdevents.cpp; do not edit\n#include \n\n#include \"wx/wxvbam.h\"\n#include \"wx/wxhead.h\"\n\nstruct cmditem cmdtab[] = {\n") SET(EVLINES ) FOREACH(EV ${MW}) # stripping the wxID_ makes it look better, but it's still all-caps diff --git a/src/wx/dialogs/accel-config.cpp b/src/wx/dialogs/accel-config.cpp index 6d53eb4c..4ec92180 100644 --- a/src/wx/dialogs/accel-config.cpp +++ b/src/wx/dialogs/accel-config.cpp @@ -1,4 +1,4 @@ -#include "dialogs/accel-config.h" +#include "wx/dialogs/accel-config.h" #include #include @@ -7,12 +7,12 @@ #include #include -#include "config/shortcuts.h" -#include "config/user-input.h" -#include "dialogs/validated-child.h" -#include "opts.h" -#include "widgets/user-input-ctrl.h" -#include "wxvbam.h" +#include "wx/config/shortcuts.h" +#include "wx/config/user-input.h" +#include "wx/dialogs/validated-child.h" +#include "wx/opts.h" +#include "wx/widgets/user-input-ctrl.h" +#include "wx/wxvbam.h" namespace dialogs { diff --git a/src/wx/dialogs/accel-config.h b/src/wx/dialogs/accel-config.h index 8037b271..b999d34c 100644 --- a/src/wx/dialogs/accel-config.h +++ b/src/wx/dialogs/accel-config.h @@ -6,8 +6,8 @@ #include #include -#include "config/shortcuts.h" -#include "widgets/keep-on-top-styler.h" +#include "wx/config/shortcuts.h" +#include "wx/widgets/keep-on-top-styler.h" // Forward declarations. class wxControl; diff --git a/src/wx/dialogs/directories-config.cpp b/src/wx/dialogs/directories-config.cpp index d6530765..ff38a0b7 100644 --- a/src/wx/dialogs/directories-config.cpp +++ b/src/wx/dialogs/directories-config.cpp @@ -1,11 +1,11 @@ -#include "dialogs/directories-config.h" +#include "wx/dialogs/directories-config.h" #include #include -#include "dialogs/validated-child.h" -#include "widgets/option-validator.h" +#include "wx/dialogs/validated-child.h" +#include "wx/widgets/option-validator.h" namespace dialogs { diff --git a/src/wx/dialogs/directories-config.h b/src/wx/dialogs/directories-config.h index 11f8feb3..8ead7bf0 100644 --- a/src/wx/dialogs/directories-config.h +++ b/src/wx/dialogs/directories-config.h @@ -3,7 +3,7 @@ #include -#include "widgets/keep-on-top-styler.h" +#include "wx/widgets/keep-on-top-styler.h" namespace dialogs { diff --git a/src/wx/dialogs/display-config.cpp b/src/wx/dialogs/display-config.cpp index 77b4bc40..55599d6e 100644 --- a/src/wx/dialogs/display-config.cpp +++ b/src/wx/dialogs/display-config.cpp @@ -1,4 +1,4 @@ -#include "dialogs/display-config.h" +#include "wx/dialogs/display-config.h" #include #include @@ -13,14 +13,14 @@ #include -#include "config/option-id.h" -#include "config/option-proxy.h" -#include "config/option.h" -#include "dialogs/validated-child.h" -#include "rpi.h" -#include "widgets/option-validator.h" -#include "widgets/render-plugin.h" -#include "wxvbam.h" +#include "wx/config/option-id.h" +#include "wx/config/option-proxy.h" +#include "wx/config/option.h" +#include "wx/dialogs/validated-child.h" +#include "wx/rpi.h" +#include "wx/widgets/option-validator.h" +#include "wx/widgets/render-plugin.h" +#include "wx/wxvbam.h" namespace dialogs { diff --git a/src/wx/dialogs/display-config.h b/src/wx/dialogs/display-config.h index 5a917690..ec99b2a3 100644 --- a/src/wx/dialogs/display-config.h +++ b/src/wx/dialogs/display-config.h @@ -4,8 +4,8 @@ #include #include -#include "config/option-observer.h" -#include "widgets/keep-on-top-styler.h" +#include "wx/config/option-observer.h" +#include "wx/widgets/keep-on-top-styler.h" // Forward declarations. class wxChoice; diff --git a/src/wx/dialogs/game-boy-config.cpp b/src/wx/dialogs/game-boy-config.cpp index 107d8c3a..ec7f53a2 100644 --- a/src/wx/dialogs/game-boy-config.cpp +++ b/src/wx/dialogs/game-boy-config.cpp @@ -1,4 +1,4 @@ -#include "dialogs/game-boy-config.h" +#include "wx/dialogs/game-boy-config.h" #include #include @@ -13,10 +13,10 @@ #include -#include "config/option-observer.h" -#include "config/option-proxy.h" -#include "dialogs/validated-child.h" -#include "widgets/option-validator.h" +#include "wx/config/option-observer.h" +#include "wx/config/option-proxy.h" +#include "wx/dialogs/validated-child.h" +#include "wx/widgets/option-validator.h" namespace dialogs { diff --git a/src/wx/dialogs/game-boy-config.h b/src/wx/dialogs/game-boy-config.h index 897ab10e..520473fd 100644 --- a/src/wx/dialogs/game-boy-config.h +++ b/src/wx/dialogs/game-boy-config.h @@ -1,12 +1,10 @@ #ifndef VBAM_WX_DIALOGS_GAME_BOY_CONFIG_H_ #define VBAM_WX_DIALOGS_GAME_BOY_CONFIG_H_ -#include - #include #include -#include "widgets/keep-on-top-styler.h" +#include "wx/widgets/keep-on-top-styler.h" namespace dialogs { diff --git a/src/wx/dialogs/game-maker.cpp b/src/wx/dialogs/game-maker.cpp index 07db17c6..48bd7d8c 100644 --- a/src/wx/dialogs/game-maker.cpp +++ b/src/wx/dialogs/game-maker.cpp @@ -1,4 +1,4 @@ -#include "game-maker.h" +#include "wx/dialogs/game-maker.h" #include diff --git a/src/wx/dialogs/gb-rom-info.cpp b/src/wx/dialogs/gb-rom-info.cpp index 504275bb..e5dfef09 100644 --- a/src/wx/dialogs/gb-rom-info.cpp +++ b/src/wx/dialogs/gb-rom-info.cpp @@ -1,12 +1,12 @@ -#include "dialogs/gb-rom-info.h" +#include "wx/dialogs/gb-rom-info.h" #include #include #include "core/base/sizes.h" #include "core/gb/gb.h" -#include "dialogs/game-maker.h" -#include "dialogs/validated-child.h" +#include "wx/dialogs/game-maker.h" +#include "wx/dialogs/validated-child.h" namespace dialogs { diff --git a/src/wx/dialogs/gb-rom-info.h b/src/wx/dialogs/gb-rom-info.h index ce471090..1e5b51ec 100644 --- a/src/wx/dialogs/gb-rom-info.h +++ b/src/wx/dialogs/gb-rom-info.h @@ -3,7 +3,7 @@ #include -#include "widgets/keep-on-top-styler.h" +#include "wx/widgets/keep-on-top-styler.h" namespace dialogs { diff --git a/src/wx/dialogs/joypad-config.cpp b/src/wx/dialogs/joypad-config.cpp index 82286e19..de781db1 100644 --- a/src/wx/dialogs/joypad-config.cpp +++ b/src/wx/dialogs/joypad-config.cpp @@ -1,11 +1,11 @@ -#include "dialogs/joypad-config.h" +#include "wx/dialogs/joypad-config.h" #include -#include "dialogs/validated-child.h" -#include "opts.h" -#include "widgets/option-validator.h" -#include "widgets/user-input-ctrl.h" +#include "wx/dialogs/validated-child.h" +#include "wx/opts.h" +#include "wx/widgets/option-validator.h" +#include "wx/widgets/user-input-ctrl.h" namespace dialogs { diff --git a/src/wx/dialogs/joypad-config.h b/src/wx/dialogs/joypad-config.h index b19aeb6f..3cc96f6d 100644 --- a/src/wx/dialogs/joypad-config.h +++ b/src/wx/dialogs/joypad-config.h @@ -3,7 +3,7 @@ #include -#include "widgets/keep-on-top-styler.h" +#include "wx/widgets/keep-on-top-styler.h" namespace dialogs { diff --git a/src/wx/drawing.h b/src/wx/drawing.h index 2332a030..42a54a04 100644 --- a/src/wx/drawing.h +++ b/src/wx/drawing.h @@ -1,7 +1,7 @@ -#ifndef GAME_DRAWING_H -#define GAME_DRAWING_H +#ifndef VBAM_WX_DRAWING_H_ +#define VBAM_WX_DRAWING_H_ -#include "wxvbam.h" +#include "wx/wxvbam.h" class BasicDrawingPanel : public DrawingPanel { public: @@ -67,4 +67,4 @@ public: }; #endif -#endif /* GAME_DRAWING_H */ +#endif // VBAM_WX_DRAWING_H_ diff --git a/src/wx/dsound.cpp b/src/wx/dsound.cpp index a509e1b1..06e2c427 100644 --- a/src/wx/dsound.cpp +++ b/src/wx/dsound.cpp @@ -1,5 +1,5 @@ // Application -#include "wxvbam.h" +#include "wx/wxvbam.h" // Internals #include "core/base/sound_driver.h" diff --git a/src/wx/extra-translations.cpp b/src/wx/extra-translations.cpp index c6504847..013e1f6d 100644 --- a/src/wx/extra-translations.cpp +++ b/src/wx/extra-translations.cpp @@ -3,7 +3,8 @@ // // Please sort. -#include "wxhead.h" +#include +#include [[maybe_unused]] void f() { diff --git a/src/wx/faudio.cpp b/src/wx/faudio.cpp index 6d2b478f..18001d24 100644 --- a/src/wx/faudio.cpp +++ b/src/wx/faudio.cpp @@ -1,7 +1,7 @@ #ifndef NO_FAUDIO // Application -#include "wxvbam.h" +#include "wx/wxvbam.h" #include // Interface diff --git a/src/wx/gfxviewers.cpp b/src/wx/gfxviewers.cpp index 308013eb..aefb5389 100644 --- a/src/wx/gfxviewers.cpp +++ b/src/wx/gfxviewers.cpp @@ -5,11 +5,11 @@ #include #include -#include "config/option-proxy.h" #include "core/gb/gbGlobals.h" #include "core/gba/gbaGlobals.h" -#include "viewsupt.h" -#include "wxvbam.h" +#include "wx/config/option-proxy.h" +#include "wx/viewsupt.h" +#include "wx/wxvbam.h" namespace { void utilReadScreenPixels(uint8_t* dest, int w, int h) { diff --git a/src/wx/guiinit.cpp b/src/wx/guiinit.cpp index dda2e853..4a97d56f 100644 --- a/src/wx/guiinit.cpp +++ b/src/wx/guiinit.cpp @@ -5,14 +5,13 @@ // other non-viewer dialogs are at least validated enough that they won't crash // viewer dialogs are not commonly used, so they are initialized on demand -#include "wxvbam.h" +#include "wx/wxvbam.h" #include #include #include #include -#include #include #include #include @@ -32,26 +31,27 @@ #include #include -#include "config/option-proxy.h" #include "core/gb/gb.h" #include "core/gb/gbCheats.h" #include "core/gb/gbGlobals.h" -#include "core/gba/gbaCheats.h" #include "core/gba/gbaCheatSearch.h" +#include "core/gba/gbaCheats.h" #include "core/gba/gbaFlash.h" #include "core/gba/gbaGlobals.h" -#include "dialogs/accel-config.h" -#include "dialogs/directories-config.h" -#include "dialogs/display-config.h" -#include "dialogs/game-boy-config.h" -#include "dialogs/gb-rom-info.h" -#include "dialogs/joypad-config.h" -#include "opts.h" -#include "widgets/option-validator.h" -#include "wxhead.h" +#include "wx/config/option-proxy.h" +#include "wx/dialogs/accel-config.h" +#include "wx/dialogs/directories-config.h" +#include "wx/dialogs/display-config.h" +#include "wx/dialogs/game-boy-config.h" +#include "wx/dialogs/gb-rom-info.h" +#include "wx/dialogs/joypad-config.h" +#include "wx/opts.h" +#include "wx/widgets/option-validator.h" +#include "wx/widgets/checkedlistctrl.h" +#include "wx/wxhead.h" #if defined(__WXGTK__) -#include "wayland.h" +#include "wx/wayland.h" #endif // The program icon, in case it's missing from .xrc (MSW gets it from .rc file) diff --git a/src/wx/macsupport.mm b/src/wx/macsupport.mm index ea285614..103df1a1 100644 --- a/src/wx/macsupport.mm +++ b/src/wx/macsupport.mm @@ -4,8 +4,8 @@ #include -#include "wxvbam.h" -#include "drawing.h" +#include "wx/drawing.h" +#include "wx/wxvbam.h" Quartz2DDrawingPanel::Quartz2DDrawingPanel(wxWindow* parent, int _width, int _height) : BasicDrawingPanel(parent, _width, _height) diff --git a/src/wx/openal.cpp b/src/wx/openal.cpp index fe4c1559..c82ac37d 100644 --- a/src/wx/openal.cpp +++ b/src/wx/openal.cpp @@ -5,7 +5,7 @@ // for gopts // also, wx-related -#include "wxvbam.h" +#include "wx/wxvbam.h" // Interface #include "core/base/sound_driver.h" diff --git a/src/wx/opts.cpp b/src/wx/opts.cpp index b5a64902..4f4b736a 100644 --- a/src/wx/opts.cpp +++ b/src/wx/opts.cpp @@ -1,4 +1,4 @@ -#include "opts.h" +#include "wx/opts.h" #include #include @@ -10,13 +10,13 @@ #include #include -#include "config/option-observer.h" -#include "config/option-proxy.h" -#include "config/option.h" -#include "config/user-input.h" -#include "strutils.h" -#include "wxhead.h" -#include "wxvbam.h" +#include "wx/config/option-observer.h" +#include "wx/config/option-proxy.h" +#include "wx/config/option.h" +#include "wx/config/user-input.h" +#include "wx/strutils.h" +#include "wx/wxhead.h" +#include "wx/wxvbam.h" /* disableSfx(F) -> cpuDisableSfx diff --git a/src/wx/opts.h b/src/wx/opts.h index b31488a6..7fa3d25c 100644 --- a/src/wx/opts.h +++ b/src/wx/opts.h @@ -1,15 +1,15 @@ -#ifndef WX_OPTS_H -#define WX_OPTS_H +#ifndef VBAM_WX_OPTS_H_ +#define VBAM_WX_OPTS_H_ #include #include #include -#include "config/game-control.h" -#include "config/shortcuts.h" -#include "config/user-input.h" -#include "wxhead.h" +#include "wx/config/game-control.h" +#include "wx/config/shortcuts.h" +#include "wx/config/user-input.h" +#include "wx/wxhead.h" // Forward declaration. class wxFileHistory; @@ -95,4 +95,4 @@ void update_shortcut_opts(); // returns true if option name correct; prints error if val invalid void opt_set(const wxString& name, const wxString& val); -#endif /* WX_OPTS_H */ +#endif // VBAM_WX_OPTS_H_ diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index cd891664..aad5a6d3 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -25,10 +25,6 @@ #include "background-input.h" #include "components/draw_text/draw_text.h" #include "components/filters/filters.h" -#include "config/game-control.h" -#include "config/option-proxy.h" -#include "config/option.h" -#include "config/user-input.h" #include "core/base/file_util.h" #include "core/base/patch.h" #include "core/base/version.h" @@ -43,11 +39,15 @@ #include "core/gba/gbaPrint.h" #include "core/gba/gbaRtc.h" #include "core/gba/gbaSound.h" -#include "drawing.h" -#include "wayland.h" -#include "widgets/render-plugin.h" -#include "wxutil.h" -#include "wxvbam.h" +#include "wx/config/game-control.h" +#include "wx/config/option-proxy.h" +#include "wx/config/option.h" +#include "wx/config/user-input.h" +#include "wx/drawing.h" +#include "wx/wayland.h" +#include "wx/widgets/render-plugin.h" +#include "wx/wxutil.h" +#include "wx/wxvbam.h" #ifdef __WXMSW__ #include diff --git a/src/wx/rpi.h b/src/wx/rpi.h index 558393cc..ec0c01a8 100755 --- a/src/wx/rpi.h +++ b/src/wx/rpi.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef VBAM_WX_RPI_H_ +#define VBAM_WX_RPI_H_ //--------------------------------------------------------------------------------------------------------------------------- // hq2x plugin example - Steve Snake 2004. @@ -13,6 +14,8 @@ #define HMODULE void* #endif +#include + //--------------------------------------------------------------------------------------------------------------------------- typedef struct { unsigned long Size; @@ -73,3 +76,5 @@ bool rpiInit(const char* sPluginName); void rpiFilter(uint8_t* srcPtr, uint32_t srcPitch, uint8_t* deltaPtr, uint8_t* dstPtr, uint32_t dstPitch, int width, int height); void rpiCleanup(); + +#endif // VBAM_WX_RPI_H_ diff --git a/src/wx/strutils.cpp b/src/wx/strutils.cpp index a0edf623..1ad95357 100644 --- a/src/wx/strutils.cpp +++ b/src/wx/strutils.cpp @@ -1,4 +1,4 @@ -#include "strutils.h" +#include "wx/strutils.h" #include diff --git a/src/wx/strutils.h b/src/wx/strutils.h index 79a63b52..e195175e 100644 --- a/src/wx/strutils.h +++ b/src/wx/strutils.h @@ -1,5 +1,5 @@ -#ifndef STRUTILS_H -#define STRUTILS_H +#ifndef VBAM_WX_STRUTILS_H_ +#define VBAM_WX_STRUTILS_H_ #include #include @@ -16,4 +16,4 @@ wxArrayString split_with_sep(const wxString& text, const wxString& sep); } // namespace strutils -#endif +#endif // VBAM_WX_STRUTILS_H_ diff --git a/src/wx/sys.cpp b/src/wx/sys.cpp index cacc9e17..71666cbc 100644 --- a/src/wx/sys.cpp +++ b/src/wx/sys.cpp @@ -7,13 +7,13 @@ #include #include "components/audio_sdl/audio_sdl.h" -#include "config/game-control.h" -#include "config/option-proxy.h" #include "core/base/image_util.h" #include "core/gb/gbGlobals.h" #include "core/gba/gbaGlobals.h" #include "core/gba/gbaSound.h" -#include "wxvbam.h" +#include "wx/config/game-control.h" +#include "wx/config/option-proxy.h" +#include "wx/wxvbam.h" // These should probably be in vbamcore int systemVerbose; diff --git a/src/wx/tests/CMakeLists.txt b/src/wx/tests/CMakeLists.txt index 2b22424d..1eb3a31e 100644 --- a/src/wx/tests/CMakeLists.txt +++ b/src/wx/tests/CMakeLists.txt @@ -15,6 +15,12 @@ function(add_doctest_test test_src) target_include_directories("${test_name}" PRIVATE ${wxWidgets_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/third_party/include) + target_compile_options("${test_name}" PRIVATE ${wxWidgets_CXX_FLAGS}) + target_compile_definitions("${test_name}" PRIVATE ${wxWidgets_DEFINITIONS}) + if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") + target_compile_definitions("${test_name}" PRIVATE ${wxWidgets_DEFINITIONS_DEBUG}) + endif() + set_target_properties("${test_name}" PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests" diff --git a/src/wx/tests/strutils.cpp b/src/wx/tests/strutils.cpp index d0fbebba..5134e50c 100644 --- a/src/wx/tests/strutils.cpp +++ b/src/wx/tests/strutils.cpp @@ -1,4 +1,4 @@ -#include "strutils.h" +#include "wx/strutils.h" #include "tests.hpp" diff --git a/src/wx/viewers.cpp b/src/wx/viewers.cpp index edf14e0c..171c0a53 100644 --- a/src/wx/viewers.cpp +++ b/src/wx/viewers.cpp @@ -7,14 +7,14 @@ #include #include -#include "config/option-proxy.h" #include "core/gb/gb.h" #include "core/gb/gbDis.h" #include "core/gb/gbGlobals.h" #include "core/gba/gbaCpu.h" #include "core/gba/gbaCpuArmDis.h" -#include "viewsupt.h" -#include "wxvbam.h" +#include "wx/config/option-proxy.h" +#include "wx/viewsupt.h" +#include "wx/wxvbam.h" // avoid exporting classes namespace Viewers { diff --git a/src/wx/viewsupt.cpp b/src/wx/viewsupt.cpp index eeaf076a..2daa82b2 100644 --- a/src/wx/viewsupt.cpp +++ b/src/wx/viewsupt.cpp @@ -1,8 +1,8 @@ -#include "viewsupt.h" +#include "wx/viewsupt.h" -#include "config/option-proxy.h" -#include "wxvbam.h" -#include "wxutil.h" +#include "wx/config/option-proxy.h" +#include "wx/wxutil.h" +#include "wx/wxvbam.h" namespace Viewers { void Viewer::CloseDlg(wxCloseEvent& ev) diff --git a/src/wx/viewsupt.h b/src/wx/viewsupt.h index 65cdc211..67b8f51a 100644 --- a/src/wx/viewsupt.h +++ b/src/wx/viewsupt.h @@ -1,5 +1,5 @@ -#ifndef WX_VIEWSUPT_H -#define WX_VIEWSUPT_H +#ifndef VBAM_WX_VIEWSUPT_H_ +#define VBAM_WX_VIEWSUPT_H_ #include #include @@ -421,4 +421,4 @@ public: // standard widgets in graphical viewers } -#endif /* WX_VIEWSUPT_H */ +#endif // VBAM_WX_VIEWSUPT_H_ diff --git a/src/wx/wayland.cpp b/src/wx/wayland.cpp index 7d8b27cd..4f767800 100644 --- a/src/wx/wayland.cpp +++ b/src/wx/wayland.cpp @@ -1,4 +1,4 @@ -#include "wayland.h" +#include "wx/wayland.h" #ifdef HAVE_WAYLAND_SUPPORT diff --git a/src/wx/wayland.h b/src/wx/wayland.h index be25c01a..845120fc 100644 --- a/src/wx/wayland.h +++ b/src/wx/wayland.h @@ -1,5 +1,5 @@ -#ifndef VBAM_WAYLAND_H -#define VBAM_WAYLAND_H +#ifndef VBAM_WX_WAYLAND_H_ +#define VBAM_WX_WAYLAND_H_ #include @@ -48,4 +48,4 @@ inline void MoveWaylandSubsurface([[maybe_unused]] wxGLCanvas* win) {}; #endif // gtk -#endif // VBAM_WAYLAND_H +#endif // VBAM_WX_WAYLAND_H_ diff --git a/src/wx/widgets/checkedlistctrl.cpp b/src/wx/widgets/checkedlistctrl.cpp index 49b055ce..cb952a5a 100644 --- a/src/wx/widgets/checkedlistctrl.cpp +++ b/src/wx/widgets/checkedlistctrl.cpp @@ -9,6 +9,8 @@ // Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// +#include "wx/widgets/checkedlistctrl.h" + #include #ifdef __BORLANDC__ @@ -16,7 +18,6 @@ #endif // includes -#include "wx/checkedlistctrl.h" #include #include diff --git a/src/wx/widgets/wx/checkedlistctrl.h b/src/wx/widgets/checkedlistctrl.h similarity index 96% rename from src/wx/widgets/wx/checkedlistctrl.h rename to src/wx/widgets/checkedlistctrl.h index 82b5ff62..824eb02d 100644 --- a/src/wx/widgets/wx/checkedlistctrl.h +++ b/src/wx/widgets/checkedlistctrl.h @@ -9,11 +9,11 @@ // Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// -#ifndef _WX_CHECKEDLISTCTRL_H_ -#define _WX_CHECKEDLISTCTRL_H_ +#ifndef VBAM_WX_WIDGETS_CHECKEDLISTCTRL_H_ +#define VBAM_WX_WIDGETS_CHECKEDLISTCTRL_H_ // wxWidgets headers -#include "wx/webupdatedef.h" // for the WXDLLIMPEXP_WEBUPDATE macro +#include "wx/widgets/webupdatedef.h" // for the WXDLLIMPEXP_WEBUPDATE macro #include #include @@ -179,4 +179,4 @@ private: #endif // wxUSE_CHECKEDLISTCTRL -#endif // _WX_CHECKEDLISTCTRL_H_ +#endif // VBAM_WX_WIDGETS_CHECKEDLISTCTRL_H_ diff --git a/src/wx/widgets/dpi-support-mac.mm b/src/wx/widgets/dpi-support-mac.mm index 45f2e25e..da805dfe 100644 --- a/src/wx/widgets/dpi-support-mac.mm +++ b/src/wx/widgets/dpi-support-mac.mm @@ -1,4 +1,4 @@ -#include "widgets/dpi-support.h" +#include "wx/widgets/dpi-support.h" #import #import diff --git a/src/wx/widgets/dpi-support.cpp b/src/wx/widgets/dpi-support.cpp index 512ce124..f5537a7d 100644 --- a/src/wx/widgets/dpi-support.cpp +++ b/src/wx/widgets/dpi-support.cpp @@ -1,4 +1,4 @@ -#include "widgets/dpi-support.h" +#include "wx/widgets/dpi-support.h" #include diff --git a/src/wx/widgets/group-check-box.cpp b/src/wx/widgets/group-check-box.cpp index 31e6c83c..96aa2bea 100644 --- a/src/wx/widgets/group-check-box.cpp +++ b/src/wx/widgets/group-check-box.cpp @@ -1,4 +1,4 @@ -#include "widgets/group-check-box.h" +#include "wx/widgets/group-check-box.h" namespace widgets { diff --git a/src/wx/widgets/keep-on-top-styler.cpp b/src/wx/widgets/keep-on-top-styler.cpp index 75f8816b..ad3cb748 100644 --- a/src/wx/widgets/keep-on-top-styler.cpp +++ b/src/wx/widgets/keep-on-top-styler.cpp @@ -1,9 +1,8 @@ -#include "widgets/keep-on-top-styler.h" +#include "wx/widgets/keep-on-top-styler.h" #include -#include "config/option-proxy.h" -#include "config/option.h" +#include "wx/config/option.h" namespace widgets { diff --git a/src/wx/widgets/keep-on-top-styler.h b/src/wx/widgets/keep-on-top-styler.h index 9add5637..7cb00682 100644 --- a/src/wx/widgets/keep-on-top-styler.h +++ b/src/wx/widgets/keep-on-top-styler.h @@ -3,7 +3,7 @@ #include -#include "config/option-observer.h" +#include "wx/config/option-observer.h" // Forward declarations. class wxTopLevelWindow; diff --git a/src/wx/widgets/option-validator.cpp b/src/wx/widgets/option-validator.cpp index f43a4b92..73dd2123 100644 --- a/src/wx/widgets/option-validator.cpp +++ b/src/wx/widgets/option-validator.cpp @@ -1,4 +1,4 @@ -#include "widgets/option-validator.h" +#include "wx/widgets/option-validator.h" #include #include diff --git a/src/wx/widgets/option-validator.h b/src/wx/widgets/option-validator.h index ed2fab2f..753ae82f 100644 --- a/src/wx/widgets/option-validator.h +++ b/src/wx/widgets/option-validator.h @@ -3,7 +3,7 @@ #include -#include "config/option.h" +#include "wx/config/option.h" #if wxCHECK_VERSION(3, 1, 1) #define WX_HAS_VALIDATOR_SET_WINDOW_OVERRIDE 1 diff --git a/src/wx/widgets/render-plugin.cpp b/src/wx/widgets/render-plugin.cpp index 27c41da6..02889137 100644 --- a/src/wx/widgets/render-plugin.cpp +++ b/src/wx/widgets/render-plugin.cpp @@ -1,4 +1,4 @@ -#include "widgets/render-plugin.h" +#include "wx/widgets/render-plugin.h" namespace widgets { diff --git a/src/wx/widgets/render-plugin.h b/src/wx/widgets/render-plugin.h index 8a7b042f..4176d1bd 100644 --- a/src/wx/widgets/render-plugin.h +++ b/src/wx/widgets/render-plugin.h @@ -1,11 +1,10 @@ #ifndef VBAM_WX_WIDGETS_RENDER_PLUGIN_H_ #define VBAM_WX_WIDGETS_RENDER_PLUGIN_H_ -#include #include #include -#include "rpi.h" +#include "wx/rpi.h" namespace widgets { diff --git a/src/wx/widgets/sdljoy.cpp b/src/wx/widgets/sdljoy.cpp index b55d695e..9e465cd8 100644 --- a/src/wx/widgets/sdljoy.cpp +++ b/src/wx/widgets/sdljoy.cpp @@ -1,10 +1,9 @@ -#include "wx/sdljoy.h" +#include "wx/widgets/sdljoy.h" -#include #include #include -#include "../wxvbam.h" +#include "wx/wxvbam.h" namespace { diff --git a/src/wx/widgets/wx/sdljoy.h b/src/wx/widgets/sdljoy.h similarity index 97% rename from src/wx/widgets/wx/sdljoy.h rename to src/wx/widgets/sdljoy.h index 277bc78b..ff034300 100644 --- a/src/wx/widgets/wx/sdljoy.h +++ b/src/wx/widgets/sdljoy.h @@ -1,12 +1,13 @@ -#ifndef _WX_SDLJOY_H -#define _WX_SDLJOY_H +#ifndef VBAM_WX_WIDGETS_SDLJOY_H_ +#define VBAM_WX_WIDGETS_SDLJOY_H_ #include #include -#include #include + #include #include + #include #include #include @@ -152,4 +153,4 @@ private: wxLongLong last_poll_ = wxGetUTCTimeMillis(); }; -#endif /* _WX_SDLJOY_H */ +#endif // VBAM_WX_WIDGETS_SDLJOY_H_ diff --git a/src/wx/widgets/user-input-ctrl.cpp b/src/wx/widgets/user-input-ctrl.cpp index f771cce1..80df46b3 100644 --- a/src/wx/widgets/user-input-ctrl.cpp +++ b/src/wx/widgets/user-input-ctrl.cpp @@ -1,8 +1,7 @@ -#include "widgets/user-input-ctrl.h" +#include "wx/widgets/user-input-ctrl.h" -#include "config/user-input.h" - -#include "opts.h" +#include "wx/config/user-input.h" +#include "wx/opts.h" namespace widgets { diff --git a/src/wx/widgets/user-input-ctrl.h b/src/wx/widgets/user-input-ctrl.h index f42193cf..95e8fe35 100644 --- a/src/wx/widgets/user-input-ctrl.h +++ b/src/wx/widgets/user-input-ctrl.h @@ -8,9 +8,9 @@ #include #include -#include "config/game-control.h" -#include "config/user-input.h" -#include "widgets/wx/sdljoy.h" +#include "wx/config/game-control.h" +#include "wx/config/user-input.h" +#include "wx/widgets/sdljoy.h" namespace widgets { diff --git a/src/wx/widgets/wx/webupdatedef.h b/src/wx/widgets/webupdatedef.h similarity index 100% rename from src/wx/widgets/wx/webupdatedef.h rename to src/wx/widgets/webupdatedef.h diff --git a/src/wx/widgets/wxmisc.cpp b/src/wx/widgets/wxmisc.cpp index 2827fc44..37552fef 100644 --- a/src/wx/widgets/wxmisc.cpp +++ b/src/wx/widgets/wxmisc.cpp @@ -4,10 +4,11 @@ #include #include -#include "wx/wxmisc.h" #include #include +#include "wx/widgets/wxmisc.h" + bool wxBoolIntValidator::TransferToWindow() { if (!vptr) diff --git a/src/wx/widgets/wx/wxmisc.h b/src/wx/widgets/wxmisc.h similarity index 98% rename from src/wx/widgets/wx/wxmisc.h rename to src/wx/widgets/wxmisc.h index 70e3d4c1..d9e0c1e5 100644 --- a/src/wx/widgets/wx/wxmisc.h +++ b/src/wx/widgets/wxmisc.h @@ -1,5 +1,5 @@ -#ifndef WX_MISC_H -#define WX_MISC_H +#ifndef VBAM_WX_WIDGETS_WX_MISC_H_ +#define VBAM_WX_WIDGETS_WX_MISC_H_ // utility widgets #include @@ -250,4 +250,4 @@ public: // for wxTextValidator include lists extern const wxArrayString val_hexdigits, val_sigdigits, val_unsdigits; -#endif /* WX_MISC_H */ +#endif // VBAM_WX_WIDGETS_WX_MISC_H_ diff --git a/src/wx/wxhead.h b/src/wx/wxhead.h index b454ddd7..015ec9bc 100644 --- a/src/wx/wxhead.h +++ b/src/wx/wxhead.h @@ -1,5 +1,5 @@ -#ifndef WX_WXHEAD_H -#define WX_WXHEAD_H +#ifndef VBAM_WX_WXHEAD_H_ +#define VBAM_WX_WXHEAD_H_ #ifdef __BORLANDC__ #pragma hdrstop @@ -57,7 +57,7 @@ using std::int32_t; // GetAccel is inefficent anyway (often I don't want to convert to wxAccEnt) // This is a working replacement for SetAccel, at least. -#include "wxutil.h" +#include "wx/wxutil.h" // This enum must be kept in sync with the one in vbam-options-static.cpp. // TODO: These 2 enums should be unified and a validator created for this enum. @@ -93,4 +93,4 @@ static inline const wxCharBuffer UTF8(wxString str) return str.mb_str(wxConvUTF8); } -#endif /* WX_WXHEAD_H */ +#endif // VBAM_WX_WXHEAD_H_ diff --git a/src/wx/wxlogdebug.h b/src/wx/wxlogdebug.h index 52eda436..e905a536 100644 --- a/src/wx/wxlogdebug.h +++ b/src/wx/wxlogdebug.h @@ -1,5 +1,5 @@ -#ifndef WXLOGDEBUG_H_ -#define WXLOGDEBUG_H_ +#ifndef VBAM_WX_WXLOGDEBUG_H_ +#define VBAM_WX_WXLOGDEBUG_H_ #include @@ -20,4 +20,4 @@ } while(0) #endif -#endif /* WXLOGDEBUG_H_ */ +#endif // VBAM_WX_WXLOGDEBUG_H_ diff --git a/src/wx/wxutil.cpp b/src/wx/wxutil.cpp index 270d7a0a..b9e6aedd 100644 --- a/src/wx/wxutil.cpp +++ b/src/wx/wxutil.cpp @@ -1,4 +1,4 @@ -#include "wxutil.h" +#include "wx/wxutil.h" int getKeyboardKeyCode(const wxKeyEvent& event) { int uc = event.GetUnicodeKey(); diff --git a/src/wx/wxutil.h b/src/wx/wxutil.h index 75da7763..939fada4 100644 --- a/src/wx/wxutil.h +++ b/src/wx/wxutil.h @@ -1,8 +1,8 @@ -#ifndef _WX_UTIL_H -#define _WX_UTIL_H +#ifndef VBAM_WX_UTIL_H_ +#define VBAM_WX_UTIL_H_ #include int getKeyboardKeyCode(const wxKeyEvent& event); -#endif +#endif // VBAM_WX_UTIL_H_ diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index 477d563c..d0b933dd 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -3,7 +3,7 @@ // load xrc file (guiinit.cpp does most of instantiation) // create & display main frame -#include "wxvbam.h" +#include "wx/wxvbam.h" #ifdef __WXMSW__ #include @@ -39,18 +39,18 @@ #endif // defined(VBAM_ENABLE_DEBUGGER) // The built-in xrc file -#include "builtin-xrc.h" +#include "wx/builtin-xrc.h" // The built-in vba-over.ini -#include "builtin-over.h" -#include "config/game-control.h" -#include "config/option-proxy.h" -#include "config/option.h" -#include "config/user-input.h" -#include "strutils.h" -#include "wayland.h" -#include "widgets/group-check-box.h" -#include "widgets/user-input-ctrl.h" +#include "wx/builtin-over.h" +#include "wx/config/game-control.h" +#include "wx/config/option-proxy.h" +#include "wx/config/option.h" +#include "wx/config/user-input.h" +#include "wx/strutils.h" +#include "wx/wayland.h" +#include "wx/widgets/group-check-box.h" +#include "wx/widgets/user-input-ctrl.h" #ifdef __WXGTK__ #include @@ -878,7 +878,7 @@ void MainFrame::OnStatusBarChanged() { } BEGIN_EVENT_TABLE(MainFrame, wxFrame) -#include "cmd-evtable.h" +#include "wx/cmd-evtable.h" EVT_CONTEXT_MENU(MainFrame::OnMenu) // this is the main window focus? Or EVT_SET_FOCUS/EVT_KILL_FOCUS? EVT_ACTIVATE(MainFrame::OnActivate) diff --git a/src/wx/wxvbam.h b/src/wx/wxvbam.h index c66d392f..723e08d5 100644 --- a/src/wx/wxvbam.h +++ b/src/wx/wxvbam.h @@ -1,5 +1,5 @@ -#ifndef WX_WXVBAM_H -#define WX_WXVBAM_H +#ifndef VBAM_WX_WXVBAM_H_ +#define VBAM_WX_WXVBAM_H_ #include #include @@ -12,12 +12,12 @@ #include #include "core/base/system.h" -#include "config/option-observer.h" -#include "widgets/dpi-support.h" -#include "widgets/keep-on-top-styler.h" -#include "wx/sdljoy.h" -#include "wx/wxmisc.h" -#include "wxhead.h" +#include "wx/config/option-observer.h" +#include "wx/widgets/dpi-support.h" +#include "wx/widgets/keep-on-top-styler.h" +#include "wx/widgets/sdljoy.h" +#include "wx/widgets/wxmisc.h" +#include "wx/wxhead.h" #ifndef NO_LINK #include "core/gba/gbaLink.h" @@ -27,8 +27,8 @@ #include "components/av_recording/av_recording.h" #endif -#include "wxlogdebug.h" -#include "wxutil.h" +#include "wx/wxlogdebug.h" +#include "wx/wxutil.h" template void CheckPointer(T pointer) @@ -385,7 +385,7 @@ private: // Load a named wxDialog from the XRC file wxDialog* LoadXRCropertySheetDialog(const char* name); -#include "cmdhandlers.h" +#include "wx/cmdhandlers.h" }; // a class for polling joystick keys @@ -644,7 +644,7 @@ cmditem new_cmditem(const wxString cmd = wxT(""), const wxString name = wxT(""), // for binary search extern bool cmditem_lt(const struct cmditem& cmd1, const struct cmditem& cmd2); -#include "rpi.h" +#include "wx/rpi.h" #include class FilterThread; @@ -698,7 +698,7 @@ private: DECLARE_EVENT_TABLE() }; -#include "opts.h" +#include "wx/opts.h" // I should add this to SoundDriver, but wxArrayString is wx-specific // I suppose I could make subclass wxSoundDriver. maybe later. @@ -797,4 +797,4 @@ extern int autofire, autohold; #define KEYM_MOTION_IN (1 << 19) #define KEYM_MOTION_OUT (1 << 20) -#endif /* WX_WXVBAM_H */ +#endif // VBAM_WX_WXVBAM_H_ diff --git a/src/wx/wxvbam.rc b/src/wx/wxvbam.rc index 835ae0e0..427cb8e9 100644 --- a/src/wx/wxvbam.rc +++ b/src/wx/wxvbam.rc @@ -3,7 +3,7 @@ AAAAA_MAINICON ICON "icons/visualboyadvance-m.ico" #define wxUSE_NO_MANIFEST 1 -#include "wx/msw/wx.rc" +#include #include "core/base/version_gen.h" diff --git a/src/wx/xaudio2.cpp b/src/wx/xaudio2.cpp index 757c22d9..7824ac4e 100644 --- a/src/wx/xaudio2.cpp +++ b/src/wx/xaudio2.cpp @@ -1,7 +1,7 @@ #ifndef NO_XAUDIO2 // Application -#include "wxvbam.h" +#include "wx/wxvbam.h" #include // Interface