Reputation: 1267
CMake documentation states that when add_subdirectory is executed cmake looks for CMakeLists.txt in the directory. Is there any way to change the name of makefile? For example, if I have two cmake files for two completely different configurations and don't want to mix everything in one.
Of course I can create CMakeLists.txt and include something else in it depending on configuration, but I'm just curious if it's possible to make add_subdirectory look for make file with arbitrary name
Upvotes: 2
Views: 1783
Reputation: 480
I know this question is old but I'll answer anyway in case it helps someone. Per the book "Professional CMake" 3rd edition, you should use
include(fileName [OPTIONAL] [RESULT_VARIABLE myVar] [NO_POLICY_SCOPE])
"include() expects the name of a file to read in, whereas add_subdirectory() expects a directory and will look for a CMakeLists.txt file within that directory. The file name passed to include() typically has the extension .cmake, but it can be anything." pg 56.
There are other differences between add_subdirectory() and include() to be mindful of so I would suggest getting the book and giving it a read.
Upvotes: 0
Reputation: 171167
No, there is no way to do that. The file name CMakeLists.txt
is unconfigurably hard-coded in CMake itself. Your best option is, as you say, create a "signpost" CMakeLists.txt
file which will just include()
the real content based on whatever logic you need.
Upvotes: 3