Add initial Windows build support (#703)

This commit is contained in:
Luke Taylor | 卢熙诚 2025-10-01 19:09:03 +01:00 committed by GitHub
parent cfe77e0467
commit 58428f9a15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 547 additions and 131 deletions

View File

@ -9,6 +9,12 @@ on:
env:
BUILD_TESTS: ON
CMAKE_PRESET: release-vcpkg
VCPKG_DISABLE_METRICS: true
QT_VERSION: '6.8.3'
permissions:
contents: write # needed for vcpkg cache
jobs:
archlinux:
@ -208,6 +214,83 @@ jobs:
name: freebsd-14.2
path: pkg
windows:
name: Windows
runs-on: windows-latest
strategy:
matrix:
include:
- arch: amd64
qt-arch: win64_msvc2022_64
msvc-arch: amd64
triplet: x64-windows
cmake-preset: release-vcpkg
# - arch: arm64
# qt-arch: win64_msvc2022_arm64_cross_compiled
# msvc-arch: amd64_arm64
# triplet: arm64-windows
# cmake-preset: release-vcpkg-arm64
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
submodules: recursive
- name: Install CMake
uses: lukka/get-cmake@latest
- name: Install dependencies
run: choco install ninja nsis -y
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: ${{ env.QT_VERSION }}
archives: qtbase qtsvg qttools
cache: true
arch: ${{ matrix.qt-arch }}
install-deps: 'true'
- name: Setup MSVC Environment
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.msvc-arch }}
- name: Setup vcpkg cache
shell: pwsh
run: |
$cacheDir = "${{ github.workspace }}/vcpkg-binary-cache"
New-Item -ItemType Directory -Force -Path $cacheDir
echo "VCPKG_BINARY_SOURCES=clear;files,$cacheDir,readwrite" >> $env:GITHUB_ENV
echo "VCPKG_TARGET_TRIPLET=${{ matrix.triplet }}" >> $env:GITHUB_ENV
- name: Cache vcpkg
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/vcpkg-binary-cache
build-${{ matrix.cmake-preset }}_installed
key: ${{ runner.os }}-vcpkg-${{ matrix.cmake-preset }}-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}
restore-keys: |
${{ runner.os }}-vcpkg-${{ matrix.cmake-preset }}-
${{ runner.os }}-vcpkg-
- name: Set CMAKE_PRESET
shell: pwsh
run: echo "CMAKE_PRESET=${{ matrix.cmake-preset }}" >> $env:GITHUB_ENV
- name: Build & Package
run: .\ci\windows-build.ps1
shell: pwsh
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: "windows-${{ matrix.arch }}"
path: artifacts
attach:
name: Attach to release
if: github.event_name == 'release' && github.event.action == 'published'
@ -217,6 +300,7 @@ jobs:
- debian
- ubuntu
- freebsd
- windows
steps:
- name: Checkout
uses: actions/checkout@v4

4
.gitignore vendored
View File

@ -39,6 +39,7 @@ debug_toolchain.cmake
# generated files
CMakeLists.txt.user*
CMakeUserPresets.json
compile_commands.json
fooyin_version.h
packagetar.sh
@ -67,3 +68,6 @@ Debug/
release/
Release/
tmp/
/.vs
/vcpkg_installed
/out/

View File

