Skip to content

feat: add comprehensive build support for macOS and Apple Silicon (M Series)#142

Open
R2D2-3PO wants to merge 1 commit into
iamaisim:mainfrom
R2D2-3PO:fix-macos-build-support
Open

feat: add comprehensive build support for macOS and Apple Silicon (M Series)#142
R2D2-3PO wants to merge 1 commit into
iamaisim:mainfrom
R2D2-3PO:fix-macos-build-support

Conversation

@R2D2-3PO

Copy link
Copy Markdown

Overview
This PR enables macOS compatibility for ProjectAirSim, resolving critical build failures on Darwin-based systems. It specifically addresses issues with platform detection, architecture-specific dependency fetching, and Unreal Engine linking.

Detailed Changes

Build System & Environment

CMakeLists.txt: Replaced hardcoded Linux clang-13/15 compiler paths with a dynamic detection logic for macOS. Added PROJECTAIRSIM_IS_MACOS flag. Disabled Linux-specific toolchains when building on macOS. Added logic to auto-detect arm64 vs x86_64 for macOS.

build.sh: Updated to detect Darwin via uname -s and redirect to build_macos.mk.

build_macos.mk (New): Created a dedicated Makefile for macOS to drive Ninja/CMake builds for both Debug and Release configurations.

Dependency Management

JSBSim: Changed library type to STATIC for macOS to ensure symbol visibility. Included core JSBSim headers in core_sim/jsbsim/include to resolve header search path issues on Mac.

OpenSSL: Updated to use find_package(OpenSSL REQUIRED) on macOS instead of the external Linux-specific project.

ONNX Runtime: Implemented automated FetchContent logic for macOS .tgz packages with architecture-specific URL resolution.

Unreal Engine Plugin Integration

ProjectAirSim.Build.cs: Fixed dynamic library linking logic for .dylib files and corrected path resolution for SimLibs/shared_libs.

blocks_genprojfiles_vscode.sh: Adjusted to handle Mac-specific environment variables for VS Code project generation.

Source Code Adjustments

core_sim: Fixed platform-specific logic in client_authorization.cpp for Darwin.

mavlinkcom: Added macOS-compatible socket implementation headers in mavlinkcom/src/impl/apple/.

vehicle_apis: Adjusted simple_flight_api.cpp to handle Mac-specific timing and physics stepping.

Testing Environment
Hardware: MacBook Pro (Apple M-series chip)

OS: macOS 26.x

Engine: Unreal Engine 5.7

Result: Successfully generated VS Code project files and launched the Blocks environment.

@jonyMarino

Copy link
Copy Markdown
Contributor

@R2D2-3PO Thank you for your contribution, it's greatly appreciated. We need to remove the JSBSim source code from the branch; it was added by mistake.

@R2D2-3PO R2D2-3PO force-pushed the fix-macos-build-support branch from c1c6d4e to cbc6955 Compare April 24, 2026 09:40
@R2D2-3PO R2D2-3PO force-pushed the fix-macos-build-support branch from cbc6955 to 6db065c Compare April 24, 2026 09:50
@R2D2-3PO

Copy link
Copy Markdown
Author

okay, @jonyMarino I have already remove the JSBSim code from this branch

@LucasJSch

Copy link
Copy Markdown
Collaborator

Hi @R2D2-3PO! We're gonna merge soon a couple of PRs. After those, I'll gladly merge this one! I'll let you know when, so you can rebase the branch or merge it accordingly :).

Keep your efforts coming, it's greatly appreciated!

@LucasJSch LucasJSch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice job overall! 🦾
Left some comments, PTAL!

def load_text_resource(resource_path: str) -> str:
"""Loads a package text resource and returns its contents.

Uses importlib.resources.files() when available (Python >= 3.9).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonyMarino are we ok with not allowing anymore python < 3.9? if so, we should change the documentation as well to clear this out.

world = World(client, 'robot_test_type_schema.jsonc')


def test_load_scene_config_respects_caller_sim_config_path():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this was deleted?

Comment thread CMakeLists.txt
endif()

if(UNIX)
# 1. 针对不同平台设置自动下载的 URL

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete this non-english comment, or translate it to english if useful!

Comment thread CMakeLists.txt
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/_deps/onnxruntime-download
)
FetchContent_GetProperties(onnxruntime)
# 2. macOS 优先使用本地预编译包;没有提供时再自动下载

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment thread CMakeLists.txt
endif()
endif()

# 3. 先确定 ONNX Runtime 的根目录,再统一进行变量设置和文件分发

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

if(WIN32)
add_dependencies(${TARGET_NAME} nng-external)
else()
elseif(PROJECTAIRSIM_IS_LINUX)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's call this LINUX and APPLE, instead of PROJECTAIRSIM_IS_...

it can be also unix and not linux.

LIST(APPEND MAVLINK_SOURCES serial_com/wifi.cpp)

IF(UNIX)
if(APPLE)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's follow the same order everywhere:

first check windows
then linux/unix
and then macos.

PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
# ${EIGEN_INCLUDE_DIR}
lvmon

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this was deleted?

}
}
else
else if (isMac)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's follow the same order: first for windows, then linux/unix, and the macos.

# Copyright (C) 2025 IAMAI CONSULTING CORP
# MIT License.

set -euo pipefail

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🦾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants