Fix Windows configure: point find_package at OBS's exported w32-pthreads
The libobs_DIR fix in 79de5e8f worked -- libobsConfig.cmake now loads on the
Windows runner -- and immediately exposed the next link in the same chain.
obs-studio's libobsConfig.cmake.in carries, under if(MSVC), a hard
find_dependency(w32-pthreads REQUIRED)
because libobs/cmake/os-windows.cmake links PUBLIC OBS::w32-pthreads. That
lookup failed and aborted the whole configure.
The cause is not a missing export, which was the first hypothesis:
deps/w32-pthreads/CMakeLists.txt ends in target_export(w32-pthreads), the
same helper libobs itself uses, so the install(TARGETS ... EXPORT),
install(EXPORT ... NAMESPACE OBS::) and generated w32-pthreadsConfig.cmake
all exist and all run -- CMake would have hard-errored at generate time if
w32-pthreads were in no export set, and our own patch adds it under the
libobs subtree, which installs before the tolerated obs-frontend-api install
error stops the rest.
It is the same search-path mismatch libobs itself had: target_export installs
to <prefix>/${OBS_CMAKE_DESTINATION}/<target>/, which on Windows is
<prefix>/cmake/w32-pthreads/ -- a shape find_package's Config-mode suffixes
never search. So apply the same remedy CMake's own error message suggests,
and apply it before the find_package(libobs) call that transitively triggers
the find_dependency.
Also adds a fallback Findw32-pthreads.cmake, reached only when that export is
genuinely absent, which reconstructs OBS::w32-pthreads from the bootstrap's
artifacts, and a repair for a locationless imported target mirroring the
existing OBS::libobs one. The fallback deliberately lives in
cmake/windows/find-fallback/ rather than cmake/windows/, which osconfig.cmake
already puts on CMAKE_MODULE_PATH: a find module there would shadow OBS's
real exported package on every build, since MODULE mode is tried first.
Verified on Linux (this is a Linux sandbox) by reconstructing the exact
failure -- a stub libobsConfig.cmake with the same find_dependency, reached
through libobs_DIR -- and confirming it fails without this block and passes
with it, and separately that deleting the package routes find_package through
the fallback module instead. A full Linux configure of the repo is unchanged;
both new blocks are inside if(OS_WINDOWS) and the upstream find_dependency is
inside if(MSVC), so macOS and Linux are no-ops.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RL8abRmgFXkVASHkkqiJbE
This commit is contained in:
+111
@@ -184,8 +184,119 @@ if(OS_WINDOWS AND NOT libobs_DIR)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ...and the exact same problem, one level down, for w32-pthreads.
|
||||
#
|
||||
# libobs/cmake/os-windows.cmake links `PUBLIC OBS::w32-pthreads`, so
|
||||
# obs-studio's libobsConfig.cmake.in carries, verbatim:
|
||||
#
|
||||
# if(MSVC)
|
||||
# find_dependency(w32-pthreads REQUIRED)
|
||||
# endif()
|
||||
#
|
||||
# That call is REQUIRED, it runs from inside libobsConfig.cmake, and until
|
||||
# this block existed it aborted the whole configure the moment the libobs_DIR
|
||||
# fix above finally succeeded in loading that config file:
|
||||
#
|
||||
# By not providing "Findw32-pthreads.cmake" in CMAKE_MODULE_PATH this
|
||||
# project has asked CMake to find a package configuration file provided by
|
||||
# "w32-pthreads", but CMake did not find one.
|
||||
# .deps/cmake/libobs/libobsConfig.cmake:30 (find_dependency)
|
||||
#
|
||||
# This is NOT a missing export. deps/w32-pthreads/CMakeLists.txt ends with
|
||||
# `target_export(w32-pthreads)`, which is the same helper libobs itself uses
|
||||
# (cmake/common/helpers_common.cmake): it emits install(TARGETS ... EXPORT
|
||||
# w32-pthreadsTargets), install(EXPORT ... NAMESPACE OBS::), a generated
|
||||
# w32-pthreadsConfig.cmake and its version file, all COMPONENT Development.
|
||||
# Those rules *must* exist and *must* have run, for two independent reasons:
|
||||
#
|
||||
# 1. CMake hard-errors at generate time if a target in one export set links
|
||||
# to a target that is in no export set at all ("install(EXPORT
|
||||
# "libobsTargets") includes target "libobs" which requires target
|
||||
# "w32-pthreads" that is not in any export set"). obs-studio's generate
|
||||
# step succeeded, so w32-pthreads was exported.
|
||||
# 2. The install rules land under the libobs *directory* (this repo's
|
||||
# _patch_obs_studio_w32_pthreads adds deps/w32-pthreads from
|
||||
# libobs/CMakeLists.txt), and libobs is the first subdirectory the modern
|
||||
# top-level CMakeLists.txt adds -- so its whole subtree installs before
|
||||
# the tolerated UI/obs-frontend-api install error aborts the rest.
|
||||
#
|
||||
# The failure is purely the search path, identical to libobs's: target_export
|
||||
# installs the package to "${OBS_CMAKE_DESTINATION}/${target}", which on
|
||||
# Windows is <prefix>/cmake/w32-pthreads/ -- a shape find_package never
|
||||
# searches. So apply the same remedy CMake's own error message suggests, and
|
||||
# do it BEFORE find_package(libobs) below, because that is the call that
|
||||
# transitively triggers find_dependency(w32-pthreads).
|
||||
#
|
||||
# macOS and Linux never reach this: the find_dependency is inside `if(MSVC)`,
|
||||
# and OS_WINDOWS gates the block regardless -- a pure no-op off Windows.
|
||||
if(OS_WINDOWS AND NOT w32-pthreads_DIR)
|
||||
set(_stplugin_win_pthreads_dir "${CMAKE_CURRENT_SOURCE_DIR}/.deps/cmake/w32-pthreads")
|
||||
if(EXISTS "${_stplugin_win_pthreads_dir}/w32-pthreadsConfig.cmake")
|
||||
set(w32-pthreads_DIR "${_stplugin_win_pthreads_dir}" CACHE PATH
|
||||
"Directory containing w32-pthreadsConfig.cmake" FORCE)
|
||||
message(STATUS
|
||||
"w32-pthreads_DIR not set; libobsConfig.cmake's "
|
||||
"find_dependency(w32-pthreads REQUIRED) hits the same "
|
||||
"OBS_CMAKE_DESTINATION=cmake search-suffix problem as libobs "
|
||||
"itself, so pointing it directly at the from-source install: "
|
||||
"${_stplugin_win_pthreads_dir}")
|
||||
else()
|
||||
# Fall back to a hand-written find module rather than letting the
|
||||
# REQUIRED find_dependency kill the configure. cmake/windows is
|
||||
# already on CMAKE_MODULE_PATH (see cmake/common/osconfig.cmake), so
|
||||
# the fallback module deliberately lives in a subdirectory that is
|
||||
# NOT -- a Findw32-pthreads.cmake sitting on the default module path
|
||||
# would shadow OBS's own exported package on every build, and its
|
||||
# real export is the better answer whenever it is present.
|
||||
#
|
||||
# Reaching here means the bootstrap install did not produce the
|
||||
# export, so say exactly what IS in .deps/cmake/ -- the next CI log
|
||||
# then answers the question directly instead of costing another run.
|
||||
file(GLOB _stplugin_deps_cmake_dirs "${CMAKE_CURRENT_SOURCE_DIR}/.deps/cmake/*")
|
||||
message(STATUS
|
||||
"No w32-pthreadsConfig.cmake at ${_stplugin_win_pthreads_dir}; "
|
||||
"OBS CMake packages actually installed under .deps/cmake: "
|
||||
"'${_stplugin_deps_cmake_dirs}'. Falling back to this repo's own "
|
||||
"Findw32-pthreads.cmake, which builds OBS::w32-pthreads straight "
|
||||
"from the bootstrap's build artifacts.")
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/windows/find-fallback")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(libobs QUIET)
|
||||
|
||||
# OBS::w32-pthreads can come back locationless for exactly the same reason
|
||||
# OBS::libobs can (see the block below this one): the package config loads,
|
||||
# but the per-configuration w32-pthreadsTargets-release.cmake that carries
|
||||
# IMPORTED_IMPLIB/IMPORTED_LOCATION may not have been installed. libobs links
|
||||
# it PUBLIC, so it is on this plugin's own link line and an empty location is
|
||||
# a generate-time error, not a warning. Repair it from the known install
|
||||
# destinations (obs-studio/cmake/windows/defaults.cmake:
|
||||
# OBS_EXECUTABLE_DESTINATION=bin/64bit for the DLL, OBS_LIBRARY_DESTINATION=lib
|
||||
# for the import library) -- the same repair, and the same reasoning, as the
|
||||
# OBS::libobs one.
|
||||
if(OS_WINDOWS AND TARGET OBS::w32-pthreads)
|
||||
get_target_property(_stplugin_pthreads_implib OBS::w32-pthreads IMPORTED_IMPLIB)
|
||||
get_target_property(_stplugin_pthreads_implib_release OBS::w32-pthreads IMPORTED_IMPLIB_RELEASE)
|
||||
if(NOT _stplugin_pthreads_implib AND NOT _stplugin_pthreads_implib_release)
|
||||
find_file(_stplugin_pthreads_implib_found w32-pthreads.lib
|
||||
PATHS "${CMAKE_CURRENT_SOURCE_DIR}/.deps/lib" NO_DEFAULT_PATH)
|
||||
find_file(_stplugin_pthreads_dll_found w32-pthreads.dll
|
||||
PATHS "${CMAKE_CURRENT_SOURCE_DIR}/.deps/bin/64bit" NO_DEFAULT_PATH)
|
||||
if(_stplugin_pthreads_implib_found)
|
||||
set_target_properties(OBS::w32-pthreads PROPERTIES
|
||||
IMPORTED_IMPLIB "${_stplugin_pthreads_implib_found}")
|
||||
if(_stplugin_pthreads_dll_found)
|
||||
set_target_properties(OBS::w32-pthreads PROPERTIES
|
||||
IMPORTED_LOCATION "${_stplugin_pthreads_dll_found}")
|
||||
endif()
|
||||
message(STATUS
|
||||
"OBS::w32-pthreads had no imported location; pointed it at "
|
||||
"${_stplugin_pthreads_implib_found}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# The imported OBS::libobs target can come back without a location. OBS 30.0.2
|
||||
# installs libobsTargets.cmake but not the per-configuration
|
||||
# libobsTargets-<config>.cmake alongside it when libobs is built on its own,
|
||||
|
||||
Reference in New Issue
Block a user