[wip] build wxwidgets as part of the build

This commit is contained in:
Fabrice de Gans 2024-11-24 21:07:21 -08:00
parent dcb9ccca90
commit fcae420599
30 changed files with 136 additions and 141 deletions

3
.gitmodules vendored
View File

@ -5,3 +5,6 @@
[submodule "third_party/googletest"] [submodule "third_party/googletest"]
path = third_party/googletest path = third_party/googletest
url = https://github.com/google/googletest.git url = https://github.com/google/googletest.git
[submodule "third_party/wxWidgets"]
path = third_party/wxWidgets
url = https://github.com/wxWidgets/wxWidgets.git

View File

@ -22,7 +22,7 @@ if(TAG_RELEASE)
include(MakeReleaseCommitAndTag) include(MakeReleaseCommitAndTag)
endif() endif()
set(VCPKG_DEPS pkgconf zlib pthreads "sdl2[samplerate]" gettext wxwidgets) set(VCPKG_DEPS pkgconf zlib pthreads "sdl2[samplerate]" gettext)
set(VCPKG_DEPS_OPTIONAL set(VCPKG_DEPS_OPTIONAL
sfml ENABLE_LINK sfml ENABLE_LINK
@ -73,16 +73,32 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True) set(CMAKE_C_STANDARD_REQUIRED True)
project(VBA-M C CXX) set(VBAM_LANGUAGES C CXX)
if(APPLE)
list(APPEND VBAM_LANGUAGES OBJCXX)
endif()
project(VBA-M ${VBAM_LANGUAGES})
include(CTest)
include(FetchContent)
include(GNUInstallDirs) include(GNUInstallDirs)
include(Architecture) include(Architecture)
include(Options) include(Options)
include(Toolchain) include(Toolchain)
include(Dependencies) include(Dependencies)
function(configure_vbam_target target)
get_target_property(target_type ${target} TYPE)
if(target_type STREQUAL "INTERFACE_LIBRARY")
set(target_scope "INTERFACE")
else()
set(target_scope "PRIVATE")
endif()
target_compile_definitions(${target} ${target_scope} ${VBAM_COMPILE_DEFS})
target_compile_options(${target} ${target_scope} ${VBAM_COMPILE_OPTS})
target_link_options(${target} ${target_scope} ${VBAM_LINK_OPTS})
endfunction()
# Disable tests when not in a git checkout. # Disable tests when not in a git checkout.
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git") if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(BUILD_TESTING OFF) set(BUILD_TESTING OFF)
@ -92,10 +108,21 @@ endif()
if(BUILD_TESTING) if(BUILD_TESTING)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
add_subdirectory(./third_party/googletest) add_subdirectory(third_party/googletest)
include(GoogleTest) include(GoogleTest)
endif() endif()
# Configure wxWidgets.
if(NOT VBAM_DEPS_wxWidgets_SYSTEM)
set(wxBUILD_SHARED OFF CACHE BOOL "" FORCE)
set(wxBUILD_INSTALL OFF CACHE BOOL "" FORCE)
set(wxUSE_WEBVIEW OFF CACHE BOOL "" FORCE)
set(wxWidgets_SOURCE_DIR "${CMAKE_SOURCE_DIR}/third_party/wxWidgets")
add_subdirectory(third_party/wxWidgets)
set(wxWidgets_LIBRARIES wx::xrc wx::xml wx::html wx::adv wx::net wx::core wx::base wx::gl)
set(wxWidgets_INCLUDE_DIRS third_party/wxWidgets/include)
endif()
if(NOT CMAKE_PREFIX_PATH AND (NOT ("$ENV{CMAKE_PREFIX_PATH}" STREQUAL ""))) if(NOT CMAKE_PREFIX_PATH AND (NOT ("$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")))
set(CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}") set(CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
endif() endif()

View File

@ -64,7 +64,7 @@ if(ENABLE_FFMPEG)
endif() endif()
endif() endif()
else() else()
add_compile_definitions(NO_FFMPEG) list(APPEND VBAM_COMPILE_DEFS NO_FFMPEG)
endif() endif()
if(ENABLE_LINK) if(ENABLE_LINK)
@ -80,10 +80,10 @@ if(ENABLE_LINK)
include(CheckFunctionExists) include(CheckFunctionExists)
check_function_exists(sem_timedwait SEM_TIMEDWAIT) check_function_exists(sem_timedwait SEM_TIMEDWAIT)
if(SEM_TIMEDWAIT) if(SEM_TIMEDWAIT)
add_compile_definitions(HAVE_SEM_TIMEDWAIT) list(APPEND VBAM_COMPILE_DEFS HAVE_SEM_TIMEDWAIT)
endif() endif()
else() else()
add_compile_definitions(NO_LINK) list(APPEND VBAM_COMPILE_DEFS NO_LINK)
endif() endif()
# for now, only GBALink.cpp uses gettext() directly # for now, only GBALink.cpp uses gettext() directly

View File

@ -57,7 +57,7 @@
# define the SFML_STATIC macro if static build was chosen # define the SFML_STATIC macro if static build was chosen
if(SFML_STATIC_LIBRARIES) if(SFML_STATIC_LIBRARIES)
add_compile_definitions(SFML_STATIC) list(APPEND VBAM_COMPILE_DEFS SFML_STATIC)
endif() endif()
# define the list of search paths for headers and libraries # define the list of search paths for headers and libraries

View File

@ -161,4 +161,23 @@ if(TRANSLATIONS_ONLY AND (ENABLE_SDL OR ENABLE_WX))
message(FATAL_ERROR "The SDL and wxWidgets ports can't be built when TRANSLATIONS_ONLY is enabled") message(FATAL_ERROR "The SDL and wxWidgets ports can't be built when TRANSLATIONS_ONLY is enabled")
endif() endif()
if(ENABLE_WX)
if(WIN32 OR APPLE)
# We always build wxWidgets from source on Windows and macOS. We do not
# support using a system wxWidgets on these platforms.
set(VBAM_DEPS_wxWidgets_SYSTEM_DEFAULT OFF)
else()
# On other platforms, we first look for a system wxWidgets, and if that
# fails, we build from source. Note that we still prefer building from
# source on Linux.
find_package(wxWidgets COMPONENTS xrc xml html adv net core base gl)
if(wxWidgets_FOUND)
set(VBAM_DEPS_wxWidgets_SYSTEM_DEFAULT ON)
else()
set(VBAM_DEPS_wxWidgets_SYSTEM_DEFAULT OFF)
endif()
endif()
option(VBAM_DEPS_wxWidgets_SYSTEM "Use system wxWidgets" ${VBAM_DEPS_wxWidgets_SYSTEM_DEFAULT})
endif()
option(GPG_SIGNATURES "Create GPG signatures for release files" OFF) option(GPG_SIGNATURES "Create GPG signatures for release files" OFF)

View File

@ -5,8 +5,8 @@ endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
check_cxx_compiler_flag(/fsanitize=address MSVC_ASAN_SUPPORTED) check_cxx_compiler_flag(/fsanitize=address MSVC_ASAN_SUPPORTED)
if(MSVC_ASAN_SUPPORTED) if(MSVC_ASAN_SUPPORTED)
add_compile_options(/fsanitize=address) list(APPEND VBAM_COMPILE_OPTS /fsanitize=address)
add_compile_definitions(_DISABLE_VECTOR_ANNOTATION _DISABLE_STRING_ANNOTATION) list(APPEND VBAM_COMPILE_DEFS _DISABLE_VECTOR_ANNOTATION _DISABLE_STRING_ANNOTATION)
else() else()
message(WARNING "ASAN not available for the compiler, disabling.") message(WARNING "ASAN not available for the compiler, disabling.")
set(ENABLE_ASAN OFF) set(ENABLE_ASAN OFF)
@ -27,8 +27,8 @@ else()
set(CMAKE_EXE_LINKER_FLAGS ${BACKUP_LINKER_FLAGS}) set(CMAKE_EXE_LINKER_FLAGS ${BACKUP_LINKER_FLAGS})
if(ASAN_SUPPORTED) if(ASAN_SUPPORTED)
add_compile_options(-fsanitize=address) list(APPEND VBAM_COMPILE_OPTS -fsanitize=address)
add_link_options(-fsanitize=address) list(APPEND VBAM_LINK_OPTS -fsanitize=address)
else() else()
message(WARNING "ASAN not available for the compiler, disabling.") message(WARNING "ASAN not available for the compiler, disabling.")
set(ENABLE_ASAN OFF) set(ENABLE_ASAN OFF)

View File

@ -1,19 +1,19 @@
if(X86_32 OR X86_64) if(X86_32 OR X86_64)
add_compile_options(-mfpmath=sse -msse2) list(APPEND VBAM_COMPILE_OPTS -mfpmath=sse -msse2)
endif() endif()
if(UPSTREAM_RELEASE) if(UPSTREAM_RELEASE)
if(X86_64) if(X86_64)
# Require and optimize for Core2 level support, tune for generic. # Require and optimize for Core2 level support, tune for generic.
add_compile_options(-march=core2 -mtune=generic) list(APPEND VBAM_COMPILE_OPTS -march=core2 -mtune=generic)
elseif(X86_32) elseif(X86_32)
# Optimize for pentium-mmx and tune for generic for older builds. # Optimize for pentium-mmx and tune for generic for older builds.
add_compile_options(-march=pentium-mmx -mtune=generic) list(APPEND VBAM_COMPILE_OPTS -march=pentium-mmx -mtune=generic)
endif() endif()
endif() endif()
# Common flags. # Common flags.
add_compile_options( list(APPEND VBAM_COMPILE_OPTS
-pipe -pipe
$<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-copy> $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-copy>
-Wformat -Wformat
@ -22,9 +22,9 @@ add_compile_options(
) )
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-unused-command-line-argument) list(APPEND VBAM_COMPILE_OPTS -Wno-unused-command-line-argument)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-feliminate-unused-debug-types) list(APPEND VBAM_COMPILE_OPTS -feliminate-unused-debug-types)
endif() endif()
# check if ssp flags are supported. # check if ssp flags are supported.
@ -32,23 +32,23 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
check_cxx_compiler_flag(-fstack-protector-strong STACK_PROTECTOR_SUPPORTED) check_cxx_compiler_flag(-fstack-protector-strong STACK_PROTECTOR_SUPPORTED)
if(STACK_PROTECTOR_SUPPORTED) if(STACK_PROTECTOR_SUPPORTED)
add_compile_options(-fstack-protector-strong) list(APPEND VBAM_COMPILE_OPTS -fstack-protector-strong)
check_cxx_compiler_flag("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_SUPPORTED) check_cxx_compiler_flag("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_SUPPORTED)
if(SSP_BUFFER_SIZE_SUPPORTED) if(SSP_BUFFER_SIZE_SUPPORTED)
add_compile_options(--param ssp-buffer-size=4) list(APPEND VBAM_COMPILE_OPTS --param ssp-buffer-size=4)
endif() endif()
endif() endif()
endif() endif()
if(NOT ENABLE_ASM) # inline asm is not allowed with -fPIC if(NOT ENABLE_ASM) # inline asm is not allowed with -fPIC
add_compile_options(-fPIC) list(APPEND VBAM_COMPILE_OPTS -fPIC)
endif() endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-ggdb3 -fno-omit-frame-pointer -Wall -Wextra) list(APPEND VBAM_COMPILE_OPTS -ggdb3 -fno-omit-frame-pointer -Wall -Wextra)
else() else()
add_compile_options(-Ofast -fomit-frame-pointer) list(APPEND VBAM_COMPILE_OPTS -Ofast -fomit-frame-pointer)
endif() endif()
# for some reason this is necessary # for some reason this is necessary
@ -58,17 +58,17 @@ endif()
if(VBAM_STATIC) if(VBAM_STATIC)
if(APPLE) if(APPLE)
add_link_options(-static-libstdc++) list(APPEND VBAM_LINK_OPTS -static-libstdc++)
else() else()
add_link_options(-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread) list(APPEND VBAM_LINK_OPTS -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread)
endif() endif()
endif() endif()
# To support LTO, this must always fail. # To support LTO, this must always fail.
add_compile_options(-Werror=odr -Werror=strict-aliasing) list(APPEND VBAM_COMPILE_OPTS -Werror=odr -Werror=strict-aliasing)
add_link_options( -Werror=odr -Werror=strict-aliasing) list(APPEND VBAM_LINK_OPTS -Werror=odr -Werror=strict-aliasing)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Werror=lto-type-mismatch) list(APPEND VBAM_COMPILE_OPTS -Werror=lto-type-mismatch)
add_link_options( -Werror=lto-type-mismatch) list(APPEND VBAM_LINK_OPTS -Werror=lto-type-mismatch)
endif() endif()

View File

@ -3,38 +3,37 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:DEBUG>:Debug>" CACHE INT
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# MSVC-specific flags (not supported by clang-cl). # MSVC-specific flags (not supported by clang-cl).
add_compile_options(/nologo) list(APPEND VBAM_COMPILE_OPTS /nologo)
if (NOT CMAKE_GENERATOR MATCHES "Ninja") if (NOT CMAKE_GENERATOR MATCHES "Ninja")
# Multi-processor compilation does not work well with Ninja. # Multi-processor compilation does not work well with Ninja.
add_compile_options(/MP) list(APPEND VBAM_COMPILE_OPTS /MP)
endif() endif()
endif() endif()
include_directories("${CMAKE_SOURCE_DIR}/win32-deps/msvc") include_directories("${CMAKE_SOURCE_DIR}/win32-deps/msvc")
add_compile_definitions( add_compile_definitions(
_FORCENAMELESSUNION
WIN32_LEAN_AND_MEAN
WIN32
_WINDOWS
__STDC_LIMIT_MACROS __STDC_LIMIT_MACROS
__STDC_CONSTANT_MACROS __STDC_CONSTANT_MACROS
_CRT_SECURE_NO_WARNINGS
_UNICODE _UNICODE
UNICODE UNICODE
WINVER=0x0A00 WINVER=0x0A00
NTDDI_VERSION=0x0A000007 NTDDI_VERSION=0x0A000007
)
list(APPEND VBAM_COMPILE_DEFS
WIN32_LEAN_AND_MEAN
WIN32
_CRT_SECURE_NO_WARNINGS
NOMINMAX NOMINMAX
) )
add_compile_options( list(APPEND VBAM_COMPILE_OPTS
/W4 /W4
/GR /GR
/EHsc /EHsc
) )
if (CMAKE_BUILD_TYPE STREQUAL "Debug") if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(_DEBUG)
add_compile_options(/Ob0 /Od /RTC1)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND NOT ENABLE_ASAN) if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND NOT ENABLE_ASAN)
# Use Edit and Continue with MSVC. # Use Edit and Continue with MSVC.
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "EditAndContinue" CACHE STRING "" FORCE) set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "EditAndContinue" CACHE STRING "" FORCE)
@ -42,17 +41,9 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase" CACHE STRING "" FORCE) set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase" CACHE STRING "" FORCE)
endif() endif()
else() else()
add_compile_options(/MT /Oi /Gy) add_compile_options(/Oi /Gy)
add_link_options(/OPT:REF /OPT:ICF) add_link_options(/OPT:REF /OPT:ICF)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase" CACHE STRING "" FORCE) set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "ProgramDatabase" CACHE STRING "" FORCE)
if (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
add_compile_options(/O1 /Ob1)
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_compile_options(/O2 /Ob1)
else()
add_compile_options(/O2)
endif()
endif() endif()
if(CMAKE_VERSION VERSION_LESS "3.25") if(CMAKE_VERSION VERSION_LESS "3.25")
@ -67,17 +58,3 @@ if(CMAKE_VERSION VERSION_LESS "3.25")
message(FATAL_ERROR "Unknown value for CMAKE_MSVC_DEBUG_INFORMATION_FORMAT: ${CMAKE_MSVC_DEBUG_INFORMATION_FORMAT}") message(FATAL_ERROR "Unknown value for CMAKE_MSVC_DEBUG_INFORMATION_FORMAT: ${CMAKE_MSVC_DEBUG_INFORMATION_FORMAT}")
endif() endif()
endif() endif()
set(CMAKE_RC_FLAGS "-c65001 /DWIN32" CACHE STRING "" FORCE)
# We need to explicitly set all of these to override the CMake defaults.
set(CMAKE_CXX_FLAGS "" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS "" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELEASE "" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_MINSIZEREL "" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_MINSIZEREL "" CACHE STRING "" FORCE)

View File

@ -29,30 +29,30 @@ endif()
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
if(NOT HTTPS) if(NOT HTTPS)
add_compile_definitions(NO_HTTPS) list(APPEND VBAM_COMPILE_DEFS NO_HTTPS)
endif() endif()
if(ENABLE_GBA_LOGGING) if(ENABLE_GBA_LOGGING)
add_compile_definitions(GBA_LOGGING ) list(APPEND VBAM_COMPILE_DEFS GBA_LOGGING )
endif() endif()
if(ENABLE_MMX) if(ENABLE_MMX)
add_compile_definitions(MMX) list(APPEND VBAM_COMPILE_DEFS MMX)
endif() endif()
if(NOT ENABLE_ONLINEUPDATES) if(NOT ENABLE_ONLINEUPDATES)
add_compile_definitions(NO_ONLINEUPDATES) list(APPEND VBAM_COMPILE_DEFS NO_ONLINEUPDATES)
endif() endif()
# The debugger is enabled by default # The debugger is enabled by default
if(ENABLE_DEBUGGER) if(ENABLE_DEBUGGER)
add_compile_definitions(VBAM_ENABLE_DEBUGGER) list(APPEND VBAM_COMPILE_DEFS VBAM_ENABLE_DEBUGGER)
endif() endif()
# The ASM core is disabled by default because we don't know on which platform we are # The ASM core is disabled by default because we don't know on which platform we are
if(NOT ENABLE_ASM_CORE) if(NOT ENABLE_ASM_CORE)
add_compile_definitions(C_CORE) list(APPEND VBAM_COMPILE_DEFS C_CORE)
endif() endif()
# Set up "src" and generated directory as a global include directory. # Set up "src" and generated directory as a global include directory.
@ -63,26 +63,19 @@ include_directories(
) )
# C defines # C defines
add_compile_definitions(HAVE_NETINET_IN_H HAVE_ARPA_INET_H HAVE_ZLIB_H FINAL_VERSION SDL USE_OPENGL SYSCONF_INSTALL_DIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}") list(APPEND VBAM_COMPILE_DEFS HAVE_NETINET_IN_H HAVE_ARPA_INET_H HAVE_ZLIB_H FINAL_VERSION SDL USE_OPENGL SYSCONF_INSTALL_DIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
add_compile_definitions(PKGDATADIR="${CMAKE_INSTALL_FULL_DATADIR}/vbam") list(APPEND VBAM_COMPILE_DEFS PKGDATADIR="${CMAKE_INSTALL_FULL_DATADIR}/vbam")
add_compile_definitions(__STDC_FORMAT_MACROS) list(APPEND VBAM_COMPILE_DEFS __STDC_FORMAT_MACROS)
add_compile_definitions(LOCALEDIR="${LOCALEDIR}") list(APPEND VBAM_COMPILE_DEFS LOCALEDIR="${LOCALEDIR}")
# Common compiler settings.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(DEBUG)
else()
add_compile_definitions(NDEBUG)
endif()
if(APPLE) if(APPLE)
add_compile_definitions(MACHO) list(APPEND VBAM_COMPILE_DEFS MACHO)
elseif("${CMAKE_SYSTEM}" MATCHES "Linux") elseif("${CMAKE_SYSTEM}" MATCHES "Linux")
add_compile_definitions(ELF) list(APPEND VBAM_COMPILE_DEFS ELF)
endif() endif()
if(X86_64) if(X86_64)
add_compile_definitions(__AMD64__ __X86_64__) list(APPEND VBAM_COMPILE_DEFS __AMD64__ __X86_64__)
endif() endif()
# Enable ASAN if requested and supported. # Enable ASAN if requested and supported.

View File

@ -9,7 +9,6 @@ Known preprocessor switches:
- VBAM_ENABLE_DEBUGGER: Enable remote debugging support - VBAM_ENABLE_DEBUGGER: Enable remote debugging support
- MMX: Enable MMX instruction set - MMX: Enable MMX instruction set
- RGB555: Use 16bit colors with 5bit green instead of 6bit green in hq3x/4x filters (C++ version) - RGB555: Use 16bit colors with 5bit green instead of 6bit green in hq3x/4x filters (C++ version)
- NO_OGL: Exclude OpenGL code
- NO_D3D: Exclude Direct3D code - NO_D3D: Exclude Direct3D code
- VBAM_ENABLE_XAUDIO2: Enable XAudio2 code (the XAudio2 interface is DirectSound's successor) - VBAM_ENABLE_XAUDIO2: Enable XAudio2 code (the XAudio2 interface is DirectSound's successor)
- VBAM_ENABLE_FAUDIO: Enable FAudio code (the FAudio interface is an open source multiplatform re-implementation of XAudio2) - VBAM_ENABLE_FAUDIO: Enable FAudio code (the FAudio interface is an open source multiplatform re-implementation of XAudio2)

View File

@ -16,3 +16,5 @@ target_include_directories(vbam-components-av-recording
target_link_libraries(vbam-components-av-recording target_link_libraries(vbam-components-av-recording
PUBLIC ${FFMPEG_LIBRARIES} PUBLIC ${FFMPEG_LIBRARIES}
) )
configure_vbam_target(vbam-components-av-recording)

View File

@ -8,3 +8,5 @@ target_sources(vbam-components-draw-text
target_link_libraries(vbam-components-draw-text target_link_libraries(vbam-components-draw-text
PRIVATE vbam-core-base PRIVATE vbam-core-base
) )
configure_vbam_target(vbam-components-draw-text)

View File

@ -45,3 +45,5 @@ else()
internal/hq/c/hq_shared.h internal/hq/c/hq_shared.h
) )
endif() endif()
configure_vbam_target(vbam-components-filters)

