sinojelly / mockcpp

Two C/C++ testing tools, mockcpp and testngpp.
Apache License 2.0
66 stars 39 forks source link

mockcpp does not build against latest googletest 1.13 #48

Open cshaw-identiv opened 1 year ago

cshaw-identiv commented 1 year ago

The main branch of mockcpp does not build against the latest version of googletest (v1.13 onwards) when specifying gtest as the unit test framework. The build fails when building ports/failure/gtest_report_failure.cpp.o because the included gtest.h forces an error with a message about the compiler being required to support C++14.

This was seen on Windows, using both cygwin and WSL Ubuntu.

This error occurs because the mockcpp build enforces c++11 compilation. The relevant code is in src/CMakeLists.txt::83:

IF(MSVC)
    ADD_DEFINITIONS(-DMSVC_VMG_ENABLED) #  /Z7)
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /vmg")
    INCLUDE_DIRECTORIES(BEFORE ${MOCKCPP_SRC_ROOT}/3rdparty/msinttypes)
ELSE(MSVC)
    ADD_DEFINITIONS(-std=c++11)
ENDIF(MSVC)

When the -std flag is removed, the latest version of googletest builds without problem. Presumably the enforcing -std flag is there for a reason, but can it be either removed completely, or removed for gtest dependency?