Commit 689be623 authored by Saleem Abdulrasool's avatar Saleem Abdulrasool

Generator: support per-language link library flag

This enables the use of MSVC and Swift on Windows in a single project.
MSVC uses no flag to indicate linked libraries while Swift uses `-l`.
Add support for a language specific link library flag which takes
precedence over the global `CMAKE_LINK_LIBRARY_FLAG` which preserves
compatibility with earlier releases.
parent 1996e015
......@@ -383,6 +383,7 @@ Variables that Control the Build
* The new :variable:`CMAKE_<LANG>_LINK_LIBRARY_FLAG` flag allows you to now
control the flag used to specify linking to a library on a per-language basis.
This is useful for mixed-language projects where the different drivers may use
different flags.
Flag to be used to link a library into a shared library or executable.
This flag will be used to specify a library to link to a shared library or an
executable for the specific language. On most compilers this is ``-l``.
......@@ -36,6 +36,7 @@ set(CMAKE_Swift_DEFINE_FLAG -D)
set(CMAKE_Swift_LINKER_WRAPPER_FLAG "-Xlinker" " ")
......@@ -285,8 +285,13 @@ cmComputeLinkInformation::cmComputeLinkInformation(
// Get options needed to link libraries.
this->LibLinkFlag =
if (const char* flag = this->Makefile->GetDefinition(
"CMAKE_" + this->LinkLanguage + "_LINK_LIBRARY_FLAG")) {
this->LibLinkFlag = flag;
} else {
this->LibLinkFlag =
this->LibLinkFileFlag =
this->LibLinkSuffix =
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment