Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

cmake v2.8.19.2 include folder from outside project

I am trying to build a library using cmake version 2.8.10.2

A header is included from a directory outside of the project, I’ve tried adding the path to the directory using:

add_subdirectory($ENV{PRJ2}/path/)

I’ve check the path is correct but when building I get:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

fatal error: header_name.h: No such file or directory

It’s driving me crazy…

>Solution :

add_subdirectory adds a folder to the cmake project, searching for the CMakeLists.txt file in it and loading the configuration. If you want to add headers from a directory to a project you should use include_directories (link here)

Consider that using a directory out of the main folder of the project is not convenient. I suggest you two possibilities:

  • If you are using some headers that are not part of another project (for example you developed by yourself for other reasons and want to add them to your project), then move them inside one of your project folders
  • If the headers are from another library/project add them using the find_package system. I was not able to find a good guide for the 2.x versions of cmake, but I strongly suggest you to move to 3.x
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading