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 5366e9b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
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
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,13 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
)

add_subdirectory(examples)

# the library is only supporting 32-bit pointers ATM
# switch to 32-bit multilib on 64-bit systems, if this is top-level project
if ((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) AND (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")
endif()

0 comments on commit 5366e9b

Please sign in to comment.