@ -15,6 +15,7 @@ FetchContent_Declare(
kdsingleapplication
GIT_REPOSITORY https://www.github.com/KDAB/KDSingleApplication.git
GIT_TAG v1.2.0
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(kdsingleapplication)

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.18)
cmake_minimum_required(VERSION 3.19)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
@ -62,33 +62,35 @@ fooyin_option(BUILD_ASAN "Enable AddressSanitizer" OFF)
fooyin_option(INSTALL_FHS "Install in Linux distros /usr hierarchy" ON)
fooyin_option(INSTALL_HEADERS "Install public development headers" OFF)
list(
APPEND
FOOYIN_COMPILE_OPTIONS
-Wall
-Wextra
-Wpedantic
-Wunused
-Wshadow
-Wundef
-Wuninitialized
-Wredundant-decls
-Wcast-align
-Winit-self
-Wmissing-include-dirs
-Wstrict-overflow=2
-Wunused-parameter
-Wdisabled-optimization
-Woverloaded-virtual
-Wold-style-cast
-Wno-array-bounds
)
if(BUILD_WERROR)
list(APPEND FOOYIN_COMPILE_OPTIONS -Werror)
endif()
if(BUILD_ASAN)
list(APPEND FOOYIN_COMPILE_OPTIONS -fsanitize=address,undefined)
list(APPEND FOOYIN_LINK_OPTIONS -fsanitize=address,undefined)
if(UNIX)
list(
APPEND
FOOYIN_COMPILE_OPTIONS
-Wall
-Wextra
-Wpedantic
-Wunused
-Wshadow
-Wundef
-Wuninitialized
-Wredundant-decls
-Wcast-align
-Winit-self
-Wmissing-include-dirs
-Wstrict-overflow=2
-Wunused-parameter
-Wdisabled-optimization
-Woverloaded-virtual
-Wold-style-cast
-Wno-array-bounds
)
if(BUILD_WERROR)
list(APPEND FOOYIN_COMPILE_OPTIONS -Werror)
endif()
if(BUILD_ASAN)
list(APPEND FOOYIN_COMPILE_OPTIONS -fsanitize=address,undefined)
list(APPEND FOOYIN_LINK_OPTIONS -fsanitize=address,undefined)
endif()
endif()
list(
@ -134,6 +136,17 @@ find_package(
SWRESAMPLE
)
if(WIN32)
find_path(GETOPT_INCLUDE_DIR getopt.h)
if (NOT GETOPT_INCLUDE_DIR)
message(FATAL_ERROR "Cannot find getopt.h")
endif()
find_library(GETOPT_LIBRARY getopt)
if (NOT GETOPT_LIBRARY)
message(FATAL_ERROR "Cannot find getopt library")
endif()
endif()
include(3rdparty/3rdparty.cmake)
if(BUILD_CCACHE)
@ -180,6 +193,7 @@ file(RELATIVE_PATH FOOYIN_RELATIVE_PLUGIN_PATH "/${BIN_INSTALL_DIR}" "/${FOOYIN_
if(NOT FOOYIN_OUTPUT_PREFIX)
set(FOOYIN_OUTPUT_PREFIX "${PROJECT_BINARY_DIR}/run")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${FOOYIN_OUTPUT_PREFIX}/${BIN_INSTALL_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${FOOYIN_OUTPUT_PREFIX}/${LIB_INSTALL_DIR}")
set(FOOYIN_PLUGIN_OUTPUT_DIRECTORY "${FOOYIN_OUTPUT_PREFIX}/${FOOYIN_PLUGIN_INSTALL_DIR}")
@ -353,7 +367,7 @@ set(SOURCES ${SOURCES} src/app/main.cpp src/app/commandline.cpp)
qt_add_resources(SOURCES data/data.qrc)
qt_add_resources(SOURCES data/icons.qrc)
add_executable(fooyin ${SOURCES} ${TRANSLATIONS})
add_executable(fooyin WIN32 ${SOURCES} ${TRANSLATIONS})
fooyin_set_rpath(fooyin ${BIN_INSTALL_DIR})
target_compile_features(fooyin PUBLIC ${FOOYIN_REQUIRED_CXX_FEATURES})
target_compile_definitions(fooyin PRIVATE ${FOOYIN_COMPILE_DEFINITIONS})
@ -368,12 +382,34 @@ target_link_libraries(
Fooyin::CorePrivate
)
if(WIN32)
target_include_directories(fooyin PRIVATE ${GETOPT_INCLUDE_DIR})
target_link_libraries(fooyin PRIVATE ${GETOPT_LIBRARY})
endif()
# ---- Fooyin install ----
if(NOT CMAKE_SKIP_INSTALL_RULES)
include(FooyinInstall)
endif()
if(WIN32)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/DeployQt.cmake")
windeployqt(fooyin)
if(qm_files)
add_custom_command(
TARGET fooyin POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
"$<TARGET_FILE_DIR:fooyin>/translations"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${qm_files}
"$<TARGET_FILE_DIR:fooyin>/translations"
COMMENT "Copying fooyin translation files ..."
)
endif()
endif()
# ---- Fooyin uninstall ----
configure_file(

View File

@ -2,32 +2,48 @@
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 16,
"minor": 18,
"patch": 0
},
"configurePresets": [
{
"name": "base",
"displayName": "base preset",
"displayName": "Base preset",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build-${presetName}",
"hidden": true
},
{
"name": "dev",
"displayName": "Build as debug",
"name": "vcpkg-base",
"displayName": "Base vcpkg preset",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
},
"X_VCPKG_APPLOCAL_DEPS_INSTALL": "ON",
"VCPKG_INSTALL_OPTIONS": "--x-abi-tools-use-exact-versions",
"QT_DIR": "$env{QT_ROOT_DIR}/lib/cmake/Qt6",
"Qt6_DIR": "$env{QT_ROOT_DIR}/lib/cmake/Qt6",
"INSTALL_FHS": "OFF",
"BUILD_TESTING": false
},
"inherits": [ "base" ]
},
{
"name": "debug",
"displayName": "Debug build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"BUILD_TESTING": "ON"
},
"inherits": [
"base"
]
"inherits": [ "base" ]
},
{
"name": "dev-clang",
"displayName": "dev-clang",
"name": "debug-clang",
"displayName": "Debug build (Clang)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
@ -37,46 +53,101 @@
"CXX": "clang++",
"CCACHE_DISABLE": "ON"
},
"inherits": [
"base"
]
"inherits": [ "base" ]
},
{
"name": "debug-vcpkg",
"displayName": "Debug build via vcpkg (x64)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"VCPKG_TARGET_TRIPLET": "x64-windows"
},
"inherits": [ "vcpkg-base" ]
},
{
"name": "debug-vcpkg-arm64",
"displayName": "Debug build via vcpkg (ARM64)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"VCPKG_TARGET_TRIPLET": "arm64-windows"
},
"inherits": [ "vcpkg-base" ]
},
{
"name": "release",
"displayName": "Build as release",
"displayName": "Release build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
},
"inherits": [
"base"
]
"inherits": [ "base" ]
},
{
"name": "release-vcpkg",
"displayName": "Release build via vcpkg (x64)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"VCPKG_TARGET_TRIPLET": "x64-windows"
},
"inherits": [ "vcpkg-base" ]
},
{
"name": "release-vcpkg-arm64",
"displayName": "Release build via vcpkg (ARM64)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"VCPKG_TARGET_TRIPLET": "arm64-windows"
},
"inherits": [ "vcpkg-base" ]
},
{
"name": "profile",
"displayName": "profile",
"displayName": "Profile build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
},
"inherits": [
"base"
]
"inherits": [ "base" ]
}
],
"buildPresets": [
{
"name": "dev",
"configurePreset": "dev",
"targets": [
"all"
]
"name": "debug",
"configurePreset": "debug",
"targets": [ "all" ]
},
{
"name": "dev-clang",
"configurePreset": "dev-clang"
"name": "debug-clang",
"configurePreset": "debug-clang",
"targets": [ "all" ]
},
{
"name": "debug-vcpkg",
"configurePreset": "debug-vcpkg",
"targets": [ "all" ]
},
{
"name": "debug-vcpkg-arm64",
"configurePreset": "debug-vcpkg-arm64",
"targets": [ "all" ]
},
{
"name": "release",
"configurePreset": "release"
"configurePreset": "release",
"targets": [ "all" ]
},
{
"name": "release-vcpkg",
"configurePreset": "release-vcpkg",
"targets": [ "all" ]
},
{
"name": "release-vcpkg-arm64",
"configurePreset": "release-vcpkg-arm64",
"targets": [ "all" ]
},
{
"name": "profile",
"configurePreset": "profile",
"targets": [ "all" ]
}
]
}

