Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to set link directories in CMake

📅 2015-Aug-05 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cmake, library, linker ⬩ 📚 Archive

For most common libraries, CMake has inbuilt modules which find and include them for compilation and linking. But, there are situations where you need to use library files (say *.so) that are in a custom directory somewhere that need to be linked with the code you are building.

One or more of such paths which should be requested to search for library files while linking can be specified like this:


The library files in these directories can now be specified in link_libraries or target_link_libraries using the usual -l syntax.

Reference: link_directories

Tried with: CMake and Ubuntu 14.04

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