www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - CMake support for D

reply Dibyendu Majumdar <d.majumdar gmail.com> writes:
Does CMake recognise D in the enable_language command?

If not is there a workaround?

Thanks and Regards
Dibyendu
Jan 03 2016
next sibling parent Trent Forkert <trentforkert+d gmail.com> writes:
On Sunday, 3 January 2016 at 17:30:15 UTC, Dibyendu Majumdar 
wrote:
 Does CMake recognise D in the enable_language command?
No.
 If not is there a workaround?
I have a fork of CMake that adds D support here: https://github.com/trentforkert/cmake It's been a while since I published updates, but it should still work. If you encounter bugs please file them.
Jan 03 2016
prev sibling next sibling parent reply Luis <luis.panadero gmail.com> writes:
On Sunday, 3 January 2016 at 17:30:15 UTC, Dibyendu Majumdar 
wrote:
 Does CMake recognise D in the enable_language command?

 If not is there a workaround?

 Thanks and Regards
 Dibyendu
I suggest use dub instead of cmake. I did a try to use cmake some time ago (a few years ago, before dub), and was a nightmare to get ir working on GNU/Linux and Windows. With dub , simply works fine with a simple json file.
Jan 04 2016
next sibling parent Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Mon, 2016-01-04 at 08:28 +0000, Luis via Digitalmars-d-learn wrote:

=20
 I suggest use dub instead of cmake. I did a try to use cmake some=C2=A0
 time ago (a few years ago, before dub), and was a nightmare to=C2=A0
 get ir working on GNU/Linux and Windows. With dub , simply works=C2=A0
 fine with a simple json file.
The problem though is twofold: 1. IDE support, cf. CLion required CMake. 2. Getting things packaged in Debian/Fedora. As far as I am aware, Dub is not yet packaged by Debian and Fedora and so cannot be used for creating Debian or Fedora packages. If Dub could be packaged then it opens up a whole new world of possibilities. For now though use of SCons and CMake is nigh on required for projects aiming to get packaged. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Jan 04 2016
prev sibling parent reply Dibyendu Majumdar <d.majumdar gmail.com> writes:
On Monday, 4 January 2016 at 08:28:03 UTC, Luis wrote:
 I suggest use dub instead of cmake. I did a try to use cmake 
 some time ago (a few years ago, before dub), and was a 
 nightmare to get ir working on GNU/Linux and Windows. With dub 
 , simply works fine with a simple json file.
CMake has worked well for me for C/C++ projects, on Windows, Linux and OSX. Pity no official support for D. I need support for apps that have a mixed code base not just D. Thanks for suggesting dub, will check it out. Also premake seems to support D so that is another option. Regards
Jan 04 2016
parent Edwin van Leeuwen <edder tkwsping.nl> writes:
On Monday, 4 January 2016 at 12:40:23 UTC, Dibyendu Majumdar 
wrote:
 Thanks for suggesting dub, will check it out. Also premake 
 seems to support D so that is another option.
Another alternative is reggae which supports mixed code base: https://github.com/atilaneves/reggae and can generate ninja/make/tup build rules (similarly to cmake).
Jan 04 2016
prev sibling parent reply King_DuckZ <king_duckz gmx.com> writes:
On Sunday, 3 January 2016 at 17:30:15 UTC, Dibyendu Majumdar 
wrote:
 Does CMake recognise D in the enable_language command?

 If not is there a workaround?

 Thanks and Regards
 Dibyendu
One year later, is there any progress on this? Now that gdc has gained support for .so (it seems), lack of cmake support is the only thing that is preventing me from adopting D. I agree that cmake is not the prettiest thing out there, but I think there are many good reasons for wanting it: 1) As already said, it's needed for CLion 2) Many programmers, including myself, are already familiar with its syntax - pretty or not, learning a new tool is extra work 3) As far as I know, you can't mix C++ and D with dub 4) I could just drop D code in my pre-existing C++ projects without much effort on the build system I hope to hear some promising news on this side!
Jan 16 2017
parent reply Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Mon, 2017-01-16 at 11:40 +0000, King_DuckZ via Digitalmars-d-learn
wrote:
 On Sunday, 3 January 2016 at 17:30:15 UTC, Dibyendu Majumdar=C2=A0
 wrote:
 Does CMake recognise D in the enable_language command?
=20
 If not is there a workaround?
=20
 Thanks and Regards
 Dibyendu