39
ci/windows-build.ps1 Normal file
View File

@ -0,0 +1,39 @@
$ErrorActionPreference = "Stop"
$CMAKE_PRESET = $env:CMAKE_PRESET
$BUILD_DIR = "build-$CMAKE_PRESET"
$ARTIFACTS_DIR = Join-Path $env:GITHUB_WORKSPACE "artifacts"
if (-not (Test-Path $ARTIFACTS_DIR)) {
Write-Host "Creating artifacts directory: $ARTIFACTS_DIR"
New-Item -ItemType Directory -Path $ARTIFACTS_DIR | Out-Null
}
Write-Host "Configuring CMake with preset $CMAKE_PRESET..."
& cmake --preset $CMAKE_PRESET -DBUILD_TESTING=OFF
if ($LASTEXITCODE -ne 0) {
Write-Error "CMake configuration failed with exit code $LASTEXITCODE."
exit $LASTEXITCODE
}
Write-Host "Building project in $BUILD_DIR..."
& cmake --build $BUILD_DIR --config Release
if ($LASTEXITCODE -ne 0) {
Write-Error "CMake build failed with exit code $LASTEXITCODE."
exit $LASTEXITCODE
}
Write-Host "Packaging project..."
& cmake --build $BUILD_DIR --target package --config Release
if ($LASTEXITCODE -ne 0) {
Write-Error "CMake packaging failed with exit code $LASTEXITCODE."
exit $LASTEXITCODE
}
Write-Host "Moving packages to $ARTIFACTS_DIR..."
$packageTypes = "*.zip", "*.exe"
foreach ($type in $packageTypes) {
Get-ChildItem -Path $BUILD_DIR -Filter $type -File | Move-Item -Destination $ARTIFACTS_DIR -Force
}
Write-Host "All packages have been moved to $ARTIFACTS_DIR"

43
cmake/DeployQt.cmake Normal file
View File

@ -0,0 +1,43 @@
function(windeployqt target)
set(qt_bin_dir "$ENV{QT_ROOT_DIR}/bin")
find_program(WINDEPLOYQT_RELEASE windeployqt HINTS "${qt_bin_dir}")
find_program(WINDEPLOYQT_DEBUG windeployqt.debug.bat HINTS "${qt_bin_dir}")
if(NOT WINDEPLOYQT_RELEASE)
message(FATAL_ERROR "windeployqt not found in ${qt_bin_dir}")
endif()
if(NOT WINDEPLOYQT_DEBUG)
set(WINDEPLOYQT_DEBUG ${WINDEPLOYQT_RELEASE})
endif()
add_custom_command(TARGET ${target} POST_BUILD
COMMAND $<IF:$<CONFIG:Debug>,${WINDEPLOYQT_DEBUG},${WINDEPLOYQT_RELEASE}>
--verbose 1
$<IF:$<CONFIG:Debug>,--debug,--release>
--concurrent
--include-plugins qsqlite
--dir "$<TARGET_FILE_DIR:${target}>"
$<TARGET_FILE:${target}>
COMMENT "Deploying Qt libraries for '${target}' ($<CONFIG>)..."
)
install(CODE "
execute_process(
COMMAND \"${WINDEPLOYQT_RELEASE}\"
--release
--verbose 1
--concurrent
--include-plugins qsqlite
--dir \"\${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR}\"
\"\${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR}/${target}.exe\"
)
"
COMPONENT fooyin
)
install(DIRECTORY "$<TARGET_FILE_DIR:fooyin>/"
DESTINATION ${BIN_INSTALL_DIR}
FILES_MATCHING PATTERN "*.dll"
)
endfunction()

View File

