Skip to content

Conversation

@nathan-white-mojang
Copy link

Fixes #49720.

Guards the add_library call so that consumers of the package can call find_package without needing to guard to avoid the CMake build:

_add_library cannot create imported target "Microsoft::CppWinRT" because
  another target with the same name already exists.

Copy link
Contributor

@dg0yt dg0yt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it is not your fault, apart from theCPPWINRT_TOOL item. I just comment what I see.


set(_cppwinrt_exe "${_cppwinrt_root}/@tool_path@")
if (EXISTS "${_cppwinrt_exe}")
if (NOT TARGET Microsoft::CppWinRT)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guarding add_library is right, but

else()

set(cppwinrt_FOUND FALSE)
if (EXISTS "${_cppwinrt_exe}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is pointless. The executable is always installed by the port.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but I would like to leave the number of changes I'm making minimal

)

set(cppwinrt_FOUND TRUE)
set(CPPWINRT_TOOL ${_cppwinrt_exe})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It must always set CPPWINRT_TOOL in the local scope, regardless of the library target.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate why please?

INTERFACE_LINK_LIBRARIES "${_cppwinrt_root}/lib/@lib_name@"
)

set(cppwinrt_FOUND TRUE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is handled by CMake if the call is spelled find_package(cppwinrt ...).


else()

set(cppwinrt_FOUND FALSE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't happen when lib and exe are installed.

@nathan-white-mojang

This comment was marked as resolved.

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.

[cppwinrt] missing add_library guard

2 participants