=20 One year later, is there any progress on this? Now that gdc has=C2=A0 gained support for .so (it seems), lack of cmake support is the=C2=A0 only thing that is preventing me from adopting D. I agree that=C2=A0 cmake is not the prettiest thing out there, but I think there are=C2=A0 many good reasons for wanting it:
Does this do the job?=20 https://github.com/dcarp/cmake-d
 1) As already said, it's needed for CLion
I wish CLion would support Meson. Meson can build D stuff out of the box.
 2) Many programmers, including myself, are already familiar with=C2=A0
 its syntax - pretty or not, learning a new tool is extra work
Which can actually be a good thing, learning is something we should all be doing all the time.
 3) As far as I know, you can't mix C++ and D with dub
I'm having difficulty getting Dub to compile D and clean up afterwards. :-(
 4) I could just drop D code in my pre-existing C++ projects=C2=A0
 without much effort on the build system
I was going to try moving Me TV from C++ to D, but the path of least resistance is to just continue with it in C++ and put all the C++17 stuff in.=20
 I hope to hear some promising news on this side!
--=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Jan 16 2017
parent reply King_DuckZ <king_duckz gmx.com> writes:
On Monday, 16 January 2017 at 12:29:46 UTC, Russel Winder wrote:
 On Mon, 2017-01-16 at 11:40 +0000, King_DuckZ via 
 Digitalmars-d-learn wrote:
 On Sunday, 3 January 2016 at 17:30:15 UTC, Dibyendu Majumdar 
 wrote:
 Does CMake recognise D in the enable_language command?
 
 If not is there a workaround?
 
 Thanks and Regards
 Dibyendu
One year later, is there any progress on this? Now that gdc has gained support for .so (it seems), lack of cmake support is the only thing that is preventing me from adopting D. I agree that cmake is not the prettiest thing out there, but I think there are many good reasons for wanting it:
Does this do the job? https://github.com/dcarp/cmake-d
I had forgotten about that... I even used it at some point a long time ago, maybe I should give it another try, since it seems to have received lots of commits since then!
 1) As already said, it's needed for CLion
I wish CLion would support Meson. Meson can build D stuff out of the box.
Hadn't heard of this before, I'll have a look. Btw I don't see any mention of D on their home page.
 2) Many programmers, including myself, are already familiar 
 with its syntax - pretty or not, learning a new tool is extra 
 work
Which can actually be a good thing, learning is something we should all be doing all the time.
I'm not saying we shouldn't be learning things, but time is limited and I'd rather practice my C++ or D than learn yet another build system, especially if I only have limited use for it :)
 3) As far as I know, you can't mix C++ and D with dub
I'm having difficulty getting Dub to compile D and clean up afterwards. :-(
 4) I could just drop D code in my pre-existing C++ projects 
 without much effort on the build system
I was going to try moving Me TV from C++ to D, but the path of least resistance is to just continue with it in C++ and put all the C++17 stuff in.
I feel the same about many small tools I wrote.
 I hope to hear some promising news on this side!
Jan 16 2017
parent reply Russel Winder via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Mon, 2017-01-16 at 17:47 +0000, King_DuckZ via Digitalmars-d-learn
wrote:
=20
[=E2=80=A6]
 Meson can build D stuff out of the box.
=20
=20 Hadn't heard of this before, I'll have a look. Btw I don't see=C2=A0 any mention of D on their home page.
It is very nice. D seems to work OOTB. [=E2=80=A6]
 I'm not saying we shouldn't be learning things, but time is=C2=A0
 limited and I'd rather practice my C++ or D than learn yet=C2=A0
 another build system, especially if I only have limited use for=C2=A0
 it :)
Some of us find build fun. [=E2=80=A6] --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Jan 16 2017
parent reply King_DuckZ <king_duckz gmx.com> writes:
On Monday, 16 January 2017 at 19:44:34 UTC, Russel Winder wrote:
 On Mon, 2017-01-16 at 17:47 +0000, King_DuckZ via 
 Digitalmars-d-learn wrote:
 
[…]
 Meson can build D stuff out of the box.
 
Hadn't heard of this before, I'll have a look. Btw I don't see any mention of D on their home page.
It is very nice. D seems to work OOTB. […]
 I'm not saying we shouldn't be learning things, but time is 
 limited and I'd rather practice my C++ or D than learn yet 
 another build system, especially if I only have limited use 
 for it :)
