Skip to content

Commit

Permalink
Update performance_test_fixture to C++17. (#21)
Browse files Browse the repository at this point in the history
The two reasons to do this are:

1. So that we can compile performance_test_fixture
   with the clang static analyzer. As of clang++-14
   (what is in Ubuntu 22.04), the default still seems
   to be C++14, so we need to specify C++17 so that new
   things in the rclcpp headers work properly.
2. So we can build with a newer version of gtest which requires this.

Further, due to reasons I don't fully understand, I needed to
set CMAKE_CXX_STANDARD_REQUIRED in order for clang to really use
that version. So set this as well.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
  • Loading branch information
clalancette committed Jan 30, 2023
1 parent ec8ae54 commit fe9857b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
@@ -1,9 +1,10 @@
cmake_minimum_required(VERSION 3.5)
project(performance_test_fixture CXX)

# Default to C++14
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down

1 comment on commit fe9857b

@openvmp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the build at least on the latest MacOS with the latest XCode.
osrf_testing_tools_cpp keeps using C++11 and, thus, uses "mpark variant" while performance_test_fixture starts expecting "std::variant".
That causes symbols mismatch during linking and, thus:

<<<
--- stderr: performance_test_fixture
Undefined symbols for architecture x86_64:
"osrf_testing_tools_cpp::memory_tools::on_unexpected_calloc(std::__1::variant<std::__1::function<void (osrf_testing_tools_cpp::memory_tools::MemoryToolsService&)>, std::__1::function<void ()>, std::nullptr_t>)", referenced from:
performance_test_fixture::PerformanceTest::SetUp(benchmark::State&) in performance_test_fixture.cpp.o
"osrf_testing_tools_cpp::memory_tools::on_unexpected_malloc(std::__1::variant<std::__1::function<void (osrf_testing_tools_cpp::memory_tools::MemoryToolsService&)>, std::__1::function<void ()>, std::nullptr_t>)", referenced from:
performance_test_fixture::PerformanceTest::SetUp(benchmark::State&) in performance_test_fixture.cpp.o
"osrf_testing_tools_cpp::memory_tools::on_unexpected_realloc(std::__1::variant<std::__1::function<void (osrf_testing_tools_cpp::memory_tools::MemoryToolsService&)>, std::__1::function<void ()>, std::nullptr_t>)", referenced from:
performance_test_fixture::PerformanceTest::SetUp(benchmark::State&) in performance_test_fixture.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libperformance_test_fixture.dylib] Error 1
make[1]: *** [CMakeFiles/performance_test_fixture.dir/all] Error 2
make: *** [all] Error 2

Please sign in to comment.