View File

@ -4,3 +4,5 @@ target_sources(vbam-components-filters-agb
PRIVATE filters_agb.cpp PRIVATE filters_agb.cpp
PUBLIC filters_agb.h PUBLIC filters_agb.h
) )
configure_vbam_target(vbam-components-filters-agb)

View File

@ -4,3 +4,5 @@ target_sources(vbam-components-filters-interframe
PRIVATE interframe.cpp PRIVATE interframe.cpp
PUBLIC interframe.h PUBLIC interframe.h
) )
configure_vbam_target(vbam-components-filters-interframe)

View File

@ -4,3 +4,5 @@ target_sources(vbam-components-user-config
PRIVATE user_config.cpp PRIVATE user_config.cpp
PUBLIC user_config.h PUBLIC user_config.h
) )
configure_vbam_target(vbam-components-user-config)

View File

@ -137,4 +137,6 @@ if(ENABLE_LINK)
) )
endif() endif()
configure_vbam_target(vbam-core)
add_subdirectory(test) add_subdirectory(test)

View File

@ -22,3 +22,5 @@ target_sources(vbam-core-apu
Gb_Oscs.h Gb_Oscs.h
Multi_Buffer.h Multi_Buffer.h
) )
configure_vbam_target(vbam-core-apu)

View File

