[build] Clean up build files

* Use add_compile_definitions everywhere.
* Remove unused intermediate target.
* Add ASAN support for MSVC.
* Remove duplicate option definitions.
This commit is contained in:
Fabrice de Gans 2024-03-13 15:57:09 -07:00
parent aa59d94490
commit fd2d7c8001
12 changed files with 129 additions and 289 deletions

View File

@ -56,10 +56,6 @@ project(VBA-M C CXX)
find_package(Git)
find_package(PkgConfig)
include(GNUInstallDirs)
include(Options)
include(Architecture)
if(NOT CMAKE_PREFIX_PATH AND (NOT ("$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")))
set(CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
endif()
@ -80,54 +76,24 @@ if(BUILD_TESTING)
enable_testing()
endif()
set(ALL_TARGETS fex visualboyadvance-m vbamcore vbam)
add_custom_target(generate)
include(GNUInstallDirs)
include(Options)
include(Architecture)
include(Toolchain)
#Output all binaries at top level
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
if(NOT HTTPS)
add_definitions(-DNO_HTTPS)
add_compile_definitions(NO_HTTPS)
endif()
if(WIN32 OR CMAKE_TOOLCHAIN_FILE MATCHES "[Mm][Ii][Nn][Gg][Ww]")
# Win32 deps submodule
set(git_checkout FALSE)
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(git_checkout TRUE)
execute_process(
COMMAND git submodule update --init --remote --recursive
RESULT_VARIABLE git_status
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
endif()
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
if(NOT (git_checkout AND git_status EQUAL 0))
message(FATAL_ERROR "Please pull in git submodules, e.g.\nrun: git submodule update --init --remote --recursive")
endif()
endif()
endif()
if(MSVC)
include_directories("${CMAKE_SOURCE_DIR}/dependencies/msvc")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
# TODO: We should update the XAudio headers to build with clang-cl. See
# https://github.com/visualboyadvance-m/visualboyadvance-m/issues/1021
add_definitions(-DNO_XAUDIO2)
endif()
option(ENABLE_GBA_LOGGING "Enable extended GBA logging" ON)
if(ENABLE_GBA_LOGGING)
add_definitions(-DGBA_LOGGING )
add_compile_definitions(GBA_LOGGING )
endif()
if(ENABLE_MMX)
add_definitions(-DMMX)
add_compile_definitions(MMX)
endif()
# The SDL port can't be built without debugging support
@ -135,13 +101,6 @@ if(NOT ENABLE_DEBUGGER AND ENABLE_SDL)
message(SEND_ERROR "The SDL port can't be built without debugging support")
endif()
# this has to run after the toolchain is initialized so it can't be in
# Win32deps.cmake
if(MINGW)
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-include")
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
include(GitTagVersion)
git_version(VERSION REVISION VERSION_RELEASE)
@ -203,57 +162,11 @@ include_directories(${CMAKE_BINARY_DIR})
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\1,\\2,\\3,0" WIN_VERSION "${VERSION}")
configure_file("${CMAKE_SOURCE_DIR}/src/version.h.in" "${CMAKE_BINARY_DIR}/version.h" @ONLY)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(-DDEBUG)
else()
add_definitions(-DNDEBUG)
endif()
# hack for ninja in msys2
if(WIN32 AND CMAKE_GENERATOR STREQUAL Ninja AND NOT "$ENV{MSYSTEM_PREFIX}" STREQUAL "")
set(MSYS ON)
endif()
include(VbamFunctions)
if(MSYS AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
if($ENV{MSYSTEM} STREQUAL CLANG64)
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/x86_64-w64-mingw32")
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
elseif($ENV{MSYSTEM} STREQUAL CLANG32)
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/i686-w64-mingw32")
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
endif()
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" CACHE INTERNAL "prefix search path for find_XXXX" FORCE)
endif()
# We do not support amd64 asm yet
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(ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS)
if(MSVC)
if(NOT EXISTS ${CMAKE_BINARY_DIR}/nuget.exe)
file(DOWNLOAD "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" ${CMAKE_BINARY_DIR}/nuget.exe)
endif()
execute_process(
COMMAND nuget.exe install nasm2 -OutputDirectory ${CMAKE_BINARY_DIR}/nuget
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
file(GLOB pkg ${CMAKE_BINARY_DIR}/nuget/nasm2*)
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools)
endif()
enable_language(ASM_NASM)
set(ASM_ENABLED ON)
endif()
if(NOT WIN32)
find_library(PTHREAD_LIB pthread)
if(PTHREAD_LIB)
@ -345,11 +258,11 @@ if(ENABLE_FFMPEG)
endif()
endif()
else()
add_definitions(-DNO_FFMPEG)
add_compile_definitions(NO_FFMPEG)
endif()
if(NOT ENABLE_ONLINEUPDATES)
add_definitions(-DNO_ONLINEUPDATES)
add_compile_definitions(NO_ONLINEUPDATES)
endif()
if(ENABLE_LIRC)
@ -359,19 +272,18 @@ else()
endif()
# C defines
add_definitions(-DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DHAVE_ZLIB_H -DFINAL_VERSION -DSDL -DUSE_OPENGL -DSYSCONF_INSTALL_DIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}" -DWITH_LIRC=${WITHLIRC})
add_definitions(-DPKGDATADIR="${CMAKE_INSTALL_FULL_DATADIR}/vbam" -DPACKAGE=)
add_definitions(-D__STDC_FORMAT_MACROS)
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}" WITH_LIRC=${WITHLIRC})
add_compile_definitions(PKGDATADIR="${CMAKE_INSTALL_FULL_DATADIR}/vbam")
add_compile_definitions(__STDC_FORMAT_MACROS)
# For C++, default to nonstd::optional and nonstd::variant for now due to mac
# build issues.
if(APPLE)
add_definitions(-Doptional_CONFIG_SELECT_OPTIONAL=optional_OPTIONAL_NONSTD)
add_definitions(-Dvariant_CONFIG_SELECT_VARIANT=variant_VARIANT_NONSTD)
add_compile_definitions(optional_CONFIG_SELECT_OPTIONAL=optional_OPTIONAL_NONSTD)
add_compile_definitions(variant_CONFIG_SELECT_VARIANT=variant_VARIANT_NONSTD)
else()
add_definitions(-Doptional_CONFIG_SELECT_OPTIONAL=optional_OPTIONAL_STD)
add_definitions(-Dvariant_CONFIG_SELECT_VARIANT=variant_VARIANT_STD)
add_compile_definitions(optional_CONFIG_SELECT_OPTIONAL=optional_OPTIONAL_STD)
add_compile_definitions(variant_CONFIG_SELECT_VARIANT=variant_VARIANT_STD)
endif()
if(ENABLE_LINK)
@ -387,29 +299,29 @@ if(ENABLE_LINK)
include(CheckFunctionExists)
check_function_exists(sem_timedwait SEM_TIMEDWAIT)
if(SEM_TIMEDWAIT)
add_definitions(-DHAVE_SEM_TIMEDWAIT)
add_compile_definitions(HAVE_SEM_TIMEDWAIT)
endif()
else()
add_definitions(-DNO_LINK)
add_compile_definitions(NO_LINK)
endif()
# The debugger is enabled by default
if(NOT ENABLE_DEBUGGER)
add_definitions(-DNO_DEBUGGER)
add_compile_definitions(NO_DEBUGGER)
else()
add_definitions(-DBKPT_SUPPORT)
add_compile_definitions(BKPT_SUPPORT)
endif()
# The ASM core is disabled by default because we don't know on which platform we are
if(NOT ENABLE_ASM_CORE)
add_definitions(-DC_CORE)
add_compile_definitions(C_CORE)
endif()
# Enable internationalization
if(ENABLE_NLS)
set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale)
add_definitions(-DENABLE_NLS)
add_definitions(-DLOCALEDIR="${LOCALEDIR}")
add_compile_definitions(ENABLE_NLS)
add_compile_definitions(LOCALEDIR="${LOCALEDIR}")
# for now, only GBALink.cpp uses gettext() directly
if(APPLE)
# use Homebrew gettext if available
@ -445,18 +357,6 @@ if(ENABLE_NLS)
endif()
endif()
include(Toolchain)
if(APPLE)
add_definitions(-DMACHO)
elseif("${CMAKE_SYSTEM}" MATCHES "Linux")
add_definitions(-DELF)
endif()
if(X86_64)
add_definitions(-D__AMD64__ -D__X86_64__)
endif()
if(NOT TRANSLATIONS_ONLY)
add_subdirectory(fex)
endif()
@ -694,7 +594,7 @@ if(ENABLE_ASM_SCALERS)
else()
set(SRC_FILTERS ${SRC_FILTERS} ${SRC_HQ_C})
set(HDR_FILTERS ${HDR_FILTERS} ${HDR_HQ_C})
add_definitions(-DNO_ASM)
add_compile_definitions(NO_ASM)
endif()
@ -761,7 +661,6 @@ if(NOT TRANSLATIONS_ONLY)
${HDR_DEBUGGER}
${HDR_STB_IMAGE}
)
add_dependencies(vbamcore generate)
target_include_directories(vbamcore PUBLIC ${SDL2_INCLUDE_DIRS})
endif()

