Skip to content

Commit 39d2ce4

Browse files
KyleFromKitwarekwrobot
authored andcommitted
Merge topic 'per-language-link-library-flag'
689be62 Generator: support per-language link library flag Acked-by: Kitware Robot <[email protected]> Merge-request: !3668
2 parents 7099d11 + 689be62 commit 39d2ce4

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

Help/manual/cmake-variables.7.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ Variables that Control the Build
384384
/variable/CMAKE_LANG_CPPCHECK
385385
/variable/CMAKE_LANG_CPPLINT
386386
/variable/CMAKE_LANG_INCLUDE_WHAT_YOU_USE
387+
/variable/CMAKE_LANG_LINK_LIBRARY_FLAG
387388
/variable/CMAKE_LANG_VISIBILITY_PRESET
388389
/variable/CMAKE_LIBRARY_OUTPUT_DIRECTORY
389390
/variable/CMAKE_LIBRARY_OUTPUT_DIRECTORY_CONFIG
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
per-lang-link-library-flag
2+
--------------------------
3+
4+
* The new :variable:`CMAKE_<LANG>_LINK_LIBRARY_FLAG` flag allows you to now
5+
control the flag used to specify linking to a library on a per-language basis.
6+
This is useful for mixed-language projects where the different drivers may use
7+
different flags.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CMAKE_<LANG>_LINK_LIBRARY_FLAG
2+
------------------------------
3+
4+
Flag to be used to link a library into a shared library or executable.
5+
6+
This flag will be used to specify a library to link to a shared library or an
7+
executable for the specific language. On most compilers this is ``-l``.

Modules/CMakeSwiftInformation.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ set(CMAKE_Swift_DEFINE_FLAG -D)
3636
set(CMAKE_Swift_FRAMEWORK_SEARCH_FLAG "-F ")
3737
set(CMAKE_Swift_LIBRARY_PATH_FLAG "-L ")
3838
set(CMAKE_Swift_LIBRARY_PATH_TERMINATOR "")
39+
set(CMAKE_Swift_LINK_LIBRARY_FLAG "-l")
3940
set(CMAKE_Swift_LINKER_WRAPPER_FLAG "-Xlinker" " ")
4041
set(CMAKE_Swift_RESPONSE_FILE_LINK_FLAG @)
4142

Source/cmComputeLinkInformation.cxx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,13 @@ cmComputeLinkInformation::cmComputeLinkInformation(
285285
}
286286

287287
// Get options needed to link libraries.
288-
this->LibLinkFlag =
289-
this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG");
288+
if (const char* flag = this->Makefile->GetDefinition(
289+
"CMAKE_" + this->LinkLanguage + "_LINK_LIBRARY_FLAG")) {
290+
this->LibLinkFlag = flag;
291+
} else {
292+
this->LibLinkFlag =
293+
this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG");
294+
}
290295
this->LibLinkFileFlag =
291296
this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FILE_FLAG");
292297
this->LibLinkSuffix =

0 commit comments

Comments
 (0)