@ -61,4 +61,6 @@ target_link_libraries(vbam-core-base
PUBLIC ${ZLIB_LIBRARY} PUBLIC ${ZLIB_LIBRARY}
) )
configure_vbam_target(vbam-core-base)
add_subdirectory(test) add_subdirectory(test)

View File

@ -10,3 +10,6 @@ add_library(vbam-core-base-test
target_link_libraries(vbam-core-base-test target_link_libraries(vbam-core-base-test
INTERFACE GTest::gtest) INTERFACE GTest::gtest)
configure_vbam_target(vbam-core-base-test)

View File

@ -71,3 +71,5 @@ target_include_directories(vbam-fex
target_link_libraries(vbam-fex target_link_libraries(vbam-fex
PRIVATE ${ZLIB_LIBRARY} PRIVATE ${ZLIB_LIBRARY}
) )
configure_vbam_target(vbam-fex)

View File

@ -11,3 +11,5 @@ target_sources(vbam-core-fake
PRIVATE PRIVATE
fake_core.cpp fake_core.cpp
) )
configure_vbam_target(vbam-core-fake)

View File

@ -68,6 +68,8 @@ if(WIN32)
target_link_libraries(vbam wsock32 ws2_32 winmm version imm32 ${SDL2MAIN_LIBRARY}) target_link_libraries(vbam wsock32 ws2_32 winmm version imm32 ${SDL2MAIN_LIBRARY})
endif() endif()
configure_vbam_target(vbam)
# Installation scripts. # Installation scripts.
install( install(
PROGRAMS ${PROJECT_BINARY_DIR}/vbam${CMAKE_EXECUTABLE_SUFFIX} PROGRAMS ${PROJECT_BINARY_DIR}/vbam${CMAKE_EXECUTABLE_SUFFIX}

View File

@ -155,38 +155,9 @@ if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
set(wxWidgets_DIR "${VCPKG_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/share/wxwidgets") set(wxWidgets_DIR "${VCPKG_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/share/wxwidgets")
endif() endif()
set(ENABLE_OPENGL TRUE)
find_package(wxWidgets COMPONENTS xrc xml html adv net core base gl ${wx_find_extra})
if(NOT wxWidgets_FOUND)
find_package(wxWidgets COMPONENTS xrc xml html adv net core base ${wx_find_extra} REQUIRED)
set(ENABLE_OPENGL FALSE)
endif()
# Fixup wxWidgets paths for vcpkg debug builds.
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
set(wxWidgets_ROOT_DIR "${wxWidgets_ROOT_DIR}/debug" CACHE INTERNAL "wxWidgets root directory" FORCE)
string(REGEX REPLACE "/lib$" "/debug/lib" wxWidgets_LIB_DIR "${wxWidgets_LIB_DIR}")
set(wxWidgets_LIB_DIR "${wxWidgets_LIB_DIR}" CACHE INTERNAL "wxWidgets library directory" FORCE)
endif()
# Find OpenAL (required). # Find OpenAL (required).
find_package(OpenAL REQUIRED) find_package(OpenAL REQUIRED)
# Workaround of static liblzma not being found on MSYS2.
if(VBAM_STATIC AND MSYS)
unset(cleaned_up_wx_libs)
foreach(lib ${wxWidgets_LIBRARIES})
if(lib STREQUAL "-llzma")
set(lib "liblzma.a")
endif()
list(APPEND cleaned_up_wx_libs "${lib}")
endforeach()
set(wxWidgets_LIBRARIES "${cleaned_up_wx_libs}")
endif()
list(APPEND CMAKE_REQUIRED_LIBRARIES ${wxWidgets_LIBRARIES}) list(APPEND CMAKE_REQUIRED_LIBRARIES ${wxWidgets_LIBRARIES})
list(APPEND CMAKE_REQUIRED_INCLUDES ${wxWidgets_INCLUDE_DIRS}) list(APPEND CMAKE_REQUIRED_INCLUDES ${wxWidgets_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_FLAGS ${wxWidgets_CXX_FLAGS}) list(APPEND CMAKE_REQUIRED_FLAGS ${wxWidgets_CXX_FLAGS})
@ -197,6 +168,7 @@ endforeach()
# Configure common settings for wx-based targets, like linking, include # Configure common settings for wx-based targets, like linking, include
# directories, compile options, and definitions. # directories, compile options, and definitions.
function(configure_wx_target target) function(configure_wx_target target)
configure_vbam_target(${target})
get_target_property(target_type ${target} TYPE) get_target_property(target_type ${target} TYPE)
if(target_type STREQUAL "EXECUTABLE") if(target_type STREQUAL "EXECUTABLE")
set(target_is_executable TRUE) set(target_is_executable TRUE)
@ -292,12 +264,7 @@ function(configure_wx_target target)
_add_link_libraries(${VBAM_SDL2_LIBS}) _add_link_libraries(${VBAM_SDL2_LIBS})
# OpenGL. # OpenGL.
if(ENABLE_OPENGL) _add_link_libraries(${OPENGL_LIBRARIES})
_add_link_libraries(${OPENGL_LIBRARIES})
else()
_add_compile_definitions(NO_OGL)
endif()
endfunction() endfunction()
# Sub-projects. # Sub-projects.

View File

@ -137,11 +137,7 @@ std::array<Option, kNbOptions>& Option::All() {
Interframe interframe = Interframe::kNone; Interframe interframe = Interframe::kNone;
bool keep_on_top = false; bool keep_on_top = false;
int32_t max_threads = 0; int32_t max_threads = 0;
#if defined(NO_OGL)
RenderMethod render_method = RenderMethod::kSimple;
#else
RenderMethod render_method = RenderMethod::kOpenGL; RenderMethod render_method = RenderMethod::kOpenGL;
#endif
double video_scale = 3; double video_scale = 3;
bool retain_aspect = true; bool retain_aspect = true;

View File

@ -263,9 +263,7 @@ DisplayConfig::DisplayConfig(wxWindow* parent)
GetValidatedChild("OutputQuartz2D")->Hide(); GetValidatedChild("OutputQuartz2D")->Hide();
#endif #endif
#ifdef NO_OGL #if defined(HAVE_WAYLAND_SUPPORT) && !defined(HAVE_WAYLAND_EGL)
GetValidatedChild("OutputOpenGL")->Hide();
#elif defined(HAVE_WAYLAND_SUPPORT) && !defined(HAVE_WAYLAND_EGL)
// wxGLCanvas segfaults on Wayland before wx 3.2. // wxGLCanvas segfaults on Wayland before wx 3.2.
if (IsWayland()) { if (IsWayland()) {
GetValidatedChild("OutputOpenGL")->Hide(); GetValidatedChild("OutputOpenGL")->Hide();
@ -276,7 +274,7 @@ DisplayConfig::DisplayConfig(wxWindow* parent)
#else #else
GetValidatedChild("OutputOpenGL") GetValidatedChild("OutputOpenGL")
->SetValidator(RenderValidator(config::RenderMethod::kOpenGL)); ->SetValidator(RenderValidator(config::RenderMethod::kOpenGL));
#endif // NO_OGL #endif // defined(HAVE_WAYLAND_SUPPORT) && !defined(HAVE_WAYLAND_EGL)
#if defined(__WXMSW__) && !defined(NO_D3D) #if defined(__WXMSW__) && !defined(NO_D3D)
// Enable the Direct3D option on Windows. // Enable the Direct3D option on Windows.

View File

@ -12,12 +12,6 @@ protected:
virtual void DrawImage(wxWindowDC& dc, wxImage* im); virtual void DrawImage(wxWindowDC& dc, wxImage* im);
}; };
// wx <= 2.8 may not be compiled with opengl support
#if !wxCHECK_VERSION(2, 9, 0) && !wxUSE_GLCANVAS
#define NO_OGL
#endif
#ifndef NO_OGL
#include <wx/glcanvas.h> #include <wx/glcanvas.h>
// shuffled parms for 2.9 indicates non-auto glcontext // shuffled parms for 2.9 indicates non-auto glcontext
@ -65,6 +59,5 @@ public:
Quartz2DDrawingPanel(wxWindow* parent, int _width, int _height); Quartz2DDrawingPanel(wxWindow* parent, int _width, int _height);
virtual void DrawImage(wxWindowDC& dc, wxImage* im); virtual void DrawImage(wxWindowDC& dc, wxImage* im);
}; };
#endif
#endif // VBAM_WX_DRAWING_H_ #endif // VBAM_WX_DRAWING_H_

View File

@ -1167,11 +1167,9 @@ void GameArea::OnIdle(wxIdleEvent& event)
new Quartz2DDrawingPanel(this, basic_width, basic_height); new Quartz2DDrawingPanel(this, basic_width, basic_height);
break; break;
#endif #endif
#ifndef NO_OGL
case config::RenderMethod::kOpenGL: case config::RenderMethod::kOpenGL:
panel = new GLDrawingPanel(this, basic_width, basic_height); panel = new GLDrawingPanel(this, basic_width, basic_height);
break; break;
#endif
#if defined(__WXMSW__) && !defined(NO_D3D) #if defined(__WXMSW__) && !defined(NO_D3D)
case config::RenderMethod::kDirect3d: case config::RenderMethod::kDirect3d:
panel = new DXDrawingPanel(this, basic_width, basic_height); panel = new DXDrawingPanel(this, basic_width, basic_height);
@ -2147,17 +2145,18 @@ void BasicDrawingPanel::DrawImage(wxWindowDC& dc, wxImage* im)
dc.DrawBitmap(bm, 0, 0); dc.DrawBitmap(bm, 0, 0);
} }
#ifndef NO_OGL
// following 3 for vsync // following 3 for vsync
#ifdef __WXMAC__ #ifdef __WXMAC__
#include <OpenGL/OpenGL.h> #include <OpenGL/OpenGL.h>
#endif #endif
#ifdef __WXGTK__ // should actually check for X11, but GTK implies X11 #ifdef __WXGTK__ // should actually check for X11, but GTK implies X11
#ifndef Status #ifndef Status
#define Status int #define Status int
#endif #endif
#include <GL/glx.h> #include <GL/glx.h>
#endif #endif
#ifdef __WXMSW__ #ifdef __WXMSW__
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glext.h> #include <GL/glext.h>
@ -2415,8 +2414,6 @@ void GLDrawingPanel::DrawArea(wxWindowDC& dc)
SwapBuffers(); SwapBuffers();
} }
#endif // GL support
#if defined(__WXMSW__) && !defined(NO_D3D) #if defined(__WXMSW__) && !defined(NO_D3D)
#define DIRECT3D_VERSION 0x0900 #define DIRECT3D_VERSION 0x0900
#include <d3d9.h> // main include file #include <d3d9.h> // main include file

View File

@ -30,7 +30,6 @@ using std::int8_t;
using std::int16_t; using std::int16_t;
using std::int32_t; using std::int32_t;
#ifndef NO_OGL
// glcanvas must be included before SFML for MacOSX // glcanvas must be included before SFML for MacOSX
// originally, this was confined to drawing.h. // originally, this was confined to drawing.h.
#include <wx/glcanvas.h> #include <wx/glcanvas.h>
@ -41,7 +40,6 @@ using std::int32_t;
#ifdef BadRequest #ifdef BadRequest
#undef BadRequest #undef BadRequest
#endif #endif
#endif
// compatibility with wx-2.9 // compatibility with wx-2.9
// The only reason I use wxTRANSLATE at all is to get wxT as a side effect. // The only reason I use wxTRANSLATE at all is to get wxT as a side effect.

1
third_party/wxWidgets vendored Submodule

@ -0,0 +1 @@
Subproject commit eda54e82e281ce949ae44f6796ae50669f7c1924