Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to add include directories in CMake

📅 2013-Oct-10 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cmake, include directory ⬩ 📚 Archive

It is common in many setups to have additional include directories that need to be used during compilation of C, C++ or CUDA code. These can be both global or relative local directories. Adding include directories to all targets or specific targets is easy in CMake.

include_directories(
    /usr/local/flac
    include
    src
    )
target_include_directories(
    foobar PUBLIC
    /usr/local/flac
    include
    src
    )

Tried with: CMake 2.8.7 and Ubuntu 14.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