fix(windows): skip add_library override when using vcpkg toolchain#1
Open
takaya-murakami-RF wants to merge 1 commit into
Open
fix(windows): skip add_library override when using vcpkg toolchain#1takaya-murakami-RF wants to merge 1 commit into
takaya-murakami-RF wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
platform/windows.cmakeのadd_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
map4_engine_v3Windows ビルド)🤖 Generated with Claude Code