microsoft / microsoft/winappCli
[Feature]: Add include and link path to CMakeLists.txt based on winapp.yaml
- Dominant language
- C#
- Stars
- 1.3k
- Forks
- 80
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 51
Description
### Is your feature request related to a problem? Please describe.
Hi folks,
I'm using winappCLI in my prototype projects following [C++ guideline](https://github.com/microsoft/winappCli/blob/main/docs/guides/cpp.md). I noticed the suggested CMakeLists.txt includes only ${CMAKE_CURRENT_SOURCE_DIR}/.winapp/include, while it does not automatically include other packages in winapp.yaml automatically. My projects use wil, which is downlaoded to ${ENV:UserProfile}/.winapp/packages but not referenced.
I try to hardcode the include path in CMakeLists.txt. It works, but I have to maintain the consistency of the package names and versions between CMakeLists.txt and winapp.yaml.
### Describe the solution you'd like
I'm wondering if it's possible we can add built-in tools (e.g. consider subcommand like ``winapp resolve-package-path ``) so we can create steps like ``add_custom_command()`` in CMakeLists.txt to get include path and link path, but don't have to download package names and versions in CMakeLists.txt
```CMake
## Today's solution - I have to maintain the package name and value
set(WIL_PACKAGE_VERSION "1.0.260126.7")
set(WIL_PACKAGE_DIR "$ENV{UserProfile}/.winapp/packages/Microsoft.Windows.ImplementationLibrary.${WIL_PACKAGE_VERSION}")
# Add Windows App SDK include directory
target_include_directories(RegistryWatcher PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.winapp/include)
target_include_directories(RegistryWatcher PRIVATE ${WIL_PACKAGE_DIR}/include/)
```
```CMake
## Expected solution - The package path is retrieved from winapp.yaml.
## Or the winapp.yaml can be omitted.
execute_process(
COMMAND winapp resolve-package-path --package Microsoft.Windows.ImplementationLibrary --config .\winapp.yaml
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE WIL_PACKAGE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
target_include_directories(RegistryWatcher PRIVATE ${WIL_PACKAGE_DIR}/include/)
```
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with docs/guides/cpp.md and the CMakeLists.txt pattern described in the issue, then inspect how package paths and versions are represented in winapp.yaml. The work is complete when a supported CLI workflow can retrieve a package's include and link paths from that configuration for CMake use, without duplicating package details.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system, cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100