-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathbuild.cmd
More file actions
80 lines (66 loc) · 2.2 KB
/
build.cmd
File metadata and controls
80 lines (66 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
@echo off
setlocal
REM Set the path to the LogMonitor folder
set PROJECT_DIR=%~dp0LogMonitor
REM Set up environment variables
set VCPKG_DIR=%~dp0vcpkg
set BUILD_DIR=%~dp0build
set TOOLCHAIN_FILE=%VCPKG_DIR%\scripts\buildsystems\vcpkg.cmake
set BUILD_TYPE=Release
set BUILD_ARCH=x64
set VCPKG_TRIPLET=%BUILD_ARCH%-windows-static
REM Step 1: Clone and bootstrap vcpkg if not already done
if not exist "%VCPKG_DIR%\vcpkg.exe" (
echo === Cloning vcpkg ===
git clone https://github.com/microsoft/vcpkg.git "%VCPKG_DIR%"
echo === Bootstrapping vcpkg ===
pushd "%VCPKG_DIR%"
call .\bootstrap-vcpkg.bat
popd
)
REM Step 2: Locate cmake — prefer PATH, then VS, then vcpkg's downloaded copy
where cmake >nul 2>&1
if errorlevel 1 (
if exist "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" (
set "PATH=%PATH%;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin"
goto cmake_found
)
for /f "delims=" %%i in ('dir /s /b "%VCPKG_DIR%\downloads\tools\cmake-*\bin\cmake.exe" 2^>nul') do (
set "PATH=%PATH%;%%~dpi"
goto cmake_found
)
echo cmake not found. Install cmake or Visual Studio CMake tools.
exit /b 1
)
:cmake_found
REM Step 3: Install nlohmann-json dependencies
echo === Installing nlohmann dependencies ===
"%VCPKG_DIR%\vcpkg.exe" install nlohmann-json:%VCPKG_TRIPLET% --no-binarycaching
if errorlevel 1 (
echo Failed to install nlohmann-json dependencies.
exit /b 1
)
REM Step 4: Create the build directory if it doesn't exist
if not exist "%PROJECT_DIR%\build" (
mkdir "%PROJECT_DIR%\build"
)
REM Navigate into the build directory
cd /d "%PROJECT_DIR%\build"
REM Run CMake configuration with toolchain and triplet
cmake .. ^
-DCMAKE_TOOLCHAIN_FILE=%TOOLCHAIN_FILE% ^
-DCMAKE_BUILD_TYPE=%BUILD_TYPE% ^
-DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET% ^
-A %BUILD_ARCH%
if errorlevel 1 (
echo CMake configuration failed.
exit /b 1
)
REM Build the project
cmake --build . --config %BUILD_TYPE% --parallel
if errorlevel 1 (
echo Build failed.
exit /b 1
)
echo === Build completed successfully ===
endlocal