DEV Community

Damir Franusic
Damir Franusic

Posted on • Updated on

Autotools vs Cmake

I have used autotools since I started programming on Linux and got used to the whole process. When you first encounter autotools, you are bombarded by numerous scripts and files and can get intimidated very quickly. When you manage to get yourself together, you begin to realize that there are only TWO files that need editing; configure.ac and Makefile.am.

Cmake has always managed to irritate me and cause an overall feeling of disgust. I know that many famous open source projects use Cmake and would like to know your opinion whether I should start using Cmake for my next C project, or continue with well known autotools. I don't plan to support any other platform but Linux (x86 and ARM embedded systems).

Thank You,
Comment away ;)

Top comments (12)

 
deciduously profile image
Ben Lovy • Edited

re: emacs pinky, I've had decent success retraining myself to use my hand instead of my finger tip for the control key. I use the bone right at the base of the pinky to activate C, and my thumb as usual for M. It reduces stress, but isn't quite as easy - definitely took some practice, and I get way more thrown off switching to different size keyboards, but I really didn't want to give up Emacs keybindings...

 
vimmer9 profile image
Damir Franusic • Edited

Not so hard when you get used to it and have the right set of plugins. I will post my vimrc later. Most useful plugins are YouCompleMe, ctrlP and vim-gutentags. There's more, but with these you have auto complete, can move between files and locate declarations and definitions of functions, etc. And I don't use mouse while using vim.

Collapse
 
ahferroin7 profile image
Austin S. Hemmelgarn

If you truly never intend to support anything other than UNIX-like systems (autotools actually works rather well on most BSD platforms, as well as being passably usable on OS X and MINIX if you handle them right), then yeah, just use autotools. You're already familiar with it, and there's very little that CMake can do that autotools can't that you're likely to care about if you only intend to build and run on UNIX-like systems.

Collapse
 
vimmer9 profile image
Damir Franusic

I assumed the same, It's just that the project I'm currently hired to do requires me to use Cmake for some reason. I created both versions, but still prefer autotools. I really don't understand the hype about Cmake, that is the whole reason for this post; I wanted to hear other people's opinions and experiences.

Thank You for your comment

 
deciduously profile image
Ben Lovy

I do the hard key press thing too, even being aware of the problem isn't quite enough to stop myself. I think my mechanical keyboard is probably the best hardware purchase I've ever made - I hate when I don't have it on me! I just use it in my home, hadn't considered the noise in a workplace. That might catalyze my split keyboard purchase after all.

Thread Thread
 
vimmer9 profile image
Damir Franusic

My .vimrc as requsted, not a pretty site :)

"+-----------+
"| " general |
"+-----------+
set exrc
set secure
set t_Co:256
set tabstop=8
set softtabstop=4
set shiftwidth=4
set nocursorline
"set noexpandtab
set expandtab
set number
"set foldmethod=syntax
"set foldlevel=99
set nofoldenable
set nowrap
"set viminfo^=%
syntax on
"set paste
highlight clear SignColumn
"set hidden (enable switching from changed buffer)
set hidden
set backupcopy=yes
set sessionoptions-=options
runtime! ftplugin/man.vim
let g:netrw_liststyle=0
"pathogen
execute pathogen#infect()

"+---------+
"| windows |
"+---------+
function! WinMove(key)
  let t:curwin = winnr()
  exec "wincmd ".a:key
  if (t:curwin == winnr()) "we havent moved
    if (match(a:key,'[jk]')) "were we going up/down
      wincmd v
    else
      wincmd s
    endif
    exec "wincmd ".a:key
  endif
endfunction
map <leader>h :call WinMove('h')<cr>
map <leader>k :call WinMove('k')<cr>
map <leader>l :call WinMove('l')<cr>
map <leader>j :call WinMove('j')<cr>
map <leader>wc :wincmd q<cr>
map <leader>wr <C-W>r
nmap <leader><left>  :3wincmd <<cr>
nmap <leader><right> :3wincmd ><cr>
nmap <leader><up>    :3wincmd +<cr>
nmap <leader><down>  :3wincmd -<cr>

"+-----------+
"| shortcuts |
"+-----------+
" plugins
map <F9> :UndotreeToggle<CR>
map <F8> :TagbarToggle<CR>
autocmd FileType c,cpp nnoremap <buffer><Leader>cf :<C-u>ClangFormat<CR>
" buffers
nnoremap <silent> <F12> :bnext<CR>
nnoremap <silent> <F11> :bprevious<CR>
nnoremap <F5> :CtrlPBuffer<CR>
nnoremap <Leader>q :Bdelete<CR>
" tabs
nnoremap <Leader>tc :tabclose<cr>
nnoremap <Leader>ts :tab split<cr>
" man
nnoremap K :Man <cword><CR>
" copy/paste
noremap <Leader>y "*y
noremap <Leader>p "+p

"+---------+
"| airline |
"+---------+
set laststatus:2
set ttimeoutlen:50
set encoding:utf-8
"let g:airline#extensions#tabline#enabled = 1
"let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#capslock#enabled = 1

let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
    let g:airline_symbols = {}
endif

"+-----------+
"| syntastic |
"+-----------+
let g:syntastic_cpp_remove_include_errors = 1                                                                                                                                                                                                                       
let g:syntastic_cpp_check_header = 0
let g:syntastic_cpp_auto_refresh_includes = 1
let g:syntastic_mode_map={"mode":"active", "active_filetypes": [], "passive_filetypes": ["c","cpp"]}

"+-----+
"| Ale |
"+-----+
let g:ale_linters = {
\   'javascript': ['eslint', 'flow-language-server']
\}
let g:ale_fixers = {
\   'javascript': ['eslint']
\}
let g:ale_completion_enabled = 1
let g:ale_statusline_format = ['X %d', '? %d', '']
let g:ale_echo_msg_format = '%linter% says %s'
let g:ale_linters_explicit = 1
set completeopt=menu,menuone,preview,noselect,noinsert
map <F7> <Plug>(ale_fix)

"+-----------+
"| ultisnips |
"+-----------+
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"

"+-----+
"| ycm |
"+-----+
let g:ycm_add_preview_to_completeopt = 1
let g:ycm_autoclose_preview_window_after_completion = 0
let g:ycm_autoclose_preview_window_after_insertion = 1
"let g:loaded_youcompleteme = 1
let g:ycm_register_as_syntastic_checker = 0
let g:ycm_collect_identifiers_from_tags_files = 0
let g:ycm_auto_trigger = 1
let g:ycm_warning_symbol = 'WW'
let g:ycm_error_symbol = 'EE'

"+-------------+
"| javascript  |
"+-------------+
let g:jsx_ext_required = 0
let g:javascript_plugin_flow = 1
let g:ctrlp_regexp = 1
let g:ctrlp_extensions = ['tag']
let g:ctrlp_custom_ignore = {
  \ 'dir':  '\.git$\|\.yardoc\|node_modules\|log\|tmp$',
  \ 'file': '\.so$\|\.dat$|\.DS_Store$'
  \}
let g:ctrlp_root_markers = ['.project_root']
let g:gutentags_project_root = ['.project_root']


"+---------+
"| "colors |
"+---------+
"let g:solarized_termtrans=1
"let g:solarized_termcolors=256
set background=dark
colorscheme gruvbox
highlight Normal ctermbg=None

And finally the list of plugins I use (using Pathogen)

~/.vim/bundle/

  • ale
  • auto-pairs
  • bbye
  • ctrlp.vim
  • emmet-vim
  • nerdcommenter
  • promptline.vim
  • tagbar
  • tlib_vim
  • ultisnips
  • undotree
  • vim-addon-mw-utils
  • vim-airline
  • vim-clang-format
  • vim-cpp-enhanced-highlight
  • vim-gitgutter
  • vim-gutentags
  • vim-javascript
  • vim-jsdoc
  • vim-jsx
  • vim-react-snippets
  • vim-snippets
  • vim-toml
  • YouCompleteMe
 
deciduously profile image
Ben Lovy

Ah, gotcha - I don't think I could manage this style at all on a split keyboard like that, which is too bad because otherwise I'd absolutely want one. It's frustrating how ill-equipped our bodies are for this line of work, or at least our current peripherals. I try to force breaks at least every two hours but a) often fail to and b) that's probably still not even enough.

I have absolutely noticed a difference already since trying the new method, after just a few months. I'm not constantly curling and uncurling it, more just levering up and down in place. Biggest annoyance is imprecision - it's pretty easy to also catch the shift key with your hand.

Sadly it does seem like Emacs bindings are not the greatest choice long-term. I only discovered Emacs a year or so ago, and I'm planning to keep, you know, typing code for probably decades. The fact that I've already had to make a change for physical reasons doesn't bode well.

Collapse
 
vimmer9 profile image
Damir Franusic

I am currently reading Cmake documentation and It will take some time to convert from autotools, but everything seems logical enough. It isn't all that bad like I assumed it would be. I currently have 50 lines in CMakeLists.txt, compared to combined 200 lines of configure.ac and Makefile.am.

The only thing that I am actively avoiding is cross compiling with Cmake. With autotools it's very simple; configure --host and off you go.

Collapse
 
vimmer9 profile image
Damir Franusic

I think we digressed a bit from the initial topic but the gist of it is that there's no clear winner. For my current project, I created both autotools and cmake versions and they are both equally effective. It will take me some time to adjust to cmake syntax and learn all the commands, but I think it's worth the effort. One feature that goes in favour of cmake is, in my opinion, the lack of those disgusting m4 scripts.

Collapse
 
kamtron profile image
Cameron Druyor

+1 for lack of m4

other cmake pros for me:

  • transitive dependency management (cmake 3 targets)
  • integration with CLion
  • automatic parallel compilation for fortran (useful for huge legacy codes)

cmake cons:

  • modern cmake (3.0+) fixes a lot of old cmake problems, but just googling for a solution when you first start using cmake pulls up lots of wrong/old stuff that can lead you into using anti-patterns

If you're determined enough, you can write a horrifying build system in either one! I've seen it done (and been guilty myself while learning).

Collapse
 
vimmer9 profile image
Damir Franusic • Edited

Full on VIM guy here :). Thanks for the tip, guess I'll have to learn a bit more about Cmake.

 
vimmer9 profile image
Damir Franusic

No problem, just conjure up a 💩load of patience and try to minimise profanities directed at me 😄