@echo off

if DEFINED DESTDIR (
  echo "Destdir.............%DESTDIR%"
  set DESTDIR_ARG="--root=%DESTDIR%"
)

cd "@INSTALL_CMD_WORKING_DIRECTORY@"

if NOT EXIST "@SETUPTOOLS_INSTALL_PREFIX@\@PYTHON_INSTALL_DIR@\" (
  mkdir "@SETUPTOOLS_INSTALL_PREFIX@\@PYTHON_INSTALL_DIR@"
)

set "PYTHONPATH=@SETUPTOOLS_INSTALL_PREFIX@\@PYTHON_INSTALL_DIR@;@CMAKE_BINARY_DIR@\@PYTHON_INSTALL_DIR@"
set "CATKIN_BINARY_DIR=@CMAKE_BINARY_DIR@"
for /f "usebackq tokens=*" %%a in ('@SETUPTOOLS_INSTALL_PREFIX@') do (
  set _SETUPTOOLS_INSTALL_PATH=%%~pna
  set _SETUPTOOLS_INSTALL_ROOT=%%~da
)

"@PYTHON_EXECUTABLE@" ^
    "@CMAKE_CURRENT_SOURCE_DIR@\setup.py" ^
    build --build-base "@CMAKE_CURRENT_BINARY_DIR@" ^
    install %DESTDIR_ARG% @SETUPTOOLS_ARG_EXTRA@ ^
    --prefix="%_SETUPTOOLS_INSTALL_PATH%" ^
    --install-scripts="%_SETUPTOOLS_INSTALL_PATH%\@CATKIN_GLOBAL_BIN_DESTINATION@" ^
    --root=%_SETUPTOOLS_INSTALL_ROOT%\
