feat: add comprehensive build support for macOS and Apple Silicon (M Series)#142
feat: add comprehensive build support for macOS and Apple Silicon (M Series)#142R2D2-3PO wants to merge 1 commit into
Conversation
|
@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. |
c1c6d4e to
cbc6955
Compare
cbc6955 to
6db065c
Compare
|
okay, @jonyMarino I have already remove the JSBSim code from this branch |
|
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
left a comment
There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
@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(): |
| endif() | ||
|
|
||
| if(UNIX) | ||
| # 1. 针对不同平台设置自动下载的 URL |
There was a problem hiding this comment.
delete this non-english comment, or translate it to english if useful!
| DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/_deps/onnxruntime-download | ||
| ) | ||
| FetchContent_GetProperties(onnxruntime) | ||
| # 2. macOS 优先使用本地预编译包;没有提供时再自动下载 |
| endif() | ||
| endif() | ||
|
|
||
| # 3. 先确定 ONNX Runtime 的根目录,再统一进行变量设置和文件分发 |
| if(WIN32) | ||
| add_dependencies(${TARGET_NAME} nng-external) | ||
| else() | ||
| elseif(PROJECTAIRSIM_IS_LINUX) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
| } | ||
| } | ||
| else | ||
| else if (isMac) |
There was a problem hiding this comment.
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 |
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.