Skip to content

Commit

Permalink
Enable build with FBX SDK on macOS (#124)
Browse files Browse the repository at this point in the history
Summary:
- Update FindFbxSdk.cmake logic for macOS to properly find Iconv, creating FindIconv.cmake
- Install FBX SDK 2020.3.7 on the macOS CI jobs
- Update README about FBX support for macOS

- [x] Adheres to the [style guidelines](https://facebookincubator.github.io/momentum/docs/developer_guide/style_guide)
- [x] Codebase formatted by running `pixi run lint`

Test Plan:
**Local testing**:

1. Install FBX SDK for macOS from https://aps.autodesk.com/developer/overview/fbx-sdk
2. Run:
   ```
   $ MOMENTUM_BUILD_IO_FBX=ON pixi run test_py
   ```

**CI**:

Confirmed that the build passes with MOMENTUM_BUILD_IO_FBX:

- momentum: https://github.com/facebookincubator/momentum/actions/runs/11646358777/job/32430353382#step:5:60
- pymomentum: https://github.com/facebookincubator/momentum/actions/runs/11646358777/job/32430353542#step:5:61

Differential Revision: D65391142

Pulled By: jeongseok-meta
  • Loading branch information
jeongseok-meta committed Nov 3, 2024
1 parent 860837a commit f1f1505
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 34 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/ci_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,21 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install FBX SDK
run: |
curl -O https://damassets.autodesk.net/content/dam/autodesk/www/files/fbx202037_fbxsdk_clang_mac.pkg.tgz
tar -xvf fbx202037_fbxsdk_clang_mac.pkg.tgz
sudo installer -pkg fbx202037_fbxsdk_clang_macos.pkg -target /
- name: Set up pixi
uses: prefix-dev/[email protected]
with:
cache: true

- name: Build and test Momentum
run: |
pixi run test${{ matrix.mode }}
MOMENTUM_BUILD_IO_FBX=ON \
pixi run test${{ matrix.mode }}
- name: Install Momentum and Build hello_world
run: |
Expand All @@ -53,10 +60,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install FBX SDK
run: |
curl -O https://damassets.autodesk.net/content/dam/autodesk/www/files/fbx202037_fbxsdk_clang_mac.pkg.tgz
tar -xvf fbx202037_fbxsdk_clang_mac.pkg.tgz
sudo installer -pkg fbx202037_fbxsdk_clang_macos.pkg -target /
- name: Set up pixi
uses: prefix-dev/[email protected]
with:
cache: true

- name: Build and test PyMomentum
run: |
pixi run test_py
MOMENTUM_BUILD_IO_FBX=ON \
pixi run test_py
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,30 +133,26 @@ Momentum uses OpenFBX to load Autodesk's FBX file format, which is enabled by de

The FBX SDK will be automatically installed when you run `pixi run config`, so no additional steps are required.

##### macOS
##### macOS and Windows

Currently, building with the FBX SDK on macOS is not supported.

##### Windows

You can download it from Autodesk's [website](https://aps.autodesk.com/developer/overview/fbx-sdk) or use [this direct link](https://damassets.autodesk.net/content/dam/autodesk/www/files/fbx202037_fbxsdk_vs2019_win.exe). After installing the SDK, build Momentum from source with `MOMENTUM_BUILD_IO_FBX=ON` option as:
You can download it from Autodesk's [website](https://aps.autodesk.com/developer/overview/fbx-sdk) or use direct links ([macOS](https://damassets.autodesk.net/content/dam/autodesk/www/files/fbx202037_fbxsdk_clang_mac.pkg.tgz), [Windows](https://damassets.autodesk.net/content/dam/autodesk/www/files/fbx202037_fbxsdk_vs2019_win.exe)). After installing the SDK, build Momentum from source with `MOMENTUM_BUILD_IO_FBX=ON` option as:

```
# Powershell
# macOS
MOMENTUM_BUILD_IO_FBX=ON pixi run <target>
# Windows (Powershell)
$env:MOMENTUM_BUILD_IO_FBX = "ON"; pixi run <target>
# cmd
# Windows (cmd)
set MOMENTUM_BUILD_IO_FBX=ON && pixi run <target>
```

For example, file conversion can be run as follows:

```
# Powershell
# Windows (Powershell)
$env:MOMENTUM_BUILD_IO_FBX = "ON"; pixi run convert_model -d <input.glb> -o <out.fbx>
# cmd
set MOMENTUM_BUILD_IO_FBX=ON && pixi run convert_model -d <input.glb> -o <out.fbx>
```

## 📖 Documentation
Expand Down
4 changes: 2 additions & 2 deletions cmake/FindFbxSdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ set(
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
list(APPEND FBXSDK_LIBRARIES "-framework CoreFoundation")
list(APPEND FBXSDK_LIBRARIES_DEBUG "-framework CoreFoundation")
find_package(Iconv CONFIG QUIET)
find_package(LibXml2 CONFIG QUIET)
find_package(iconv CONFIG QUIET)
list(APPEND FBXSDK_LIBRARIES LibXml2::LibXml2 Iconv::Iconv)
list(APPEND FBXSDK_LIBRARIES_DEBUG LibXml2::LibXml2 Iconv::Iconv)
list(APPEND required_vars LIBXML2_LIBRARIES iconv_FOUND)
list(APPEND required_vars LibXml2_FOUND Iconv_FOUND)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(LibXml2 MODULE QUIET)
list(APPEND FBXSDK_LIBRARIES LibXml2::LibXml2)
Expand Down
42 changes: 42 additions & 0 deletions cmake/FindIconv.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# This module defines
# Iconv_FOUND : Variable indicating if the iconv support was found.
# Iconv_INCLUDE_DIRS: The directories containing the iconv headers.
# Iconv_LIBRARIES : The iconv libraries to be linked.
# Iconv::Iconv :IMPORTED target

execute_process(
COMMAND xcrun --sdk macosx --show-sdk-path
OUTPUT_VARIABLE XCODE_SDK_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

find_path(
Iconv_INCLUDE_DIR "iconv.h"
PATHS "${XCODE_SDK_PATH}/usr/include"
PATH_SUFFIXES "include"
)

find_library(Iconv_LIBRARY NAMES iconv
PATHS "${XCODE_SDK_PATH}/usr/lib"
NO_DEFAULT_PATH
)
set(Iconv_LIBRARIES ${Iconv_LIBRARY})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Iconv
FAIL_MESSAGE DEFAULT_MGS
REQUIRED_VARS Iconv_INCLUDE_DIR Iconv_LIBRARIES
)

if(Iconv_FOUND)
add_library(Iconv::Iconv INTERFACE IMPORTED)
set_target_properties(Iconv::Iconv PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Iconv_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${Iconv_LIBRARIES}"
)
endif()
20 changes: 8 additions & 12 deletions momentum/website/docs/02_user_guide/01_getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,28 +112,24 @@ Momentum uses OpenFBX to load Autodesk's FBX file format, which is enabled by de

The FBX SDK will be automatically installed when you run `pixi run config`, so no additional steps are required.

#### macOS
#### macOS and Windows

Currently, building with the FBX SDK on macOS is not supported.

#### Windows

You can download it from Autodesk's [website](https://aps.autodesk.com/developer/overview/fbx-sdk) or use [this direct link](https://damassets.autodesk.net/content/dam/autodesk/www/files/fbx202037_fbxsdk_vs2019_win.exe). After installing the SDK, build Momentum from source with `MOMENTUM_BUILD_IO_FBX=ON` option as:
You can download it from Autodesk's [website](https://aps.autodesk.com/developer/overview/fbx-sdk) or use direct links ([macOS](https://damassets.autodesk.net/content/dam/autodesk/www/files/fbx202037_fbxsdk_clang_mac.pkg.tgz), [Windows](https://damassets.autodesk.net/content/dam/autodesk/www/files/fbx202037_fbxsdk_vs2019_win.exe)). After installing the SDK, build Momentum from source with `MOMENTUM_BUILD_IO_FBX=ON` option as:

```
# Powershell
# macOS
MOMENTUM_BUILD_IO_FBX=ON pixi run <target>
# Windows (Powershell)
$env:MOMENTUM_BUILD_IO_FBX = "ON"; pixi run <target>
# cmd
# Windows (cmd)
set MOMENTUM_BUILD_IO_FBX=ON && pixi run <target>
```

For example, file conversion can be run as follows:

```
# Powershell
# Windows (Powershell)
$env:MOMENTUM_BUILD_IO_FBX = "ON"; pixi run convert_model -d <input.glb> -o <out.fbx>
# cmd
set MOMENTUM_BUILD_IO_FBX=ON && pixi run convert_model -d <input.glb> -o <out.fbx>
```
12 changes: 6 additions & 6 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,15 @@ pytorch = ">=2.4.0"
[target.osx.tasks]
build_py = { cmd = """
python setup.py build_ext --cmake-args='\
-DMOMENTUM_BUILD_IO_FBX=OFF \
-DMOMENTUM_BUILD_IO_FBX=$MOMENTUM_BUILD_IO_FBX \
-DMOMENTUM_BUILD_EXAMPLES=OFF \
-DMOMENTUM_BUILD_TESTING=ON \
-DMOMENTUM_ENABLE_SIMD=ON \
-DMOMENTUM_ENABLE_SIMD=$MOMENTUM_ENABLE_SIMD \
-DMOMENTUM_USE_SYSTEM_GOOGLETEST=ON \
-DMOMENTUM_USE_SYSTEM_PYBIND11=ON \
-DMOMENTUM_USE_SYSTEM_RERUN_CPP_SDK=ON \
'
""" }
""", env = { MOMENTUM_BUILD_IO_FBX = "OFF", MOMENTUM_ENABLE_SIMD = "ON" } }
test_py = { cmd = """
pytest \
pymomentum/test/test_closest_points.py \
Expand All @@ -229,15 +229,15 @@ pytorch = ">=2.4.0"
[target.osx-arm64.tasks]
build_py = { cmd = """
python setup.py build_ext --cmake-args='\
-DMOMENTUM_BUILD_IO_FBX=OFF \
-DMOMENTUM_BUILD_IO_FBX=$MOMENTUM_BUILD_IO_FBX \
-DMOMENTUM_BUILD_EXAMPLES=OFF \
-DMOMENTUM_BUILD_TESTING=ON \
-DMOMENTUM_ENABLE_SIMD=ON \
-DMOMENTUM_ENABLE_SIMD=$MOMENTUM_ENABLE_SIMD \
-DMOMENTUM_USE_SYSTEM_GOOGLETEST=ON \
-DMOMENTUM_USE_SYSTEM_PYBIND11=ON \
-DMOMENTUM_USE_SYSTEM_RERUN_CPP_SDK=ON \
'
""" }
""", env = { MOMENTUM_BUILD_IO_FBX = "OFF", MOMENTUM_ENABLE_SIMD = "ON" } }
test_py = { cmd = """
pytest \
pymomentum/test/test_closest_points.py \
Expand Down

0 comments on commit f1f1505

Please sign in to comment.