diff --git a/.ci/compile.sh b/.ci/compile.sh index ffe733c72..01804d9ae 100755 --- a/.ci/compile.sh +++ b/.ci/compile.sh @@ -114,6 +114,11 @@ if [[ $PACKAGE_TYPE ]]; then flags+=("-DCPACK_GENERATOR=$PACKAGE_TYPE") fi +#if [[ $RUNNER_OS == Windows ]]; then +# VCPKG_TOOLCHAIN_FILE="D:/a/Cockatrice/vcpkg/scripts/buildsystems/vcpkg.cmake" +# flags+=("-DCMAKE_TOOLCHAIN_FILE=$VCPKG_TOOLCHAIN_FILE" "-DVCPKG_TARGET_TRIPLET=x64-windows") +#fi + # Add cmake --build flags buildflags=(--config "$BUILDTYPE") @@ -151,19 +156,13 @@ if [[ $USE_CCACHE ]]; then echo "::endgroup::" fi -echo "::group::Configure cmake" +echo "::group::Configure CMake" cmake --version cmake .. "${flags[@]}" echo "::endgroup::" echo "::group::Build project" -if [[ $RUNNER_OS == Windows ]]; then - # Enable MTT, see https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/ - # and https://devblogs.microsoft.com/cppblog/cpp-build-throughput-investigation-and-tune-up/#multitooltask-mtt - cmake --build . "${buildflags[@]}" -- -p:UseMultiToolTask=true -p:EnableClServerMode=true -else - cmake --build . "${buildflags[@]}" -fi +cmake --build . "${buildflags[@]}" echo "::endgroup::" if [[ $USE_CCACHE ]]; then @@ -184,6 +183,27 @@ if [[ $MAKE_INSTALL ]]; then echo "::endgroup::" fi +if [[ $RUNNER_OS == Windows ]]; then + echo "Searching for liblzma.dll after build..." + FOUND_DLL=$(find . -name "liblzma.dll" 2>/dev/null) + + if [ -n "$FOUND_DLL" ]; then + echo "liblzma.dll found at:" + echo "$FOUND_DLL" + + echo "Cleaning up duplicate debug DLLs" + rm -f ./oracle/liblzma.dll + rm -f ./vcpkg_installed/x64-windows/debug/bin/liblzma.dll + + find . -iname "liblzma.dll" + + else + echo "ERROR: liblzma.dll not found after build!" + exit 1 + fi + +fi + if [[ $MAKE_PACKAGE ]]; then echo "::group::Create package" diff --git a/.github/workflows/desktop-build.yml b/.github/workflows/desktop-build.yml index 63e45d9fe..9c7926109 100644 --- a/.github/workflows/desktop-build.yml +++ b/.github/workflows/desktop-build.yml @@ -405,20 +405,17 @@ jobs: needs: configure runs-on: windows-2022 env: - CMAKE_GENERATOR: 'Visual Studio 17 2022' + CMAKE_GENERATOR: 'Ninja' steps: - - name: Add msbuild to PATH - id: add-msbuild - uses: microsoft/setup-msbuild@v2 - with: - msbuild-architecture: x64 - - name: Checkout uses: actions/checkout@v4 with: submodules: recursive + - name: Setup MSVC + uses: ilammy/msvc-dev-cmd@v1 + - name: Install Qt ${{matrix.qt_version}} uses: jurplel/install-qt-action@v4 with: @@ -441,7 +438,6 @@ jobs: env: PACKAGE_SUFFIX: '-Win${{matrix.target}}' CMAKE_GENERATOR: '${{env.CMAKE_GENERATOR}}' - CMAKE_GENERATOR_PLATFORM: 'x64' QTDIR: '${{github.workspace}}\Qt\${{matrix.qt_version}}\win64_${{matrix.qt_arch}}' VCPKG_DISABLE_METRICS: 1 VCPKG_BINARY_SOURCES: 'clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite' diff --git a/CMakeLists.txt b/CMakeLists.txt index 29ee84798..e3f0518a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ # This file sets all the variables shared between the projects # like the installation path, compilation flags etc.. -# cmake 3.16 is required if using qt6 +# CMake 3.16 is required if using Qt6 cmake_minimum_required(VERSION 3.10) # Early detect ccache @@ -81,7 +81,7 @@ if(NOT DEFINED GIT_TAG_RELEASENAME) set(GIT_TAG_RELEASENAME "Omenpath") endif() -# Use c++20 for all targets +# Use C++20 for all targets set(CMAKE_CXX_STANDARD 20 CACHE STRING "C++ ISO Standard" @@ -183,7 +183,7 @@ elseif(CMAKE_COMPILER_IS_GNUCXX) endif() endforeach() else() - # other: osx/llvm, bsd/llvm + # Other: osx/llvm, bsd/llvm set(CMAKE_CXX_FLAGS_RELEASE "-O2") if(WARNING_AS_ERROR) set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wextra -Werror -Wno-unused-parameter") @@ -232,7 +232,7 @@ if(${Protobuf_VERSION} VERSION_LESS "3.21.0.0" AND NOT EXISTS "${Protobuf_PROTOC message(FATAL_ERROR "No protoc command found!") endif() -#Find OpenSSL +# Find OpenSSL if(WIN32) find_package(OpenSSL REQUIRED) if(OPENSSL_FOUND) @@ -245,7 +245,7 @@ if(WIN32) endif() endif() -#Find VCredist +# Find VCredist if(MSVC) find_package(VCredistRuntime) endif() @@ -273,7 +273,7 @@ if(UNIX) set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/dmgBackground.tif") set(CPACK_PRE_BUILD_SCRIPTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/SignMacApplications.cmake") else() - # linux + # Linux if(CPACK_GENERATOR STREQUAL "RPM") set(CPACK_RPM_PACKAGE_LICENSE "GPLv2") set(CPACK_RPM_MAIN_COMPONENT "cockatrice") @@ -284,7 +284,7 @@ if(UNIX) endif() set(CPACK_RPM_PACKAGE_GROUP "Amusements/Games") set(CPACK_RPM_PACKAGE_URL "http://github.com/Cockatrice/Cockatrice") - # stop directories from making package conflicts + # Stop directories from making package conflicts set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/share/applications /usr/share/icons @@ -314,10 +314,31 @@ elseif(WIN32) set(TRICE_IS_64_BIT 0) endif() - # Configure file with custom definitions for NSIS. + # Configure file with custom definitions for NSIS configure_file("${COCKATRICE_CMAKE_PATH}/NSIS.definitions.nsh.in" "${PROJECT_BINARY_DIR}/NSIS.definitions.nsh") - # include vcredist into the package; NSIS will take care of running it + # Include liblzma.dll into the package + # install(FILES "${CMAKE_SOURCE_DIR}/vcpkg_installed/x64-windows/bin/liblzma.dll" DESTINATION ./) + # install(FILES "${CMAKE_SOURCE_DIR}/vcpkg_installed/x64-windows/bin/liblzma.dll" DESTINATION "bin") + + # set(LIBLZMA_DLL "${CMAKE_SOURCE_DIR}/vcpkg_installed/x64-windows/bin/liblzma.dll") + # + # if(EXISTS "${LIBLZMA_DLL}") + # install(FILES "${LIBLZMA_DLL}" DESTINATION ./) + # else() + # message(WARNING "liblzma.dll not found at ${LIBLZMA_DLL}, skipping DLL install.") + # endif() + + # Make sure vcpkg's toolchain is in use and lzma is available as a target + # find_package(lzma CONFIG REQUIRED) + # This will install the DLL if present (vcpkg target will point to the correct location) + # install(TARGETS lzma + # RUNTIME DESTINATION . + # LIBRARY DESTINATION lib + # ARCHIVE DESTINATION lib + # ) + + # Include vcredist into the package; NSIS will take care of running it if(VCREDISTRUNTIME_FOUND) install(FILES "${VCREDISTRUNTIME_FILE}" DESTINATION ./) endif() @@ -352,6 +373,6 @@ if(TEST) endif() if(Qt6_FOUND AND Qt6_VERSION_MINOR GREATER_EQUAL 3) - # Qt6.3+ requires project finalization to support translations + # Qt 6.3+ requires project finalization to support translations qt6_finalize_project() endif() diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index f8be8aca5..dd2029f32 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -1,12 +1,12 @@ # CMakeLists for cockatrice directory # -# provides the cockatrice binary +# Provides the cockatrice binary project(Cockatrice VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") set(cockatrice_SOURCES ${VERSION_STRING_CPP} - # sort by alphabetical order, so that there is no debate about where to add new sources to the list + # Sort by alphabetical order, so that there is no debate about where to add new sources to the list src/client/game_logic/abstract_client.cpp src/client/game_logic/key_signals.cpp src/client/get_text_with_max.cpp @@ -278,11 +278,11 @@ if(UPDATE_TRANSLATIONS) set(cockatrice_TS "${CMAKE_CURRENT_SOURCE_DIR}/cockatrice_en@source.ts") else() file(GLOB cockatrice_TS "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts") -endif(UPDATE_TRANSLATIONS) +endif() if(WIN32) set(cockatrice_SOURCES ${cockatrice_SOURCES} cockatrice.rc) -endif(WIN32) +endif() if(APPLE) set(MACOSX_BUNDLE_ICON_FILE appicon.icns) @@ -290,7 +290,7 @@ if(APPLE) ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) set(cockatrice_SOURCES ${cockatrice_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns) -endif(APPLE) +endif() if(Qt6_FOUND) qt6_add_resources(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES}) @@ -329,7 +329,7 @@ if(Qt6_FOUND) MANUAL_FINALIZATION ) elseif(Qt5_FOUND) - # Qt5 Translations need to be linked at executable creation time + # Qt5 translations need to be linked at executable creation time if(Qt5LinguistTools_FOUND) if(UPDATE_TRANSLATIONS) qt5_create_translation(cockatrice_QM ${translate_SRCS} ${cockatrice_TS}) @@ -371,7 +371,7 @@ if(UNIX) install(TARGETS cockatrice BUNDLE DESTINATION ./) else() - # Assume linux + # Assume Linux install(TARGETS cockatrice RUNTIME DESTINATION bin/) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/cockatrice.png DESTINATION ${ICONDIR}/hicolor/48x48/apps) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/cockatrice.svg DESTINATION ${ICONDIR}/hicolor/scalable/apps) @@ -381,27 +381,17 @@ elseif(WIN32) install(TARGETS cockatrice RUNTIME DESTINATION ./) endif() +include(BundleUtilities) + if(APPLE) - # these needs to be relative to CMAKE_INSTALL_PREFIX + # These needs to be relative to CMAKE_INSTALL_PREFIX set(plugin_dest_dir cockatrice.app/Contents/Plugins) set(qtconf_dest_dir cockatrice.app/Contents/Resources) - # Qt plugins: audio (Qt5), iconengines, imageformats, multimedia (Qt6), platforms, printsupport (Qt5), styles, tls (Qt6) - install( - DIRECTORY "${QT_PLUGINS_DIR}/" - DESTINATION ${plugin_dest_dir} + install(DIRECTORY "${QT_PLUGINS_DIR}/" + DESTINATION cockatrice.app/Contents/Plugins COMPONENT Runtime - FILES_MATCHING - PATTERN "*.dSYM" EXCLUDE - PATTERN "*_debug.dylib" EXCLUDE - PATTERN "audio/*.dylib" - PATTERN "iconengines/*.dylib" - PATTERN "imageformats/*.dylib" - PATTERN "multimedia/*.dylib" - PATTERN "platforms/*.dylib" - PATTERN "printsupport/*.dylib" - PATTERN "styles/*.dylib" - PATTERN "tls/*.dylib" + FILES_MATCHING PATTERN "*.dylib" ) install( @@ -411,94 +401,53 @@ if(APPLE) PATTERN "*.ini" ) - install( - CODE " - file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] -Plugins = Plugins -Translations = Resources/translations -Data = Resources\") - " - COMPONENT Runtime - ) + # Copy qt.conf with correct paths + install(CODE " + file(WRITE \"\${CMAKE_INSTALL_PREFIX}/cockatrice.app/Contents/Resources/qt.conf\" \"[Paths] + Plugins = Plugins + Translations = Resources/translations + Data = Resources\") + ") - install( - CODE " - file(GLOB_RECURSE QTPLUGINS - \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\") - set(BU_CHMOD_BUNDLE_ITEMS ON) - include(BundleUtilities) - fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/cockatrice.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") - " - COMPONENT Runtime - ) + install(CODE " + set(BU_CHMOD_BUNDLE_ITEMS ON) + file(GLOB_RECURSE QTPLUGINS + \"\${CMAKE_INSTALL_PREFIX}/cockatrice.app/Contents/Plugins/*.dylib\") + fixup_bundle( + \"\${CMAKE_INSTALL_PREFIX}/cockatrice.app\" + \"\${QTPLUGINS}\" + \"${QT_LIBRARY_DIR}\" + ) + ") endif() if(WIN32) - # these needs to be relative to CMAKE_INSTALL_PREFIX + # These needs to be relative to CMAKE_INSTALL_PREFIX set(plugin_dest_dir Plugins) set(qtconf_dest_dir .) - install( - DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/" - DESTINATION ./ - FILES_MATCHING - PATTERN "*.dll" + install(DIRECTORY "${QT_PLUGINS_DIR}/" + DESTINATION Plugins + COMPONENT Runtime + FILES_MATCHING PATTERN "*.dll" ) install( DIRECTORY "${CMAKE_BINARY_DIR}/cockatrice/" DESTINATION ./ - FILES_MATCHING - PATTERN "*.ini" + FILES_MATCHING PATTERN "*.ini" ) - # Qt plugins: audio (Qt5), iconengines, imageformats, multimedia (Qt6) platforms, printsupport (Qt5), styles, tls (Qt6) - install( - DIRECTORY "${QT_PLUGINS_DIR}/" - DESTINATION ${plugin_dest_dir} - COMPONENT Runtime - FILES_MATCHING - PATTERN "audio/qtaudio_wasapi.dll" - PATTERN "audio/qtaudio_windows.dll" - PATTERN "iconengines/qsvgicon.dll" - PATTERN "imageformats/*.dll" - PATTERN "mediaservice/dsengine.dll" - PATTERN "mediaservice/wmfengine.dll" - PATTERN "multimedia/*.dll" - PATTERN "platforms/qdirect2d.dll" - PATTERN "platforms/qminimal.dll" - PATTERN "platforms/qoffscreen.dll" - PATTERN "platforms/qwindows.dll" - PATTERN "printsupport/windowsprintersupport.dll" - PATTERN "styles/qcertonlybackend.dll" - PATTERN "styles/qopensslbackend.dll" - PATTERN "styles/qschannelbackend.dll" - PATTERN "styles/qwindowsvistastyle.dll" - PATTERN "tls/qcertonlybackend.dll" - PATTERN "tls/qopensslbackend.dll" - PATTERN "tls/qschannelbackend.dll" - ) - - install( - CODE " - file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths] -Plugins = Plugins -Translations = Resources/translations -Data = Resources\") - " - COMPONENT Runtime - ) - - install( - CODE " - file(GLOB_RECURSE QTPLUGINS - \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\") - set(BU_CHMOD_BUNDLE_ITEMS ON) - include(BundleUtilities) - fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Cockatrice.exe\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\") - " - COMPONENT Runtime - ) + install(CODE " + set(BU_CHMOD_BUNDLE_ITEMS ON) + file(GLOB_RECURSE QTPLUGINS + \"\${CMAKE_INSTALL_PREFIX}/Plugins/*.dll\") + fixup_bundle( + \"\${CMAKE_INSTALL_PREFIX}/Cockatrice.exe\" + \"\${QTPLUGINS}\" + \"${QT_LIBRARY_DIR}\" + ) + ") if(OPENSSL_FOUND) install(FILES ${OPENSSL_INCLUDE_DIRS} DESTINATION ./) diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index 5a76f3274..7ba4a3470 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -49,11 +49,11 @@ if(UPDATE_TRANSLATIONS) set(oracle_TS "${CMAKE_CURRENT_SOURCE_DIR}/oracle_en@source.ts") else() file(GLOB oracle_TS "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts") -endif(UPDATE_TRANSLATIONS) +endif() if(WIN32) set(oracle_SOURCES ${oracle_SOURCES} oracle.rc) -endif(WIN32) +endif() if(APPLE) set(MACOSX_BUNDLE_ICON_FILE appicon.icns) @@ -61,7 +61,7 @@ if(APPLE) ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) set(oracle_SOURCES ${oracle_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns) -endif(APPLE) +endif() if(Qt6_FOUND) qt6_add_resources(oracle_RESOURCES_RCC ${oracle_RESOURCES}) @@ -72,12 +72,11 @@ endif() include_directories(../cockatrice/src) include_directories(../common) -# Libz is required to support zipped files +# Libz is required to support zip files find_package(ZLIB) if(ZLIB_FOUND) include_directories(${ZLIB_INCLUDE_DIRS}) add_definitions("-DHAS_ZLIB") - set(oracle_SOURCES ${oracle_SOURCES} src/zip/unzip.cpp src/zip/zipglobal.cpp) else() message(STATUS "Oracle: zlib not found; ZIP support disabled") @@ -88,7 +87,6 @@ find_package(LibLZMA) if(LIBLZMA_FOUND) include_directories(${LIBLZMA_INCLUDE_DIRS}) add_definitions("-DHAS_LZMA") - set(oracle_SOURCES ${oracle_SOURCES} src/lzma/decompress.cpp) else() message(STATUS "Oracle: LibLZMA not found; xz support disabled") @@ -152,7 +150,7 @@ if(UNIX) install(TARGETS oracle BUNDLE DESTINATION ./) else() - # Assume linux + # Assume Linux install(TARGETS oracle RUNTIME DESTINATION bin/) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/oracle.png DESTINATION ${ICONDIR}/hicolor/48x48/apps) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/oracle.svg DESTINATION ${ICONDIR}/hicolor/scalable/apps) @@ -163,7 +161,7 @@ endif() if(NOT WIN32 AND NOT APPLE) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/oracle.desktop DESTINATION ${DESKTOPDIR}) -endif(NOT WIN32 AND NOT APPLE) +endif() if(APPLE) # these needs to be relative to CMAKE_INSTALL_PREFIX @@ -206,17 +204,17 @@ Translations = Resources/translations\") endif() if(WIN32) - # these needs to be relative to CMAKE_INSTALL_PREFIX + # These needs to be relative to CMAKE_INSTALL_PREFIX set(plugin_dest_dir Plugins) set(qtconf_dest_dir .) list(APPEND libSearchDirs ${QT_LIBRARY_DIR}) - install( - DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/" - DESTINATION ./ - FILES_MATCHING - PATTERN "*.dll" - ) + # install( + # DIRECTORY "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${CMAKE_BUILD_TYPE}/" + # DESTINATION ./ + # FILES_MATCHING + # PATTERN "*.dll" + # ) # Qt plugins: iconengines, platforms, styles, tls (Qt6) install( @@ -247,16 +245,16 @@ Translations = Resources/translations\") COMPONENT Runtime ) - install( - CODE " - file(GLOB_RECURSE QTPLUGINS - \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\") - set(BU_CHMOD_BUNDLE_ITEMS ON) - include(BundleUtilities) - fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Oracle.exe\" \"\${QTPLUGINS}\" \"${libSearchDirs}\") - " - COMPONENT Runtime - ) + # install( + # CODE " + # file(GLOB_RECURSE QTPLUGINS + # \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\") + # set(BU_CHMOD_BUNDLE_ITEMS ON) + # include(BundleUtilities) + # fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Oracle.exe\" \"\${QTPLUGINS}\" \"${libSearchDirs}\") + # " + # COMPONENT Runtime + # ) endif() if(Qt6_FOUND AND Qt6LinguistTools_FOUND) @@ -289,3 +287,15 @@ endif() if(Qt6_FOUND) qt6_finalize_target(oracle) endif() + +if(WIN32) + install(CODE " + include(BundleUtilities) + set(BU_CHMOD_BUNDLE_ITEMS ON) + fixup_bundle( + \"\${CMAKE_INSTALL_PREFIX}/Oracle.exe\" + \"\" + \"\${CMAKE_INSTALL_PREFIX}\" + ) + ") +endif()