Request: CMake integration sets flags to same values as vcpkg builds #17921
arthur-tacca
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When vcpkg builds libraries, it chooses the command line switches for the compiler, with some options depending on the selected triplet. For example, it adds
/Z7
so that debug symbols are generated even in release builds. But when you build a CMake project using the vcpkg toolchain, these command line options aren't set. I find this quite surprising - surely you want all parts of the project to be built in a consistent way, at least as a default? This is especially true if the project you're working on is a library that you're considering using from within vcpkg later.The most significant impact of this (you probably saw this coming) is if you are building with a triplet like
x64-windows-static
that uses the static CRT. In that case the default compiler options will give you a mismatched CRT and probably a linker error or a runtime crash. As far as I can tell, in the absence of the requested feature, the correct command line to build a CMake project with static libraries is:Even this doesn't cover all cases (e.g. it doesn't attempt to fix MinSizeRel or RelWithDebInfo, although I don't think vcpkg supports those anyway, and it only sets C++ flags not C flags). This is not exactly intuitive! It's not even mentioned in the docs (where those extra options are hidden in a "
...
").Please could it possible (and, ideally, the default) for the vcpkg toolchain to set the compiler flags? I resisted making the title something like "Please make building static projects easier" because I don't just care about the /MT switch. Similarly, for consistentcy with vcpkg, dynamic-library-linking triplets should set
-DBUILD_SHARED_LIBS=true
.Thanks for considering it.
Beta Was this translation helpful? Give feedback.
All reactions