Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate CMakeLists.txt?

Tags:

c++

c

cmake

I need some pointers/advice on how to automatically generate CMakeLists.txt files for CMake. Does anyone know of any existing generators? I've checked the ones listed in the CMake Wiki but unfortunately they are not suitable for me.

I already have a basic Python script which traverses my project's directory structure and generates the required files but it's really "dumb" right now. I would like to augment it to take into account for example the different platforms I'm building for, the compiler\cross-compiler I'm using or different versions of the libraries dependencies I might have. I don't have much\expert experience with CMake and an example I could base my work or an already working generator could be of great help.

like image 538
celavek Avatar asked Aug 02 '11 15:08

celavek


People also ask

How do I create CMakeLists?

To build with just cmake change directory into where you want the binaries to be placed. For an in-place build you then run cmake and it will produce a CMakeCache. txt file that contains build options that you can adjust using any text editor.

Where do I find CMakeLists txt?

CMakeLists. txt is placed at the root of the source tree of any application, library it will work for. If there are multiple modules, and each module can be compiled and built separately, CMakeLists. txt can be inserted into the sub folder.

How do I make a CMakeLists TXT file in CLion?

Click on Tools > CMake > Unload CMake Project . Open a source file and you will be presented with the option of selecting a new CMakeLists. txt file or creating a new one. Select create new.


2 Answers

I am of the opinion that you need not use an automated script for generating CMakeLists.Txt as it is a very simple task to write one, after you have understood the basic procedure. Yeah I do agree that understanding the procedure to write one as given in CMake Wiki is also difficult as it is too much detailed.

A very basic example showing how to write CMakeLists.txt is shown here, which I think will be of use to everyone, even someone who is going to write CMakeLists.txt for the first time.

like image 86
Preeti Kaur Avatar answered Sep 30 '22 23:09

Preeti Kaur


Well i dont have much of an experience in Cmake either, but to perform a cross platform make a lot of files need to be written and modified including the CMakeLists.txt file, i suggest that you use this new tool called the ProjectGenerator Tool, its pretty cool, it does all the extra work needed and makes it easy to generate such files for 3'rd party sources with little effort. Just read the README carefully before using it.

Link: http://www.ogre3d.org/forums/viewtopic.php?f=1&t=54842

like image 24
wOlVeRiNe Avatar answered Sep 30 '22 21:09

wOlVeRiNe