View File

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

View File

@ -4,7 +4,7 @@ option(BUILD_SHARED_LIBS "Build dynamic libraries" OFF)
option(ENABLE_SDL "Build the SDL port" ON)
option(ENABLE_WX "Build the wxWidgets port" ON)
option(ENABLE_DEBUGGER "Enable the debugger" ON)
option(ENABLE_ASAN "Enable -fsanitize=<option>, address by default, requires debug build" OFF)
option(ENABLE_ASAN "Enable -fsanitize=address by default. Requires debug build with GCC/Clang" OFF)
# Static linking
set(VBAM_STATIC_DEFAULT OFF)
@ -49,7 +49,7 @@ option(ENABLE_LIRC "Enable LIRC support" OFF)
# Link / SFML
find_package(SFML 2.4 COMPONENTS network system)
if(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
if(SFML_STATIC_LIBRARIES AND SFML_NETWORK_LIBRARY_STATIC_DEBUG AND SFML_SYSTEM_LIBRARY_STATIC_DEBUG)
set(SFML_LIBRARIES ${SFML_NETWORK_LIBRARY_STATIC_DEBUG} ${SFML_SYSTEM_LIBRARY_STATIC_DEBUG})
elseif(SFML_NETWORK_LIBRARY_DYNAMIC_DEBUG AND SFML_SYSTEM_LIBRARY_DYNAMIC_DEBUG)
@ -99,7 +99,7 @@ option(ENABLE_ONLINEUPDATES "Enable online update checks" ${ONLINEUPDATES_DEFAUL
option(HTTPS "Use https URL for winsparkle" ON)
# We generally don't want LTO when debugging because it makes linking slow
if(CMAKE_BUILD_TYPE STREQUAL Debug)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(LTO_DEFAULT OFF)
else()
set(LTO_DEFAULT ON)

View File

@ -0,0 +1,37 @@
if(NOT ENABLE_ASAN)
return()
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)
else()
message(WARNING "ASAN not available for the compiler, disabling.")
set(ENABLE_ASAN OFF)
return()
endif()
else()
# ASAN does not work on non-debug builds for GCC and Clang.
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
message(WARNING "ASAN requires debug build, set -DCMAKE_BUILD_TYPE=Debug, disabling.")
set(ENABLE_ASAN OFF)
return()
endif()
# It is necessary to modify the linker flagas for the compiler check to work.
set(BACKUP_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address")
check_cxx_compiler_flag(-fsanitize=address ASAN_SUPPORTED)
set(CMAKE_EXE_LINKER_FLAGS ${BACKUP_LINKER_FLAGS})
if(ASAN_SUPPORTED)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
else()
message(WARNING "ASAN not available for the compiler, disabling.")
set(ENABLE_ASAN OFF)
return()
endif()
endif()

View File

@ -1,5 +1,3 @@
include(CheckCXXCompilerFlag)
if(X86_32 OR X86_64)
add_compile_options(-mfpmath=sse -msse2)
endif()
@ -22,27 +20,6 @@ add_compile_options(
-fdiagnostics-color=always
)
if(ENABLE_ASAN)
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
message(WARNING "ASAN requires debug build, set -DCMAKE_BUILD_TYPE=Debug, disabling.")
set(ENABLE_ASAN OFF)
endif()
# It is necessary to modify the linker flagas for the compiler check to work.
set(BACKUP_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address")
check_cxx_compiler_flag(-fsanitize=address ASAN_SUPPORTED)
set(CMAKE_EXE_LINKER_FLAGS ${BACKUP_LINKER_FLAGS})
if(ASAN_SUPPORTED)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
else()
message(WARNING "ASAN not available for the compiler, disabling.")
set(ENABLE_ASAN OFF)
endif()
endif()
# check if ssp flags are supported.
if(CMAKE_BUILD_TYPE STREQUAL Debug)
check_cxx_compiler_flag(-fstack-protector-strong STACK_PROTECTOR_SUPPORTED)

View File

@ -1,41 +0,0 @@
if(CMAKE_C_COMPILER_ID STREQUAL Clang)
set(compiler "${CMAKE_C_COMPILER}")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(compiler "${CMAKE_CXX_COMPILER}")
else()
return()
endif()
foreach(tool ar ranlib ld nm objdump as)
execute_process(
COMMAND "${compiler}" -print-prog-name=llvm-${tool}
OUTPUT_VARIABLE prog_path
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# for FreeBSD
if(NOT prog_path MATCHES "^/")
get_filename_component(
abs_path ${prog_path} ABSOLUTE
BASE_DIR /usr/local/llvm-devel/bin
)
if(EXISTS ${abs_path})
set(prog_path ${abs_path})
endif()
endif()
if(prog_path MATCHES "^/")
if(tool STREQUAL ld)
set(tool linker)
elseif(tool STREQUAL as)
set(tool asm_compiler)
endif()
string(TOUPPER ${tool} utool)
set(CMAKE_${utool} "${prog_path}" PARENT_SCOPE)
set(CMAKE_${utool} "${prog_path}" CACHE FILEPATH "${tool}" FORCE)
endif()
endforeach()

View File

@ -1,5 +1,4 @@
# this has to run after the toolchain is initialized so it can't be in
# Win32deps.cmake
# this has to run after the toolchain is initialized.
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-include")
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
@ -20,40 +19,3 @@ if(NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
endif()
endif()
# hack for ninja in msys2
if(WIN32 AND CMAKE_GENERATOR STREQUAL Ninja AND NOT "$ENV{MSYSTEM_PREFIX}" STREQUAL "")
set(MSYS ON)
endif()
if(MSYS AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
if($ENV{MSYSTEM} STREQUAL CLANG64)
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/x86_64-w64-mingw32")
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
elseif($ENV{MSYSTEM} STREQUAL CLANG32)
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/i686-w64-mingw32")
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
endif()
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" CACHE INTERNAL "prefix search path for find_XXXX" FORCE)
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()

View File

@ -1,7 +1,7 @@
# Set the runtime library properly.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:DEBUG>:Debug>" CACHE INTERNAL "")
if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# MSVC-specific flags (not supported by clang-cl).
add_compile_options(/nologo)
if (NOT CMAKE_GENERATOR MATCHES "Ninja")
@ -28,16 +28,15 @@ add_compile_options(
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(_DEBUG DEBUG)
add_compile_definitions(_DEBUG)
add_compile_options(/Ob0 /Od /RTC1)
if (CMAKE_CXX_COMPILER_ID STREQUAL MSVC)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND NOT ENABLE_ASAN)
# Use Edit and Continue with MSVC.
add_compile_options(/ZI)
else()
add_compile_options(/Zi)
endif()
else()
add_compile_definitions(NDEBUG)
add_compile_options(/MT /Oi /Gy /Zi)
add_link_options(/OPT:REF /OPT:ICF)

View File

@ -1,4 +1,6 @@
# Compiler stuff
include(CheckCXXCompilerFlag)
include(ProcessorCount)
ProcessorCount(num_cpus)
@ -13,11 +15,26 @@ if (ENABLE_LTO)
endif()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT MSVC)
# TODO: This should also be done for clang-cl.
include(Toolchain-llvm)
# Common compiler settings.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(DEBUG)
else()
add_compile_definitions(NDEBUG)
endif()
if(APPLE)
add_compile_definitions(MACHO)
elseif("${CMAKE_SYSTEM}" MATCHES "Linux")
add_compile_definitions(ELF)
endif()
if(X86_64)
add_compile_definitions(__AMD64__ __X86_64__)
endif()
include(Toolchain-asan)
# Toolchain-specific settings.
if(MSVC)
# This also includes clang-cl.
include(Toolchain-msvc)
@ -29,7 +46,28 @@ else()
message(FATAL_ERROR "Unsupported compiler")
endif()
# Assembler flags
# Assembler flags.
if(ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS)
if(MSVC)
if(NOT EXISTS ${CMAKE_BINARY_DIR}/nuget.exe)
file(DOWNLOAD "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" ${CMAKE_BINARY_DIR}/nuget.exe)
endif()
execute_process(
COMMAND nuget.exe install nasm2 -OutputDirectory ${CMAKE_BINARY_DIR}/nuget
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
file(GLOB pkg ${CMAKE_BINARY_DIR}/nuget/nasm2*)
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools)
endif()
enable_language(ASM_NASM)
set(ASM_ENABLED ON)
endif()
if(ASM_ENABLED)
string(REGEX REPLACE "<FLAGS>" "-I${CMAKE_SOURCE_DIR}/src/filters/hq/asm/ -O1 -w-orphan-labels" CMAKE_ASM_NASM_COMPILE_OBJECT ${CMAKE_ASM_NASM_COMPILE_OBJECT})
endif()

View File

@ -42,5 +42,3 @@ ADD_LIBRARY(
STATIC
${SRC_FEX}
)
add_dependencies(fex generate)

View File

@ -3,42 +3,33 @@ include(VbamFunctions)
set(VBAM_LIBS ${VBAMCORE_LIBS})
if(WIN32)
# not yet implemented
option(ENABLE_DIRECT3D "Enable Direct3D rendering for the wxWidgets port" OFF)
option(ENABLE_XAUDIO2 "Enable xaudio2 sound output for the wxWidgets port" ON)
endif()
option(ENABLE_FAUDIO "Enable FAudio sound output for the wxWidgets port" OFF)
find_package(OpenAL REQUIRED)
include_directories(${OPENAL_INCLUDE_DIR})
if(OPENAL_STATIC OR (WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe)))
add_definitions(-DAL_LIBTYPE_STATIC)
add_compile_definitions(AL_LIBTYPE_STATIC)
endif()
list(APPEND VBAM_LIBS ${OPENAL_LIBRARY})
if(APPLE)
add_definitions(-DwxMAC_USE_CORE_GRAPHICS)
add_compile_definitions(wxMAC_USE_CORE_GRAPHICS)
endif()
if(NOT ENABLE_XAUDIO2)
add_definitions(-DNO_XAUDIO2)
add_compile_definitions(NO_XAUDIO2)
endif()
if(NOT ENABLE_DIRECT3D)
add_definitions(-DNO_D3D)
add_compile_definitions(NO_D3D)
endif()
if(ENABLE_FAUDIO)
find_package(FAudio REQUIRED)
list(APPEND VBAM_LIBS FAudio::FAudio)
else()
add_definitions(-DNO_FAUDIO)
add_compile_definitions(NO_FAUDIO)
endif()
# on unix we have to check for X11 before we overwrite all the compile/link
@ -49,10 +40,10 @@ if(NOT WIN32 AND NOT APPLE)
if(X11_X11_LIB)
include_directories(${X11_INCLUDE_DIR})
list(APPEND VBAM_LIBS ${X11_X11_LIB})
add_definitions(-DHAVE_X11)
add_compile_definitions(HAVE_X11)
if(X11_Xscreensaver_LIB)
list(APPEND VBAM_LIBS ${X11_Xscreensaver_LIB})
add_definitions(-DHAVE_XSS)
add_compile_definitions(HAVE_XSS)
endif()
endif()
@ -60,7 +51,7 @@ if(NOT WIN32 AND NOT APPLE)
if(EGL_LIBRARY)
list(APPEND VBAM_LIBS ${EGL_LIBRARY})
add_definitions(-DHAVE_EGL)
add_compile_definitions(HAVE_EGL)
endif()
find_library(WAYLAND_LIBRARY wayland-client)
@ -72,7 +63,7 @@ endif()
# Win32 definitions common to all toolchains.
if (WIN32)
add_definitions(-D_UNICODE -DUNICODE -DwxUSE_GUI=1 -D__WXMSW__ -DWINVER=0x0A00 -DNTDDI_VERSION=0x0A000007)
add_compile_definitions(_UNICODE UNICODE wxUSE_GUI=1 __WXMSW__ WINVER=0x0A00 NTDDI_VERSION=0x0A000007)
endif()
find_program(ZIP_PROGRAM zip)
@ -94,7 +85,7 @@ if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
set(path_prefix debug)
set(build_suffix -dbg)
add_definitions(-D_DEBUG)
add_compile_definitions(_DEBUG)
endif()
set(build_suffix_rel -rel)
@ -108,7 +99,7 @@ if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
set(build_suffix -static${build_suffix})
else()
add_definitions(-DWXUSINGDLL)
add_compile_definitions(WXUSINGDLL)
endif()
set(common_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix})
@ -195,11 +186,6 @@ else()
set(wxWidgets_USE_DEBUG ON) # noop if wx is compiled with --disable-debug, like in Mac Homebrew atm
endif()
# on e.g. msys2 add a couple of libraries wx needs
#if(WIN32 AND (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang))
# set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -luuid -lwinspool")
#endif()
set(wxWidgets_USE_UNICODE ON)
# Check for gtk4 then gtk3 packages first, some dists like arch rename the
@ -240,15 +226,15 @@ else()
execute_process(COMMAND "${wxWidgets_CONFIG_EXECUTABLE} --debug=yes" RESULT_VARIABLE WX_CONFIG_DEBUG OUTPUT_QUIET ERROR_QUIET)
if(WX_CONFIG_DEBUG EQUAL 0)
add_definitions(-DwxDEBUG_LEVEL=1)
add_compile_definitions(wxDEBUG_LEVEL=1)
endif()
# this one should be safe in non-debug builds too
add_definitions(-DWXDEBUG)
add_compile_definitions(WXDEBUG)
endif()
foreach(DEF ${wxWidgets_DEFINITIONS})
add_definitions("-D${DEF}")
add_compile_definitions("${DEF}")
endforeach()
foreach(CXX_COMPILE_FLAG ${wxWidgets_CXX_FLAGS})
@ -458,7 +444,7 @@ int main(int argc, char** argv) {
endif()
if(NOT WX_HAS_OPENGL)
add_definitions(-DNO_OGL)
add_compile_definitions(NO_OGL)
endif()
# end of wx compile checks
@ -1061,8 +1047,6 @@ if(NOT TRANSLATIONS_ONLY)
endif()
endif()
option(TRANSLATIONS_ONLY "Build only the translations.zip" OFF)
# Make the translations.zip
if(ENABLE_NLS)
add_custom_command(
@ -1122,8 +1106,6 @@ if(NOT TRANSLATIONS_ONLY)
)
endif()
option(ZIP_SUFFIX [=[suffix for release zip files, e.g. "-somebranch".zip]=] OFF)
if(NOT ZIP_SUFFIX)
set(ZIP_SUFFIX "")
endif()
@ -1334,7 +1316,6 @@ if(NOT TRANSLATIONS_ONLY)
TARGET visualboyadvance-m
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove ${appzip}.asc
# COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/interactive-pause.cmake
COMMAND ${GPG_PROGRAM} --detach-sign -a ${appzip}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
@ -1364,5 +1345,3 @@ if(NOT TRANSLATIONS_ONLY)
add_subdirectory(tests)
endif()
endif()
# vim:sw=4 et tw=0:

View File

@ -58,11 +58,7 @@ bool GetXA2Devices(wxArrayString& names, wxArrayString& ids)
{
HRESULT hr;
IXAudio2* xa = NULL;
UINT32 flags = 0;
#ifdef _DEBUG
flags = XAUDIO2_DEBUG_ENGINE;
#endif
hr = XAudio2Create(&xa, flags);
hr = XAudio2Create(&xa, 0);
if (hr != S_OK) {
wxLogError(_("The XAudio2 interface failed to initialize!"));
@ -342,11 +338,7 @@ bool XAudio2_Output::init(long sampleRate)
HRESULT hr;
// Initialize XAudio2
UINT32 flags = 0;
//#ifdef _DEBUG
// flags = XAUDIO2_DEBUG_ENGINE;
//#endif
hr = XAudio2Create(&xaud, flags);
hr = XAudio2Create(&xaud, 0);
if (hr != S_OK) {
wxLogError(_("The XAudio2 interface failed to initialize!"));