Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMAKE include_directories

Tags:

c++

c

gcc

cmake

I am trying to link my library with some other library lib1 using CMAKE 2.8. It should be said it's on Windows.

In CMakeLists.txt I have:

add_library(mylib ${sources})
include_directories(${CMAKE_SOURCE_DIR}/lib1/include)
target_link_libraries(mylib ${lib1_path})

But compiler says that some #include <lib1/foo.h> in my library is unresolved, maybe because there is no -I.../lib1/include command-line parameter for gcc.

UPDATE: It should be said that compiler is complaining when compiling TESTS not the mylib.

like image 688
Cartesius00 Avatar asked Nov 19 '11 08:11

Cartesius00


1 Answers

Check the following:

  1. Does the path ${CMAKE_SOURCE_DIR}/lib1/include/lib1/foo.h exist?

  2. Quote (") the path passed to include_directories, otherwise you may be passing several paths when it is split by spaces

  3. Try running make VERBOSE=1 to see exactly what options are being passed to gcc

like image 195
Silas Parker Avatar answered Sep 21 '22 00:09

Silas Parker