Skip to content

Pass VCPKG_LINKER_FLAGS_<CONFIG> from triplets to ports #11129

@psfrolov

Description

@psfrolov

Problem

Currently it is not possible to pass debug/release-specific linker flags to dynamic library builds. In practice I use release linker flags to fine-tune link-time optimisation with MSVC and Clang and debug linker flags to link with sanitiser runtimes.

Ports can use these flags via CMake built-in variables CMAKE_SHARED_LINKER_FLAGS_DEBUG and CMAKE_SHARED_LINKER_FLAGS_RELEASE. In fact, boost-modular-build for example already respects these variables while generating build config for b2). The only piece missing is to forward VCPKG_LINKER_FLAGS_RELEASE and VCPKG_LINKER_FLAGS_DEBUG variables from triplets to CMake.

Proposed solution

  1. Forward the mentioned variables from triplet to project in scripts/cmake/vcpkg_configure_cmake.cmake
  2. Setup appropriate CMake variables (e.g. CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT and CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT) in toolchain files (scripts/toolchains).

I use this approach in my Vcpkg fork, could make a PR.

Metadata

Metadata

Assignees

Labels

category:vcpkg-featureThe issue is a new capability of the tool that doesn’t already exist and we haven’t committed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions