From f5f95635b4afb87dc89c8a62319cbe849c5f5bfc Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Sun, 10 Mar 2019 15:14:08 +0100 Subject: [PATCH] gtest: fix poisoned exit in compile flags 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" --- cmake/gtest/gtest.cmake | 6 ++++++ src/include/visibility.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/gtest/gtest.cmake b/cmake/gtest/gtest.cmake index 94c4103ce5..3b74cfb211 100644 --- a/cmake/gtest/gtest.cmake +++ b/cmake/gtest/gtest.cmake @@ -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}") diff --git a/src/include/visibility.h b/src/include/visibility.h index 3717b63704..1a956f02e8 100644 --- a/src/include/visibility.h +++ b/src/include/visibility.h @@ -86,7 +86,7 @@ #ifdef __cplusplus #include #endif -//#pragma GCC poison exit +#pragma GCC poison exit #include