Skip to content

Commit

Permalink
Disable more things and fix Linux cross compilation (#11)
Browse files Browse the repository at this point in the history
Add logic for the Linux ARM platforms.

Disable OpenMP and Fortran to reduce dependencies, and LAPACKE, because it wasn't used by anything.
  • Loading branch information
Gold856 authored Feb 24, 2025
1 parent 8d17c07 commit 78f76ae
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
include:
- container: wpilib/raspbian-cross-ubuntu:bookworm-22.04
artifact-name: Arm32
build-options: -Pplatform=linux-arm32
build-options: -Pplatform=linux-arm32 -Ptoolchain=/usr/local/toolchain-config.cmake
- container: wpilib/aarch64-cross-ubuntu:bookworm-22.04
artifact-name: Arm64
build-options: -Pplatform=linux-arm64
build-options: -Pplatform=linux-arm64 -Ptoolchain=/usr/local/toolchain-config.cmake
- container: wpilib/ubuntu-base:22.04
artifact-name: Linux
build-options:
Expand All @@ -38,11 +38,11 @@ jobs:
name: Install dependencies
- uses: actions/checkout@v4
with:
submodules: 'true'
submodules: "true"
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
distribution: "temurin"
- run: ./gradlew publish ${{ matrix.build-options }}
name: Build with Gradle
- run: ls build*/install/lib/*
Expand Down Expand Up @@ -70,11 +70,11 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
submodules: "true"
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
distribution: "temurin"
- uses: ilammy/[email protected]
with:
arch: ${{ matrix.tool-arch }}
Expand All @@ -94,11 +94,11 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
submodules: "true"
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
distribution: "temurin"
- run: brew install cmake ninja
name: install ninja
- run: ./gradlew publish
Expand Down Expand Up @@ -136,10 +136,10 @@ jobs:
./gradlew publish -Pthirdparty
working-directory: combiner
env:
RUN_AZURE_ARTIFACTORY_RELEASE: 'TRUE'
RUN_AZURE_ARTIFACTORY_RELEASE: "TRUE"
ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- uses: actions/upload-artifact@v4
with:
name: Maven
path: ~/releases
path: ~/releases
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,30 @@ cmake_minimum_required(VERSION 3.25)
set(CMAKE_OSX_ARCHITECTURES arm64 x86_64)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded)
project(thirdparty-ceres C CXX)

if(TOOLCHAIN_TRIPLE STREQUAL aarch64-linux-gnu)
# Hack around opensdk not having the wrong arch and Ceres not being able to detect the Eigen version when on aarch64
set(CMAKE_SYSTEM_PROCESSOR ARM64)
endif()
set(BUILD_SHARED_LIBS OFF)
set(BUILD_TESTING OFF)
set(BUILD_EXAMPLES OFF)

set(NO_CBLAS ON)
set(NO_LAPACKE ON)
set(C_LAPACK ON)
set(USE_LOCKING ON)
set(USE_THREAD OFF)
set(NOFORTRAN ON)

set(SUITESPARSE_ENABLE_PROJECTS cholmod)
set(SUITESPARSE_USE_CUDA OFF)
set(SUITESPARSE_USE_FORTRAN OFF)
set(SUITESPARSE_USE_OPENMP OFF)
set(SUITESPARSE_USE_PYTHON OFF)
set(CHOLMOD_GPL OFF)
if(NOT APPLE)
set(BLA_VENDOR OpenBLAS)
endif()
if(MSVC)
set(SUITESPARSE_USE_FORTRAN OFF)
endif()

set(EIGEN_BUILD_CMAKE_PACKAGE ON)

Expand Down Expand Up @@ -63,6 +66,7 @@ fetchcontent_declare(
GIT_TAG 0fb2ed140d4fc0108553ecfb25f2d7fc1a9319a1
OVERRIDE_FIND_PACKAGE
PATCH_COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/0003-Make-assignment-constexpr.patch
UPDATE_DISCONNECTED 1
)

fetchcontent_declare(
Expand Down
11 changes: 9 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ext.platformClassifier = ext.platformPath.replaceFirst('/', '')
if (!project.hasProperty('repo')) {
ext.repo = 'development'
}
def pubVersion = "$ext.version-1"
def pubVersion = "$ext.version-2"

def outputsFolder = file("$project.buildDir/outputs")

Expand All @@ -94,11 +94,18 @@ ext.addTaskToCopyAllOutputs = { task ->

['Debug', 'RelWithDebInfo'].each { buildtype ->
task "configure$buildtype" (type: Exec) {
def baseArgs = ["-B", "build$buildtype", "-DCMAKE_BUILD_TYPE=$buildtype", "-G", "Ninja"]
def baseArgs = ["-B", "build$buildtype", "-DCMAKE_BUILD_TYPE=$buildtype", "-G", "Ninja", "--fresh"]
if (platform == "windows-arm64") {
// Need to set CMAKE_CROSSCOMPILING because getarch can't be crosscompiled and executed on the host.
// Also, TARGET must be generic. You need to set it if crosscompiling, but setting it to ARMV8, it will try to use assembly, which fails on Windows
baseArgs += ["-DCMAKE_CROSSCOMPILING=1", "-DCMAKE_SYSTEM_NAME=Windows", "-DCMAKE_SYSTEM_PROCESSOR=ARM64", "-DTARGET=GENERIC", "-DARCH=ARM64"]
} else if (platform.startsWith("linux-arm64")) {
baseArgs += ["-DTARGET=ARMV8", "-DARCH=ARM64"]
} else if (platform.startsWith("linux-arm32")) {
baseArgs += ["-DTARGET=ARMV6", "-DARCH=ARM"]
}
if (project.hasProperty("toolchain")) {
baseArgs += ["--toolchain=$toolchain"]
}
outputs.dir "build$buildtype"
executable "cmake"
Expand Down

0 comments on commit 78f76ae

Please sign in to comment.