stnava/ANTs — pull request #15 by adrienkaiser (2013-04-11 19:09:04+00:00)
Title: BUG: Prevent Boost from compiling libraries and Fix windows compilation errors

## Commits

- `BUG: Prevent Boost from compiling libraries (ANTS only needs the header-only components of boost)`
In file SuperBuild/configureboost.cmake:
The option "--with-libraries=" in boost/bootstrap.sh sets the list of libraries to compile to an empty string, which has for consequence to compile ALL boost libraries, so the opposite of what we want.
To fix this, I used the other option --without-libraries which allow to prevent boost from compiling all libraries by giving all their names:
`--without-libraries=atomic,chrono,context,date_time,exception,filesystem,graph,graph_parallel,iostreams,locale,math,mpi,program_options,python,random,regex,serialization,signals,system,test,thread,timer,wave`
The names of the libraries are then hard coded, but this is not an issue, as the ANTs SuperBuild downloads a certain revision of boost. It will just be necessary to update this list whenever a different version of boost is used in the SuperBuild.

As I tried to compile ANTs on Windows, I encountered several issues:

- `COMP: Add boost compilation commands for Windows`
On Windows, the command to be ran to configure boost is bootstrap.bat and it does not allow options.
Therefore, the --prefix option and all the --without- arguments are given to ./b2 when building.

- `BUG: Fix windows compilation errors`
Some code did not compile on Windows, I propose an alternative solution for each of the errors.
NB: I was not able to fix one of the errors in the External Applications, so the windows build has compiled without the external applications built:
In file [ExternalApplications/MALF/CorrectiveLearning/segAdapter.cxx](http://github.com/adrienkaiser/ANTs/blob/master/ExternalApplications/MALF/CorrectiveLearning/segAdapter.cxx#L330-L331)
```
1>1>------ Build started: Project: sa, Configuration: Debug Win32 ------
1>1>Compiling...
1>1>segAdapter.cxx
1>1>..\..\..\..\ANTs\ExternalApplications\MALF\CorrectiveLearning\segAdapter.cxx(330) : error C2143: syntax error : missing ')' before '{'
1>1>..\..\..\..\ANTs\ExternalApplications\MALF\CorrectiveLearning\segAdapter.cxx(330) : error C2059: syntax error : ')'
1>1>..\..\..\..\ANTs\ExternalApplications\MALF\CorrectiveLearning\segAdapter.cxx(330) : error C2143: syntax error : missing ';' before '{'
1>1>..\..\..\..\ANTs\ExternalApplications\MALF\CorrectiveLearning\segAdapter.cxx(330) : error C2143: syntax error : missing ';' before '}'
1>1>..\..\..\..\ANTs\ExternalApplications\MALF\CorrectiveLearning\segAdapter.cxx(330) : error C2059: syntax error : ')'
1>1>..\..\..\..\ANTs\ExternalApplications\MALF\CorrectiveLearning\segAdapter.cxx(331) : error C2143: syntax error : missing ')' before '{'
1>1>..\..\..\..\ANTs\ExternalApplications\MALF\CorrectiveLearning\segAdapter.cxx(331) : error C2059: syntax error : ')'
1>1>..\..\..\..\ANTs\ExternalApplications\MALF\CorrectiveLearning\segAdapter.cxx(331) : error C2143: syntax error : missing ';' before '{'
1>1>..\..\..\..\ANTs\ExternalApplications\MALF\CorrectiveLearning\segAdapter.cxx(331) : error C2143: syntax error : missing ';' before '}'
1>1>..\..\..\..\ANTs\ExternalApplications\MALF\CorrectiveLearning\segAdapter.cxx(331) : error C2059: syntax error : ')'
1>1>Build log was saved at "file://c:\Devel\ANTs-build2\ANTS-build\ExternalApplications\MALF\sa.dir\Debug\BuildLog.htm"
1>1>sa - 10 error(s), 0 warning(s)
1>========== Build: 0 succeeded, 1 failed, 159 up-to-date, 0 skipped ==========
1>Project : error PRJ0019: A tool returned an error code from "Performing build step for 'ANTS'"
1>Build log was saved at "file://c:\Devel\ANTs-build2\ANTS.dir\Debug\BuildLog.htm"
1>ANTS - 11 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 3 up-to-date, 0 skipped ==========
```

There was also a missing cmake argument in the inner build external project declaration ([BUILD_EXTERNAL_APPLICATIONS](http://github.com/adrienkaiser/ANTs/blob/master/SuperBuild.cmake#L284)), which made the External Applications compile even with the option set to OFF.

## Testing
This patch has been tested and passed all tests with the following options on the following platforms:

- CMake version: 2.8.10.2

- CMake Options:
```
ANTS_SUPERBUILD ON
BUILD_EXTERNAL_APPLICATIONS ON (OFF for Windows)
BUILD_SHARED_LIBS OFF
BUILD_STYLE_UTILS OFF
BUILD_TESTING ON
CMAKE_BUILD_TYPE Release
CMAKE_INSTALL_PREFIX /usr/local
EXTERNAL_PROJECT_BUILD_TYPE Release
FORCE_EXTERNAL_BUILDS OFF
ITK_VERSION_MAJOR 4
OLD_BASELINE_TESTS OFF
RUN_LONG_TESTS ON
RUN_SHORT_TESTS ON
SuperBuild_ANTS_USE_GIT_PROTOC ON
USE_SYSTEM_ITK OFF
USE_SYSTEM_SlicerExecutionMode OFF
USE_VTK OFF
```

- Linux: Scientific linux, an adapted version of Fedora (64 bit)
Compiler: c++ (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)
cc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)
gmake GNU Make 3.81

- MAC OS X 10.7.5 (11G63b) (64 bit)
Compiler: c++ (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)
cc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)
gmake GNU Make 3.81

- Windows 7 64 bit + Service Pack 1
Compiler: Microsoft Visual Studio 2008 Version 9.0.30729.1 SP
Microsoft .NET Framework Version 3.5 SP1