Skip to content

Cmake: Fixes Windows cmake install path config#45

Merged
kixelated merged 8 commits into
moq-dev:mainfrom
danrossi:win-build-fix-new
Jun 29, 2026
Merged

Cmake: Fixes Windows cmake install path config#45
kixelated merged 8 commits into
moq-dev:mainfrom
danrossi:win-build-fix-new

Conversation

@danrossi

Copy link
Copy Markdown
Contributor

The Windows cmake install config needs the path reformatted to forward slashes to compile and install correctly.

Adds Windows specific build docs

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • If the goal is to normalize the Windows install prefix to forward slashes, consider using cmake_path(CONVERT $ENV{ALLUSERSPROFILE} TO_CMAKE_PATH ALLUSERSPROFILE_PATH) rather than cmake_path(SET ...), which only assigns the value without conversion.
  • The Windows build instructions hard-code specific tool versions and generator names (e.g., visualstudio2026buildtools, Visual Studio 18 2026); consider clarifying the actual supported Visual Studio version or making the instructions version-agnostic to avoid confusion as these names change.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- If the goal is to normalize the Windows install prefix to forward slashes, consider using `cmake_path(CONVERT $ENV{ALLUSERSPROFILE} TO_CMAKE_PATH ALLUSERSPROFILE_PATH)` rather than `cmake_path(SET ...)`, which only assigns the value without conversion.
- The Windows build instructions hard-code specific tool versions and generator names (e.g., `visualstudio2026buildtools`, `Visual Studio 18 2026`); consider clarifying the actual supported Visual Studio version or making the instructions version-agnostic to avoid confusion as these names change.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kixelated, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 54 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dafb6610-4048-43fa-b17b-e92f3ee05082

📥 Commits

Reviewing files that changed from the base of the PR and between e0ab0e7 and 489f29f.

📒 Files selected for processing (5)
  • CMakeLists.txt
  • README.md
  • WINDOWS.md
  • src/moq-dock.cpp
  • src/obs-moq.cpp

Walkthrough

Adds WINDOWS.md with Windows build, install, and debug steps, updates README.md setup and streaming documentation formatting, and refreshes the supported build environments table. It also changes Windows install-prefix construction in cmake/windows/defaults.cmake, adds Windows system libraries in CMakeLists.txt, updates dock default relay and broadcast values, and adds Windows console allocation and log redirection in src/obs-moq.cpp.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main Windows CMake install path fix and related documentation work.
Description check ✅ Passed The description is on-topic and describes the Windows path fix and added build docs.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
WINDOWS.md (2)

1-38: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Missing prerequisite: PowerShell execution policy and administrator elevation.

