Home > front end >  Cmake include header only library with -I option
Cmake include header only library with -I option

Time:04-24

I have a header only library that is contained in a "headers/" directory in the main project. When compiling from terminal I include it with #include "symbolicc .h", but I need to pass the option -I "headers/" when compiling with g . How can I include this in a Cmake project? (And also, in general how can I pass other option such as -pthread to Cmake?

CodePudding user response:

Adding include directories in CMake is done by using the target_include_directories directive.

Use it this way (in your CMakeLists.txt):

target_include_directories(${TARGET_NAME} PUBLIC ${SOME_INCLUDE_DIR}) 

Some more info: target_include_directories

  • Related