summaryrefslogtreecommitdiff
path: root/build/shared/CMakeUtils.bat
blob: 42e4c5f31199d4601d949504f8b287b955adfaae (plain)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
:: =================================================================================================
:: Copyright 2013 Adobe Systems Incorporated
:: All Rights Reserved.
::
:: NOTICE:  Adobe permits you to use, modify, and distribute this file in accordance with the terms
:: of the Adobe license agreement accompanying it.
:: =================================================================================================

REM Available Arguments:
REM [64|32] Bit Architecture (optional, 64 is default)
REM [2008|2011|2011|2015|2017|2019] VS Version(optional, 2022 is default)
REM [Dynamic | Static] optional, Dynamic by default
REM [WarningAsError] optional
REM [Clean] optional

echo OFF

SETLOCAL
:SetDefaultArguments
set Project=XMP
set CleanCMake=OFF
set XMPROOT=%buildSharedLoc%/../..

:: Default Generator
set GeneratorVersion=Visual Studio 17 2022
set GeneratorArchitecture=x64
set CMake_Arch64Bit=ON
set CMake_ARCH=x64

::Defualt Build Settings
set CMake_BuildStatic=Off
set CMake_Build_Warning_As_Error=Off

:: Folder arguments
set CMake64_Folder_Suffix=_x64
set CMakeGenVersion_FolderSuffix=
set CMake_LibTypeFolderName=dynamic

:: Parse over argumets using loop and shift
:Loop
	if /I "%1"=="" GOTO EndLoop
	
	
	if /I "%1"=="Clean" (
	echo "Clean make specified"
	set CleanCMake=ON
	)

	:: Static/Dynamic
	if /I "%1"=="Static" (
	echo "Static build on"
	set CMake_BuildStatic=On
	set CMake_LibTypeFolderName=static
	)
	if /I "%1"=="Dynamic" (
	echo "Static build off"
	set CMake_BuildStatic=Off
	set CMake_LibTypeFolderName=dynamic
	)

	:: Visual Studio Version
	if /I "%1"=="2022" (
	echo "Generator VS 2022 specified"
	set GeneratorVersion=Visual Studio 17 2022
	set CMakeGenVersion_FolderSuffix=
	)

	if /I "%1"=="WarningAsError" (
	echo "sensible warnings activated"
	set CMake_Build_Warning_As_Error=On
	)

	if /I "%1"=="32" (
	set CMake_ARCH=x86
	set GeneratorArchitecture=Win32
	set CMake_Arch64Bit=OFF
	)

	if /I "%1"=="64" (
	echo 64 bit specified
	set CMake_Arch64Bit=ON
	set CMake_ARCH=x64
	)
	
	shift
	goto Loop

:EndLoop

if "%CMake_Arch64Bit%"=="ON" (
set CMake64_Folder_Suffix=_x64
) else (
set CMake64_Folder_Suffix=
)

:: CMake Folder specified:
set CMakeFolder="vc17/%CMake_LibTypeFolderName%/windows%CMake64_Folder_Suffix%"
echo CMakeFolder: %CMakeFolder%

echo Generator used: %GeneratorVersion%

:: Delete old cmake folder on "clean"
if "%CleanCMake%"=="ON" (
echo deleting folder %CleanCMake%
if exist %CMakeFolder% rmdir /S /Q %CMakeFolder%
)

mkdir %CMakeFolder%
cd %CMakeFolder%
echo cmake ../../../. -G"%GeneratorVersion%" -A %GeneratorArchitecture% -DXMP_CMAKEFOLDER_NAME="%CMakeFolder%" -DCMAKE_CL_64=%CMake_Arch64Bit% -DCMAKE_ARCH=%CMake_ARCH% -DXMP_BUILD_WARNING_AS_ERROR=%CMake_Build_Warning_As_Error% -DXMP_BUILD_STATIC="%CMake_BuildStatic%" 
cmake ../../../. -G"%GeneratorVersion%" -A %GeneratorArchitecture% -DXMP_CMAKEFOLDER_NAME="%CMakeFolder%" -DCMAKE_CL_64=%CMake_Arch64Bit% -DCMAKE_ARCH=%CMake_ARCH% -DXMP_BUILD_WARNING_AS_ERROR=%CMake_Build_Warning_As_Error% -DXMP_BUILD_STATIC="%CMake_BuildStatic%" 

if errorlevel 1 goto error
goto ok

:error
cd ../../..
echo Failed %Project% build cmake.
echo "Exiting CMakeUtils.bat"
exit /B 1

:ok
echo Success %Project% build cmake.
cd ../../..
echo "Exiting CMakeUtils.bat"
exit /B 0