[vtkusers] Windows build script for multiple library options

Kenneth Porter shiva at sewingwitch.com
Sun Mar 22 12:51:21 EDT 2015


I need to build VTK as a statically-linked library for lots of different 
options: VC10/VC11/VC12 compilers, static/dynamic runtime linking, 32/64 
bit, and debug/release. I've come up with the attached script to build all 
24 variations. It takes quite awhile (ie. many hours). What can I do to 
optimize it? I'm not super-familiar with cmake so I expect I can fold some 
of the operations into a single command. The script assumes that the VTK 
environment variable points to the root of a tree where the source has been 
unpacked and where output binaries will be placed. I'm using 
\devel\VTK\6.2.0 for the current release. 
-------------- next part --------------
@rem create the VTK project files for vc10/vc11/vc12, static/dynamic CRT, 32/64 architecture

@rem cmake isn't necessarily in the path so pass its location on the command line as 1st arg
set cmake=%1

@if "%cmake%"=="" exit /B 1
@if "%vtk%"=="" exit /B 1

@echo cmake at %cmake%
@echo vtk at %vtk%

mkdir %vtk%\output\vs10
mkdir %vtk%\output\vs11
mkdir %vtk%\output\vs12

mkdir %vtk%\output\vs10_x64
mkdir %vtk%\output\vs11_x64
mkdir %vtk%\output\vs12_x64

mkdir %vtk%\output\vs10_static
mkdir %vtk%\output\vs11_static
mkdir %vtk%\output\vs12_static

mkdir %vtk%\output\vs10_static_x64
mkdir %vtk%\output\vs11_static_x64
mkdir %vtk%\output\vs12_static_x64

cd %vtk%\output\vs12_x64
%cmake% -D CMAKE_DEBUG_POSTFIX="_d" -D CMAKE_INSTALL_PREFIX=%vtk%/vs12_x64 -D BUILD_SHARED_LIBS=OFF -D VTK_DEBUG_LEAKS=ON -G "Visual Studio 12 Win64" ..\..\vtk-6.2.0
%cmake% --build . --config Debug --target install
%cmake% --build . --config Release --target install

cd %vtk%\output\vs11_x64
%cmake% -D CMAKE_DEBUG_POSTFIX="_d" -D CMAKE_INSTALL_PREFIX=%vtk%/vs11_x64 -D BUILD_SHARED_LIBS=OFF -D VTK_DEBUG_LEAKS=ON -G "Visual Studio 11 Win64" ..\..\vtk-6.2.0
%cmake% --build . --config Debug --target install
%cmake% --build . --config Release --target install

cd %vtk%\output\vs10_x64
%cmake% -D CMAKE_DEBUG_POSTFIX="_d" -D CMAKE_INSTALL_PREFIX=%vtk%/vs10_x64 -D BUILD_SHARED_LIBS=OFF -D VTK_DEBUG_LEAKS=ON -G "Visual Studio 10 Win64" ..\..\vtk-6.2.0
%cmake% --build . --config Debug --target install
%cmake% --build . --config Release --target install

cd %vtk%\output\vs12
%cmake% -D CMAKE_DEBUG_POSTFIX="_d" -D CMAKE_INSTALL_PREFIX=%vtk%/vs12 -D BUILD_SHARED_LIBS=OFF -D VTK_DEBUG_LEAKS=ON -G "Visual Studio 12" ..\..\vtk-6.2.0
%cmake% --build . --config Debug --target install
%cmake% --build . --config Release --target install

cd %vtk%\output\vs11
%cmake% -D CMAKE_DEBUG_POSTFIX="_d" -D CMAKE_INSTALL_PREFIX=%vtk%/vs11 -D BUILD_SHARED_LIBS=OFF -D VTK_DEBUG_LEAKS=ON -G "Visual Studio 11" ..\..\vtk-6.2.0
%cmake% --build . --config Debug --target install
%cmake% --build . --config Release --target install

