Skip to content

add flag to specify demo #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,26 @@ For example:
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON <open_model_zoo>/demos
```

### <a name="build_specific_demos"></a>Build Specific Demos

To build specific demos, follow the instructions for building the demo applications above,
but add `--target <list of demos>` to the `cmake` or `--target="<list of demos>"` to the `build_demos*` command.
Note, CMake `--build` tool supports multiple targets starting with version 3.15. With lower versions you can specify only one target.
For example:

```sh
cmake -DCMAKE_BUILD_TYPE=Release <open_model_zoo>/demos
cmake --build . --config Release --target <Demo_1> <Demo_2>
```

```sh
build_demos.sh --target="classification_demo segmentation_demo"
```

```bat
build_demos_msvc.bat --target="classification_demo segmentation_demo"
```

## Get Ready for Running the Demo Applications

### Get Ready for Running the Demo Applications on Linux*
Expand Down
11 changes: 9 additions & 2 deletions demos/build_demos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ error() {
trap 'error ${LINENO}' ERR

extra_cmake_opts=()
extra_cmake_build_opts=()

for opt in "$@"; do
case "$opt" in
-DENABLE_PYTHON=*)
extra_cmake_opts+=("$opt")
;;
--target=*)
tmp="${opt%\"}"
tmp="${tmp#\"}"
extra_cmake_build_opts+=("${tmp//=/ }")
;;
*)
printf "Unknown option: %q\n" "$opt"
exit 1
Expand Down Expand Up @@ -82,6 +88,7 @@ fi
mkdir -p "$build_dir"

(cd "$build_dir" && cmake -DCMAKE_BUILD_TYPE=Release "${extra_cmake_opts[@]}" "$DEMOS_PATH")
cmake --build "$build_dir" -- "$NUM_THREADS"
c="cmake --build $build_dir ${extra_cmake_build_opts[@]} -- $NUM_THREADS"
eval "$c"

printf "\nBuild completed, you can find binaries for all demos in the %s subfolder.\n\n" "$build_dir/$OS_PATH/Release"
printf "\nBuild completed, you can find binaries for demos in the %s subfolder.\n\n" "$build_dir/$OS_PATH/Release"
11 changes: 9 additions & 2 deletions demos/build_demos_msvc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ if not "%1" == "" (
shift & shift
goto argParse
)
rem to build more than one specific demo use quotation marks,
rem list the necessary demos separated by space,
rem ex. --target="classification_demo segmentation_demo"
if "%1" == "--target" (
set EXTRA_CMAKE_BUILD_OPTS=%EXTRA_CMAKE_BUILD_OPTS% %1 %~2
shift & shift
goto argParse
)

if not "%VS_VERSION%" == "" (
echo Unexpected argument: "%1"
Expand Down Expand Up @@ -122,8 +130,7 @@ cd "%SOLUTION_DIR64%" && cmake -G "Visual Studio !VS_VERSION!" -A %PLATFORM% %EX
echo.
echo ###############^|^| Build Open Model Zoo Demos using MS Visual Studio ^|^|###############
echo.
echo cmake --build . --config Release
cmake --build . --config Release
cmake --build . --config Release %EXTRA_CMAKE_BUILD_OPTS%
if ERRORLEVEL 1 goto errorHandling

echo Done.
Expand Down