0

I have a project that needs to be built using cmake and make. However, I want the project to use libc++ (since its written in C++11) so I need to set the right linker flags. Is there a way I can pass the following flags via command line?

 LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

Or do I need to edit my CMakeLists.txt file? If so how can I add this to the file?

ohbrobig
  • 939
  • 2
  • 13
  • 34

1 Answers1

0

For the more complex linker flags use

set (CMAKE_SHARED_LINKER_FLAGS -Wl,-rpath,/usr/local/opt/llvm/lib)

To add a library search directory (-L) simply add

link_directories(/usr/local/opt/llvm/lib)

See also this and that answer

Magnus Lutz
  • 558
  • 3
  • 12