Skip to content

Commit 8ec0af9

Browse files
larryliu0820facebook-github-bot
authored andcommitted
Extend setup cmake ability (#3349)
Summary: For executorch users, we see a common pattern that they have to: ```bash bash install_requirements.sh --pybind xnnpack cmake -S . -Bcmake-out ... cmake --build ... ``` This is repeating cmake build twice, the first one is inside setup.py. Here I'm adding a way to allow setup.py to install the libraries seperately, by passing `CMAKE_ARGS` and `CMAKE_BUILD_ARGS` into setup.py, through `install_requirements.sh`. After this change, user can do: ```bash export CMAKE_ARGS="-DCMAKE_INSTALL_PREFIX=<install dir> \ -DEXECUTORCH_BUILD_OPTIMIZED=ON \ ..." export CMAKE_BUILD_ARGS="--target install" bash install_requirements.sh --pybind xnnpack ``` Then we should be able to find `libxnnpack.a` `liboptimized_ops_lib.a` etc under install dir. Pull Request resolved: #3349 Reviewed By: mikekgfb Differential Revision: D56560786 Pulled By: larryliu0820 fbshipit-source-id: fb6cd230df2317067f07ae0f1e72d0596b7b454b
1 parent 319a4f2 commit 8ec0af9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

install_requirements.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ fi
2727

2828
# Parse options.
2929
EXECUTORCH_BUILD_PYBIND=OFF
30-
CMAKE_ARGS=""
3130

3231
for arg in "$@"; do
3332
case $arg in
@@ -110,4 +109,5 @@ $PIP_EXECUTABLE install --extra-index-url "${TORCH_NIGHTLY_URL}" \
110109

111110
EXECUTORCH_BUILD_PYBIND="${EXECUTORCH_BUILD_PYBIND}" \
112111
CMAKE_ARGS="${CMAKE_ARGS}" \
112+
CMAKE_BUILD_ARGS="${CMAKE_BUILD_ARGS}" \
113113
$PIP_EXECUTABLE install . --no-build-isolation -v

setup.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,14 @@ def run(self):
399399
if "CMAKE_ARGS" in os.environ:
400400
cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" ") if item]
401401

402+
# Allow adding extra build args through the environment. Used by some
403+
# tests and demos to expand the set of targets included in the pip
404+
# package.
405+
if "CMAKE_BUILD_ARGS" in os.environ:
406+
build_args += [
407+
item for item in os.environ["CMAKE_BUILD_ARGS"].split(" ") if item
408+
]
409+
402410
# Put the cmake cache under the temp directory, like
403411
# "pip-out/temp.<plat>/cmake-out".
404412
cmake_cache_dir = os.path.join(repo_root, self.build_temp, "cmake-out")

0 commit comments

Comments
 (0)