Include header files in cmake

I have a CMakeList.txt file that has only one include(startevn.cmake) 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 need to move the launch to another directory. After that, I added the following line for "startevn.cmake",

 include_directories("/new_folder_location/sub_folder") 

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

+4
source share
1 answer

call the code before:

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

he indicated the location of the library,

but after, your include_directories() may not.

to try:

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

(or you need to use find_library () cmake earlier to check if it was found correctly.)

+2
source

Source: https://habr.com/ru/post/1492059/


All Articles