diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-09-15 10:28:32 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-09-15 11:23:15 +0200 |
commit | 54214d618390292f96bd9ab055e4bbe5d54e1fbd (patch) | |
tree | 970f4a99566a39d51bb80cfb3a7d009fac8c1852 /CMakeLists.txt | |
parent | e098b5f5071ca3eeee138785de1b8db3c1152f8d (diff) | |
download | libgit2-54214d618390292f96bd9ab055e4bbe5d54e1fbd.tar.gz |
cmake: fix linker error with dbghelper library
When the MSVC_CRTDBG option is set by the developer, we will link in the
dbghelper library to enable memory lead detection in MSVC projects. We
are doing so by adding it to the variable `CMAKE_C_STANDARD_LIBRARIES`,
so that it is linked for every library and executable built by CMake.
But this causes our builds to fail with a linker error:
```
LINK: fatal error LNK1104: cannot open file 'advapi32.lib;Dbghelp.lib'
```
The issue here is that we are treating the variable as if it were an
array of libraries by setting it via the following command:
```
SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}"
"Dbghelp.lib")
```
The generated build commands will then simply stringify the variable,
concatenating all the contained libraries with a ";". This causes the
observed linking failure.
To fix the issue, we should just treat the variabable as a simple
string. So instead of adding multiple members, we just add the
"Dbghelp.lib" library to the existing string, separated by a space
character.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c03aa053..713b2b713 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,7 +173,7 @@ IF (MSVC) IF (MSVC_CRTDBG) SET(GIT_MSVC_CRTDBG 1) SET(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}") - SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}" "Dbghelp.lib") + SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib") ENDIF() # /Zi - Create debugging information |