compileMsbuild.bat 1.45 KB
Newer Older
1 2 3

@echo off

4 5
:: add *_HOME to PATH temporarily
IF NOT [%cmake_HOME%] == [] (
6
	set PATH="%cmake_HOME%;%PATH%"
7 8
)
IF NOT [%msbuild_HOME%] == [] (
9
	set PATH="%msbuild_HOME%;%PATH%"
10 11 12 13 14
)

:: check if needed programs are in PATH
where cmake
IF NOT %ERRORLEVEL% EQU 0 (
15
	echo "Can not find cmake in PATH! Aborting."
16
    echo "Try setting the environment variable cmake_HOME to the base of your installation or adding it to your PATH!"
17
	exit /B 1
18 19 20
)
where vcvars64.bat
IF NOT %ERRORLEVEL% EQU 0 (
21
	echo "Can not find vcvars64.bat in PATH! Aborting."
22
    echo "Try setting the environment variable msbuild_HOME to the base of your installation or adding it to your PATH!"
23
	exit /B 1
24
)
25 26 27 28 29 30

:: source additional environment variables
call vcvars64.bat
call %ROS2_HOME%\local_setup.bat

:: Post source check if needed programs are in PATH
31 32
where msbuild
IF NOT %ERRORLEVEL% EQU 0 (
33
	echo "Can not find msbuild in PATH! Aborting."
34
    echo "Try setting the environment variable msbuild_HOME to the base of your installation or adding it to your PATH!"
35
	exit /B 1
36
)
37 38
where ros2
IF NOT %ERRORLEVEL% EQU 0 (
39
	echo "Can not find ros2 in PATH! Aborting."
40
    echo "Try setting the environment variable ROS2_HOME to the base of your installation or adding it to your PATH!"
41
	exit /B 1
42
)
43

44 45 46 47 48
SET curDir=%~dp0
:: configure cmake
cmake -B%curDir%/build/ -H%curDir%/src/ -DCMAKE_INSTALL_PREFIX=%curDir%/install -G "Visual Studio 15 2017 Win64" %*
:: build
cmake --build %curDir%/build/ --target install --config Release