mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Windows build scripts: if CMake generator not passed, deduce the generator from VS env vars.
This commit is contained in:
@@ -34,16 +34,16 @@ the cmake/ folder.
|
|||||||
|
|
||||||
The preferred way to fetch and build this project's dependencies is to use the build scripts
|
The preferred way to fetch and build this project's dependencies is to use the build scripts
|
||||||
in win/ folder. See [win/readme.md] for more information. Instructions in a nutshell
|
in win/ folder. See [win/readme.md] for more information. Instructions in a nutshell
|
||||||
(assuming Visual Studio x64 environment variables set):
|
(**assuming Visual Studio 2015 x64 environment variables set**):
|
||||||
|
|
||||||
> git clone https://github.com/IfcOpenShell/IfcOpenShell.git
|
> git clone https://github.com/IfcOpenShell/IfcOpenShell.git
|
||||||
> cd oce\win
|
> cd oce\win
|
||||||
> build-deps.cmd (defaults to using VS 2015 x64 RelWithDebInfo build)
|
> build-deps.cmd (defaults to RelWithDebInfo build)
|
||||||
> run-cmake.bat (defaults to using VS 2015 x64)
|
> run-cmake.bat
|
||||||
> ..\build-vs2015-x64\IfcOpenShell.sln
|
> ..\build-vs2015-x64\IfcOpenShell.sln
|
||||||
|
|
||||||
You can now build the solution using the RelWithDebInfo configuration (freshly created solution by CMake defaults to Debug).
|
You can now build the solution using the `RelWithDebInfo` configuration (freshly created solution by CMake defaults to `Debug`).
|
||||||
Build the INSTALL project to deploy the headers and binaries into a single location if wanted/needed.
|
Build the `INSTALL` project to deploy the headers and binaries into a single location if wanted/needed.
|
||||||
|
|
||||||
Alternatively, the old Visual Studio solution and project files requiring manual work can
|
Alternatively, the old Visual Studio solution and project files requiring manual work can
|
||||||
be found from the win/sln folder.
|
be found from the win/sln folder.
|
||||||
|
|||||||
+11
-9
@@ -14,19 +14,21 @@ the requirements for a successful execution. The script allows a few user-config
|
|||||||
which are listed in the usage instructions. Either edit the script file or set these values before
|
which are listed in the usage instructions. Either edit the script file or set these values before
|
||||||
running the script.
|
running the script.
|
||||||
|
|
||||||
`build-deps.cmd` expects a CMake generator as `%1` and a build configuration type as `%2`. If the parameters
|
`build-deps.cmd` expects a CMake generator as `%1` and a build configuration type (`RelWithDebInfo/Release/MinSizeRel/Debug`,
|
||||||
are not provided, the default values are used (`"Visual Studio 14 2015 Win64"` and `RelWithDebInfo` respectively).
|
defaults to `RelWithDebInfo`) as `%2`. If the generator is not provided, the generator is deduced from the Visual Studio
|
||||||
A build type (`Build/Rebuild/Clean`) can be provided as `%3`, if wanted (defaults to `Build`). See `vs-cfg.cmd`
|
environment variables. A build type (`Build/Rebuild/Clean`, defaults to `Build`) can be provided as `%3`. See `vs-cfg.cmd`
|
||||||
if you want to change the defaults. The batch file will create `deps\` and `deps-vs<VERSION>-<ARCHITECTURE>-installed\`
|
if you wish to change the defaults. The batch file will create `deps\` and `deps-vs<VERSION>-<ARCHITECTURE>-installed\`
|
||||||
directories to the project root. Debug and release builds of the depedencies can co-exist by simply running
|
directories to the project root. Debug and release builds of the depedencies can co-exist by simply running
|
||||||
`build-deps.cmd <GENERATOR> Debug` and `build-deps.cmd <GENERATOR> <Release|RelWithDebInfo|MinSizeRel>`.
|
`build-deps.cmd <GENERATOR> Debug` and `build-deps.cmd <GENERATOR> <Release|RelWithDebInfo|MinSizeRel>`.
|
||||||
|
|
||||||
After the dependencies are build, execute `run-cmake.bat`. The batch file expects always a CMake generator as
|
After the dependencies are build, execute `run-cmake.bat`. The batch file expects always a CMake generator as `%1`
|
||||||
`%1` (if not provided, the same default value as above is used), and the rest of possible parameters are passed as is.
|
(if not provided, the same default value as above is used), and the rest of possible parameters are passed as is.
|
||||||
|
**If you wish to use any library from a custom location, modify the paths in `run-cmake.bat` accordingly**. The batch
|
||||||
|
script will create a folder of form `build-vs<VERSION>-<ARCHITECTURE>\` which will contain the solution and project
|
||||||
|
files for Visual Studio.
|
||||||
|
|
||||||
The batch script will create a folder of form `build-vs<VERSION>-<ARCHITECTURE>\` which will contain the solution and project files for Visual Studio.
|
Note that building IfcOpenShell as 64-bit is recommended as many of real life IFC files has been observed to take
|
||||||
**If you wish to use any library from a custom location, modify the paths in run-cmake.bat
|
easily more than 2 GBs of RAM while converting.
|
||||||
accordingly**.
|
|
||||||
|
|
||||||
After this, one can build the project using the `IfcOpenShell.sln` file in the build folder. Build the `INSTALL` project
|
After this, one can build the project using the `IfcOpenShell.sln` file in the build folder. Build the `INSTALL` project
|
||||||
if wanted. The project will be installed to `installed-vs<VERSION>-<ARCHITECTURE>\` folder in the project's root
|
if wanted. The project will be installed to `installed-vs<VERSION>-<ARCHITECTURE>\` folder in the project's root
|
||||||
|
|||||||
+2
-1
@@ -26,6 +26,7 @@ set PROJECT_NAME=IfcOpenShell
|
|||||||
setlocal EnableDelayedExpansion
|
setlocal EnableDelayedExpansion
|
||||||
:: TODO Getting warning print in vs-cfg.cmd for missing build type although this script doesn't need it specified
|
:: TODO Getting warning print in vs-cfg.cmd for missing build type although this script doesn't need it specified
|
||||||
call vs-cfg.cmd %1
|
call vs-cfg.cmd %1
|
||||||
|
IF NOT %ERRORLEVEL%==0 GOTO :Error
|
||||||
|
|
||||||
:: Read Python related variables from BuildDepsCache.txt
|
:: Read Python related variables from BuildDepsCache.txt
|
||||||
for /f "delims== tokens=1,2" %%G in (BuildDepsCache-%TARGET_ARCH%.txt) do set %%G=%%H
|
for /f "delims== tokens=1,2" %%G in (BuildDepsCache-%TARGET_ARCH%.txt) do set %%G=%%H
|
||||||
@@ -103,7 +104,7 @@ goto :Finish
|
|||||||
|
|
||||||
:Error
|
:Error
|
||||||
echo.
|
echo.
|
||||||
cecho {0C}An error occurred! Aborting!"
|
call %~dp0\utils\cecho.cmd 0 12 "An error occurred! Aborting!"
|
||||||
goto :Finish
|
goto :Finish
|
||||||
|
|
||||||
:Finish
|
:Finish
|
||||||
|
|||||||
+32
-16
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
:: This script initializes various Visual Studio -related environment variables needed for building
|
:: This script initializes various Visual Studio -related environment variables needed for building
|
||||||
:: This batch file expects CMake generator as %1 and build configuration type as %2.
|
:: This batch file expects CMake generator as %1 and build configuration type as %2.
|
||||||
|
:: If %1 is not provided, it is deduced from the VisualStudioVersion environment variable and from the location of cl.exe.
|
||||||
|
|
||||||
:: NOTE This batch file expects the generator string to be CMake 3.0.0 and newer format, i.e.
|
:: NOTE This batch file expects the generator string to be CMake 3.0.0 and newer format, i.e.
|
||||||
:: "Visual Studio 10 2010" instead of "Visual Studio 10". However, one can use this batch file
|
:: "Visual Studio 10 2010" instead of "Visual Studio 10". However, one can use this batch file
|
||||||
:: also with CMake 2 as the generator will be converted into the older format if necessary.
|
:: also with CMake 2 as the generator will be converted into the older format if necessary.
|
||||||
@@ -33,29 +35,43 @@ set GENERATOR=%1
|
|||||||
:: F.ex. "vs2013-32" and/or "vc14-64"
|
:: F.ex. "vs2013-32" and/or "vc14-64"
|
||||||
|
|
||||||
:: Supported Visual Studio versions:
|
:: Supported Visual Studio versions:
|
||||||
set GENERATORS[0]="Visual Studio 14 2015"
|
set GENERATORS[0]="Visual Studio 9 2008 Win64"
|
||||||
set GENERATORS[1]="Visual Studio 14 2015 Win64"
|
set GENERATORS[1]="Visual Studio 9 2008"
|
||||||
set GENERATORS[2]="Visual Studio 12 2013"
|
set GENERATORS[2]="Visual Studio 10 2010 Win64"
|
||||||
set GENERATORS[3]="Visual Studio 12 2013 Win64"
|
set GENERATORS[3]="Visual Studio 10 2010"
|
||||||
set GENERATORS[4]="Visual Studio 11 2012"
|
set GENERATORS[4]="Visual Studio 11 2012 Win64"
|
||||||
set GENERATORS[5]="Visual Studio 11 2012 Win64"
|
set GENERATORS[5]="Visual Studio 11 2012"
|
||||||
set GENERATORS[6]="Visual Studio 10 2010"
|
set GENERATORS[6]="Visual Studio 12 2013 Win64"
|
||||||
set GENERATORS[7]="Visual Studio 10 2010 Win64"
|
set GENERATORS[7]="Visual Studio 12 2013"
|
||||||
set GENERATORS[8]="Visual Studio 9 2008"
|
set GENERATORS[8]="Visual Studio 14 2015 Win64"
|
||||||
set GENERATORS[9]="Visual Studio 9 2008 Win64"
|
set GENERATORS[9]="Visual Studio 14 2015"
|
||||||
set GENERATOR_DEFAULT=%GENERATORS[1]%
|
set LAST_GENERATOR_IDX=9
|
||||||
|
|
||||||
IF "!GENERATOR!"=="" (
|
REM Deduce desired architecture from the location of cl.exe
|
||||||
set GENERATOR=%GENERATOR_DEFAULT%
|
where cl.exe | findstr /r /c:"amd64" >nul
|
||||||
call utils\cecho.cmd 0 14 "%~nx0: Warning: Generator not passed - using the default '`"%GENERATOR_DEFAULT%`'`t
|
set START=%ERRORLEVEL%
|
||||||
|
set STEP=2
|
||||||
|
|
||||||
|
IF "!GENERATOR!"=="" IF NOT "%VisualStudioVersion%"=="" (
|
||||||
|
set VC_VER=%VisualStudioVersion:.0=%
|
||||||
|
FOR /l %%i in (%START%,%STEP%,%LAST_GENERATOR_IDX%) DO (
|
||||||
|
REM http://stackoverflow.com/a/8758579
|
||||||
|
REM NOTE add space before VC_VER so that e.g. "12" doesn't match with "2012"
|
||||||
|
echo(!GENERATORS[%%i]! | findstr /r /c:" !VC_VER!" >nul && (
|
||||||
|
set GENERATOR=!GENERATORS[%%i]!
|
||||||
|
call utils\cecho.cmd black cyan "Generator not passed, but VisualStudioVersion=%VisualStudioVersion% environment variable detected:"
|
||||||
|
call utils\cecho.cmd black cyan "using '`"!GENERATOR!`'" as the generator."
|
||||||
|
GOTO :GeneratorValid
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
FOR /l %%i in (0,1,9) DO (
|
FOR /l %%i in (0,1,%LAST_GENERATOR_IDX%) DO (
|
||||||
IF !GENERATOR!==!GENERATORS[%%i]! GOTO :GeneratorValid
|
IF !GENERATOR!==!GENERATORS[%%i]! GOTO :GeneratorValid
|
||||||
)
|
)
|
||||||
call utils\cecho.cmd 0 12 "%~nx0: Invalid or unsupported CMake generator string passed: '`"!GENERATOR!`'". Cannot proceed, aborting!"
|
call utils\cecho.cmd 0 12 "%~nx0: Invalid or unsupported CMake generator string passed: '`"!GENERATOR!`'". Cannot proceed, aborting!"
|
||||||
echo Supported CMake generator strings:
|
echo Supported CMake generator strings:
|
||||||
FOR /l %%i in (0,1,9) DO (
|
FOR /l %%i in (0,1,%LAST_GENERATOR_IDX%) DO (
|
||||||
echo !GENERATORS[%%i]!
|
echo !GENERATORS[%%i]!
|
||||||
)
|
)
|
||||||
exit /b 1
|
exit /b 1
|
||||||
|
|||||||
Reference in New Issue
Block a user