@ -3,57 +3,59 @@
set(README_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
install(
FILES ${LICENSE_FILE}
DESTINATION ${DOC_INSTALL_DIR}
RENAME LICENSE
COMPONENT fooyin
)
install(
FILES ${README_FILE}
DESTINATION ${DOC_INSTALL_DIR}
RENAME README
COMPONENT fooyin
)
install(FILES "${CMAKE_BINARY_DIR}/dist/linux/org.fooyin.fooyin.desktop"
DESTINATION ${XDG_APPS_INSTALL_DIR}
COMPONENT fooyin
)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/dist/linux/org.fooyin.fooyin.metainfo.xml"
DESTINATION ${APPDATA_INSTALL_DIR}
COMPONENT fooyin
)
set(ICON_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/data/icons)
set(ICON_SIZE
16
22
32
48
64
128
256
512
)
foreach(SIZE ${ICON_SIZE})
if(UNIX)
install(
FILES ${ICON_SRC_PATH}/${SIZE}-fooyin.png
DESTINATION ${ICON_INSTALL_DIR}/hicolor/${SIZE}x${SIZE}/apps
RENAME org.fooyin.fooyin.png
FILES ${LICENSE_FILE}
DESTINATION ${DOC_INSTALL_DIR}
RENAME LICENSE
COMPONENT fooyin
)
endforeach(SIZE)
install(
FILES ${ICON_SRC_PATH}/sc-fooyin.svg
DESTINATION ${ICON_INSTALL_DIR}/hicolor/scalable/apps
RENAME org.fooyin.fooyin.svg
COMPONENT fooyin
)
install(
FILES ${README_FILE}
DESTINATION ${DOC_INSTALL_DIR}
RENAME README
COMPONENT fooyin
)
install(FILES ${TRANSLATIONS} DESTINATION ${TRANSLATION_INSTALL_DIR})
install(FILES "${CMAKE_BINARY_DIR}/dist/linux/org.fooyin.fooyin.desktop"
DESTINATION ${XDG_APPS_INSTALL_DIR}
COMPONENT fooyin
)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/dist/linux/org.fooyin.fooyin.metainfo.xml"
DESTINATION ${APPDATA_INSTALL_DIR}
COMPONENT fooyin
)
set(ICON_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/data/icons)
set(ICON_SIZE
16
22
32
48
64
128
256
512
)
foreach(SIZE ${ICON_SIZE})
install(
FILES ${ICON_SRC_PATH}/${SIZE}-fooyin.png
DESTINATION ${ICON_INSTALL_DIR}/hicolor/${SIZE}x${SIZE}/apps
RENAME org.fooyin.fooyin.png
COMPONENT fooyin
)
endforeach(SIZE)
install(
FILES ${ICON_SRC_PATH}/sc-fooyin.svg
DESTINATION ${ICON_INSTALL_DIR}/hicolor/scalable/apps
RENAME org.fooyin.fooyin.svg
COMPONENT fooyin
)
install(FILES ${TRANSLATIONS} DESTINATION ${TRANSLATION_INSTALL_DIR})
endif()
# ---- Fooyin executable ----

View File

