Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I got a bunch of C++ sources files and headers. They may use external libraries such as Boost e.g. I am interested in the process of building binaries for Windows and *nix.

  • Makefiles (*nix) and .vcproj (Windows) call compilers with some specifications such as the order of compilation, compilation options and stuff.

  • CMakeLists.txt can be used by CMake to build either makefiles or .vcproj and use very helpful commands such as recursive search of files, automatic linkage with known libraries, installers, variables that can be used in source files...

Is there any existing tool that would generate a CMakeLists.txt from specified options ? Options could be like : scan this folder and make a library out of it, then scan this other folder and make an executable and automatically link both with Boost as well along with a user friendly installer with generated INSTALL.txt and README.txt. Something very powerful like that.

share|improve this question

closed as not constructive by gnat, Matthieu, Jim G., Walter, ChrisF Oct 6 '12 at 21:52

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
If it was flexible enough to qualify as powerful, it would boil down to an alternative syntax for CMake. Which hardly justifies the trouble of creating such a thing. –  delnan Sep 6 '12 at 13:43
    
I am actually asking because I don't have a clue how open-source cross-platform programmers build their files. I would be comfortable with an answer like "Make systems like CMake are the most user-friendly tools to deploy your applications. Just deal with it". –  vanna Sep 6 '12 at 14:34
1  
Why'd this get downvoted? This question helped me, have an upvote. :) –  jakev Sep 6 '12 at 15:59
    
@SixSlayer : thanks. I guess my question was a bit vague. However finding the right formulation is equivalent to answering my question myself. The world of advanced cross-platform deployment process is extremely opaque for beginners like me and this can get very frustrating. It is encouraging to see I am not the only one ! –  vanna Sep 6 '12 at 17:17

1 Answer 1

up vote 2 down vote accepted

I recently started learning CMake myself, and like Delnan mentions in his comment there is really no point in wrapping the creation of those scripts further in some kind of tool. The problems that you are trying to solve are pretty much the purpose of CMake and its reason for existence.

In fact, what you say you want to do sounds a lot like what the CMakeLists.txt for a project actually would do (without the installation part, which is slightly more involved depending on your needs).

e.g. scanning a folder for source and turning it into a lib is at its heart just a few commands:

cmake_minimum_required(VERSION 2.8)
project(YourProject)

# This is a built-in utility to grab all the source files from a specific
# location into a list
AUX_SOURCE_DIRECTORY(. LOG_SOURCES)

# This is all you need to do to tell CMake that a specific list of files
# should be built as a library (shared in this case)
add_library(Logging SHARED ${LOG_SOURCES})

The above doesn't yet link any other libraries automatically, or deal with compiler settings, but all of that stuff is possible and relatively straightforward once you start wrapping your head around the CMake-way.

share|improve this answer
    
CMake is just much more powerful than what I expected I guess ! –  vanna Sep 6 '12 at 15:46
    
@vanna - once you dig into it, you will be surprised. There's CTest for running test targets (which are usually just a special case of an executable target with the same source), there's a whole "install" section in CMake you can use to gather built outputs in a secondary tree, etc. –  Joris Timmermans Sep 6 '12 at 16:06
    
I needed to be sure that digging into was worth it - along with some motivation - and it seems to be the case. Thanks a lot ! –  vanna Sep 6 '12 at 17:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.