[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: Supporting the CMake file API in the project/build plugin ?
From:       Alexander Neundorf <neundorf () kde ! org>
Date:       2023-11-20 21:23:59
Message-ID: 2374176.NG923GbCHz () unknownc4d9870202f1
[Download RAW message or body]

On Donnerstag, 16. November 2023 08:20:53 CET christoph@cullmann.io wrote:
> On 2023-11-15 23:09, Alexander Neundorf wrote:
> > Hi,
> > 
> > On Donnerstag, 7. September 2023 20:44:07 CET christoph@cullmann.io
> > 
> > wrote:
> >> On 2023-09-06 23:32, Alexander Neundorf wrote:
> >> > Hi,
> >> > 
> >> > currently cmake can generate a kate project file, and then, when kate
> >> > opens
> >> > some file in the buildtree, e.g. the project file, the kate project
> >> > plugin reads
> >> > the project file and populates the list of files and the build targets.
> >> > With cmake 3.27 this has been marked officially as obsolete (even
> >> > though the
> >> > kate project generator gained some features in cmake 3.27).
> >> > 
> >> > Nevertheless, medium term it would be better if kate would use the
> >> > cmake file
> >> > API.
> >> > What would that mean ?
> >> > kate could search the CMakeCache.txt for CMAKE_PROGRAM, which contains
> >> > the
> >> > path to the cmake executable which generated this buildtree.
> >> > Then kate would write some simple json file into the build tree, and
> >> > then rerun
> >> > cmake on that buildtree.
> >> > cmake will see the file kate has written, and generate a json file
> >> > which
> >> > contains the source directory, the list of targets, the source files
> >> > for each
> >> > target.
> >> > With this information kate could:
> >> > - use that list of source files as project files, or use the git/svn
> >> > support in
> >> > kate to get all files which are in the source directory
> >> > - get  the list of targets and generate a build target for each of
> >> > them. Those
> >> > could be executed by running cmake (so it would automatically work for
> >> > any
> >> > build tree, whether it is ninja, make, or msvc): cmake --build
> >> > <buildir> --
> >> > config <Config> --target <target>
> >> > 
> >> > What do you suggest how this would fit into the project- and
> >> > build-plugins ?
> >> > I guess the session support is not related ?
> >> 
> >> Hi,
> >> 
> >> thanks for taking a look at that!
> >> 
> >> I think that would fit into the project plugin as another
> >> auto-discovery
> >> mode,
> >> like we have it for the various version control systems.
> >> 
> >> There we execute the git/.../... commands.
> > 
> > I've got a first version working locally here (still Qt5 based).
> > So I'll clone on gitlab and create a merge request ?
> 
> Hi,
> 
> Great ;)
> 
> Yes, or put it to some work/xxx branch in the
> main repo, that makes it even easier to try.

it's here now:
https://invent.kde.org/utilities/kate/-/commit/
54b4b88d3cb470b4226f4ac91ea54d99c0b8eb59[1]
I haven't actually tried to build it against the KF6 version of kate yet, building against Qt6 
worked.

Basically it works, it creates the project, with build rules for all targets in all build 
configurations, the source files taken from the cmake files and the correct source dir. It 
also creates a compile_commands.json and copies it to thr source dir.

I'm not very happy with the usability.
If the user opens a CMakeCache.txt (or any other file in the build tree), it automatically 
creates a kate project automatically, similar to git and svn.

This is a bit hard to discover, since usually users don't open files in the buildtree.
If the user has opened a file in the source tree before, and git/svn auto projects are 
enabled, no cmake project will be created, i.e. no build commands.

Should I add an explicit entry like "Open CMake build tree" or something like this in the 
project menu ?
I also wonder whether it should optionally populate the project files from the git/svn 
repos, instead of using the files from the CMakeLists.txt.

Any comments ?

Alex


--------
[1] https://invent.kde.org/utilities/kate/-/commit/
54b4b88d3cb470b4226f4ac91ea54d99c0b8eb59

