Quantcast
Viewing all articles
Browse latest Browse all 22040

disable all warnings for google tests from cmake

I have a c++ project that I am compiling with cmake. I am also using google tests. These are my cmake files:

cmake_minimum_required(VERSION 3.5)project(se-03-team-08 LANGUAGES CXX)set(CMAKE_CXX_STANDARD 14)if(EXISTS $ENV{HOME}/Qt/5.14.2/gcc_64)  set(CMAKE_PREFIX_PATH $ENV{HOME}/Qt/5.14.2/gcc_64)endif()if(EXISTS $ENV{HOME}/Qt/5.14.1/gcc_64)  set(CMAKE_PREFIX_PATH $ENV{HOME}/Qt/5.14.1/gcc_64)endif()include_directories(src)add_subdirectory(src)add_subdirectory(tests)set(directory db)add_custom_target(build-time-make-directory ALL    COMMAND ${CMAKE_COMMAND} -E make_directory ${directory})

Tests:

cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)include_directories(${CMAKE_SOURCE_DIR})set(CMAKE_AUTOMOC ON)set(CMAKE_AUTOUIC ON)find_package(GTest REQUIRED)include_directories(${GTEST_INCLUDE_DIRS})# Find the QtTest libraryfind_package(Qt5 COMPONENTS Widgets Network Charts WebEngineWidgets Sql CONFIG REQUIRED)qt5_add_resources(RESOURCES ../src/frontend/resource.qrc)# Populate two CMake variables with the sourcesset(test_SRCS tests.cpp)set(project_SRCS     ../src/backend/game.cpp    ../src/frontend/resource.qrc    )add_executable(beergame-tests ${test_SRCS} ${project_SRCS} ${RESOURCES})# set_target_properties(beergame-tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/)target_link_libraries(beergame-tests Qt5::Widgets Qt5::Charts Qt5::WebEngineWidgets Qt5::Sql ${GTEST_LIBRARIES} pthread)set(CMAKE_CXX_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage")set(CMAKE_C_FLAGS "-g -O0 -Wall -W -fprofile-arcs -ftest-coverage")set(CMAKE_EXE_LINKER_FLAGS "-fprofile-arcs -ftest-coverage")

The tests.cpp file gives a few warnings during compilation with make. For example about unused variables. I believe these are coming from gcc:

warning: unused variable ‘C’ [-Wunused-variable]     PlayerDialog* C = new PlayerDialog(&w, *newgame, consumer);

Is there any way I can disable them?

I tried adding -w here:

set(CMAKE_C_FLAGS "-g -O0 -Wall -W -fprofile-arcs -ftest-coverage")

but it didn't work.


Viewing all articles
Browse latest Browse all 22040

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>