[CMake] reusing CMAKELISTS.txt

Sylvain Joubert joubert.sy at gmail.com
Mon Nov 6 14:44:17 EST 2017


Le 06/11/2017 à 20:36, llvm 999 a écrit :
> I have a CMAKELIST.txt file which can be used for more than 1 subdirectory.
> 
> 
> Is there a way to "reuse" this CMAKELISTS.txt file?
> 

As such I don't think so.

> 
> I have tried placing this file at a common folder and then to place a 
> shortcut or softlink in the sub-directories.
> 
> But, this does not work. CMAKE does not seem to recognize the link.
> 
> 
> Any help would be much appreciated.
> 
> 
> 

What you can do is create a function in a top/common CMakeLists.txt and 
call that function in each CMakeLists.txt of the different folders.
You still need a file per folder but you don't duplicate code.


More information about the CMake mailing list