13

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?

3
  • 5
    Could "something similar to include" include include? :-) Commented Apr 2, 2014 at 7:59
  • Yes, :) Though googling anything + cmake and include didnt lead to that answer( for obvious reasons) Commented Apr 5, 2014 at 8:33
  • Yeah - I just added it as a comment since I thought I was maybe misunderstanding the question. I'll stick it in as an answer which should let you close this. Commented Apr 5, 2014 at 9:23

1 Answer 1

16

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.