Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Fix malformed CMake package location on Windows #11114

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

PatTheMav
Copy link
Member

Description

Fix package export destination for Windows to meet CMake requirements exclusive to that platform.

Motivation and Context

CMake doesn't expect CMake package files to be separated in subdirectories on Windows and instead expects all files to be put in a single directory cmake found within one of the PREFIX paths.

Also fixes circular dependency in w32-pthreads CMake package config file.

Required to unblock obsproject/obs-plugintemplate#126.

How Has This Been Tested?

Tested on Windows 11.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

CMake doesn't expect CMake package files to be separated in
subdirectories on Windows and instead expects all files to be put in
a single directory `cmake` found within one of the PREFIX paths.

Also fixes circular dependency in w32-pthreads CMake package config
file.
@PatTheMav PatTheMav force-pushed the windows-cmake-export-fix branch from 6ad0a59 to 72bb2c0 Compare August 14, 2024 17:01
@RytoEX
Copy link
Member

RytoEX commented Aug 14, 2024

What should be the observed before/after on this?

@PatTheMav
Copy link
Member Author

What should be the observed before/after on this?

Without this fix it's impossible to build/link anything on Windows that uses libobs as the dependency on w32-pthreads creates a circular dependency on libobs again.

As the plugin template has used the legacy path so far, the issue wasn't exposed and apparently no-one else attempted to use a non-legacy libobs build procedure to link against it.

@RytoEX
Copy link
Member

RytoEX commented Aug 15, 2024

And the package change location change?

@PatTheMav
Copy link
Member Author

And the package change location change?

Before: <prefix>/cmake/<target>/<target>Config.cmake

After: <prefix>/cmake/<target>Config.cmake,
which hits the second variant according to https://cmake.org/cmake/help/latest/command/find_package.html#id10.

Windows-specific alternatives would have been:

  • <prefix>/cmake/<target>/cmake/<target>Config.cmake
  • <prefix>/<target>/<target>Config.cmake
  • <prefix>/<target>/cmake/<target>/<target>Config.cmake
  • <prefix>/<target>/lib/cmake/<target>/<target>Config.cmake
  • <prefix>/<target>/lib/<target>/<target>Config.cmake
  • <prefix>/<target>/lib/<target>/cmake/<target>Config.cmake

Variant #2 seemed to be the simplest one to meet Windows-specific requirements and should be in line with how the legacy system exported the files.

@RytoEX RytoEX merged commit c89cef3 into obsproject:master Aug 20, 2024
15 checks passed
@PatTheMav PatTheMav deleted the windows-cmake-export-fix branch August 20, 2024 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Affects Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants