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

[Bug]: Passing -DGTEST_HAS_RTTI=0 using cmake has no effect #4678

Open
eyalgolan1337 opened this issue Dec 11, 2024 · 0 comments
Open

[Bug]: Passing -DGTEST_HAS_RTTI=0 using cmake has no effect #4678

eyalgolan1337 opened this issue Dec 11, 2024 · 0 comments

Comments

@eyalgolan1337
Copy link

Describe the issue

When passing -DGTEST_HAS_RTTI=0 to cmake the value of GTEST_HAS_RTTI still ends being 1, which causes gtest to use typeid. This is obviously a problem when trying to use gtest with code that was compiled with -fno-rtti.

As a side-note, I ran into this problem when using gtest though vcpkg, so in order to define this preprocessor macro i had to add a patch to gtest's CMakeLists.txt and add add_definitions(-DGTEST_HAS_RTTI=0) because it does not support passing the options defined in gtest-port.h. Consider adding support for these options in the cmakelists file in the future so a patch is not needed and instead passing GTEST_HAS_RTTI=OFF to vcpkg_cmake_configure will be enough

Steps to reproduce the problem

try and link gtest compiled with -DGTEST_HAS_RTTI=0 into a binary compiled with -fno-rtti. The problem occurs when trying to use TYPED_TEST_SUITE()

What version of GoogleTest are you using?

1.14.0 through vcpkg

What operating system and version are you using?

ubuntu22.04

What compiler and version are you using?

gcc 13.2

What build system are you using?

cmake 3.28

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant