Skip to content

Conversation

@dhaneesh646
Copy link

Description
This PR fixes Issue #1198 where impl headers were missing when installing in CLI11_PRECOMPILED mode (e.g., via Spack).

Changes Made:

  1. Installation Fix: Removed the conditional check that prevented impl headers from being installed when CLI11_PRECOMPILED was ON. The public headers include these files, so they must always be present.
  2. Windows Build Fix: Added target_link_libraries(CLI11 PUBLIC Shell32) for Windows builds in precompiled mode. Without this, the build fails on Windows with LNK2019: unresolved external symbol __imp_CommandLineToArgvW.

Verification
Tested locally on Windows with:

  • cmake .. -DCLI11_PRECOMPILED=ON
  • cmake --build . --target install
    Verified that include/CLI/impl/ is now populated correctly.
image_ca10e6

@phlptp
Copy link
Collaborator

phlptp commented Dec 24, 2025

what build system/compiler are you using on Windows? This is not required to be included on Visual studio? Also the impl headers are not required for the precompiled library. The only reason they would be needed is if you want to use the library as header only, and still have the option of the precompiled part?

@dhaneesh646
Copy link
Author

Hi @phlptp, thanks for the review!

Regarding the build system: I am using Visual Studio 2022 (MSVC 19.50) with CMake.
When CLI11_PRECOMPILED is ON, the build fails on Windows without linking Shell32. The specific error is:
error LNK2019: unresolved external symbol __imp_CommandLineToArgvW referenced in function compute_win32_argv.
It seems CommandLineToArgvW is being used for argument parsing on Windows, so the link is necessary.

Regarding the impl headers:
This change fixes the reported Issue #1198. Even when CLI11_PRECOMPILED is used, the public headers (like StringTools.hpp) still contain #include "impl/StringTools_inl.hpp".
If the impl folder is not installed, consumers of the library encounter:
fatal error: 'impl/StringTools_inl.hpp' file not found
(as documented in the linked issue).

This PR ensures those files are present so the public headers remain valid.

@phlptp
Copy link
Collaborator

phlptp commented Jan 6, 2026

I have a few concerns with these changes. I will look into the shell issue more, I am thus far unable to replicate the issue. Regarding the installation of the impl headers I am still not clear why this is necessary. The impl headers are not needed when CLI11_PRECOMPILED is enabled. The only reason they would be is if the installation is needed for both precompiled and header only in the same installation. Which is the reason the CLI11_FULL_INSTALL was enabled and why future versions of spack installer will include that option by default. So just installing all the headers all the time is wrong and potentially confusing.

@dhaneesh646
Copy link
Author

Thanks for the feedback!

1. Regarding the Windows Shell32 Issue:
I am consistently reproducing this on Windows 11 with Visual Studio 2022 (MSVC 19.50).
The error happens because CLI::detail::compute_win32_argv calls CommandLineToArgvW, which requires linking against Shell32.lib.

Here is the exact linker error from my build log:

CLI11.lib(Precompile.obj) : error LNK2019: unresolved external symbol __imp_CommandLineToArgvW referenced in function "class std::vector<class std::basic_string<char... > ... compute_win32_argv(void)"

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.

2 participants