Skip to content

Commit fa42441

Browse files
jeongseok-metafacebook-github-bot
authored andcommitted
Build with FBX SDK by default on Ubuntu (#117)
Summary: - Add find module for FBX SDK (i.e., `FindFbxSdk.cmake`) to consolidate the find logic for multiple OSes -- macOS still doesn't work - Install FBX SDK on Linux when running pixi tasks - Run CI for Linux building with FBX SDK ## Checklist: - [x] Adheres to the [style guidelines](https://facebookincubator.github.io/momentum/docs/developer_guide/style_guide) - [x] Codebase formatted by running `pixi run lint` Pull Request resolved: #117 Test Plan: Linux: ``` pixi run test # no need to specify MOMENTUM_BUILD_IO_FBX explicitly ``` Windows: ``` $env:MOMENTUM_BUILD_IO_FBX = "ON"; pixi run test ``` macOS: not supported yet Reviewed By: nickyhe-gemini Differential Revision: D65119483 Pulled By: jeongseok-meta fbshipit-source-id: c7bdf08a71018c11e7f24a2f78b1cb9d7b384395
1 parent 06ac5cf commit fa42441

File tree

6 files changed

+174
-41
lines changed

6 files changed

+174
-41
lines changed

.github/workflows/ci_ubuntu.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,29 @@ on:
1414

1515
jobs:
1616
momentum:
17-
name: momentum-simd:${{ matrix.simd }}-ubuntu
17+
name: momentum${{ matrix.simd == 'ON' && '-simd' || '' }}-ubuntu
1818
runs-on: ubuntu-latest
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
include:
23-
- simd: "ON"
24-
pymomentum: "ON"
25-
- simd: "OFF"
26-
pymomentum: "OFF"
22+
simd: ["ON", "OFF"]
2723
env:
2824
MOMENTUM_ENABLE_SIMD: ${{ matrix.simd }}
2925
steps:
3026
- name: Checkout
3127
uses: actions/checkout@v4
28+
3229
- name: Set up pixi
3330
uses: prefix-dev/setup-pixi@v0.8.1
3431
with:
3532
cache: true
33+
3634
- name: Build and test Momentum
3735
run: |
3836
MOMENTUM_BUILD_PYMOMENTUM=$MOMENTUM_BUILD_PYMOMENTUM \
3937
MOMENTUM_ENABLE_SIMD=$MOMENTUM_ENABLE_SIMD \
4038
pixi run test
39+
4140
- name: Install Momentum and Build hello_world
4241
run: |
4342
MOMENTUM_BUILD_PYMOMENTUM=$MOMENTUM_BUILD_PYMOMENTUM \

CMakeLists.txt

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -316,35 +316,9 @@ mt_library(
316316
)
317317

318318
if(MOMENTUM_BUILD_IO_FBX)
319-
if(DEFINED ENV{FBXSDK_PATH})
320-
set(fbxsdk_path $ENV{FBXSDK_PATH})
321-
else()
322-
set(fbxsdk_path "C:/Program Files/Autodesk/FBX/FBX SDK/2020.3.7")
323-
endif()
324-
325-
if(NOT EXISTS "${fbxsdk_path}")
326-
message(FATAL_ERROR "The FBX SDK path '${fbxsdk_path}' does not exist. Please download the required FBX SDK 2020.3 from https://aps.autodesk.com/developer/overview/fbx-sdk or https://damassets.autodesk.net/content/dam/autodesk/www/files/fbx202037_fbxsdk_vs2019_win.exe. After installation, set FBXSDK_PATH to the installation directory if it's not installed to the default path.")
327-
endif()
328-
329-
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
330-
set(io_fbx_sources_var io_fbx_sources)
331-
set(fbxsdk_libs
332-
"${fbxsdk_path}/lib/x64/release/libfbxsdk-md.lib"
333-
"${fbxsdk_path}/lib/x64/release/libxml2-md.lib"
334-
"${fbxsdk_path}/lib/x64/release/zlib-md.lib"
335-
)
336-
else()
337-
message(FATAL_ERROR "Unsupported platform")
338-
endif()
339-
340-
mt_library(
341-
NAME fbxsdk
342-
PUBLIC_INCLUDE_DIRECTORIES
343-
"${fbxsdk_path}/include"
344-
PUBLIC_LINK_LIBRARIES
345-
${fbxsdk_libs}
346-
)
347-
set(io_fbx_private_link_libraries fbxsdk)
319+
set(io_fbx_sources_var io_fbx_sources)
320+
find_package(FbxSdk MODULE REQUIRED)
321+
set(io_fbx_private_link_libraries fbxsdk::fbxsdk)
348322
else()
349323
set(io_fbx_sources_var io_fbx_sources_unsupported)
350324
set(io_fbx_private_link_libraries )

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,21 @@ pixi run clean
125125

126126
Momentum uses the `build/` directory for CMake builds, and `.pixi/` for the Pixi virtual environment. You can clean up everything by either manually removing these directories or by running the command above.
127127

128-
#### FBX support (Windows only)
128+
#### FBX Support
129129

130-
Momentum uses OpenFBX to load Autodesk's FBX file format, which is built by default. To save files in FBX format, you need to install the FBX SDK 2020.3. 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:
130+
Momentum uses OpenFBX to load Autodesk's FBX file format, which is enabled by default. To save files in FBX format, you must install the FBX SDK 2020.3.
131+
132+
##### Linux
133+
134+
The FBX SDK will be automatically installed when you run `pixi run config`, so no additional steps are required.
135+
136+
##### macOS
137+
138+
Currently, building with the FBX SDK on macOS is not supported.
139+
140+
##### Windows
141+
142+
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:
131143

132144
```
133145
# Powershell

cmake/FindFbxSdk.cmake

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
set(_fbxsdk_version "2020.3.7")
7+
8+
message(DEBUG "Looking for FBX SDK version: ${_fbxsdk_version}")
9+
10+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
11+
set(_fbxsdk_approot "/Applications/Autodesk/FBX SDK")
12+
set(_fbxsdk_libdir_release "lib/clang/release")
13+
set(_fbxsdk_libdir_debug "lib/clang/debug")
14+
list(APPEND _fbxsdk_libnames_release "libalembic.a" "libfbxsdk.a")
15+
list(APPEND _fbxsdk_libnames_debug "libalembic.a" "libfbxsdk.a")
16+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
17+
set(_fbxsdk_approot "C:/Program Files/Autodesk/FBX/FBX SDK")
18+
set(_fbxsdk_libdir_release "lib/x64/release")
19+
set(_fbxsdk_libdir_debug "lib/x64/debug")
20+
list(APPEND _fbxsdk_libnames_release "libfbxsdk-md.lib" "alembic-md.lib" "libxml2-md.lib" "zlib-md.lib")
21+
list(APPEND _fbxsdk_libnames_debug "libfbxsdk-md.lib" "alembic-md.lib" "libxml2-md.lib" "zlib-md.lib")
22+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
23+
set(_fbxsdk_approot "/usr/fbxsdk")
24+
set(_fbxsdk_libdir_release "lib/release")
25+
set(_fbxsdk_libdir_debug "lib/debug")
26+
list(APPEND _fbxsdk_libnames_release "libalembic.a" "libfbxsdk.a")
27+
list(APPEND _fbxsdk_libnames_debug "libalembic.a" "libfbxsdk.a")
28+
else()
29+
message(FATAL_ERROR "Unsupported OS: ${CMAKE_SYSTEM_NAME}")
30+
endif()
31+
32+
# overwrite if FBXSDK_PATH is defined
33+
if(DEFINED ENV{FBXSDK_PATH})
34+
set(_fbxsdk_approot "$ENV{FBXSDK_PATH}")
35+
endif()
36+
37+
# should point the the FBX SDK installation dir
38+
set(_fbxsdk_root "${_fbxsdk_approot}/${_fbxsdk_version}")
39+
message(DEBUG "_fbxsdk_root: ${_fbxsdk_root}")
40+
41+
# find header dir
42+
find_path(
43+
FBXSDK_INCLUDE_DIR "fbxsdk.h"
44+
PATHS ${_fbxsdk_root}
45+
PATH_SUFFIXES "include"
46+
)
47+
message(DEBUG "FBXSDK_INCLUDE_DIR: ${FBXSDK_INCLUDE_DIR}")
48+
49+
# find release libs
50+
foreach(libname ${_fbxsdk_libnames_release})
51+
find_library(
52+
lib_${libname} ${libname}
53+
PATHS ${_fbxsdk_root}
54+
PATH_SUFFIXES ${_fbxsdk_libdir_release}
55+
)
56+
list(APPEND FBXSDK_LIBRARIES ${lib_${libname}})
57+
endforeach()
58+
message(DEBUG "FBXSDK_LIBRARIES: ${FBXSDK_LIBRARIES}")
59+
60+
# find debug libs
61+
foreach(libname ${_fbxsdk_libnames_debug})
62+
find_library(
63+
lib_${libname}_debug ${libname}
64+
PATHS ${_fbxsdk_root}
65+
PATH_SUFFIXES ${_fbxsdk_libdir_debug}
66+
)
67+
list(APPEND FBXSDK_LIBRARIES_DEBUG ${lib_${libname}_debug})
68+
endforeach()
69+
message(DEBUG "FBXSDK_LIBRARIES_DEBUG: ${FBXSDK_LIBRARIES_DEBUG}")
70+
71+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
72+
list(APPEND FBXSDK_LIBRARIES "-framework CoreFoundation")
73+
list(APPEND FBXSDK_LIBRARIES_DEBUG "-framework CoreFoundation")
74+
find_package(libxml2 CONFIG QUIET)
75+
find_package(iconv CONFIG QUIET)
76+
list(APPEND FBXSDK_LIBRARIES LibXml2::LibXml2 Iconv::Iconv)
77+
list(APPEND FBXSDK_LIBRARIES_DEBUG LibXml2::LibXml2 Iconv::Iconv)
78+
endif()
79+
80+
# Set (NAME)_FOUND if all the variables and the version are satisfied.
81+
include(FindPackageHandleStandardArgs)
82+
find_package_handle_standard_args(FbxSdk
83+
FAIL_MESSAGE "Failed to find FBX SDK. Please download the required FBX SDK 2020.3.7 from https://aps.autodesk.com/developer/overview/fbx-sdk. After installation, set FBXSDK_PATH to the installation directory if it's not installed to the default path."
84+
REQUIRED_VARS
85+
FBXSDK_INCLUDE_DIR
86+
FBXSDK_LIBRARIES
87+
FBXSDK_LIBRARIES_DEBUG
88+
VERSION_VAR _fbxsdk_version
89+
)
90+
91+
if(FbxSdk_FOUND)
92+
add_library(fbxsdk::fbxsdk INTERFACE IMPORTED)
93+
set_target_properties(fbxsdk::fbxsdk PROPERTIES
94+
INTERFACE_INCLUDE_DIRECTORIES "${FBXSDK_INCLUDE_DIR}"
95+
INTERFACE_LINK_LIBRARIES "${FBXSDK_LIBRARIES}"
96+
)
97+
98+
add_library(fbxsdk::fbxsdk_debug INTERFACE IMPORTED)
99+
set_target_properties(fbxsdk::fbxsdk_debug PROPERTIES
100+
INTERFACE_INCLUDE_DIRECTORIES "${FBXSDK_INCLUDE_DIR}"
101+
INTERFACE_LINK_LIBRARIES "${FBXSDK_LIBRARIES_DEBUG}"
102+
)
103+
endif()

momentum/website/docs/02_user_guide/01_getting_started.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,21 @@ pixi run clean
104104

105105
Momentum uses the `build/` directory for CMake builds, and `.pixi/` for the Pixi virtual environment. You can clean up everything by either manually removing these directories or by running the command above.
106106

107-
### FBX support (Windows only)
107+
### FBX Support
108108

109-
Momentum uses OpenFBX to load Autodesk's FBX file format, which is built by default. To save files in FBX format, you need to install the FBX SDK 2020.3. 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:
109+
Momentum uses OpenFBX to load Autodesk's FBX file format, which is enabled by default. To save files in FBX format, you must install the FBX SDK 2020.3.
110+
111+
#### Linux
112+
113+
The FBX SDK will be automatically installed when you run `pixi run config`, so no additional steps are required.
114+
115+
#### macOS
116+
117+
Currently, building with the FBX SDK on macOS is not supported.
118+
119+
#### Windows
120+
121+
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:
110122

111123
```
112124
# Powershell

pixi.toml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ config = { cmd = """
5252
-G Ninja \
5353
-DCMAKE_BUILD_TYPE=Release \
5454
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
55-
-DMOMENTUM_BUILD_IO_FBX=OFF \
55+
-DMOMENTUM_BUILD_IO_FBX=$MOMENTUM_BUILD_IO_FBX \
5656
-DMOMENTUM_BUILD_TESTING=ON \
5757
-DMOMENTUM_BUILD_EXAMPLES=ON \
5858
-DMOMENTUM_BUILD_PYMOMENTUM=$MOMENTUM_BUILD_PYMOMENTUM \
5959
-DMOMENTUM_ENABLE_SIMD=$MOMENTUM_ENABLE_SIMD \
6060
-DMOMENTUM_USE_SYSTEM_GOOGLETEST=ON \
6161
-DMOMENTUM_USE_SYSTEM_PYBIND11=ON \
6262
-DMOMENTUM_USE_SYSTEM_RERUN_CPP_SDK=ON
63-
""", env = { MOMENTUM_ENABLE_SIMD = "ON", MOMENTUM_BUILD_PYMOMENTUM = "ON" } }
63+
""", env = { MOMENTUM_BUILD_IO_FBX = "OFF", MOMENTUM_ENABLE_SIMD = "ON", MOMENTUM_BUILD_PYMOMENTUM = "ON" } }
6464
build = { cmd = "cmake --build build -j --target all", depends_on = ["config"] }
6565
test = { cmd = "ctest --test-dir build --output-on-failure", depends_on = [
6666
"build",
@@ -86,6 +86,39 @@ pytorch = ">=2.4.0"
8686
sysroot_linux-64 = ">=2.28"
8787

8888
[target.linux-64.tasks]
89+
# TODO: Check sha256 of fbx202037_fbxsdk_linux
90+
install_fbxsdk = { cmd = """
91+
mkdir -p .deps \
92+
&& curl -fsSL https://damassets.autodesk.net/content/dam/autodesk/www/files/fbx202037_fbxsdk_gcc_linux.tar.gz -o .deps/fbx_sdk.tar.gz \
93+
&& mkdir -p .deps/fbxsdk_download \
94+
&& tar -xzf .deps/fbx_sdk.tar.gz -C .deps/fbxsdk_download \
95+
&& rm .deps/fbx_sdk.tar.gz \
96+
&& chmod ugo+x .deps/fbxsdk_download/fbx202037_fbxsdk_linux \
97+
&& mkdir -p .deps/fbxsdk/2020.3.7 \
98+
&& yes yes | .deps/fbxsdk_download/fbx202037_fbxsdk_linux .deps/fbxsdk/2020.3.7 \
99+
&& rm -rf .deps/fbxsdk_download/fbx202037_fbxsdk_linux
100+
""", outputs = [
101+
".deps/fbxsdk/2020.3.7",
102+
] }
103+
install_deps = { depends_on = ["install_fbxsdk"] }
104+
config = { cmd = """
105+
cmake \
106+
-S . \
107+
-B build \
108+
-G Ninja \
109+
-DCMAKE_BUILD_TYPE=Release \
110+
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
111+
-DMOMENTUM_BUILD_IO_FBX=ON \
112+
-DMOMENTUM_BUILD_TESTING=ON \
113+
-DMOMENTUM_BUILD_EXAMPLES=ON \
114+
-DMOMENTUM_BUILD_PYMOMENTUM=$MOMENTUM_BUILD_PYMOMENTUM \
115+
-DMOMENTUM_ENABLE_SIMD=$MOMENTUM_ENABLE_SIMD \
116+
-DMOMENTUM_USE_SYSTEM_GOOGLETEST=ON \
117+
-DMOMENTUM_USE_SYSTEM_PYBIND11=ON \
118+
-DMOMENTUM_USE_SYSTEM_RERUN_CPP_SDK=ON
119+
""", env = { FBXSDK_PATH = ".deps/fbxsdk", MOMENTUM_ENABLE_SIMD = "ON", MOMENTUM_BUILD_PYMOMENTUM = "ON" }, depends_on = [
120+
"install_deps",
121+
] }
89122
build_pymomentum = { cmd = "pip install -e ." }
90123
test_pymomentum = { cmd = """
91124
pytest \

0 commit comments

Comments
 (0)