@ -11,7 +11,7 @@ endfunction()
function(create_fooyin_plugin plugin_name)
cmake_parse_arguments(
LIB
""
"NO_INSTALL"
"JSON_IN"
"DEPENDS;SOURCES"
${ARGN}
@ -62,7 +62,11 @@ function(create_fooyin_plugin plugin_name)
target_compile_definitions(${plugin_name} PRIVATE QT_USE_QSTRINGBUILDER)
if(NOT CMAKE_SKIP_INSTALL_RULES)
install(TARGETS ${plugin_name} DESTINATION ${FOOYIN_PLUGIN_INSTALL_DIR})
if(NOT CMAKE_SKIP_INSTALL_RULES AND NOT LIB_NO_INSTALL)
install(
TARGETS ${plugin_name}
RUNTIME DESTINATION ${FOOYIN_PLUGIN_INSTALL_DIR}
LIBRARY DESTINATION ${FOOYIN_PLUGIN_INSTALL_DIR}
)
endif()
endfunction()

View File

@ -123,9 +123,9 @@ function(create_fooyin_library name)
install(
TARGETS ${name}
EXPORT FooyinTargets
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
COMPONENT fooyin
NAMELINK_SKIP
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT fooyin
LIBRARY DESTINATION ${LIB_INSTALL_DIR} COMPONENT fooyin NAMELINK_SKIP
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} COMPONENT fooyin_development
)
if(INSTALL_HEADERS)
@ -142,17 +142,24 @@ function(create_fooyin_library name)
endfunction()
function(create_fooyin_plugin_internal plugin_name)
create_fooyin_plugin(${ARGV})
create_fooyin_plugin(${ARGV} NO_INSTALL)
set_target_properties(
${plugin_name}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${FOOYIN_PLUGIN_OUTPUT_DIRECTORY}"
LIBRARY_OUTPUT_DIRECTORY "${FOOYIN_PLUGIN_OUTPUT_DIRECTORY}"
ARCHIVE_OUTPUT_DIRECTORY "${FOOYIN_PLUGIN_OUTPUT_DIRECTORY}"
)
target_compile_features(${plugin_name} PUBLIC ${FOOYIN_REQUIRED_CXX_FEATURES})
target_compile_definitions(${plugin_name} PRIVATE ${FOOYIN_COMPILE_DEFINITIONS})
target_compile_options(${plugin_name} PRIVATE ${FOOYIN_COMPILE_OPTIONS})
target_link_options(${plugin_name} INTERFACE ${FOOYIN_LINK_OPTIONS})
if(NOT CMAKE_SKIP_INSTALL_RULES)
install(
TARGETS ${plugin_name}
RUNTIME DESTINATION ${FOOYIN_PLUGIN_INSTALL_DIR} COMPONENT fooyin
LIBRARY DESTINATION ${FOOYIN_PLUGIN_INSTALL_DIR} COMPONENT fooyin
)
endif()
endfunction()

View File

@ -1,11 +1,10 @@
set(CPACK_PACKAGE_NAME "fooyin")
set(CPACK_PACKAGE_VENDOR "fooyin")
set(CPACK_PACKAGE_CONTACT "Luke Taylor <luket1@proton.me>")
set(CPACK_PACKAGE_CONTACT "Luke Taylor <luket@pm.me>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A customisable music player")
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_VERBATIM_VARIABLES ON)
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_NAME})
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/data/icons/sc-fooyin.svg")
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_NAME})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_VERSION_MAJOR "${FOOYIN_VERSION_MAJOR}")
@ -15,13 +14,29 @@ set(CPACK_PACKAGE_VERSION "${FOOYIN_VERSION}")
set(CPACK_PACKAGE_RELOCATABLE ON CACHE BOOL "Build relocatable package")
set(CPACK_PACKAGE_RELEASE 1)
if(WIN32)
set(CPACK_GENERATOR "NSIS" "ZIP")
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/data/icons\\\\fooyin.ico")
set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/data/icons\\\\fooyin.ico")
set(CPACK_NSIS_URL_INFO_ABOUT "https://www.fooyin.org/")
set(CPACK_NSIS_INSTALLED_ICON_NAME "${CPACK_PACKAGE_NAME}{CMAKE_EXECUTABLE_SUFFIX}")
set(CPACK_NSIS_MENU_LINKS "${LICENSE_FILE}" "License" "${README_FILE}" "Readme")
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "${CPACK_PACKAGE_NAME}.exe")
set(CPACK_COMPONENTS_ALL fooyin)
set(CPACK_NSIS_EXECUTABLES_DIRECTORY "${BIN_INSTALL_DIR}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "fooyin")
else()
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/data/icons/sc-fooyin.svg")
endif()
set(CPACK_SOURCE_IGNORE_FILES "\\\\.#;/#;.*~;\\\\.o$")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.git/")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.github/")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/build/")
list(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_BINARY_DIR}/")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Luke Taylor <luket1@proton.me>")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Luke Taylor <luket@pm.me>")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PROJECT_URL})
set(CPACK_DEBIAN_PACKAGE_SECTION "sound")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")

BIN
data/icons/fooyin.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

View File

