Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmake : include directory - parent directory [duplicate]

myproject/
  lib/
  src/
  project2/
    **CMakeLists.txt**
    test.cpp

I wrote CMakeLists.txt for compile 'test.cpp' file. I'd like to include /src because i should access src's file.

How could i include src file above? I tried like set(MORE_INCLUDE_DIR "-I${CMAKE_SOURCE_DIR}../../ but it's not working.

I should compile 'test.cpp' seperately please somebody help me.

Thanks in advance!

like image 412
N.hwang Avatar asked Jul 03 '26 19:07

N.hwang


1 Answers

In this case, cmake required absolute path not relative. Let's try call include_directories like this:

    get_filename_component(PARENT_DIR ../ ABSOLUTE)
    include_directories(${PARENT_DIR}/src)

It can help.

like image 150
Vanya Usalko Avatar answered Jul 05 '26 12:07

Vanya Usalko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!