build: make some minor CMake improvements

Default `ENABLE_SDL3` to whether `find_package(SDL3)` can find it.

Only add libsamplerate for SDL2 with vcpkg.

Install gettext tools on Windows if they are not available, not just
under MSVC. This makes the `x86-mingw-static` triplet work as well.

Fix syntax error.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2025-05-20 01:36:14 +00:00
parent c9ca85b839
commit 5b9a26ba6c
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
4 changed files with 15 additions and 7 deletions

View File

@ -26,9 +26,9 @@ else()
find_package(SDL2 REQUIRED)
endif()
# Add libsamplerate to SDL3 with vcpkg
# Add libsamplerate to SDL2 with vcpkg
unset(SDL_LIBRARY_TEMP)
if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
if((NOT ENABLE_SDL3) AND CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
if(WIN32)
unset(arch_suffix)
unset(path_prefix)
@ -40,7 +40,7 @@ if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
endif()
set(installed_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}/${path_prefix})
SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} ${installed_prefix}/lib/samplerate.lib)
SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} "${installed_prefix}/lib/samplerate${CMAKE_STATIC_LIBRARY_SUFFIX}")
else()
SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} -lsamplerate)
endif()

View File

@ -14,7 +14,10 @@ if(WIN32 OR APPLE)
set(ENABLE_SDL_DEFAULT OFF)
endif()
option(ENABLE_SDL3 "Use SDL3" ON)
find_package(SDL3 QUIET)
option(ENABLE_SDL3 "Use SDL3" "${SDL3_FOUND}")
option(ENABLE_GENERIC_FILE_DIALOGS "Use generic file dialogs" OFF)
option(DISABLE_OPENGL "Disable OpenGL" OFF)
option(ENABLE_SDL "Build the SDL port" ${ENABLE_SDL_DEFAULT})

View File

@ -1 +0,0 @@
/Users/andyvand/vbam-build-mac-ARM64/root/lib/cmake/SDL3

View File

@ -89,7 +89,10 @@ if(NOT ZIP_PROGRAM)
endif()
endif()
if(MSVC)
find_program(XGETTEXT xgettext)
find_program(MSGINIT msginit)
if(CMAKE_HOST_WIN32 AND (NOT XGETTEXT OR NOT MSGINIT))
# Install gettext tools from nuget.
# First fetch the nuget binary.
@ -117,6 +120,9 @@ if(MSVC)
list(APPEND CMAKE_PROGRAM_PATH ${pkg}/tools/bin)
endif()
unset(XGETTEXT)
unset(MSGINIT)
find_package(Gettext REQUIRED)
find_program(XGETTEXT xgettext)
find_program(MSGINIT msginit)
@ -386,7 +392,7 @@ if(APPLE)
)
endif()
endif()
/
target_sources(visualboyadvance-m PRIVATE ${VBAM_WX_COMMON} ${VBAM_ICON_PATH})
if(ENABLE_SDL3)