@ -30,21 +30,59 @@
using namespace Qt::StringLiterals;
namespace {
#ifdef Q_OS_WIN
QString decodeName(wchar_t* opt)
{
return QString::fromWCharArray(opt);
}
#else
QString decodeName(char* opt)
{
return QFile::decodeName(opt);
}
#endif
} // namespace
CommandLine::CommandLine(int argc, char** argv)
: m_argc{argc}
#ifdef Q_OS_WIN
, m_argv{CommandLineToArgvW(GetCommandLineW(), &argc)}
#else
, m_argv{argv}
#endif
, m_skipSingle{false}
, m_playerAction{PlayerAction::None}
{ }
bool CommandLine::parse()
{
static constexpr option cmdOptions[]
= {{"help", no_argument, nullptr, 'h'}, {"version", no_argument, nullptr, 'v'},
{"skip-single", no_argument, nullptr, 'x'}, {"play-pause", no_argument, nullptr, 't'},
{"play", no_argument, nullptr, 'p'}, {"pause", no_argument, nullptr, 'u'},
{"stop", no_argument, nullptr, 's'}, {"next", no_argument, nullptr, 'f'},
{"previous", no_argument, nullptr, 'r'}, {nullptr, 0, nullptr, 0}};
static constexpr option cmdOptions[] = {
#ifdef Q_OS_WIN
{L"help", no_argument, nullptr, 'h'},
{L"version", no_argument, nullptr, 'v'},
{L"skip-single", no_argument, nullptr, 'x'},
{L"play-pause", no_argument, nullptr, 't'},
{L"play", no_argument, nullptr, 'p'},
{L"pause", no_argument, nullptr, 'u'},
{L"stop", no_argument, nullptr, 's'},
{L"next", no_argument, nullptr, 'f'},
{L"previous", no_argument, nullptr, 'r'},
{nullptr, 0, nullptr, 0
#else
{"help", no_argument, nullptr, 'h'},
{"version", no_argument, nullptr, 'v'},
{"skip-single", no_argument, nullptr, 'x'},
{"play-pause", no_argument, nullptr, 't'},
{"play", no_argument, nullptr, 'p'},
{"pause", no_argument, nullptr, 'u'},
{"stop", no_argument, nullptr, 's'},
{"next", no_argument, nullptr, 'f'},
{"previous", no_argument, nullptr, 'r'},
{nullptr, 0, nullptr, 0
#endif
}
};
static const auto help = u"%1: fooyin [%2] [%3]\n"
"\n"
@ -64,7 +102,11 @@ bool CommandLine::parse()
" urls %15\n"_s;
for(;;) {
#ifdef Q_OS_WIN
const int c = getopt_long(m_argc, m_argv, L"hvxtpusfr", cmdOptions, nullptr);
#else
const int c = getopt_long(m_argc, m_argv, "hvxtpusfr", cmdOptions, nullptr);
#endif
if(c == -1) {
break;
}
@ -112,7 +154,8 @@ bool CommandLine::parse()
}
for(int i{optind}; i < m_argc; ++i) {
const QFileInfo fileinfo{QFile::decodeName(m_argv[i])};
const QString file = decodeName(m_argv[i]);
QFileInfo fileinfo{file};
if(fileinfo.exists()) {
m_files.append(QUrl::fromLocalFile(fileinfo.canonicalFilePath()));
}

View File

@ -22,6 +22,10 @@
#include <QList>
#include <QUrl>
#ifdef Q_OS_WIN
#include <windows.h>
#endif
class CommandLine
{
public:
@ -50,7 +54,11 @@ public:
private:
int m_argc;
#ifdef Q_OS_WIN32
LPWSTR* m_argv;
#else
char** m_argv;
#endif
QList<QUrl> m_files;
bool m_skipSingle;
PlayerAction m_playerAction;

View File

@ -34,6 +34,18 @@
using namespace Qt::StringLiterals;
namespace {
#ifdef Q_OS_WIN
#include <windows.h>
void configurePluginSearchPaths()
{
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
const QDir appPath{QCoreApplication::applicationDirPath()};
const QString pluginDir = appPath.absolutePath() + u"/plugins"_s;
AddDllDirectory(reinterpret_cast<LPCWSTR>(pluginDir.utf16()));
}
#endif
void parseCmdOptions(Fooyin::Application& app, Fooyin::GuiApplication& guiApp, CommandLine& cmdLine)
{
const auto playerAction = cmdLine.playerAction();
@ -80,6 +92,10 @@ int main(int argc, char** argv)
QGuiApplication::setDesktopFileName(u"org.fooyin.fooyin"_s);
QGuiApplication::setQuitOnLastWindowClosed(false);
#ifdef Q_OS_WIN
configurePluginSearchPaths();
#endif
CommandLine commandLine{argc, argv};
auto checkInstance = [&commandLine](KDSingleApplication& instance) {

View File

@ -145,7 +145,9 @@ create_fooyin_library(
target_link_libraries(
fooyin_core
PRIVATE fooyin_version fooyin_config
PRIVATE fooyin_version
fooyin_config
${FFMPEG_LIBRARIES}
PUBLIC Qt6::Core
Qt6::Widgets
Qt6::Sql
@ -153,9 +155,9 @@ target_link_libraries(
Qt6::Network
Taglib::Taglib
Fooyin::Utils
${FFMPEG_LIBRARIES}
)
target_include_directories(
fooyin_core PRIVATE ${FFMPEG_INCLUDE_DIRS}
fooyin_core
PRIVATE ${FFMPEG_INCLUDE_DIRS}
)

View File

@ -32,6 +32,13 @@
#include <QFile>
#include <QIODevice>
#if defined(Q_OS_WINDOWS)
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#endif
#if defined(__GNUG__)
#pragma GCC diagnostic ignored "-Wold-style-cast"
#elif defined(__clang__)

View File

@ -21,14 +21,14 @@
#include "fycore_export.h"
#include <core/playlist/playlistparser.h>
#include <memory>
#include <shared_mutex>
#include <QStringList>
namespace Fooyin {
class PlaylistParser;
class FYCORE_EXPORT PlaylistLoader
{
public:

View File

@ -378,6 +378,8 @@ create_fooyin_library(
target_link_libraries(
fooyin_gui
PUBLIC Fooyin::Core Fooyin::Utils
PRIVATE Fooyin::CorePrivate Qt::Svg
PUBLIC Fooyin::Core
Fooyin::Utils
PRIVATE Fooyin::CorePrivate
Qt::Svg
)

View File

@ -1,12 +1,16 @@
if(BUILD_ALSA)
add_subdirectory(alsa)
endif()
if(UNIX AND NOT APPLE)
add_subdirectory(mpris)
endif()
add_subdirectory(fileops)
add_subdirectory(filters)
add_subdirectory(gme)
add_subdirectory(libarchive)
add_subdirectory(lyrics)
add_subdirectory(mpris)
add_subdirectory(openmpt)
add_subdirectory(pipewire)
add_subdirectory(rawaudio)

View File

@ -25,6 +25,9 @@
#include <QLoggingCategory>
#include <QMimeDatabase>
#ifdef Q_OS_WIN
#define NOMINMAX
#endif
#include <archive_entry.h>
Q_LOGGING_CATEGORY(LIBARCH, "fy.libarchive")

View File

@ -79,7 +79,11 @@ SdlOutput::SdlOutput()
, m_initialised{false}
, m_device{u"default"_s}
, m_volume{1.0}
{ }
{
#ifdef Q_OS_WIN32
SDL_setenv("SDL_AUDIODRIVER", "directsound", true); // WASAPI driver (default) is broken
#endif
}
bool SdlOutput::init(const AudioFormat& format)
{

21
vcpkg.json Normal file
View File

@ -0,0 +1,21 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"builtin-baseline": "4334d8b4c8916018600212ab4dd4bbdc343065d1",
"dependencies": [
"ffmpeg",
"icu",
"taglib",
"sdl2",
"getopt",
"libopenmpt",
"libsndfile",
"libarchive",
"libgme"
],
"features": {
"fooyin-tests": {
"description": "Build tests",
"dependencies": [ "gtest" ]
}
}
}