[cmake-developers] [Discussion] Add python support for CMakeLists

Shmuel H, shmuelhcmake at gmail.com
Fri Jan 13 11:45:07 EST 2017


I think that the special thing about CMake, is the option to customize a
build system (if needed). This is also the thing that makes CMake harder to
use than other declarative-based build systems.

Therefore, I think we should combine these things together:

   - From one side, we would have (for example) a global list of targets
   with the option to export it to (for example) a JSON document and then
   simply load it.
   - From the other side, programmers should be able to use a script
   language to customize their build process.

That would enable programmers, IDEs and automated tools to create a valid
and simple documents for simple projects and also would give programmers
the power they need in order to customize cmake for their needs.

For example, a simple declaration (pseudo code):
cmake_libraries += {
                                   ["name":      "myLib",
                                    "files":         "myLib.c",
                                    "link_type": "static"]
                                }

And a customized script for easily adding a library for a cpp class:
def my_add_library(name, class_name):
    cmake_libraries += {
                                       ["name":      name,
                                        "files":         [class_name +
'.cpp', class_name + '.h'],
                                        "link_type": MY_LINK_TYPE]
                                    }

# Then, add my customized library:
 my_add_library('myLib', 'myLib')

Note that it still would be possible to export these "scripted files" to a
simple JSON file.

I would be happy to hear your opinion about this general design.


On Fri, Jan 13, 2017 at 5:56 PM, Brad King <brad.king at kitware.com> wrote:

> On 01/12/2017 01:20 PM, Shmuel H, wrote:
> > maybe a general problem with dependencies, which generally
> > make our life harder?
>
> Yes.  People typically install CMake only in order to build something else.
> If Python were added as an external dependency then that would be yet
> another step.  If it were bundled then our bootstrap script and CMake-based
> build of CMake itself would both have to learn to build Python.  Python
> is also a distribution in addition to a language, so deploying it raises
> the question of what to bundle with it.  None of these is something I'd
> like to have added to the responsibilities of maintaining and distributing
> CMake.
>
> There are already other build systems that use Python as their language,
> but many people still choose CMake over them anyway.
>
> > However, for me - a user, a known and well-designed programming language
> > for CMake would be very helpful. I can't say that for every other user,
> > but I think it would make their life a lot easier too.
>
> As Charles Huet mentioned Lua is a good choice because it provides a
> language and is portable to everywhere that has C.  It is also not a
> distribution.  I've posted in the past a design for a cmake_lua command
> that allows one to use Lua code within CMakeLists.txt files.  Actually
> using it as a full replacement language though will first require more
> refactoring internally as I mentioned in my previous post.
>
> As I've mentioned in previous discussions, if we're going to go through
> a language change we should make sure it addresses important needs.
> Having a declarative specification that can be externally tooled will
> be helpful to IDEs.  I'd envision such a format that is then imported
> by the procedural-language part of the configuration process for
> evaluation of conditions and finalization for the current target.
>
> Without a comprehensive design I'm hesitant to proceed on any such effort.
>
> -Brad
> --
>
> 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-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20170113/cef60632/attachment.html>


More information about the cmake-developers mailing list