File: generate_solution.cmd

package info (click to toggle)
lz4 1.10.0-8
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,544 kB
  • sloc: ansic: 19,102; makefile: 1,060; python: 812; sh: 504; cpp: 173
file content (55 lines) | stat: -rw-r--r-- 1,583 bytes parent folder | download | duplicates (3)
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
:: Requires 1 parameter == GENERATOR
@echo off
setlocal

:: Set path
set "BUILD_BASE_DIR=%~dp0"  :: Use the directory where the script is located
set "CMAKELIST_DIR=..\..\cmake"

if "%~1"=="" (
    echo No generator specified as first parameter
    exit /b 1
)
set "GENERATOR=%~1"

:: Check if a user-defined CMAKE_PATH is set and prioritize it
if defined CMAKE_PATH (
    set "CMAKE_EXECUTABLE=%CMAKE_PATH%\cmake.exe"
    echo Using user-defined cmake at %CMAKE_PATH%
) else (
    :: Attempt to find cmake in the system PATH
    where cmake >nul 2>&1
    if %ERRORLEVEL% neq 0 (
        :: Use the default standard cmake installation directory if not found in PATH
        set "CMAKE_PATH=C:\Program Files\CMake\bin"
        echo CMake not in system PATH => using default CMAKE_PATH=%CMAKE_PATH%
        set "CMAKE_EXECUTABLE=%CMAKE_PATH%\cmake.exe"
    ) else (
        set "CMAKE_EXECUTABLE=cmake"
        echo CMake found in system PATH.
    )
)

:: Set the build directory to a subdirectory named after the generator
set "BUILD_DIR=%BUILD_BASE_DIR%\%GENERATOR%"

:: Create the build directory if it doesn't exist
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"

:: Run CMake to configure the project and generate the solution
pushd "%BUILD_DIR%"
"%CMAKE_EXECUTABLE%" -G "%GENERATOR%" "%CMAKELIST_DIR%"
if %ERRORLEVEL% neq 0 goto :error

:: If successful, end script
echo Build configuration successful for %GENERATOR%.
goto :end

:error
echo Failed to configure build for %GENERATOR%.
exit /b 1

:end
popd
endlocal
@echo on