[Attachment #3 (unknown)]

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">On \
Donnerstag, 16. November 2023 08:20:53 CET christoph@cullmann.io wrote:</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; On 2023-11-15 \
23:09, Alexander Neundorf wrote:</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt; Hi,</p> \
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt; </p> \
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt; On \
Donnerstag, 7. September 2023 20:44:07 CET christoph@cullmann.io</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt; </p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt; \
wrote:</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; On 2023-09-06 23:32, Alexander Neundorf wrote:</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
Hi,</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; </p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
currently cmake can generate a kate project file, and then, when kate</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
opens</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; some file in the buildtree, e.g. the project file, the kate project</p> \
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; \
&gt; plugin reads</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
the project file and populates the list of files and the build targets.</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
With cmake 3.27 this has been marked officially as obsolete (even</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
though the</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; kate project generator gained some features in cmake 3.27).</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; Nevertheless, medium term it would be better if kate would use the</p> \
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; \
&gt; cmake file</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
API.</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; What would that mean ?</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
kate could search the CMakeCache.txt for CMAKE_PROGRAM, which contains</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
the</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; path to the cmake executable which generated this buildtree.</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
Then kate would write some simple json file into the build tree, and</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
then rerun</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; cmake on that buildtree.</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
cmake will see the file kate has written, and generate a json file</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
which</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; contains the source directory, the list of targets, the source \
files</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; for each</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
target.</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; With this information kate could:</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
- use that list of source files as project files, or use the git/svn</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
support in</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; kate to get all files which are in the source directory</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
- get&nbsp; the list of targets and generate a build target for each of</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
them. Those</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; could be executed by running cmake (so it would automatically work \
for</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; any</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
build tree, whether it is ninja, make, or msvc): cmake --build</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
&lt;buildir&gt; --</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
config &lt;Config&gt; --target &lt;target&gt;</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; &gt; What do you suggest how this would fit into the project- and</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
build-plugins ?</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; &gt; \
I guess the session support is not related ?</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; </p> \
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; \
Hi,</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; </p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; thanks for taking a look at that!</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; </p> \
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; I \
think that would fit into the project plugin as another</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; \
auto-discovery</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; \
mode,</p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; \
&gt;&gt; like we have it for the various version control systems.</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; </p> \
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt;&gt; \
There we execute the git/.../... commands.</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt; </p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt; I've got \
a first version working locally here (still Qt5 based).</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; &gt; So I'll \
clone on gitlab and create a merge request ?</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; </p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; Hi,</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; </p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; Great ;)</p> \
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; </p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; Yes, or put \
it to some work/xxx branch in the</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">&gt; main repo, \
that makes it even easier to try.</p> <br /><p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">it's here now:</p> \
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><a \
href="https://invent.kde.org/utilities/kate/-/commit/54b4b88d3cb470b4226f4ac91ea54d99c \
0b8eb59">https://invent.kde.org/utilities/kate/-/commit/54b4b88d3cb470b4226f4ac91ea54d99c0b8eb59</a></p>
 <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">I haven't \
actually tried to build it against the KF6 version of kate yet, building against Qt6 \
worked.</p> <br /><p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Basically it \
works, it creates the project, with build rules for all targets in all build \
configurations, the source files taken from the cmake files and the correct source \
dir. It also creates a compile_commands.json and copies it to thr source dir.</p> <br \
/><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">I'm not very \
happy with the usability.</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">If the user opens \
a CMakeCache.txt (or any other file in the build tree), it automatically creates a \
kate project automatically, similar to git and svn.</p> <br /><p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">This is a bit hard \
to discover, since usually users don't open files in the buildtree.</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">If the user has \
opened a file in the source tree before, and git/svn auto projects are enabled, no \
cmake project will be created, i.e. no build commands.</p> <br /><p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Should I add an \
explicit entry like &quot;Open CMake build tree&quot; or something like this in the \
project menu ?</p> <p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">I also wonder \
whether it should optionally populate the project files from the git/svn repos, \
instead of using the files from the CMakeLists.txt.</p> <br /><p \
style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Any comments ?</p> \
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Alex</p> \
<br /></body> </html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic