build - Understanding the Purpose Behind CMake -
i trying understand purpose behind cmake. why designed right now. here questions have answered.
- why cmake generate makefiles instead of building project?
- why cmake files series of commands , not configuration files eg: ini/xml/yaml
- what commands write cmakelists.txt supposed do? calling compiler easy guess
- in order supposed commands?
- is case insensitive? can write lower case?
- why tutorials advise me list every source file explicitly?
- how structure cmakelists.txt keep short , simple maintain. every file looked in real projects looked cluttered.
it can difficult understand how cmake works. i'll best briefly answer of questions posted.
why cmake generate makefiles instead of building project?
cmake cross-platform make system , compiler independent. doesn't generate make build systems, generates visual studio solution files. same cmakelist.txt file can create windows build (visual studio) or linux build (g++).
why cmake files [a series of] commands , not configuration files eg: ini/xml/yaml
compilers don't use universal configuration, cmake must adapt target compiler.
cmake files series of commands generate appropriate configuration target compiler.
what commands write cmakelists.txt supposed do? calling compiler easy guess
they suppose generate appropriate configuration target compiler, , if written correctly.
in order supposed commands?
in order matters, if order matters @ all. yes it's vague answer, depends on project. example include() command used add additional cmake files, , if include them in wrong order, can break generation of build system.
the first command in cmake file must minimum required version latest version of cmake (3.0.1). there depends. :)
for example command not work versions of cmake less 2.6. cmake_minimum_required (version 2.6)
see of tutorial links @ end of answer.
is case insensitive? can write lower case?
as stated on cmake wiki's language syntax page, of commands case insensitive, must consider case contents passed command.
why tutorials advise me list every source file explicitly?
because have list every source file explicitly. can done inside cmake file or separate file list referenced in cmake file. please see antonio's answer caveat of using separate file list.
cmake provide command aux_source_directory collects names of source files in specified directory , stores list variable, should used "generated" source files same reason mentioned in antonio's answer.
how structure cmakelists.txt keep short , simple maintain. every file looked in real projects looked cluttered.
it's easy clutter cmake file, , 1 way use .cmake files reference using include command.
a resource (although still under development) can found on cmake page.
it's broken several sections:
- overview
- statistics (under development)
- participants
- documentation
- license
- success stories
- publications
- news
tutorials
cmake tutorial - official cmake documentation page
getting started cmake - tutorial uses cmake gcc.
using cmake build qt projects - tutorial uses cmake qt.
Comments
Post a Comment