Use -O2 not -O3 on MinGW to workaround issue with Eigen. - MinGW produces code that segfaults when performing matrix multiplications in Eigen when compiled with -O3 (see below), as such force the use of -O2 which works. - http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556 Change-Id: I420e965d5033944374a5cc93490546c25e46bce5
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b7c29a..2896788 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -660,6 +660,17 @@ SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CERES_CXX_FLAGS}") +IF (MINGW) + # MinGW produces code that segfaults when performing matrix multiplications + # in Eigen when compiled with -O3 (see [1]), as such force the use of -O2 + # which works. + # + # [1] http://eigen.tuxfamily.org/bz/show_bug.cgi?id=556 + MESSAGE("-- MinGW detected, forcing use of -O2 not -O3 in Release for Eigen.") + STRING(REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + UPDATE_CACHE_VARIABLE(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") +ENDIF (MINGW) + # After the tweaks for the compile settings, disable some warnings on MSVC. IF (MSVC) # Disable signed/unsigned int conversion warnings.