cd %vtk%\output\vs10
%cmake% -D CMAKE_DEBUG_POSTFIX="_d" -D CMAKE_INSTALL_PREFIX=%vtk%/vs10 -D BUILD_SHARED_LIBS=OFF -D VTK_DEBUG_LEAKS=ON -G "Visual Studio 10" ..\..\vtk-6.2.0
%cmake% --build . --config Debug --target install
%cmake% --build . --config Release --target install

@rem for static variations, replace /MD with /MT on CMakeCache.txt and re-run CMake to update project files

cd %vtk%\output\vs12_static_x64
%cmake% -D CMAKE_DEBUG_POSTFIX="_d" -D CMAKE_INSTALL_PREFIX=%vtk%/vs12_static_x64 -D BUILD_SHARED_LIBS=OFF -D VTK_DEBUG_LEAKS=ON -G "Visual Studio 12 Win64" ..\..\vtk-6.2.0
perl -pi.bak -e "s|/MD|/MT|g" CMakeCache.txt
%cmake% .
%cmake% --build . --config Debug --target install
%cmake% --build . --config Release --target install

cd %vtk%\output\vs11_static_x64
%cmake% -D CMAKE_DEBUG_POSTFIX="_d" -D CMAKE_INSTALL_PREFIX=%vtk%/vs11_static_x64 -D BUILD_SHARED_LIBS=OFF -D VTK_DEBUG_LEAKS=ON -G "Visual Studio 11 Win64" ..\..\vtk-6.2.0
perl -pi.bak -e "s|/MD|/MT|g" CMakeCache.txt
%cmake% .
%cmake% --build . --config Debug --target install
%cmake% --build . --config Release --target install

cd %vtk%\output\vs10_static_x64
%cmake% -D CMAKE_DEBUG_POSTFIX="_d" -D CMAKE_INSTALL_PREFIX=%vtk%/vs10_static_x64 -D BUILD_SHARED_LIBS=OFF -D VTK_DEBUG_LEAKS=ON -G "Visual Studio 10 Win64" ..\..\vtk-6.2.0
perl -pi.bak -e "s|/MD|/MT|g" CMakeCache.txt
%cmake% .
%cmake% --build . --config Debug --target install
%cmake% --build . --config Release --target install

cd %vtk%\output\vs12_static
%cmake% -D CMAKE_DEBUG_POSTFIX="_d" -D CMAKE_INSTALL_PREFIX=%vtk%/vs12_static -D BUILD_SHARED_LIBS=OFF -D VTK_DEBUG_LEAKS=ON -G "Visual Studio 12" ..\..\vtk-6.2.0
perl -pi.bak -e "s|/MD|/MT|g" CMakeCache.txt
%cmake% .
%cmake% --build . --config Debug --target install
%cmake% --build . --config Release --target install

cd %vtk%\output\vs11_static
%cmake% -D CMAKE_DEBUG_POSTFIX="_d" -D CMAKE_INSTALL_PREFIX=%vtk%/vs11_static -D BUILD_SHARED_LIBS=OFF -D VTK_DEBUG_LEAKS=ON -G "Visual Studio 11" ..\..\vtk-6.2.0
perl -pi.bak -e "s|/MD|/MT|g" CMakeCache.txt
%cmake% .
%cmake% --build . --config Debug --target install
%cmake% --build . --config Release --target install

cd %vtk%\output\vs10_static
%cmake% -D CMAKE_DEBUG_POSTFIX="_d" -D CMAKE_INSTALL_PREFIX=%vtk%/vs10_static -D BUILD_SHARED_LIBS=OFF -D VTK_DEBUG_LEAKS=ON -G "Visual Studio 10" ..\..\vtk-6.2.0
perl -pi.bak -e "s|/MD|/MT|g" CMakeCache.txt
%cmake% .
%cmake% --build . --config Debug --target install
%cmake% --build . --config Release --target install


More information about the vtkusers mailing list