Using CMake for general scripting tasks?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Using CMake for general scripting tasks?

Sebastian Gniazdowski
Hello 
CMake has so many powerful features that I always suspected, that it can be used for tasks normally handled by Bash or sh. I've found following package manager written in CMake: 

https://docs.hunter.sh/en/latest/overview/what-is-it.html 

So I think this project confirms CMake's potential for handling general scripting tasks. However, it's hard to get some inspiration from Hunter, it's just a large collection of CMake packages focused on one specialized goal. 

But maybe someone used CMake for less specialized scripting tasks and would share? I'm writing Zsh plugin manager, Zplugin, and I want to integrate with CMake somehow, to get some swiss army knife features. 

--  
Sebastian Gniazdowski
psprint /at/ zdharma.org

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Using CMake for general scripting tasks?

Alex Turbov
Hi Sebastian,

Particularly I've used CMake "scripts" in some "build configurations" at our CI server as a truly cross-platform scripting language for generic tasks like download archive, check sha/md5, unpack it, do some file operations... it works perfectly for Linux and Windows (it is why I chose CMake %).

BTW, also I use it to talk to some REST API a little, but found lack of setting arbitrary HTTP method... :( for simple requests it is fine, but really soon it is not enough existed methods of `file` command... it is why I'm thinking about to extend it (curl library used by CMake can do all that I need)... but need to discuss first, cus I think `file` command is not a suitable candidate for such kind of extension... (casting Brad King into the thread %)

On Tue, Nov 14, 2017 at 12:39 AM, Sebastian Gniazdowski <[hidden email]> wrote:
Hello 
CMake has so many powerful features that I always suspected, that it can be used for tasks normally handled by Bash or sh. I've found following package manager written in CMake: 

https://docs.hunter.sh/en/latest/overview/what-is-it.html 

So I think this project confirms CMake's potential for handling general scripting tasks. However, it's hard to get some inspiration from Hunter, it's just a large collection of CMake packages focused on one specialized goal. 

But maybe someone used CMake for less specialized scripting tasks and would share? I'm writing Zsh plugin manager, Zplugin, and I want to integrate with CMake somehow, to get some swiss army knife features. 

--
Sebastian Gniazdowski
psprint /at/ zdharma.org

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Using CMake for general scripting tasks?

Raymond Wan-2
In reply to this post by Sebastian Gniazdowski
Hi Sebastian,


On Tue, Nov 14, 2017 at 8:39 AM, Sebastian Gniazdowski
<[hidden email]> wrote:
> So I think this project confirms CMake's potential for handling general scripting tasks. However, it's hard to get some inspiration from Hunter, it's just a large collection of CMake packages focused on one specialized goal.


I don't know if this will get me banned from this mailing list :-) ...
but for general scripting tasks, I've recently started using
snakemake.  Of course, the two do not overlap and I still use CMake as
a build-system.

Anyway, not sure if this helps, but maybe you can look into snakemake...

Ray
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Using CMake for general scripting tasks?

Konstantin Tokarev
In reply to this post by Sebastian Gniazdowski


14.11.2017, 03:46, "Sebastian Gniazdowski" <[hidden email]>:
> Hello
> CMake has so many powerful features that I always suspected, that it can be used for tasks normally handled by Bash or sh. I've found following package manager written in CMake:
>
> https://docs.hunter.sh/en/latest/overview/what-is-it.html
>
> So I think this project confirms CMake's potential for handling general scripting tasks. However, it's hard to get some inspiration from Hunter, it's just a large collection of CMake packages focused on one specialized goal.
>
> But maybe someone used CMake for less specialized scripting tasks and would share? 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

>
> --
> Sebastian Gniazdowski
> psprint /at/ zdharma.org
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake

--
Regards,
Konstantin
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Using CMake for general scripting tasks?

Johannes Zarl-Zierl
In reply to this post by Sebastian Gniazdowski
Hello,

On Dienstag, 14. November 2017 01:39:47 CET Sebastian Gniazdowski wrote:
> But maybe someone used CMake for less specialized scripting tasks and would
> share? I'm writing Zsh plugin manager, Zplugin, and I want to integrate
> with CMake somehow, to get some swiss army knife features.

Why do you want to integrate with CMake?

I mean, the scripting features of CMake are a great way to create platform-
independent scripts for a build system, but you already know that your users
have a proper shell installed.
CMake will probably never be comparable in its scripting features to a shell
like Zsh. So, unless you really have a reason to use CMake, you should stick
with the better tool for your task (that is already guaranteed to be
installed).

Cheers,
  Johannes


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Using CMake for general scripting tasks?

Sebastian Gniazdowski
In reply to this post by Konstantin Tokarev
On 14 Nov 2017 at 10:44:09, Konstantin Tokarev ([hidden email]) 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
[hidden email]


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake