0

On UNIX-like machines, I'm using

SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/some/path")

to add /some/path to the linker path.

What is the equivalent of the -L/some/path for MSVC (Microsoft Visual Studio C++ compiler)? Or, is there any portable way of adding an additional linker path so the linker can find the additional libraries I'm linking against?

vsoftco
  • 55,410
  • 12
  • 139
  • 252
  • 1
    What is wrong with `link_libraries`/`target_link_libraries`? Specifying `-l`/`-L` flags in the `CMAKE_EXE_LINKER_FLAGS` are used mostly for *toolchain*, not for the normal libraries. – Tsyvarev Jul 21 '19 at 00:22
  • @Tsyvarev I'm adding some library that is not in the usual path, I just want to make the linker "look" into this custom path (otherwise I'm getting a linker error). So how would you specify the path in the most "cmake"-like way? – vsoftco Jul 21 '19 at 01:02
  • 1
    Have you looked into [that question](https://stackoverflow.com/questions/8774593/cmake-link-to-external-library) about linking external library? – Tsyvarev Jul 21 '19 at 08:33
  • @Tsyvarev Thanks, that was exactly what I needed, I'll mark this question as a dupe – vsoftco Jul 21 '19 at 15:31

0 Answers0