[CMake] Using CMake for general scripting tasks?

Sebastian Gniazdowski psprint at zdharma.org
Sat Nov 18 12:28:48 EST 2017


On 14 Nov 2017 at 10:44:09, Konstantin Tokarev (annulen at yandex.ru) wrote:
> 14.11.2017, 03:46, "Sebastian Gniazdowski" :
> I'm writing Zsh plugin manager, Zplugin, and I want to integrate with CMake somehow,  
> to get some swiss army knife features.
>  
> For general scripting tasks use general-purpose scripting language, e.g. Perl, Python,  
> Ruby. You will avoid many issues of sub-par languages, make your programs less verbose,  
> and will be able to use huge collections of 3rd party modules which can do almost anything  
> you can think about

I'm a specific person, although I'm certain that many share my traits – getting fun from using something in surprising and difficult way, especially if it's low level. I have a good example – I've written HTML-like ncurses library for Zsh. So, buttons, list boxes, text fields, etc. created from simple input text (the "HTML"). I have to defend myself against criticism of not using high level languages, because low-level way is really good on it's own right and good things should be defended. A proof is this curses application written in pure Zshell script with use of the library (called "ZUI"): https://asciinema.org/a/147225. Curses library correctly describes itself by its name, and with that library there's no need for more "curses" when creating terminal app.

Maybe I should ask what advanced, surprising functionality did you or someone else obtain by CMake macro or function? This could lead me to what CMake can give to Zplugin.

I have an example of such functionality, although I think it's not that much advanced, but for my beginners level it's good and informing – I spotted this function:

function( QUERY_QMAKE VAR RESULT )
  get_target_property( QMAKE_EXEC Qt5::qmake LOCATION )
  exec_program( "${QMAKE_EXEC}" ARGS "-query ${VAR}" RETURN_VALUE retval OUTPUT_VARIABLE out )
  if( retval EQUAL 0 )
  file( TO_CMAKE_PATH "${out}" out )
  set( ${RESULT} ${out} PARENT_SCOPE )
  endif()
endfunction()

It allows to query Qt's "qmake" and get library paths etc. Didn't need it, because Qt5 has proper CMake packages.
-- 
Sebastian Gniazdowski
psprint at zdharma.org




More information about the CMake mailing list