Skip to content

Commit

Permalink
gtest: fix poisoned exit in compile flags
Browse files Browse the repository at this point in the history
visibility.h is included globally in PX4 via cmake compile flags.
It contains poisoning the exit() command which is used by gtest
to close the test application. Removing the flag for gtest compilation
fixes the compile error:
gtest.cc:4757:7: error: attempt to use poisoned "exit"
  • Loading branch information
MaEtUgR committed May 9, 2019
1 parent 8eb0d66 commit f5f9563
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmake/gtest/gtest.cmake
Expand Up @@ -41,3 +41,9 @@ endif()

# Add googletest, defines gtest and gtest_main targets
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src ${CMAKE_CURRENT_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL)

# Remove visibility.h from the compile flags for gtest because of poisoned exit()
get_target_property(GTEST_COMPILE_FLAGS gtest COMPILE_OPTIONS)
list(REMOVE_ITEM GTEST_COMPILE_FLAGS "-include")
list(REMOVE_ITEM GTEST_COMPILE_FLAGS "visibility.h")
set_target_properties(gtest PROPERTIES COMPILE_OPTIONS "${GTEST_COMPILE_FLAGS}")
2 changes: 1 addition & 1 deletion src/include/visibility.h
Expand Up @@ -86,7 +86,7 @@
#ifdef __cplusplus
#include <cstdlib>
#endif
//#pragma GCC poison exit
#pragma GCC poison exit

#include <stdlib.h>

Expand Down

0 comments on commit f5f9563

Please sign in to comment.