[CPP] Unable to build with latest Visual Studio

386 views
Skip to first unread message

Hans Kester

unread,
Jun 25, 2018, 5:19:54 PM6/25/18
to Cukes
When I follow the build instructions from https://github.com/cucumber/cucumber-cpp/tree/master I get errors in the step "cmake --build build". The problem seems to be that Google Test treats errors as warnings:

d:\development\cucumber-cpp\build\gmock\src\gmock\googletest\include\gtest\internal\gtest-port.h(996): error C2220: warning treated as error - no 'object' file generated [D:\Development\cucumber-cpp\build\gmock\src\gmock-build\googlemock\gmock.vcxproj]
d:\development\cucumber-cpp\build\gmock\src\gmock\googletest\include\gtest\internal\gtest-port.h(996): warning C4996: 'std::tr1': warning STL4002: The non-Standard std::tr1 namespace and TR1-only machinery are deprecated and will be REMOVED. You can define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING to acknowledge that you have received this warning. [D:\Development\cucumber-cpp\build\gmock\src\gmock-build\googlemock\gmock.vcxproj]
  c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\include\tuple(1163): note: see declaration of 'std::tr1'

I use Visual Studio 2017 version 15.7.4.

How do I fix this?

Jeff Langr

unread,
Jul 12, 2018, 6:27:39 PM7/12/18
to Cukes
We were able to get past this with the following workaround edit to the CMakeLists.txt:

elseif(MSVC)
    set(CMAKE_CXX_FLAGS "-DNOMINMAX ${CMAKE_CXX_FLAGS}") # exclude M$ min/max macros
    set(CMAKE_CXX_FLAGS "/wd4996 ${CMAKE_CXX_FLAGS}") # don't warn about use of plain C functions without (non-portable) "_s" suffix
    set(CMAKE_EXE_LINKER_FLAGS "/WX:NO ${CMAKE_EXE_LINKER_FLAGS}" ) # don't treat warnings as compile errors--gtest doesn't build
    #set(CMAKE_CXX_FLAGS_DEBUG "/analyze ${CMAKE_CXX_FLAGS_DEBUG}")
endif()

Seems like the cucumber-cpp folks would be able to come up with a better solution, though.

Jeff / Erik
Reply all
Reply to author
Forward
0 new messages