[FR]: CMake files should provide a "main" with exceptions disabled
- Dominant language
- C++
- Stars
- 39.5k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
### Does the feature exist in the most recent commit?
Not as far as I can tell.
### Why do we need this feature?
Some targets do not support exceptions. In particular, using Emscripten to target WebAssembly with [JSPI](https://developer.chrome.com/blog/webassembly-jspi-origin-trial).
### Describe the proposal.
GTest's CMake files should expose a way to get `gmock_main` without exceptions (and ideally also without RTTI).
Internally GTest has `gmock_main_no_exception` and `gmock_main_no_rtti`, but these are not exported, only used for self-tests.
For an example see https://dawn-review.googlesource.com/c/dawn/+/247996/4/third_party/CMakeLists.txt where I've set up a custom target for gmock_main.cc with exceptions and RTTI disabled. This works but it requires directly listing source files out of the GTest source directory.
This could be as simple as exposing `gmock_main_no_exception` (and perhaps `gmock_main_no_rtti` and a new `gmock_main_no_exception_no_rtti`) but perhaps ideal would be to expose some kind of customizable target, or a just list of source files needed for `gmock_main`, so users can compile these with the flags they need. Unfortunately I am not an expert in CMake so I don't know if there's a nice canonical way to do this.
### Is the feature specific to an operating system, compiler, or build system version?
No, but it's generally only necessary on weird targets like Wasm JSPI.
Contributor guide
Research direction
Start by inspecting the CMake definitions for gmock_main and the internal gmock_main_no_exception and gmock_main_no_rtti targets used by self-tests. Compare them with the custom target in Dawn's third_party/CMakeLists.txt. Done means users can obtain or configure a gmock_main target with exceptions disabled, with the proposed RTTI variants addressed if supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100