Skip to content

feat(gtest): gate gtest_main behind 'main' feature (mcpp #168)#45

Merged
Sunrisepeak merged 1 commit into
mainfrom
feat/gtest-main-feature
Jun 25, 2026
Merged

feat(gtest): gate gtest_main behind 'main' feature (mcpp #168)#45
Sunrisepeak merged 1 commit into
mainfrom
feat/gtest-main-feature

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

Gate gtest_main.cc behind a main feature so it isn't linked by default (fixes mcpp-community/mcpp#168 where a regular-dep gtest collided with the app's main).

Compat: gtest_main.cc stays in base sources too, so old mcpp (ignores features) is unaffected (verified: 0.0.64 mcpp test still works against this descriptor). New mcpp (>=0.0.65) treats feature-listed sources as gated → default framework-only, features=["main"] opts in.

Pairs with mcpp 0.0.65 (feature-gated sources + mcpp add --dev).

gtest_main.cc provides its own main(); linked by default it collides with a
consumer's own main (e.g. app via mcpp add gtest + mcpp build → LNK2005).

Gate it behind the 'main' feature: kept in base sources (old mcpp ignores
features → no regression) AND listed under features.main.sources so new mcpp
(>=0.0.65) excludes it by default and includes it only with
gtest = { version=..., features=["main"] }. mcpp test's dev-dep main detection
is unaffected (gating is build-mode only).
@Sunrisepeak Sunrisepeak merged commit c77cae8 into main Jun 25, 2026
5 checks passed
@Sunrisepeak Sunrisepeak deleted the feat/gtest-main-feature branch June 25, 2026 05:47
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

Successfully merging this pull request may close these issues.

在mcpp.toml的[dependences]添加gtest依赖时,gtest_main与程序入口main函数冲突问题

1 participant