Skip to content

[WSLC] add WSLC CMake file in NuGet#14543

Merged
chemwolf6922 merged 4 commits intofeature/wsl-for-appsfrom
user/chemwolf6922/add-wslc-library-cmake-targets
Mar 30, 2026
Merged

[WSLC] add WSLC CMake file in NuGet#14543
chemwolf6922 merged 4 commits intofeature/wsl-for-appsfrom
user/chemwolf6922/add-wslc-library-cmake-targets

Conversation

@chemwolf6922
Copy link
Copy Markdown
Contributor

@chemwolf6922 chemwolf6922 commented Mar 26, 2026

Summary of the Pull Request

Add the CMake file in the WSLC NuGet package so developers can consume the sdk in CMake easier.
Example usage:

  1. Install the NuGet package:
 nuget install Microsoft.WSL.Containers -OutputDirectory .\packages -Prerelease
  1. Reference in CMakeLists.txt
file(GLOB WSLC_PACKAGE_DIR "${CMAKE_SOURCE_DIR}/packages/Microsoft.WSL.Containers.*")
list(APPEND CMAKE_PREFIX_PATH "${WSLC_PACKAGE_DIR}")
find_package(Microsoft.WSL.Containers REQUIRED)

target_link_libraries(test_app PRIVATE Microsoft.WSL.Containers::SDK)

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Tested locally with this minimal test app:

// main.cpp
#include <wslcsdk.h>
#include <cstdio>

int main()
{
    BOOL canRun{};
    WslcComponentFlags missingComponents{};
    HRESULT hr = WslcCanRun(&canRun, &missingComponents);

    if (FAILED(hr))
    {
        printf("WslcCanRun failed: 0x%08lx\n", hr);
        return 1;
    }

    printf("canRun: %d, missingComponents: %d\n", canRun, missingComponents);
    return 0;
}
# CMakeLists.txt
cmake_minimum_required(VERSION 3.25)
project(wslc-nuget-test)

file(GLOB WSLC_PACKAGE_DIR "${CMAKE_SOURCE_DIR}/packages/Microsoft.WSL.Containers.*")
list(APPEND CMAKE_PREFIX_PATH "${WSLC_PACKAGE_DIR}")
find_package(Microsoft.WSL.Containers REQUIRED)

add_executable(test_app main.cpp)
target_link_libraries(test_app PRIVATE Microsoft.WSL.Containers::SDK)

add_custom_command(TARGET test_app POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
        $<TARGET_RUNTIME_DLLS:test_app>
        $<TARGET_FILE_DIR:test_app>
    COMMAND_EXPAND_LISTS
)

The test app compiles fine. And prints the not implemented error code as expected.

@chemwolf6922 chemwolf6922 requested a review from a team as a code owner March 26, 2026 10:33
Copilot AI review requested due to automatic review settings March 26, 2026 10:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a CMake package config file to the Microsoft.WSL.Containers NuGet layout so CMake-based consumers can find_package(Microsoft.WSL.Containers) and link against an imported SDK target.

Changes:

  • Add Microsoft.WSL.ContainersConfig.cmake implementing Microsoft.WSL.Containers::sdk as an imported target.
  • Implement basic architecture detection (x64/arm64) and derive include/lib paths relative to the NuGet package root.
  • Add validation for expected header/import library presence before defining the imported target.

Comment thread nuget/Microsoft.WSL.Containers/build/cmake/Microsoft.WSL.ContainersConfig.cmake Outdated
Comment thread nuget/Microsoft.WSL.Containers/build/cmake/Microsoft.WSL.ContainersConfig.cmake Outdated
Comment thread nuget/Microsoft.WSL.Containers/build/cmake/Microsoft.WSL.ContainersConfig.cmake Outdated
Comment thread nuget/Microsoft.WSL.Containers/build/cmake/Microsoft.WSL.ContainersConfig.cmake Outdated
Comment thread nuget/Microsoft.WSL.Containers/build/cmake/Microsoft.WSL.ContainersConfig.cmake Outdated
Comment thread nuget/Microsoft.WSL.Containers/build/cmake/Microsoft.WSL.ContainersConfig.cmake Outdated
Comment thread nuget/Microsoft.WSL.Containers/build/cmake/Microsoft.WSL.ContainersConfig.cmake Outdated
Comment thread nuget/Microsoft.WSL.Containers/build/cmake/Microsoft.WSL.ContainersConfig.cmake Outdated
Copilot AI review requested due to automatic review settings March 27, 2026 03:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Copy link
Copy Markdown
Member

@florelis florelis left a comment

Choose a reason for hiding this comment

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

Looks good to me, aside from my comment about the file location.

@chemwolf6922 chemwolf6922 merged commit aeaf1f2 into feature/wsl-for-apps Mar 30, 2026
7 checks passed
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.

4 participants