Search code examples
cmakevisual-studio-2015cgal

Build process for CGAL with VS2015


After building with CMAKE for visual studio 2015, I found that there were some build errors that required me to edit the code. I feel that this should not be necessary and would like to know if I might have done something wrong in build process to make these errors surface

Firstly I had to correct the compiler name from vc130 to vc140 in the files include/CGAL/auto-link/auto-link.h and cmake/module/CGAL_GeneratorSpecificSettings.cmake. I assume that this is simply because it has not been tested VS2015 and someone just assumed that vc130 would follow vc120.

The other issue I ran into was that eight functions that did not compile. These were the functions

Segment_2<R_>::min 
Segment_2<R_>::max 
Segment_2<R_>::vertex 
Segment_2<R_>::point 
Segment_2<R_>::operator[] 
Segment_3<R_>::min 
Segment_3<R_>::max

The issue seemed to be that the type signature of the implementation did not match that of the declaration. I tried fixing the type signature, but was unable to get it to match exactly. To fix this I ended up moving the implementation of these functions into the declaration. I would like why this is apparently necessary as presumably it compiles for other people. Sloriot commented that it was because the VS2015 compiler was more recent than the one CGAL is tested with. It is however my understanding that the visual studio compilers are backwards compatible, an thus it should not break the code to update the compiler.


Solution

  • The first version of CGAL officially compatible with VS2015 will be CGAL 4.7. It seems that the new version of the Microsoft has some issues compiling valid C++ code it was accepting before. This explains why the release 4.6 of CGAL (or prior versions) has some compilation issues with that new compiler.