Skip to content

Commit

Permalink
change to 32-bit local multilib build
Browse files Browse the repository at this point in the history
  • Loading branch information
benedekkupper committed Jun 29, 2024
1 parent 3bf2246 commit 82cf7d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ name: CMake on a single platform

on:
push:
branches: [ "master" ]
branches: [ "master", "test" ]
pull_request:
branches: [ "master" ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
TOOLCHAIN_PATH: ${{ github.workspace }}/gcc-arm-none-eabi.cmake

jobs:
build:
Expand All @@ -23,20 +22,15 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install ARM GCC toolchain
- name: Install 32-bit multilib toolchain
run: |
sudo apt update
sudo apt install -y gcc-arm-none-eabi
- name: Download gcc-arm-none-eabi.cmake from another repository
run: |
mkdir -p ${{ github.workspace }}
curl -sSL "https://raw.githubusercontent.com/jobroe/cmake-arm-embedded/35a969878d3e6a979a0c61f0bf07327bac3aad1e/toolchain-arm-none-eabi.cmake" > "${TOOLCHAIN_PATH}"
sudo apt install -y build-essential libc6-dev-i386 g++-multilib
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_PATH}
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
# Build your program with the given configuration
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ add_subdirectory(${PROJECT_NAME})

find_package(Git REQUIRED)


# Check if the target platform is 64-bit
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "64-bit detected, adding -m32 flag for 32-bit compilation")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
else()
message(STATUS "32-bit detected, no additional flags needed")
endif()

# fetch all submodules explicitly as there are nested ones
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
Expand Down

0 comments on commit 82cf7d6

Please sign in to comment.