From b04efd50d0c31d8f63c9b67afe783f3cc43278df Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Wed, 24 Oct 2018 11:18:58 +0200 Subject: [PATCH 1/2] [cmake] Use different build flags for MSVC and GCC - MSVC: bigobj is needed even in release mode - Some flags are gcc specific and should not be added when using MSVC - Add _USE_MATH_DEFINES for MSVC (needed for M_PI) --- CMakeLists.txt | 27 ++++++++++++++------------- src/math/roots.cpp | 1 + 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fc19fe0..9660f557 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,31 +27,32 @@ ELSE() ENDIF() IF(MSVC) - add_compile_options(/wd4514 /wd4267 $<$:/bigobj>) + add_compile_options(/wd4514 /wd4267 /bigobj) + add_definitions(-D_USE_MATH_DEFINES) ELSE() IF (CMAKE_SYSTEM_PROCESSOR MATCHES "(arm64)|(ARM64)|(aarch64)|(AARCH64)") - add_definitions (-Wall -march=armv8-a -O3) + add_definitions (-march=armv8-a) ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(arm)|(ARM)|(armhf)|(ARMHF)|(armel)|(ARMEL)") - add_definitions (-Wall -march=armv7-a -O3) + add_definitions (-march=armv7-a) ELSE () - add_definitions (-Wall -march=native -O3) #TODO use correct c++11 def once everybody has moved to gcc 4.7 # for now I even removed std=gnu++0x + add_definitions (-march=native) #TODO use correct c++11 def once everybody has moved to gcc 4.7 # for now I even removed std=gnu++0x ENDIF() + add_definitions ( + -O3 + -Wall + -Wextra + #-Werror + -Wwrite-strings + -Wno-unused-parameter + -fno-strict-aliasing + ) ENDIF() IF(BUILD_POSITION_INDEPENDENT_CODE) add_definitions( -fPIC ) ENDIF() -ADD_DEFINITIONS ( --Wall --Wextra -#-Werror --Wwrite-strings --Wno-unused-parameter --fno-strict-aliasing -) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/modules/") find_package(Eigen REQUIRED) set(ADDITIONAL_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIR}/unsupported) diff --git a/src/math/roots.cpp b/src/math/roots.cpp index f87eb79d..c31b27cf 100644 --- a/src/math/roots.cpp +++ b/src/math/roots.cpp @@ -31,6 +31,7 @@ #include #include +#include std::vector opengv::math::o3_roots( const std::vector & p ) From 573fdde4618542e936253a5cf05a508e8bcc1be9 Mon Sep 17 00:00:00 2001 From: Fabien Castan Date: Wed, 24 Oct 2018 12:15:26 +0200 Subject: [PATCH 2/2] Fix MSVC build with Matrix operator* src\absolute_pose\modules\main.cpp(773): error C2677: binary '*': no global operator found which takes type 'const Eigen::Matrix' (or there is no acceptable conversion) --- src/absolute_pose/modules/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/absolute_pose/modules/main.cpp b/src/absolute_pose/modules/main.cpp index 7cff9f69..ed0c271a 100644 --- a/src/absolute_pose/modules/main.cpp +++ b/src/absolute_pose/modules/main.cpp @@ -770,7 +770,7 @@ opengv::absolute_pose::modules::upnp_main( { Eigen::Matrix s; upnp_fill_s(quaternion,s); - Eigen::Matrix valueM = s.transpose() * M * s + 2.0 * C * s; + Eigen::Matrix valueM = s.transpose() * M * s + C * s * 2.0; double value = valueM[0] + gamma; std::vector,Eigen::aligned_allocator< std::pair > >::iterator