Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler warnings related to gtest/gmock (#408) #495

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions ament_cmake_gmock/ament_cmake_gmock-extras.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ macro(_ament_cmake_gmock_find_gmock)
# add CMakeLists.txt from gmock dir
add_subdirectory("${GMOCK_FROM_SOURCE_BASE_DIR}" "${CMAKE_BINARY_DIR}/gmock")

if(NOT WIN32)
set(_gmock_compile_flags "-Wno-missing-field-initializers")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(_gmock_compile_flags "${_gmock_compile_flags} -Wno-unused-const-variable")
endif()
set_target_properties(gmock gmock_main PROPERTIES COMPILE_FLAGS "${_gmock_compile_flags}")
endif()

# mark gmock targets with EXCLUDE_FROM_ALL to only build
# when tests are built which depend on them
set_target_properties(gmock gmock_main PROPERTIES EXCLUDE_FROM_ALL 1)
Expand Down
2 changes: 1 addition & 1 deletion ament_cmake_gmock/cmake/ament_add_gmock.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function(_ament_add_gmock target)
# should be EXCLUDE_FROM_ALL if it would be possible
# to add this target as a dependency to the "test" target
add_executable("${target}" ${ARG_UNPARSED_ARGUMENTS})
target_include_directories("${target}" PUBLIC "${GMOCK_INCLUDE_DIRS}")
target_include_directories("${target}" SYSTEM PRIVATE "${GMOCK_INCLUDE_DIRS}")
if(NOT ARG_SKIP_LINKING_MAIN_LIBRARIES)
target_link_libraries("${target}" ${GMOCK_MAIN_LIBRARIES})
endif()
Expand Down
4 changes: 2 additions & 2 deletions ament_cmake_gtest/ament_cmake_gtest-extras.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ macro(_ament_cmake_gtest_find_gtest)
if(NOT WIN32)
target_compile_options(gtest PRIVATE -Wno-null-dereference)
endif()
target_include_directories(gtest BEFORE PUBLIC "${GTEST_FROM_SOURCE_INCLUDE_DIRS}")
target_include_directories(gtest_main BEFORE PUBLIC "${GTEST_FROM_SOURCE_INCLUDE_DIRS}")
target_include_directories(gtest SYSTEM BEFORE PUBLIC "${GTEST_FROM_SOURCE_INCLUDE_DIRS}")
target_include_directories(gtest_main SYSTEM BEFORE PUBLIC "${GTEST_FROM_SOURCE_INCLUDE_DIRS}")
endif()

# set the same variables as find_package()
Expand Down
2 changes: 1 addition & 1 deletion ament_cmake_gtest/cmake/ament_add_gtest_executable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function(_ament_add_gtest_executable target)
# should be EXCLUDE_FROM_ALL if it would be possible
# to add this target as a dependency to the "test" target
add_executable("${target}" ${ARG_UNPARSED_ARGUMENTS})
target_include_directories("${target}" BEFORE PUBLIC "${GTEST_INCLUDE_DIRS}")
target_include_directories("${target}" SYSTEM PRIVATE "${GTEST_INCLUDE_DIRS}")
if(NOT ARG_SKIP_LINKING_MAIN_LIBRARIES)
target_link_libraries("${target}" ${GTEST_MAIN_LIBRARIES})
endif()
Expand Down