From 1413356618746f12cc250874c57a1898938d2c9c Mon Sep 17 00:00:00 2001 From: BagelSketches Date: Thu, 3 Jul 2025 17:25:58 +1000 Subject: [PATCH] modified ajenbos original attempt to get libraries --- .github/workflows/ci.yml | 139 ++++++--------------------------------- CMakeLists.txt | 118 +++++++++++++++------------------ 2 files changed, 72 insertions(+), 185 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9fb2cc99..ceedfaca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,6 @@ jobs: build: name: ${{ matrix.name }} runs-on: ${{ matrix.os }} - container: ${{ matrix.container || '' }} defaults: run: shell: ${{ matrix.shell || 'sh' }} @@ -34,15 +33,14 @@ jobs: fail-fast: false matrix: include: - - { name: 'Linux', os: 'ubuntu-latest', dx5: false, config: true, linux: true, werror: true, clang-tidy: true } - - { name: 'MSVC (x86)', os: 'windows-latest', dx5: true, config: true, msvc: true, werror: false, clang-tidy: false, vc-arch: 'amd64_x86' } - - { name: 'MSVC (x64)', os: 'windows-latest', dx5: false, config: true, msvc: true, werror: false, clang-tidy: false, vc-arch: 'amd64' } - - { name: 'MSVC (arm64)', os: 'windows-latest', dx5: false, config: true, msvc: true, werror: false, clang-tidy: false, vc-arch: 'amd64_arm64' } - - { name: 'msys2 mingw32', os: 'windows-latest', dx5: false, config: true, mingw: true, werror: true, clang-tidy: true, msystem: 'mingw32', msys-env: 'mingw-w64-i686', shell: 'msys2 {0}' } - - { name: 'msys2 mingw64', os: 'windows-latest', dx5: false, config: true, mingw: true, werror: true, clang-tidy: true, msystem: 'mingw64', msys-env: 'mingw-w64-x86_64', shell: 'msys2 {0}' } - - { name: 'macOS', os: 'macos-latest', dx5: false, config: true, brew: true, werror: true, clang-tidy: false } - - { name: 'Emscripten', os: 'ubuntu-latest', dx5: false, config: false, emsdk: true, werror: true, clang-tidy: false, cmake-wrapper: 'emcmake' } - - { name: 'Nintendo 3DS', os: 'ubuntu-latest', dx5: false, config: false, n3ds: true, werror: true, clang-tidy: false, container: 'devkitpro/devkitarm:latest', cmake-args: '-DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake' } + - { name: 'Linux', os: 'ubuntu-latest', dx5: false, config: true, build-type: 'Debug', linux: true, werror: true, clang-tidy: true } + - { name: 'MSVC (x86)', os: 'windows-latest', dx5: true, config: false, build-type: 'Debug', msvc: true, werror: false, clang-tidy: false, vc-arch: 'amd64_x86' } + - { name: 'MSVC (x64)', os: 'windows-latest', dx5: false, config: true, build-type: 'Debug', msvc: true, werror: false, clang-tidy: false, vc-arch: 'amd64' } + - { name: 'MSVC (arm64)', os: 'windows-latest', dx5: false, config: false, build-type: 'Debug', msvc: true, werror: false, clang-tidy: false, vc-arch: 'amd64_arm64' } + - { name: 'msys2 mingw32', os: 'windows-latest', dx5: false, config: false, build-type: 'Debug', mingw: true, werror: true, clang-tidy: true, msystem: 'mingw32', msys-env: 'mingw-w64-i686', shell: 'msys2 {0}' } + - { name: 'msys2 mingw64', os: 'windows-latest', dx5: false, config: true, build-type: 'Debug', mingw: true, werror: true, clang-tidy: true, msystem: 'mingw64', msys-env: 'mingw-w64-x86_64', shell: 'msys2 {0}' } + - { name: 'macOS', os: 'macos-latest', dx5: false, config: true, build-type: 'Debug', brew: true, werror: true, clang-tidy: false } + - { name: 'Emscripten', os: 'ubuntu-latest', dx5: false, config: false, build-type: 'Debug', emsdk: true, werror: true, clang-tidy: false, cmake-wrapper: 'emcmake' } steps: - name: Setup vcvars if: ${{ !!matrix.msvc }} @@ -62,14 +60,19 @@ jobs: ${{ matrix.msys-env }}-clang-tools-extra ${{ (matrix.config && format('{0}-qt6-base', matrix.msys-env)) || '' }} + - name: Install Qt + if: ${{ !!matrix.msvc && matrix.config }} + uses: jurplel/install-qt-action@v4 + with: + cache: 'true' + - name: Install Linux dependencies (apt-get) if: ${{ matrix.linux }} run: | sudo apt-get update sudo apt-get install -y \ libx11-dev libxext-dev libxrandr-dev libxrender-dev libxfixes-dev libxi-dev libxinerama-dev \ - libxcursor-dev libwayland-dev libxkbcommon-dev wayland-protocols libgl1-mesa-dev qt6-base-dev \ - libasound2-dev qt6-xdgdesktopportal-platformtheme + libxcursor-dev libwayland-dev libxkbcommon-dev wayland-protocols libgl1-mesa-dev libglew-dev qt6-base-dev - name: Install macOS dependencies (brew) if: ${{ matrix.brew }} @@ -77,10 +80,6 @@ jobs: brew update brew install cmake ninja llvm qt6 echo "LLVM_ROOT=$(brew --prefix llvm)/bin" >> $GITHUB_ENV - - name: Install Qt - if: ${{ !matrix.n3ds }} - uses: jurplel/install-qt-action@v4 - - name: Setup Emscripten uses: mymindstorm/setup-emsdk@master @@ -95,97 +94,26 @@ jobs: - name: Configure (CMake) run: | ${{ matrix.cmake-wrapper || '' }} cmake -S . -B build -GNinja \ - ${{ matrix.cmake-args || '' }} \ - -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ -DISLE_USE_DX5=${{ !!matrix.dx5 }} \ - -DISLE_BUILD_CONFIG=${{ !!matrix.config }} \ + -DISLE_BUILD_CONFIG=${{ matrix.config }} \ -DENABLE_CLANG_TIDY=${{ !!matrix.clang-tidy }} \ -DISLE_WERROR=${{ !!matrix.werror }} \ - -DISLE_DEBUG=OFF \ -Werror=dev - name: Build (CMake) run: cmake --build build --verbose - - name: Pack QT Libs(windows) - if: ${{ matrix.os == 'windows-latest' }} - run: | - cd build - mkdir QTLibs - windeployqt isle-config.exe --dir QTLibs - - name: Package (CPack) - if: ${{ !matrix.n3ds }} run: | cd build cpack . - - name: Install linuxdeploy - if: ${{ matrix.linux }} - id: install-linuxdeploy - uses: miurahr/install-linuxdeploy-action@v1.8.0 - with: - plugins: qt appimage - - - name: Package (AppImage) - if: ${{ matrix.linux }} - run: | - cd build && \ - export LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH" && \ - NO_STRIP=1 ${{ steps.install-linuxdeploy.outputs.linuxdeploy }} \ - -p qt \ - -e isle \ - -e isle-config \ - -d packaging/linux/org.legoisland.Isle.desktop \ - -i icons/org.legoisland.Isle.svg \ - --custom-apprun=../packaging/linux/appimage/AppRun \ - --appdir packaging/linux/appimage/AppDir \ - --output appimage && \ - mv *.AppImage dist/ - - - name: Package (3DS) - if: ${{ matrix.n3ds }} - run: | - cd build - mkdir dist - mv *.3dsx dist/ - - name: Upload Build Artifacts uses: actions/upload-artifact@v4 with: - name: '${{ matrix.name }}' - path: | - build/dist/isle-* - build/dist/*.AppImage - build/dist/*.3dsx - - flatpak: - name: "Flatpak (${{ matrix.arch }})" - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - include: - - arch: x86_64 - os: ubuntu-latest - - - arch: aarch64 - os: ubuntu-22.04-arm - - container: - image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.8 - options: --privileged - - steps: - - uses: actions/checkout@v4 - - - name: Build Flatpak - uses: flatpak/flatpak-github-actions/flatpak-builder@v6 - with: - bundle: org.legoisland.Isle.${{ matrix.arch }}.flatpak - manifest-path: packaging/linux/flatpak/org.legoisland.Isle.json - arch: ${{ matrix.arch }} + name: '${{ matrix.name }} ${{ matrix.build-type }}' + path: build/dist/isle-* ncc: name: 'C++' @@ -224,31 +152,4 @@ jobs: LEGO1/omni/include/flic.h \ LEGO1/omni/src/video/flic.cpp \ $action_headers \ - --path LEGO1/omni LEGO1/lego/legoomni - - release: - name: 'Release' - if: ${{ github.event_name == 'push' && github.ref_name == 'master' }} - runs-on: ubuntu-latest - needs: - - build - - flatpak - steps: - - name: Download All Artifacts - uses: actions/download-artifact@main - with: - pattern: "*" - path: Release - merge-multiple: true - - - name: Checkout uploadtool - uses: actions/checkout@v4 - with: - repository: 'probonopd/uploadtool' - path: 'uploadtool' - - - name: Upload Continuous Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - ./uploadtool/upload.sh Release/* + --path LEGO1/omni LEGO1/lego/legoomni \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 44e50992..4378c703 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(isle LANGUAGES CXX C VERSION 0.1) if (EMSCRIPTEN) add_compile_options(-pthread) - add_link_options(-sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=2gb -sUSE_PTHREADS=1 -sPROXY_TO_PTHREAD=1 -sOFFSCREENCANVAS_SUPPORT=1 -sPTHREAD_POOL_SIZE_STRICT=0 -sFORCE_FILESYSTEM=1 -sWASMFS=1 -sEXIT_RUNTIME=1) + add_link_options(-sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=2gb -sUSE_PTHREADS=1 -sPROXY_TO_PTHREAD=1 -sPTHREAD_POOL_SIZE_STRICT=0 -sFORCE_FILESYSTEM=1 -sWASMFS=1 -sEXIT_RUNTIME=1) set(SDL_PTHREADS ON CACHE BOOL "Enable SDL pthreads" FORCE) endif() @@ -13,9 +13,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") include(CheckCXXSourceCompiles) include(CMakeDependentOption) include(CMakePushCheckState) -include(CMake/detectcpu.cmake) - -DetectTargetCPUArchitectures(ISLE_CPUS) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -29,7 +26,7 @@ else() endif() find_program(SDL_SHADERCROSS_BIN NAMES "shadercross") -find_package(Python3 3.11 COMPONENTS Interpreter) +find_package(Python3 COMPONENTS Interpreter) option(ISLE_BUILD_APP "Build isle application" ON) option(ISLE_ASAN "Enable Address Sanitizer" OFF) @@ -38,7 +35,7 @@ option(ISLE_WERROR "Treat warnings as errors" OFF) option(ISLE_DEBUG "Enable imgui debug" ON) cmake_dependent_option(ISLE_USE_DX5 "Build with internal DirectX 5 SDK" "${NOT_MINGW}" "WIN32;CMAKE_SIZEOF_VOID_P EQUAL 4" OFF) cmake_dependent_option(ISLE_MINIWIN "Use miniwin" ON "NOT ISLE_USE_DX5" OFF) -cmake_dependent_option(ISLE_BUILD_CONFIG "Build CONFIG.EXE application" ON "MSVC OR ISLE_MINIWIN;NOT NINTENDO_3DS" OFF) +cmake_dependent_option(ISLE_BUILD_CONFIG "Build CONFIG.EXE application" ON "MSVC OR ISLE_MINIWIN" OFF) cmake_dependent_option(ISLE_COMPILE_SHADERS "Compile shaders" ON "SDL_SHADERCROSS_BIN;TARGET Python3::Interpreter" OFF) option(CMAKE_POSITION_INDEPENDENT_CODE "Build with -fPIC" ON) option(ENABLE_CLANG_TIDY "Enable clang-tidy") @@ -54,8 +51,6 @@ message(STATUS "Internal miniwin: ${ISLE_MINIWIN}") message(STATUS "Isle debugging: ${ISLE_DEBUG}") message(STATUS "Compile shaders: ${ISLE_COMPILE_SHADERS}") -add_library(Isle::iniparser INTERFACE IMPORTED) - if (DOWNLOAD_DEPENDENCIES) # FetchContent downloads and configures dependencies message(STATUS "Fetching SDL3 and iniparser. This might take a while...") @@ -78,7 +73,6 @@ if (DOWNLOAD_DEPENDENCIES) set(BUILD_DOCS off) set(BUILD_SHARED_LIBS off) FetchContent_MakeAvailable(iniparser) - target_link_libraries(Isle::iniparser INTERFACE iniparser-static) endblock() else() # find_package looks for already-installed system packages. @@ -86,8 +80,10 @@ else() # to add search paths. find_package(SDL3 CONFIG REQUIRED) - find_package(iniparser REQUIRED CONFIG COMPONENTS shared) - target_link_libraries(Isle::iniparser INTERFACE iniparser-shared) + find_package(iniparser CONFIG COMPONENTS static) + if (NOT TARGET iniparser-static) + find_package(iniparser REQUIRED MODULE COMPONENTS static) + endif() endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -472,7 +468,6 @@ if (ISLE_BUILD_APP) add_executable(isle WIN32 ISLE/res/isle.rc ISLE/isleapp.cpp - ISLE/islefiles.cpp ) list(APPEND isle_targets isle) if (WIN32) @@ -488,7 +483,7 @@ if (ISLE_BUILD_APP) target_link_libraries(isle PRIVATE $<$:DirectX5::DirectX5>) # Link SDL and iniparser - target_link_libraries(isle PRIVATE SDL3::SDL3 Isle::iniparser) + target_link_libraries(isle PRIVATE SDL3::SDL3 iniparser-static) # Allow unconditional include of miniwin/miniwindevice.h target_link_libraries(isle PRIVATE miniwin-headers) @@ -523,18 +518,12 @@ if (ISLE_BUILD_APP) target_compile_definitions(isle PRIVATE "ISLE_EMSCRIPTEN_HOST=\"${ISLE_EMSCRIPTEN_HOST}\"") set_property(TARGET isle PROPERTY SUFFIX ".html") endif() - if(NINTENDO_3DS) - target_sources(isle PRIVATE - ISLE/3ds/apthooks.cpp - ISLE/3ds/config.cpp - ) - endif() endif() if (ISLE_BUILD_CONFIG) find_package(Qt6 REQUIRED COMPONENTS Core Widgets) qt_standard_project_setup() - qt_add_executable(isle-config WIN32 + qt_add_executable(config WIN32 LEGO1/mxdirectx/mxdirectxinfo.cpp LEGO1/mxdirectx/legodxinfo.cpp CONFIG/config.cpp @@ -544,22 +533,22 @@ if (ISLE_BUILD_CONFIG) CONFIG/res/config.rc CONFIG/res/config.qrc ) - target_link_libraries(isle-config PRIVATE Qt6::Core Qt6::Widgets) - set_property(TARGET isle-config PROPERTY AUTOMOC ON) - set_property(TARGET isle-config PROPERTY AUTORCC ON) - set_property(TARGET isle-config PROPERTY AUTOUIC ON) - set_property(TARGET isle-config PROPERTY AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/CONFIG/res") - list(APPEND isle_targets isle-config) - target_compile_definitions(isle-config PRIVATE _AFXDLL MXDIRECTX_FOR_CONFIG) - target_include_directories(isle-config PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/LEGO1") - target_include_directories(isle-config PUBLIC "$") + target_link_libraries(config PRIVATE Qt6::Core Qt6::Widgets) + set_property(TARGET config PROPERTY AUTOMOC ON) + set_property(TARGET config PROPERTY AUTORCC ON) + set_property(TARGET config PROPERTY AUTOUIC ON) + set_property(TARGET config PROPERTY AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/CONFIG/res") + list(APPEND isle_targets config) + target_compile_definitions(config PRIVATE _AFXDLL MXDIRECTX_FOR_CONFIG) + target_include_directories(config PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/LEGO1") + target_include_directories(config PUBLIC "$") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) - target_link_libraries(isle-config PRIVATE DirectX5::DirectX5) + target_link_libraries(config PRIVATE DirectX5::DirectX5) endif() - target_compile_definitions(isle-config PRIVATE DIRECT3D_VERSION=0x500) - target_link_libraries(isle-config PRIVATE SDL3::SDL3 Isle::iniparser) + target_compile_definitions(config PRIVATE DIRECT3D_VERSION=0x500) + target_link_libraries(config PRIVATE SDL3::SDL3 iniparser-static) if (NOT ISLE_MINIWIN) - target_link_libraries(isle-config PRIVATE ddraw dxguid) + target_link_libraries(config PRIVATE ddraw dxguid) endif() endif() @@ -573,8 +562,8 @@ if (MSVC) if (TARGET isle) target_compile_definitions(isle PRIVATE "_CRT_SECURE_NO_WARNINGS") endif() - if (TARGET isle-config) - target_compile_definitions(isle-config PRIVATE "_CRT_SECURE_NO_WARNINGS") + if (TARGET config) + target_compile_definitions(config PRIVATE "_CRT_SECURE_NO_WARNINGS") endif() endif() # Visual Studio 2017 version 15.7 needs "/Zc:__cplusplus" for __cplusplus @@ -583,8 +572,8 @@ if (MSVC) if (TARGET isle) target_compile_options(isle PRIVATE "-Zc:__cplusplus") endif() - if (TARGET isle-config) - target_compile_options(isle-config PRIVATE "-Zc:__cplusplus") + if (TARGET config) + target_compile_options(config PRIVATE "-Zc:__cplusplus") endif() endif() endif() @@ -633,18 +622,29 @@ else() include(GNUInstallDirs) endif() -string(REPLACE ";" "-" ISLE_CPUS_STRING "${ISLE_CPUS}") -string(TOLOWER "${ISLE_CPUS_STRING}" ISLE_CPUS_STRING) -set(ISLE_PACKAGE_NAME "${CMAKE_SYSTEM_NAME}-${ISLE_CPUS_STRING}" CACHE STRING "Platform name of the package") +set(ISLE_PACKAGE_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}" CACHE STRING "Platform name of the package") if(BUILD_SHARED_LIBS) list(APPEND install_extra_targets lego1) endif() -install(TARGETS isle ${install_extra_targets} - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" -) if (ISLE_BUILD_CONFIG) - install(TARGETS isle-config + find_program(WINDEPLOYQT_EXECUTABLE windeployqt) + if(WINDEPLOYQT_EXECUTABLE) + add_custom_command(TARGET config POST_BUILD + COMMAND "${WINDEPLOYQT_EXECUTABLE}" + "$" + "--libdir" + "${CMAKE_INSTALL_LIBDIR}" + "--no-compiler-runtime" + "--no-opengl-sw" + "--no-system-d3d-compiler" + "--no-translations" + "--no-quick-import" + COMMENT "Running windeployqt with minimal dependencies" + ) + else() + message(WARNING "windeployqt not found.") + endif() + install(TARGETS config RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) endif() @@ -653,29 +653,15 @@ if(EMSCRIPTEN) DESTINATION "${CMAKE_INSTALL_BINDIR}" ) endif() - -add_subdirectory(packaging) - +install(TARGETS isle ${install_extra_targets} + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" +) set(CPACK_PACKAGE_DIRECTORY "dist") -set(CPACK_PACKAGE_FILE_NAME "isle-${PROJECT_VERSION}-${ISLE_PACKAGE_NAME}") -if(NINTENDO_3DS) - ctr_generate_smdh(isle.smdh - NAME "LEGO Island" - TITLE "LEGO Island" - DESCRIPTION "LEGO Island for the Nintendo 3DS" - AUTHOR "isledecomp/isle-portable" - VERSION "${PROJECT_VERSION}" - ICON "ISLE/res/3ds/isle.png" - ) - - ctr_create_3dsx(isle SMDH isle.smdh) - install(FILES "$/isle.3dsx" DESTINATION "${CMAKE_INSTALL_BINDIR}") -endif() -if(WIN32) - install(DIRECTORY "$/QTLibs" DESTINATION "${CMAKE_INSTALL_BINDIR}") -endif() +set(CPACK_PACKAGE_FILE_NAME "isle-${PROJECT_VERSION}-${ISLE_PACKAGE_NAME}-${CMAKE_SYSTEM_PROCESSOR}") if(MSVC) set(CPACK_GENERATOR ZIP) else() set(CPACK_GENERATOR TGZ) -endif() \ No newline at end of file +endif() +include(CPack) \ No newline at end of file