Skip to content

fix(windows): skip add_library override when using vcpkg toolchain#1

Open
takaya-murakami-RF wants to merge 1 commit into
noetic-develfrom
feat/windows-base-and-common
Open

fix(windows): skip add_library override when using vcpkg toolchain#1
takaya-murakami-RF wants to merge 1 commit into
noetic-develfrom
feat/windows-base-and-common

Conversation

@takaya-murakami-RF
Copy link
Copy Markdown

Summary

  • platform/windows.cmakeadd_library オーバーライドブロックの条件を if(WIN32) から if(WIN32 AND NOT VCPKG_TOOLCHAIN) に変更

背景

vcpkg のツールチェーンファイル (-DCMAKE_TOOLCHAIN_FILE=vcpkg.cmake) を使う場合、vcpkg 自身も add_library を独自関数でオーバーライドしている。

catkin がさらに function(add_library) を定義すると、CMake の関数チェーン機構により _add_library が vcpkg の関数を指すようになる。catkin の関数が _add_library を呼ぶと vcpkg の関数が動き、その中でさらに _add_library を呼ぶと vcpkg 自身を再帰呼び出しし、スタックオーバーフローになる。

VCPKG_TOOLCHAIN は vcpkg.cmake がツールチェーンとして読み込まれたときのみ設定される変数のため、この条件で正確に分岐できる。

Test plan

  • Windows + vcpkg toolchain file でのビルドが通ること (map4_engine_v3 Windows ビルド)
  • Linux でのビルドに影響がないこと

🤖 Generated with Claude Code

catkin's add_library override (which adds __declspec(dllexport)) conflicts
with vcpkg's own add_library override for imported targets, causing infinite
recursion in CMake when find_package() creates IMPORTED library targets.

Guard with AND NOT VCPKG_TOOLCHAIN so the override only applies to
non-vcpkg Windows builds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant