83 lines
1.9 KiB
Batchfile
83 lines
1.9 KiB
Batchfile
@echo off
|
|
setlocal
|
|
|
|
:: Configuration
|
|
set "CMAKE_ARGS=-DCMAKE_PREFIX_PATH=C:/local -G Ninja -DCMAKE_BUILD_TYPE=Release"
|
|
set "BUILD_DIR=build-release"
|
|
set "BUILD_CONFIG=Release"
|
|
set "ERROR_CODE=0"
|
|
|
|
:: Clean up any existing build directory
|
|
if exist "%BUILD_DIR%" (
|
|
echo Removing existing build directory: %BUILD_DIR%
|
|
rmdir /s /q "%BUILD_DIR%"
|
|
if errorlevel 1 (
|
|
echo ERROR: Failed to remove build directory: %BUILD_DIR%
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
:: Create build directory
|
|
if not exist "%BUILD_DIR%" (
|
|
echo Creating build directory: %BUILD_DIR%
|
|
mkdir "%BUILD_DIR%"
|
|
if errorlevel 1 (
|
|
echo ERROR: Failed to create build directory: %BUILD_DIR%
|
|
exit /b 1
|
|
)
|
|
)
|
|
|
|
call "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvars64.bat"
|
|
|
|
:: Run CMake configuration
|
|
echo Running CMake configuration...
|
|
cmake -B"%BUILD_DIR%" %CMAKE_ARGS%
|
|
if errorlevel 1 (
|
|
echo ERROR: CMake configuration failed
|
|
set "ERROR_CODE=1"
|
|
goto cleanup
|
|
)
|
|
|
|
:: Build the project
|
|
echo Building project with configuration: %BUILD_CONFIG%
|
|
cmake --build "%BUILD_DIR%" --config %BUILD_CONFIG%
|
|
if errorlevel 1 (
|
|
echo ERROR: Build failed
|
|
set "ERROR_CODE=1"
|
|
goto cleanup
|
|
)
|
|
|
|
:: Change to build directory
|
|
echo Changing to build directory: %BUILD_DIR%
|
|
cd "%BUILD_DIR%"
|
|
if errorlevel 1 (
|
|
echo ERROR: Failed to change to build directory: %BUILD_DIR%
|
|
set "ERROR_CODE=1"
|
|
goto cleanup
|
|
)
|
|
|
|
:: Run CPack
|
|
echo Running CPack...
|
|
cpack
|
|
if errorlevel 1 (
|
|
echo ERROR: CPack failed
|
|
set "ERROR_CODE=1"
|
|
goto cleanup
|
|
)
|
|
|
|
echo.
|
|
echo ========================================
|
|
echo Build and packaging completed successfully!
|
|
echo ========================================
|
|
goto end
|
|
|
|
:cleanup
|
|
if "%ERROR_CODE%"=="1" (
|
|
echo.
|
|
echo ========================================
|
|
echo Build process failed!
|
|
echo ========================================
|
|
)
|
|
|
|
:end
|
|
pause |