From fcae42059907809c1c7abbe6c75d9cb8c40579b5 Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Sun, 24 Nov 2024 21:07:21 -0800 Subject: [PATCH] [wip] build wxwidgets as part of the build --- .gitmodules | 3 ++ CMakeLists.txt | 37 +++++++++++++--- cmake/Dependencies.cmake | 6 +-- cmake/FindSFML.cmake | 2 +- cmake/Options.cmake | 19 ++++++++ cmake/Toolchain-asan.cmake | 8 ++-- cmake/Toolchain-gcc-clang.cmake | 34 +++++++-------- cmake/Toolchain-msvc.cmake | 43 +++++-------------- cmake/Toolchain.cmake | 33 ++++++-------- doc/DevInfo.txt | 1 - src/components/av_recording/CMakeLists.txt | 2 + src/components/draw_text/CMakeLists.txt | 2 + src/components/filters/CMakeLists.txt | 2 + src/components/filters_agb/CMakeLists.txt | 2 + .../filters_interframe/CMakeLists.txt | 2 + src/components/user_config/CMakeLists.txt | 2 + src/core/CMakeLists.txt | 2 + src/core/apu/CMakeLists.txt | 2 + src/core/base/CMakeLists.txt | 2 + src/core/base/test/CMakeLists.txt | 3 ++ src/core/fex/CMakeLists.txt | 2 + src/core/test/CMakeLists.txt | 2 + src/sdl/CMakeLists.txt | 2 + src/wx/CMakeLists.txt | 37 +--------------- src/wx/config/internal/option-internal.cpp | 4 -- src/wx/dialogs/display-config.cpp | 6 +-- src/wx/drawing.h | 7 --- src/wx/panel.cpp | 7 +-- src/wx/wxhead.h | 2 - third_party/wxWidgets | 1 + 30 files changed, 136 insertions(+), 141 deletions(-) create mode 160000 third_party/wxWidgets diff --git a/.gitmodules b/.gitmodules index b6273b6f..e597676a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,6 @@ [submodule "third_party/googletest"] path = third_party/googletest url = https://github.com/google/googletest.git +[submodule "third_party/wxWidgets"] + path = third_party/wxWidgets + url = https://github.com/wxWidgets/wxWidgets.git diff --git a/CMakeLists.txt b/CMakeLists.txt index b0d5584a..50e619a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ if(TAG_RELEASE) include(MakeReleaseCommitAndTag) endif() -set(VCPKG_DEPS pkgconf zlib pthreads "sdl2[samplerate]" gettext wxwidgets) +set(VCPKG_DEPS pkgconf zlib pthreads "sdl2[samplerate]" gettext) set(VCPKG_DEPS_OPTIONAL sfml ENABLE_LINK @@ -73,16 +73,32 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_C_STANDARD 11) 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(Architecture) include(Options) include(Toolchain) 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. if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git") set(BUILD_TESTING OFF) @@ -92,10 +108,21 @@ endif() if(BUILD_TESTING) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) - add_subdirectory(./third_party/googletest) + add_subdirectory(third_party/googletest) include(GoogleTest) 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 ""))) set(CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}") endif() diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 4934f60b..3dbbf1d6 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -64,7 +64,7 @@ if(ENABLE_FFMPEG) endif() endif() else() - add_compile_definitions(NO_FFMPEG) + list(APPEND VBAM_COMPILE_DEFS NO_FFMPEG) endif() if(ENABLE_LINK) @@ -80,10 +80,10 @@ if(ENABLE_LINK) include(CheckFunctionExists) check_function_exists(sem_timedwait SEM_TIMEDWAIT) if(SEM_TIMEDWAIT) - add_compile_definitions(HAVE_SEM_TIMEDWAIT) + list(APPEND VBAM_COMPILE_DEFS HAVE_SEM_TIMEDWAIT) endif() else() - add_compile_definitions(NO_LINK) + list(APPEND VBAM_COMPILE_DEFS NO_LINK) endif() # for now, only GBALink.cpp uses gettext() directly diff --git a/cmake/FindSFML.cmake b/cmake/FindSFML.cmake index c8ee5295..0b26d0dc 100644 --- a/cmake/FindSFML.cmake +++ b/cmake/FindSFML.cmake @@ -57,7 +57,7 @@ # define the SFML_STATIC macro if static build was chosen if(SFML_STATIC_LIBRARIES) - add_compile_definitions(SFML_STATIC) + list(APPEND VBAM_COMPILE_DEFS SFML_STATIC) endif() # define the list of search paths for headers and libraries diff --git a/cmake/Options.cmake b/cmake/Options.cmake index 0721b585..c2f40a3f 100644 --- a/cmake/Options.cmake +++ b/cmake/Options.cmake @@ -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") 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) diff --git a/cmake/Toolchain-asan.cmake b/cmake/Toolchain-asan.cmake index 08d04469..c454aa7d 100644 --- a/cmake/Toolchain-asan.cmake +++ b/cmake/Toolchain-asan.cmake @@ -5,8 +5,8 @@ endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") check_cxx_compiler_flag(/fsanitize=address MSVC_ASAN_SUPPORTED) if(MSVC_ASAN_SUPPORTED) - add_compile_options(/fsanitize=address) - add_compile_definitions(_DISABLE_VECTOR_ANNOTATION _DISABLE_STRING_ANNOTATION) + list(APPEND VBAM_COMPILE_OPTS /fsanitize=address) + list(APPEND VBAM_COMPILE_DEFS _DISABLE_VECTOR_ANNOTATION _DISABLE_STRING_ANNOTATION) else() message(WARNING "ASAN not available for the compiler, disabling.") set(ENABLE_ASAN OFF) @@ -27,8 +27,8 @@ else() set(CMAKE_EXE_LINKER_FLAGS ${BACKUP_LINKER_FLAGS}) if(ASAN_SUPPORTED) - add_compile_options(-fsanitize=address) - add_link_options(-fsanitize=address) + list(APPEND VBAM_COMPILE_OPTS -fsanitize=address) + list(APPEND VBAM_LINK_OPTS -fsanitize=address) else() message(WARNING "ASAN not available for the compiler, disabling.") set(ENABLE_ASAN OFF) diff --git a/cmake/Toolchain-gcc-clang.cmake b/cmake/Toolchain-gcc-clang.cmake index 0f668212..41a20be3 100644 --- a/cmake/Toolchain-gcc-clang.cmake +++ b/cmake/Toolchain-gcc-clang.cmake @@ -1,19 +1,19 @@ if(X86_32 OR X86_64) - add_compile_options(-mfpmath=sse -msse2) + list(APPEND VBAM_COMPILE_OPTS -mfpmath=sse -msse2) endif() if(UPSTREAM_RELEASE) if(X86_64) # 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) # 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() # Common flags. -add_compile_options( +list(APPEND VBAM_COMPILE_OPTS -pipe $<$:-Wno-deprecated-copy> -Wformat @@ -22,9 +22,9 @@ add_compile_options( ) 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") - add_compile_options(-feliminate-unused-debug-types) + list(APPEND VBAM_COMPILE_OPTS -feliminate-unused-debug-types) endif() # 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) 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) 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() if(NOT ENABLE_ASM) # inline asm is not allowed with -fPIC - add_compile_options(-fPIC) + list(APPEND VBAM_COMPILE_OPTS -fPIC) endif() 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() - add_compile_options(-Ofast -fomit-frame-pointer) + list(APPEND VBAM_COMPILE_OPTS -Ofast -fomit-frame-pointer) endif() # for some reason this is necessary @@ -58,17 +58,17 @@ endif() if(VBAM_STATIC) if(APPLE) - add_link_options(-static-libstdc++) + list(APPEND VBAM_LINK_OPTS -static-libstdc++) 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() # To support LTO, this must always fail. -add_compile_options(-Werror=odr -Werror=strict-aliasing) -add_link_options( -Werror=odr -Werror=strict-aliasing) +list(APPEND VBAM_COMPILE_OPTS -Werror=odr -Werror=strict-aliasing) +list(APPEND VBAM_LINK_OPTS -Werror=odr -Werror=strict-aliasing) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options(-Werror=lto-type-mismatch) - add_link_options( -Werror=lto-type-mismatch) + list(APPEND VBAM_COMPILE_OPTS -Werror=lto-type-mismatch) + list(APPEND VBAM_LINK_OPTS -Werror=lto-type-mismatch) endif() diff --git a/cmake/Toolchain-msvc.cmake b/cmake/Toolchain-msvc.cmake index c2f39ab1..2fd37171 100644 --- a/cmake/Toolchain-msvc.cmake +++ b/cmake/Toolchain-msvc.cmake @@ -3,38 +3,37 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" CACHE INT if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # MSVC-specific flags (not supported by clang-cl). - add_compile_options(/nologo) + list(APPEND VBAM_COMPILE_OPTS /nologo) if (NOT CMAKE_GENERATOR MATCHES "Ninja") # Multi-processor compilation does not work well with Ninja. - add_compile_options(/MP) + list(APPEND VBAM_COMPILE_OPTS /MP) endif() endif() include_directories("${CMAKE_SOURCE_DIR}/win32-deps/msvc") add_compile_definitions( - _FORCENAMELESSUNION - WIN32_LEAN_AND_MEAN - WIN32 - _WINDOWS __STDC_LIMIT_MACROS __STDC_CONSTANT_MACROS - _CRT_SECURE_NO_WARNINGS _UNICODE UNICODE WINVER=0x0A00 NTDDI_VERSION=0x0A000007 +) + +list(APPEND VBAM_COMPILE_DEFS + WIN32_LEAN_AND_MEAN + WIN32 + _CRT_SECURE_NO_WARNINGS NOMINMAX ) -add_compile_options( +list(APPEND VBAM_COMPILE_OPTS /W4 /GR /EHsc ) 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) # Use Edit and Continue with MSVC. 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) endif() else() - add_compile_options(/MT /Oi /Gy) + add_compile_options(/Oi /Gy) add_link_options(/OPT:REF /OPT:ICF) 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() 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}") 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) diff --git a/cmake/Toolchain.cmake b/cmake/Toolchain.cmake index 9297df27..3af2f3de 100644 --- a/cmake/Toolchain.cmake +++ b/cmake/Toolchain.cmake @@ -29,30 +29,30 @@ endif() set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}) if(NOT HTTPS) - add_compile_definitions(NO_HTTPS) + list(APPEND VBAM_COMPILE_DEFS NO_HTTPS) endif() if(ENABLE_GBA_LOGGING) - add_compile_definitions(GBA_LOGGING ) + list(APPEND VBAM_COMPILE_DEFS GBA_LOGGING ) endif() if(ENABLE_MMX) - add_compile_definitions(MMX) + list(APPEND VBAM_COMPILE_DEFS MMX) endif() if(NOT ENABLE_ONLINEUPDATES) - add_compile_definitions(NO_ONLINEUPDATES) + list(APPEND VBAM_COMPILE_DEFS NO_ONLINEUPDATES) endif() # The debugger is enabled by default if(ENABLE_DEBUGGER) - add_compile_definitions(VBAM_ENABLE_DEBUGGER) + list(APPEND VBAM_COMPILE_DEFS VBAM_ENABLE_DEBUGGER) endif() # The ASM core is disabled by default because we don't know on which platform we are if(NOT ENABLE_ASM_CORE) - add_compile_definitions(C_CORE) + list(APPEND VBAM_COMPILE_DEFS C_CORE) endif() # Set up "src" and generated directory as a global include directory. @@ -63,26 +63,19 @@ include_directories( ) # 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}") -add_compile_definitions(PKGDATADIR="${CMAKE_INSTALL_FULL_DATADIR}/vbam") -add_compile_definitions(__STDC_FORMAT_MACROS) -add_compile_definitions(LOCALEDIR="${LOCALEDIR}") - -# Common compiler settings. -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - add_compile_definitions(DEBUG) -else() - add_compile_definitions(NDEBUG) -endif() +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}") +list(APPEND VBAM_COMPILE_DEFS PKGDATADIR="${CMAKE_INSTALL_FULL_DATADIR}/vbam") +list(APPEND VBAM_COMPILE_DEFS __STDC_FORMAT_MACROS) +list(APPEND VBAM_COMPILE_DEFS LOCALEDIR="${LOCALEDIR}") if(APPLE) - add_compile_definitions(MACHO) + list(APPEND VBAM_COMPILE_DEFS MACHO) elseif("${CMAKE_SYSTEM}" MATCHES "Linux") - add_compile_definitions(ELF) + list(APPEND VBAM_COMPILE_DEFS ELF) endif() if(X86_64) - add_compile_definitions(__AMD64__ __X86_64__) + list(APPEND VBAM_COMPILE_DEFS __AMD64__ __X86_64__) endif() # Enable ASAN if requested and supported. diff --git a/doc/DevInfo.txt b/doc/DevInfo.txt index a4cb9ca5..524b6ec1 100644 --- a/doc/DevInfo.txt +++ b/doc/DevInfo.txt @@ -9,7 +9,6 @@ Known preprocessor switches: - VBAM_ENABLE_DEBUGGER: Enable remote debugging support - MMX: Enable MMX instruction set - 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 - 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) diff --git a/src/components/av_recording/CMakeLists.txt b/src/components/av_recording/CMakeLists.txt index 21fda70e..ba675a13 100644 --- a/src/components/av_recording/CMakeLists.txt +++ b/src/components/av_recording/CMakeLists.txt @@ -16,3 +16,5 @@ target_include_directories(vbam-components-av-recording target_link_libraries(vbam-components-av-recording PUBLIC ${FFMPEG_LIBRARIES} ) + +configure_vbam_target(vbam-components-av-recording) diff --git a/src/components/draw_text/CMakeLists.txt b/src/components/draw_text/CMakeLists.txt index 8c70cd33..986dd441 100644 --- a/src/components/draw_text/CMakeLists.txt +++ b/src/components/draw_text/CMakeLists.txt @@ -8,3 +8,5 @@ target_sources(vbam-components-draw-text target_link_libraries(vbam-components-draw-text PRIVATE vbam-core-base ) + +configure_vbam_target(vbam-components-draw-text) diff --git a/src/components/filters/CMakeLists.txt b/src/components/filters/CMakeLists.txt index e2b9ea07..fc0aff4d 100644 --- a/src/components/filters/CMakeLists.txt +++ b/src/components/filters/CMakeLists.txt @@ -45,3 +45,5 @@ else() internal/hq/c/hq_shared.h ) endif() + +configure_vbam_target(vbam-components-filters) diff --git a/src/components/filters_agb/CMakeLists.txt b/src/components/filters_agb/CMakeLists.txt index 20dac393..0ac7c10f 100644 --- a/src/components/filters_agb/CMakeLists.txt +++ b/src/components/filters_agb/CMakeLists.txt @@ -4,3 +4,5 @@ target_sources(vbam-components-filters-agb PRIVATE filters_agb.cpp PUBLIC filters_agb.h ) + +configure_vbam_target(vbam-components-filters-agb) diff --git a/src/components/filters_interframe/CMakeLists.txt b/src/components/filters_interframe/CMakeLists.txt index d80834a4..da7744c7 100644 --- a/src/components/filters_interframe/CMakeLists.txt +++ b/src/components/filters_interframe/CMakeLists.txt @@ -4,3 +4,5 @@ target_sources(vbam-components-filters-interframe PRIVATE interframe.cpp PUBLIC interframe.h ) + +configure_vbam_target(vbam-components-filters-interframe) diff --git a/src/components/user_config/CMakeLists.txt b/src/components/user_config/CMakeLists.txt index 35ff554b..3770b132 100644 --- a/src/components/user_config/CMakeLists.txt +++ b/src/components/user_config/CMakeLists.txt @@ -4,3 +4,5 @@ target_sources(vbam-components-user-config PRIVATE user_config.cpp PUBLIC user_config.h ) + +configure_vbam_target(vbam-components-user-config) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 4a843123..827f371f 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -137,4 +137,6 @@ if(ENABLE_LINK) ) endif() +configure_vbam_target(vbam-core) + add_subdirectory(test) diff --git a/src/core/apu/CMakeLists.txt b/src/core/apu/CMakeLists.txt index 222dae90..cbbddd9b 100644 --- a/src/core/apu/CMakeLists.txt +++ b/src/core/apu/CMakeLists.txt @@ -22,3 +22,5 @@ target_sources(vbam-core-apu Gb_Oscs.h Multi_Buffer.h ) + +configure_vbam_target(vbam-core-apu) diff --git a/src/core/base/CMakeLists.txt b/src/core/base/CMakeLists.txt index 7d092583..7ddd21d0 100644 --- a/src/core/base/CMakeLists.txt +++ b/src/core/base/CMakeLists.txt @@ -61,4 +61,6 @@ target_link_libraries(vbam-core-base PUBLIC ${ZLIB_LIBRARY} ) +configure_vbam_target(vbam-core-base) + add_subdirectory(test) diff --git a/src/core/base/test/CMakeLists.txt b/src/core/base/test/CMakeLists.txt index fba4841b..8639439b 100644 --- a/src/core/base/test/CMakeLists.txt +++ b/src/core/base/test/CMakeLists.txt @@ -10,3 +10,6 @@ add_library(vbam-core-base-test target_link_libraries(vbam-core-base-test INTERFACE GTest::gtest) + +configure_vbam_target(vbam-core-base-test) + diff --git a/src/core/fex/CMakeLists.txt b/src/core/fex/CMakeLists.txt index f3fcf782..7776497b 100644 --- a/src/core/fex/CMakeLists.txt +++ b/src/core/fex/CMakeLists.txt @@ -71,3 +71,5 @@ target_include_directories(vbam-fex target_link_libraries(vbam-fex PRIVATE ${ZLIB_LIBRARY} ) + +configure_vbam_target(vbam-fex) diff --git a/src/core/test/CMakeLists.txt b/src/core/test/CMakeLists.txt index 04e2f8f1..93e4cb2f 100644 --- a/src/core/test/CMakeLists.txt +++ b/src/core/test/CMakeLists.txt @@ -11,3 +11,5 @@ target_sources(vbam-core-fake PRIVATE fake_core.cpp ) + +configure_vbam_target(vbam-core-fake) diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index 7c077918..1be14fe4 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -68,6 +68,8 @@ if(WIN32) target_link_libraries(vbam wsock32 ws2_32 winmm version imm32 ${SDL2MAIN_LIBRARY}) endif() +configure_vbam_target(vbam) + # Installation scripts. install( PROGRAMS ${PROJECT_BINARY_DIR}/vbam${CMAKE_EXECUTABLE_SUFFIX} diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index f549ccdf..67798079 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -155,38 +155,9 @@ if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg") set(wxWidgets_DIR "${VCPKG_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/share/wxwidgets") 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_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_INCLUDES ${wxWidgets_INCLUDE_DIRS}) list(APPEND CMAKE_REQUIRED_FLAGS ${wxWidgets_CXX_FLAGS}) @@ -197,6 +168,7 @@ endforeach() # Configure common settings for wx-based targets, like linking, include # directories, compile options, and definitions. function(configure_wx_target target) + configure_vbam_target(${target}) get_target_property(target_type ${target} TYPE) if(target_type STREQUAL "EXECUTABLE") set(target_is_executable TRUE) @@ -292,12 +264,7 @@ function(configure_wx_target target) _add_link_libraries(${VBAM_SDL2_LIBS}) # OpenGL. - if(ENABLE_OPENGL) - _add_link_libraries(${OPENGL_LIBRARIES}) - else() - _add_compile_definitions(NO_OGL) - endif() - + _add_link_libraries(${OPENGL_LIBRARIES}) endfunction() # Sub-projects. diff --git a/src/wx/config/internal/option-internal.cpp b/src/wx/config/internal/option-internal.cpp index 24774beb..12531240 100644 --- a/src/wx/config/internal/option-internal.cpp +++ b/src/wx/config/internal/option-internal.cpp @@ -137,11 +137,7 @@ std::array& Option::All() { Interframe interframe = Interframe::kNone; bool keep_on_top = false; int32_t max_threads = 0; -#if defined(NO_OGL) - RenderMethod render_method = RenderMethod::kSimple; -#else RenderMethod render_method = RenderMethod::kOpenGL; -#endif double video_scale = 3; bool retain_aspect = true; diff --git a/src/wx/dialogs/display-config.cpp b/src/wx/dialogs/display-config.cpp index 75cdf558..b6bcd9b8 100644 --- a/src/wx/dialogs/display-config.cpp +++ b/src/wx/dialogs/display-config.cpp @@ -263,9 +263,7 @@ DisplayConfig::DisplayConfig(wxWindow* parent) GetValidatedChild("OutputQuartz2D")->Hide(); #endif -#ifdef NO_OGL - GetValidatedChild("OutputOpenGL")->Hide(); -#elif defined(HAVE_WAYLAND_SUPPORT) && !defined(HAVE_WAYLAND_EGL) +#if defined(HAVE_WAYLAND_SUPPORT) && !defined(HAVE_WAYLAND_EGL) // wxGLCanvas segfaults on Wayland before wx 3.2. if (IsWayland()) { GetValidatedChild("OutputOpenGL")->Hide(); @@ -276,7 +274,7 @@ DisplayConfig::DisplayConfig(wxWindow* parent) #else GetValidatedChild("OutputOpenGL") ->SetValidator(RenderValidator(config::RenderMethod::kOpenGL)); -#endif // NO_OGL +#endif // defined(HAVE_WAYLAND_SUPPORT) && !defined(HAVE_WAYLAND_EGL) #if defined(__WXMSW__) && !defined(NO_D3D) // Enable the Direct3D option on Windows. diff --git a/src/wx/drawing.h b/src/wx/drawing.h index 42a54a04..90ffc821 100644 --- a/src/wx/drawing.h +++ b/src/wx/drawing.h @@ -12,12 +12,6 @@ protected: 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 // shuffled parms for 2.9 indicates non-auto glcontext @@ -65,6 +59,5 @@ public: Quartz2DDrawingPanel(wxWindow* parent, int _width, int _height); virtual void DrawImage(wxWindowDC& dc, wxImage* im); }; -#endif #endif // VBAM_WX_DRAWING_H_ diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index 46e5409c..afdd8716 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -1167,11 +1167,9 @@ void GameArea::OnIdle(wxIdleEvent& event) new Quartz2DDrawingPanel(this, basic_width, basic_height); break; #endif -#ifndef NO_OGL case config::RenderMethod::kOpenGL: panel = new GLDrawingPanel(this, basic_width, basic_height); break; -#endif #if defined(__WXMSW__) && !defined(NO_D3D) case config::RenderMethod::kDirect3d: panel = new DXDrawingPanel(this, basic_width, basic_height); @@ -2147,17 +2145,18 @@ void BasicDrawingPanel::DrawImage(wxWindowDC& dc, wxImage* im) dc.DrawBitmap(bm, 0, 0); } -#ifndef NO_OGL // following 3 for vsync #ifdef __WXMAC__ #include #endif + #ifdef __WXGTK__ // should actually check for X11, but GTK implies X11 #ifndef Status #define Status int #endif #include #endif + #ifdef __WXMSW__ #include #include @@ -2415,8 +2414,6 @@ void GLDrawingPanel::DrawArea(wxWindowDC& dc) SwapBuffers(); } -#endif // GL support - #if defined(__WXMSW__) && !defined(NO_D3D) #define DIRECT3D_VERSION 0x0900 #include // main include file diff --git a/src/wx/wxhead.h b/src/wx/wxhead.h index e4078ca2..abb697fa 100644 --- a/src/wx/wxhead.h +++ b/src/wx/wxhead.h @@ -30,7 +30,6 @@ using std::int8_t; using std::int16_t; using std::int32_t; -#ifndef NO_OGL // glcanvas must be included before SFML for MacOSX // originally, this was confined to drawing.h. #include @@ -41,7 +40,6 @@ using std::int32_t; #ifdef BadRequest #undef BadRequest #endif -#endif // compatibility with wx-2.9 // The only reason I use wxTRANSLATE at all is to get wxT as a side effect. diff --git a/third_party/wxWidgets b/third_party/wxWidgets new file mode 160000 index 00000000..eda54e82 --- /dev/null +++ b/third_party/wxWidgets @@ -0,0 +1 @@ +Subproject commit eda54e82e281ce949ae44f6796ae50669f7c1924