Catch2 fails to link when using a CMake multi-config generator

オープン
#2,892 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cmake, cpp

調査の方向性

まず、提供されている Conan と CMake のセットアップを Ninja Multi-Config で再現し、次に動作する Ninja ジェネレーターと比較します。Catch2-Target-release.cmake のコメントと設定ロジックを読み、設定がパスに追加される方法に注目してください。Multi-Config ビルドで xxx_test が、Catch2 のシンボルや main の不足なしに正常にリンクできれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug
When Catch2 is installed using Conan into a project using CMake, and the project uses a multi-config generator such as "Ninja Multi-Config", building the project results in linker errors having to do with missing references to Catch2 symbols.

Expected behavior
Project should link successfully.

Reproduction steps

  1. Install Catch2 using Conan:
[test_requires]
catch2/3.6.0
  1. Use Conan's CMake integration to find and link against Catch2:
add_executable(xxx_test ${SOURCES_WITHOUT_MAIN} ${TEST_SOURCES})
find_package(Catch2 REQUIRED)
target_link_libraries(xxx_test PRIVATE Catch2::Catch2WithMain)
  1. Configure + build using CMake and the "Ninja Multi-Config" generator
cmake -G "Ninja Multi-Config" -S. -B ./build --preset=conan-release && cmake --build ./build
  1. Observe link errors:
FAILED: Debug/xxx_test 
...
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../lib/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: CMakeFiles/xxx_test.dir/Debug/test/XXX.test.cpp.o: in function `CATCH2_INTERNAL_TEST_0()':
/home/tom/projects/xxx/projects/xxx/test/XXX.test.cpp:6:(.text+0x4e): undefined reference to `Catch::ReusableStringStream::ReusableStringStream()'
...

Platform information:

  • OS: Arch Linux
  • Compiler+version: GCC v14.1.1
  • Catch version: v3.6.0
  • Conan version: 2.5.0

Additional context

  1. When changing the generator to "Ninja" things work as expected.
  2. The following comment exists in Catch2-Target-release.cmake:
# FIXME: What is the result of this for multi-config? All configs adding themselves to path?
主要言語
C++
スター
21.6k
フォーク
3.4k
平均マージ
3日 12時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

catchorg/Catch2 のほかの issue

catchorg/Catch2 の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。