Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

include header files in cmake

Tags:

include

cmake

I have a CMakeList.txt file which has just one liner include(startevn.cmake) in startevn.cmake I have,

project(startevn)
set(headers 
   startup.h
)
set(sources
  system-init.cpp
)
new_library(startevn ${sources} ${headers})

Now I have to move the startup to a different directory. After doing that I added the following line to "startevn.cmake",

include_directories("/new_folder_location/sub_folder")

where sub_folder is where startup.h is now located but compiler still says Cannot find source file: startup.h. What am I doing wrong?

like image 949
user1566277 Avatar asked Jul 18 '13 10:07

user1566277


1 Answers

cause the code before:

new_library(startevn ${sources} ${headers})

it did tell the library's location,

but after, your include_directories() maybe isn't.

try:

set(INCLUDE_DIR /new_folder_location/sub_folder)
include_directories (${INCLUDE_DIR})     # make sure your .h all inside.

(or need to use find_library() of cmake before to check if it is rightly found.)

like image 169
vivi Avatar answered Oct 01 '22 02:10

vivi