Pintu
Pintu

Reputation: 369

cmake add include_subdirectory efficiently

I am new to CMake build process. I have a list of sub directories and each sub directory requires a set of include_directories ( files from different libraries).

My question is: is it efficient to add the include_directory call right at the main CMakeList so that it is reference in all the sub directories (i.e. I wouldn't need to add in all the sub directories) or is it efficient to add it every sub directory.

Please let me know what are the pros and cons of such a process.

Note: I do understand that I can add the common include files in the main cmakelist file but, what if I were to add the project specific include directories in the main CMakefile? Are all the include_directories included in the created static libraries for each sub directory ?

Upvotes: 1

Views: 375

Answers (1)

arrowd
arrowd

Reputation: 34411

Sometimes incude directories can have files with same names. This can lead to situation when compiler includes wrong file. Because of this the common practice is to set include dirs in subdirectories rather than in top CMakeLists.txt.

Except this, there's no difference at all.

Upvotes: 2

Related Questions