-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmake-windows.bat
More file actions
110 lines (84 loc) · 2.44 KB
/
cmake-windows.bat
File metadata and controls
110 lines (84 loc) · 2.44 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
@echo off
:: Default installation path
@if "%OPENSSL_PATH%"=="" @set OPENSSL_PATH=C:\OpenSSL-Win32
@if "%1%"=="2008" @set MSVC_VERSION=2008
@if "%2%"=="2008" @set MSVC_VERSION=2008
@if "%MSVC_VERSION%"=="" @set MSVC_VERSION=2010
@set BUILD_TYPE=Debug
@set _=%CD%
@set BUILD_TOOL=nmake
@if "%QT_ROOT%"=="" @set QT_ROOT=%_%/qt
@set BUILD_TEST=false
@set BUILD_PACKAGE=false
@if "%1%"=="test" @set BUILD_TEST=true
@if "%1%"=="package" @set BUILD_PACKAGE=true
@if "%2%"=="test" @set BUILD_TEST=true
@if "%2%"=="package" @set BUILD_PACKAGE=true
@if "%1%"=="release" @set BUILD_TYPE=Release
@if "%1%"=="Release" @set BUILD_TYPE=Release
@call :setup_jom_buildtool
@call :check_openssl || goto error
@call :print_info
@call :setup_environment_if_need || goto error
:Cleanup
@rm -rf bin
@rm -rf build
:Build
@mkdir build || goto error
@pushd build || goto error
@cmake -DCMAKE_BUILD_TYPE=Release -G"NMake Makefiles" -DQT_QMAKE_EXECUTABLE=%QT_ROOT%/bin/qmake.exe .. || goto error
@nmake || goto error
@if "%BUILD_TEST%" == "true" (
@nmake test
)
@if "%BUILD_PACKAGE%" == "true" (
@nmake package
)
@popd
@echo -- Project sucessfully built!
@exit /B 0
:: --- Helpers
:setup_jom_buildtool
@call :getcpucorescount
@echo -- CPUs: %CPU_CORE_COUNT%
@echo TODO: add jom.exe here
@exit /B 0
:getcpucorescount
@call :gettempfilename
@WMIC CPU Get NumberOfLogicalProcessors /Format:List > %TMPFILE%
@for /F "tokens=2 delims=\=" %%i in ('type %TMPFILE%') do @set CPU_CORE_COUNT=%%i
@rm -f %TMPFILE%
@exit /B 0
:gettempfilename
@set TMPFILE=%TMP%\mytempfile-%RANDOM%-%RANDOM%.tmp
@if exist "%TMPFILE%" GOTO :gettempfilename
@exit /B 0
:check_openssl
@if not exist %OPENSSL_PATH% (
@echo OpenSSL Win32 was not found. Please make sure you have it installed or you have OPENSSL_PATH env variable pointing to your custom installation directory
@echo You can install OpenSSL Win32 by downloading it from http://slproweb.com/download/Win32OpenSSL-1_0_1e.exe
@exit /B 1
)
@exit /B 0
:print_info
@echo -- Build type is %BUILD_TYPE%
@echo -- MSVC version: %MSVC_VERSION%
@exit /B 0
:setup_environment_if_need
@if not "%ENVIRONMENT_DONE%" == "OK" (
@echo -- Setting up MSVC environment
@call :setup_environment
@set ENVIRONMENT_DONE=OK
)
@exit /B 0
:setup_environment
@if %MSVC_VERSION% == 2008 (
@call "%VS90COMNTOOLS%\vsvars32.bat"
) else (
@call "%VS100COMNTOOLS%\vsvars32.bat"
)
@exit /B 0
:error
@cd %_%
@echo -- Project build FAILED
@exit /B 1