Reputation: 417
Over time my CMakeLists.txt files have grown by the addition of dozens of self functions and definitions. I would like to split these into their own file so as to simplify reuse in other projects and make the CMakeLists.txt file more readable.
currently I use a superdir CMakeLists.txt but I feel there has to be a better solution then that... something similar to \input in latex? or include in c++ for that matter Ideas?
Upvotes: 13
Views: 6127
Reputation: 78280
CMake has its own include
command which allows you to bring additional CMake code into play, with variables in the included file still in the scope of the including CMakeList file (unlike add_subdirectory
for example). Its effect should be as though you had pasted the contents of the included file into the CMakeList file at the point of the include
.
Upvotes: 16