-set wgetPath=%cd%\..\..\windows\creaTools_win_installers\CreaTools_v2_0_0_win32_installer\bin\wget.exe
-set zipPath="%ProgramFilesPath%\7-Zip\7z.exe"
-set urlCreatisSource=http://www.creatis.insa-lyon.fr/software/public/creatools/crea_ThirdParty_Libraries/source
-set urlCreatisSource=http://www.creatis.insa-lyon.fr/~caceres/software
-set vcvarsall="%ProgramFilesPath%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
-
-set installpath=%thirdpartyGeneration%\thirdparty_install
-set binpath=%thirdpartyGeneration%\thirdparty_bin
-set sourcepath=%thirdpartyGeneration%\thirdparty_source
-
-set xercesc=xerces-c-3.1.1
-set itk=InsightToolkit-3.20.0
-set gdcm=gdcm
-set vtk=VTK
-
-rem ---End Setting Global Variables----
-rem -----------------------------------
-
-call %vcvarsall%
-
-rem -----------------------------------
-rem -------Creating Folders------------
-rem -----------------------------------
-rmdir %binpath% /s /q
-
-rmdir %thirdpartyGeneration% /s /q
-mkdir %thirdpartyGeneration%
-cd %thirdpartyGeneration%
-mkdir thirdparty_source
-mkdir thirdparty_bin
-mkdir thirdparty_install
-rem ------End Creating Folders---------
-
-rem -----------------------------------
-rem ------Downloading Sources----------
-rem -----------------------------------
-cd %thirdpartyGeneration%\thirdparty_source\
-%wgetPath% %urlCreatisSource%/qt-4.7.3.zip
-%wgetPath% %urlCreatisSource%/wxWidgets-2.9.2.7z
-%wgetPath% %urlCreatisSource%/boost_1_47_0.7z
-%wgetPath% %urlCreatisSource%/vtk-5.6.1.patchCreatis.tar.gz
-%wgetPath% %urlCreatisSource%/InsightToolkit-3.20.0.patchCreatis.tar.gz
-%wgetPath% %urlCreatisSource%/gdcm_05_Mai_2011.tar.gz
-%wgetPath% %urlCreatisSource%/xerces-c-3.1.1.zip
-rem ------End Downloading Sources------
-
-rem -----------------------------------
-rem --------Qt Installation------------
-rem -----------------------------------
-rem ---Setting Enviroment Variables----
-set QTDIR=%thirdpartyGeneration%\thirdparty_source\Qt\4.7.3\
-rem ----------Extracting---------------
-cd %thirdpartyGeneration%\thirdparty_source\
-mkdir Qt\
-cd Qt\
-%zipPath% x %thirdpartyGeneration%\thirdparty_source\qt-4.7.3.zip
-del %thirdpartyGeneration%\thirdparty_source\qt-4.7.3.zip
-
-rem --------Renaming Folder------------
-rename qt-everywhere-opensource-src-4.7.3 4.7.3
-rem ----------Installing---------------
-cd 4.7.3
-echo y | configure -%buildType% -opensource -shared -qt-sql-sqlite -phonon -phonon-backend -platform win32-msvc2010 -mp
-nmake
-cd C:\
-rem ------End QT Installation----------
-
-rem -----------------------------------
-rem -----wxWidgets Installation--------
-rem -----------------------------------
-rem -------Setting Variables-----------
-set WXDIR=%thirdpartyGeneration%\thirdparty_source\wxWidgets\2.9.2\
-rem ----------Extracting---------------
-cd %thirdpartyGeneration%\thirdparty_source
-md wxWidgets\2.9.2
-cd wxWidgets\2.9.2
-%zipPath% x %thirdpartyGeneration%\thirdparty_source\wxWidgets-2.9.2.7z
-del %thirdpartyGeneration%\thirdparty_source\wxWidgets-2.9.2.7z
-rem ----------Installing---------------
-cd %thirdpartyGeneration%\thirdparty_source\wxWidgets\2.9.2\build\msw
-nmake -f makefile.vc BUILD=%buildType% UNICODE=1 SHARED=1
+set installpath=%thirdpartyGeneration%\thirdparty_install\%buildType%
+set binpath=%thirdpartyGeneration%\thirdparty_bin\%buildType%
+set sourcepath=%thirdpartyGeneration%\thirdparty_source\%buildType%
+
+if %PROCESSOR_ARCHITECTURE%==x86 (
+ set ProgramFilesPath_x86=%ProgramFiles%
+ echo "Architecture found = x86"
+) else (
+ set "ProgramFilesPath_x64=%ProgramFiles%"
+ set "ProgramFilesPath_x86=%ProgramFiles(x86)%"
+ echo "Architecture found = x64"
+)
+
+set vcvarsall="%ProgramFilesPath_x86%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
+if not exist %vcvarsall% set vcvarsall="%ProgramFilesPath_x64%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
+if not exist %vcvarsall% (
+ echo ERROR!!! Visual Studio has not been found in the system
+ exit
+)
+
+set qt=qt
+set jom=jom
+set wxWidgets=wxWidgets
+set boost=boost
+set xercesc=xerces
+set itk=itk
+set gdcm=gdcm13
+set vtk=vtk
+set sqlite=sqlite
+
+set QTDIR=%sourcepath%\%qt%
+set JOMDIR=%sourcepath%\%jom%
+set WXDIR=%sourcepath%\%wxWidgets%
+set BOOSTDIR=%sourcepath%\%boost%
+set XERCESDIR=%sourcepath%\%xercesc%
+set ITKSRCDIR=%sourcepath%\%itk%
+set VTKSRCDIR=%sourcepath%\%VTK%
+set GDCMSRCDIR=%sourcepath%\%gdcm%
+set SQLITESRCDIR=%sourcepath%\%sqlite%
+set LogFolder=%thirdpartyGeneration%\installLog
+
+echo -----------------------------------
+echo Environment variables Configuration
+echo -----------------------------------
+echo ThirdpartyGeneration=%thirdpartyGeneration%
+echo BuildType=%buildType%
+echo Visual Studio=%vcvarsall%
+echo InstallPath=%installpath%
+echo BinPath=%binpath%
+echo SourcePath=%sourcepath%
+echo QT=%qt%
+echo WX=%wxWidgets%
+echo BOOST=%boost%
+echo Xercesc=%xercesc%
+echo ITK=%itk%
+echo GDCM=%gdcm%
+echo VTK=%vtk%
+echo QTDIR=%QTDIR%
+echo WKDIR=%WXDIR%
+echo BOOSTDIR=%BOOSTDIR%
+echo XERCESDIR=%XERCESDIR%
+echo ITKSRCDIR=%ITKSRCDIR%
+echo VTKSRCDIR=%VTKSRCDIR%
+echo GDCMDIR=%GDCMSRCDIR%
+echo JOMDIR=%JOMDIR%
+echo SQLITEDIR=%SQLITESRCDIR%
+
+echo -----------------------------------
+echo ---End Setting Global Variables----
+echo -----------------------------------
+
+
+if %x86Comp%==ON (
+ set addressmodel=32
+ call %vcvarsall%
+ echo "Compilation forced x86"
+) else (
+ set addressmodel=64
+ if %PROCESSOR_ARCHITECTURE%==x86 (
+ call %vcvarsall%
+ ) else (
+ call %vcvarsall% amd64
+ )
+)
+
+if %EEDinstallQT%==FALSE GOTO SKIPINSTALLQT
+echo -----------------------------------
+echo --------Qt Installation------------
+echo -----------------------------------
+cd %QTDIR%
+set QMAKESPEC=win32-msvc2010
+echo y | configure -%buildType% -opensource -shared -qt-sql-sqlite -phonon -phonon-backend -platform win32-msvc2010 -mp >> %LogFolder%\qtInstall.log 2>&1
+%JOMDIR%\jom.exe -j %NUMBER_OF_PROCESSORS% >> %LogFolder%\qtInstall.log 2>&1