Consider adding a note that some commands (Chocolatey install, system-wide PATH modification) may require running PowerShell as Administrator. Also, the Set-ExecutionPolicy Bypass on line 6 is scoped to Process, which is good practice, but users may need to permanently allow script execution for subsequent build steps.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@WINDOWS.md` around lines 1 - 38, The Windows build guide is missing
prerequisite notes for elevated PowerShell access and script execution
permissions. Update the build setup section around the Chocolatey install and
related setup steps to explicitly mention when PowerShell must be run as
Administrator, and clarify that the current Set-ExecutionPolicy command is
process-scoped while noting any cases where users may need broader script
execution permissions for subsequent setup commands.

13-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Automate nightly toolchain selection instead of manual instruction.

Replace the manual "choose the nightly variant" step with an explicit command to ensure reproducibility:

rustup default nightly

Or if multiple toolchains are needed:

rustup toolchain install nightly
rustup default nightly
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@WINDOWS.md` at line 13, The Windows setup docs still tell users to manually
choose the nightly Rust toolchain during rustup installation; replace that
instruction with an explicit command sequence in WINDOWS.md so the setup is
reproducible. Update the relevant toolchain setup step to use rustup default
nightly, or rustup toolchain install nightly followed by rustup default nightly
if you want to preserve multiple toolchains, and remove the manual selection
wording.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@WINDOWS.md`:
- Line 9: The Windows setup instructions are out of sync with the repo’s actual
toolchain and reference the wrong Visual Studio version. Update the guidance in
WINDOWS.md to use the 2022 build tools/package names and workload names that
match the existing Windows preset and any related references to the Visual
Studio toolchain, so the documented install path aligns with the repo
configuration.
- Line 21: The build command in WINDOWS.md is redundant and inconsistent because
it hardcodes a CMake generator while the windows-x64 preset already defines the
generator in CMakePresets.json. Remove the explicit -G flag from the documented
cmake invocation and keep relying on the windows-x64 preset’s generator settings
so the command matches the preset configuration.

---

Nitpick comments:
In `@WINDOWS.md`:
- Around line 1-38: The Windows build guide is missing prerequisite notes for
elevated PowerShell access and script execution permissions. Update the build
setup section around the Chocolatey install and related setup steps to
explicitly mention when PowerShell must be run as Administrator, and clarify
that the current Set-ExecutionPolicy command is process-scoped while noting any
cases where users may need broader script execution permissions for subsequent
setup commands.
- Line 13: The Windows setup docs still tell users to manually choose the
nightly Rust toolchain during rustup installation; replace that instruction with
an explicit command sequence in WINDOWS.md so the setup is reproducible. Update
the relevant toolchain setup step to use rustup default nightly, or rustup
toolchain install nightly followed by rustup default nightly if you want to
preserve multiple toolchains, and remove the manual selection wording.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fd801b15-2073-409a-9cac-22361ba672c5

📥 Commits

Reviewing files that changed from the base of the PR and between 0c91947 and 152a1cc.

📒 Files selected for processing (2)
  • WINDOWS.md
  • cmake/windows/defaults.cmake

Comment thread WINDOWS.md Outdated
Comment thread WINDOWS.md Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Around line 33-56: The build instructions mix preset-based CMake invocation
with explicit generator/architecture flags, so update the OBS build steps to use
the preset consistently via the relevant preset name and remove the redundant
-G/-A options from the CMake command. Check the build section in README.md and
align the Windows command with the preset-defined generator/architecture in
CMakePresets.json, then verify the macOS build step uses the correct binary
directory for the macOS preset instead of assuming build_macos.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09c49fc3-690e-4d26-9b8c-8f11f8bedc40

📥 Commits

Reviewing files that changed from the base of the PR and between 152a1cc and 3087800.

📒 Files selected for processing (1)
  • README.md

Comment thread README.md
@danrossi

Copy link
Copy Markdown
Contributor Author

I've updated the build readme from the other PR. the current branch of obs-studio to build now requires Xcode 26.5 it was decided on eventually. So the docs need to be updated for that also. Still checking mac building what it needs.

@danrossi

Copy link
Copy Markdown
Contributor Author

The documented obs-studio fork doesnt compile in Windows and broken. The plugin won't load with the merged obs upstream. It's missing a dependency I think and won't load but no error produced other claiming it's not found.

I've added back in the windows console debugger to see the rust logs.

https://github.com/danrossi/obs-studio/tree/moq-merged

@kixelated

Copy link
Copy Markdown
Collaborator

I've got a Windows PC so I'll test this a bit more.

Note that you don't need the OBS fork any longer, because I added a MoQ dock.

kixelated pushed a commit to danrossi/obs that referenced this pull request Jun 29, 2026
- Drop the redundant `-G "Visual Studio 18 2026" -A x64` from the docs:
  with `--preset`, the generator and architecture come from the preset
  (Visual Studio 17 2022), and a non-matching `-G` makes CMake error.
- Align the documented Visual Studio version with the preset (2022, not
  2026), including the chocolatey build-tools package.
- Revert the macOS build doc to `cmake --build --preset macos` (matching
  the justfile) instead of a raw xcodebuild invocation.
- Fix obs-moq.cpp formatting to satisfy clang-format (IndentPPDirectives:
  None / right pointer alignment): de-indent the preprocessor blocks,
  use `const char *`, and drop the stray blank line.
- Include <cstdlib> for std::getenv rather than relying on a transitive
  include.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/obs-moq.cpp`:
- Around line 56-58: The console redirection in the obs-moq startup path should
only happen after confirming `AllocConsole()` succeeded and a valid console is
available. Update the `AllocConsole`/`freopen` sequence in `src/obs-moq.cpp` so
`stdout` and `stderr` are reopened to `CONOUT$` only when the console allocation
succeeds; otherwise skip the redirection and keep the existing process streams
intact. Use the existing startup block around `AllocConsole()` and the two
`freopen` calls as the place to add the guard.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e2277cdd-51ce-4028-98f7-34cf4de85b2d

📥 Commits

Reviewing files that changed from the base of the PR and between 3087800 and e0ab0e7.

📒 Files selected for processing (5)
  • CMakeLists.txt
  • README.md
  • WINDOWS.md
  • src/moq-dock.cpp
  • src/obs-moq.cpp
✅ Files skipped from review due to trivial changes (1)
  • WINDOWS.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

Comment thread src/obs-moq.cpp
Comment on lines +56 to +58
AllocConsole();
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Guard the freopen calls behind a verified console handle.

Lines 56-58 rewrite process-wide stdout/stderr without checking whether AllocConsole() actually produced a usable console. If that open path fails, freopen can leave OBS's stdio streams unusable for the rest of the process on this debug path.

Suggested fix
 `#ifdef` _WIN64
 	const char *logLevel = std::getenv("RUST_LOG");
 	if (logLevel && strcmp(logLevel, "debug") == 0) {
-		AllocConsole();
-		freopen("CONOUT$", "w", stdout);
-		freopen("CONOUT$", "w", stderr);
+		if (AllocConsole() || GetLastError() == ERROR_ACCESS_DENIED) {
+			FILE *out = freopen("CONOUT$", "w", stdout);
+			FILE *err = freopen("CONOUT$", "w", stderr);
+			if (!out || !err) {
+				// Leave the module loaded; console logging just stays unavailable.
+			}
+		}
 	}
 `#endif`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
AllocConsole();
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
if (AllocConsole() || GetLastError() == ERROR_ACCESS_DENIED) {
FILE *out = freopen("CONOUT$", "w", stdout);
FILE *err = freopen("CONOUT$", "w", stderr);
if (!out || !err) {
// Leave the module loaded; console logging just stays unavailable.
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/obs-moq.cpp` around lines 56 - 58, The console redirection in the obs-moq
startup path should only happen after confirming `AllocConsole()` succeeded and
a valid console is available. Update the `AllocConsole`/`freopen` sequence in
`src/obs-moq.cpp` so `stdout` and `stderr` are reopened to `CONOUT$` only when
the console allocation succeeds; otherwise skip the redirection and keep the
existing process streams intact. Use the existing startup block around
`AllocConsole()` and the two `freopen` calls as the place to add the guard.

kixcord and others added 4 commits June 29, 2026 13:12
libmoq is a Rust static library whose std runtime references Windows
system symbols (e.g. NtCreateNamedPipeFile from ntdll) that MSVC does not
auto-resolve when the archive is linked into the plugin module, causing
LNK2001/LNK1120 at link time. Link the OS import libraries reported by
`rustc --print native-static-libs` that aren't pulled in by default. They
resolve by name from the Windows SDK (no hard-coded paths), and linking
them here keeps the plugin buildable against any libmoq whose package
config predates the Windows link declaration.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Drop the redundant `-G "Visual Studio 18 2026" -A x64` from the docs:
  with `--preset`, the generator and architecture come from the preset
  (Visual Studio 17 2022), and a non-matching `-G` makes CMake error.
- Align the documented Visual Studio version with the preset (2022, not
  2026), including the chocolatey build-tools package.
- Revert the macOS build doc to `cmake --build --preset macos` (matching
  the justfile) instead of a raw xcodebuild invocation.
- Fix obs-moq.cpp formatting to satisfy clang-format (IndentPPDirectives:
  None / right pointer alignment): de-indent the preprocessor blocks,
  use `const char *`, and drop the stray blank line.
- Include <cstdlib> for std::getenv rather than relying on a transitive
  include.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Allocate the console before moq_log_level() so the Rust logger binds to a
valid stderr, and reopen stdout/stderr onto CONOUT$ -- AllocConsole sets
the process std handles but does not redirect the C runtime streams, so
without this the debug console stayed empty.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Change the MoQ dock defaults so the plugin works against the public relay
out of the box: relay URL defaults to https://cdn.moq.dev/anon, and the
broadcast name defaults to "obs-<rand>" (a 6-char suffix) so distinct
setups don't collide on the shared relay. Saved settings still override
these on subsequent launches.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kixelated kixelated force-pushed the win-build-fix-new branch from e0ab0e7 to 489f29f Compare June 29, 2026 20:12
@kixelated kixelated merged commit bb3b128 into moq-dev:main Jun 29, 2026
7 checks passed
@kixelated

Copy link
Copy Markdown
Collaborator

thanks @danrossi , lemme know if any of my changes don't work for you.

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.

3 participants