Some of us find build fun. […]
One [more] year ahead, and I found this old thread I had forgotten about. In the meantime, trentforkert has stopped (apparently) working on cmake, and dcarp's has failed me for projects larger than a couple files. It also looks like it's not receiving updates anymore. All of this kept me away from D. Now that gdc is rumoured to get merged into gcc 8 tho, is there any concrete chance of this happening? I think even rust (which came out after D) has decent cmake support at this point.
Feb 26
parent reply Russel Winder <russel winder.org.uk> writes:
On Mon, 2018-02-26 at 20:28 +0000, King_DuckZ via Digitalmars-d-learn
wrote:
 [=E2=80=A6]
=20
 One [more] year ahead, and I found this old thread I had=20
 forgotten about. In the meantime, trentforkert has stopped=20
 (apparently) working on cmake, and dcarp's has failed me for=20
 projects larger than a couple files. It also looks like it's not=20
 receiving updates anymore.
The DCarp CMake-D repository is active. If it doesn't work then it just needs more work.
 All of this kept me away from D. Now that gdc is rumoured to get=20
 merged into gcc 8 tho, is there any concrete chance of this=20
 happening? I think even rust (which came out after D) has decent=20
 cmake support at this point.
As far as I am aware CMake is not used for Rust, the vast majority of people use Cargo. This mean it is certain some Rust people will use CMake. :-) It is worth noting that the Rust plugin to CLion does not require CMake, it uses Cargo. CLion not IDEA is not the focus of the Rust plugin due to debugging. CLion is the platform for all native code language for JetBrains as I understand it exacly because of debugging support. I believe the work on D plugin support for IntelliJ IDEA should refocus on CLion. It can still use Dub it seems, and it can get access to the debugging framework. Clearly it would still be good in D had CMake support. It strikes me the DCarp's CMake-D repository is the one to support. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road m: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk
Feb 27
parent King_DuckZ <king_duckz gmx.com> writes:
On Tuesday, 27 February 2018 at 09:20:21 UTC, Russel Winder wrote:
 On Mon, 2018-02-26 at 20:28 +0000, King_DuckZ via 
 Digitalmars-d-learn wrote:
 […]
 
 One [more] year ahead, and I found this old thread I had 
 forgotten about. In the meantime, trentforkert has stopped 
 (apparently) working on cmake, and dcarp's has failed me for 
 projects larger than a couple files. It also looks like it's 
 not receiving updates anymore.
The DCarp CMake-D repository is active. If it doesn't work then it just needs more work.
 All of this kept me away from D. Now that gdc is rumoured to 
 get merged into gcc 8 tho, is there any concrete chance of 
 this happening? I think even rust (which came out after D) has 
 decent cmake support at this point.
As far as I am aware CMake is not used for Rust, the vast majority of people use Cargo. This mean it is certain some Rust people will use CMake. :-) It is worth noting that the Rust plugin to CLion does not require CMake, it uses Cargo. CLion not IDEA is not the focus of the Rust plugin due to debugging. CLion is the platform for all native code language for JetBrains as I understand it exacly because of debugging support. I believe the work on D plugin support for IntelliJ IDEA should refocus on CLion. It can still use Dub it seems, and it can get access to the debugging framework. Clearly it would still be good in D had CMake support. It strikes me the DCarp's CMake-D repository is the one to support.
Right, I stand corrected about Rust, though as you say there are those who use it with CMake. About cmake-d, there's this https://github.com/dcarp/cmake-d/issues/19, which I could work around. More seriously though, it doesn't track dependencies between .d files. So if for example you have: // a.d void foo() {} // b.d import a; int main() { foo(); return 0; } and compile it, all goes well. Now if you change a to be: //a.d void foo(a=10) { //use a somewhere } and just 'make' then you're in for some really funky crash (it may not be the exact code, but I had a problem very similar to this). The only fix is make clean; make. This is really hard to spot as soon as you start having more than a couple files, and it's really something the build system should take care of. Unfortunately I don't think a purely scripted solution for cmake will ever be able to handle this problem. Speaking of CLion, at this point I've pretty much abandoned it, vim is more than enough for me. My problem is mixing D with C and C++, and with being already so familiar with CMake that starting all over again just puts me off to the point I'd rather not do any D at all. Build systems are not my passion really, and learning CMake was already painful enough.
Feb 27