I have an open-source project that I originally wanted to license under MIT, but since I'm using a GPLv3 component that I can't quite get rid of (namely, the .g4 ANTLR grammar file that I'm using to generate a lexer/parser), I've been sort-of forced to distribute my project under GPLv3 as I understand anything that touches anything under GPLv3 needs to go under GPLv3 - I figured the ANTLR-generated code was a derivative of the grammar file, so the lexer/parser needs to be under GPLv3. Is that right?

So I'm distributing the project under GPLv3. And there's a [distinct] part of the project that's under MIT.

Now, I came across a piece of very useful code on someone's blog, a modified version of some code that was originally published under CPOL, so I figure the modified version is also under CPOL.

Can I even use that code? The CPOL explicitly forbids sublicensing, so I'm a bit lost as to what to do with this...

All I want is to give the original authors credit for their work - why does it have to be so complicated? /rant

  • 1
    Would it be better to pose the Antlr grammar question separately and let this one focus on the Code Project license?
    – RubberDuck
    Oct 6, 2015 at 21:44
  • @RubberDuck perhaps... Oct 6, 2015 at 21:46
  • 1
    You might want to ask about the license of that ANTLR file separately. It might in fact not be GPL because the output of a GPL program is in most cases not affected by the GPL. But I don't know enough about that tool to say for sure.
    – Philipp
    Oct 6, 2015 at 21:53
  • I posted a separate question about the grammar here. opensource.stackexchange.com/q/1926/775
    – RubberDuck
    Oct 6, 2015 at 22:09
  • 5
    I touched GPL code once, but I'm not licensed under the GPL.
    – Martijn
    Oct 7, 2015 at 9:23

3 Answers 3


CPOL is not an open source license according to the OSI definition. It has a clause which does not allow it to be used for any purpose as mandated by the GPL or MIT license:

You agree not to use the Work for illegal, immoral or improper purposes, or on pages containing illegal, immoral or improper material.

Neither the GPL or the MIT license force the user to agree to this. So by putting a CPOL work under either of these licenses, you remove this restriction against the will of the original author.

Although this clause is well meant, it is incompatible with any FSF or OSI approved license. That means it can not be incorporated into an open source project without making that project un-free.

All you can do is contact the original author and ask them if they license it to you under GPLv3.

  • 4
    Oh wow... that "O" is completely misleading then.. now that really makes me wonder how many open-source projects are violating CPOL then.. Oct 6, 2015 at 21:45
  • No illegal, immoral or improper purposes. So Dr. Evil will have to look somewhere else...
    – jkdev
    Oct 15, 2015 at 7:28
  • What all is required of the original author to license their (originally CPOL) work as a different license? Can they simply email me stating "I license you the XXX code under GPLv3" ? Or does it need to be more formal? How do I "document" this in my own code, then? Jan 3, 2018 at 2:33
  • 2
    @JonathonReinhart This is material for a new question.
    – Philipp
    Jan 3, 2018 at 8:52

The Free Software Foundation maintains lists of which software licenses are:

  1. Free and GPL-compatible
  2. Free and GPL-incompatible
  3. Nonfree, and therefore GPL-incompatbile

CPOL falls into the last category:

The Code Project Open License is not a free software license. Section 5.6 restricts how you can use the work. Section 5.4 prohibits commercial distribution of the software by itself—and depending on how you read section 3.4, you may not have permission to distribute the software by itself at all.


In my humble opinion, what makes the two licenses incompatible are these two snippets from the two licenses.


  1. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.


  1. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:


    d. You agree not to sell, lease, or rent any part of the Work. This does not restrict you from including the Work or any part of the Work inside a larger software distribution that itself is being sold. The Work by itself, though, cannot be sold, leased or rented.


    f. You agree not to use the Work for illegal, immoral or improper purposes, or on pages containing illegal, immoral or improper material. The Work is subject to applicable export laws. You agree to comply with all such laws and regulations that may apply to the Work after Your receipt of the Work.

The CPOL license adds extra restrictions to the GPL that could be considered surrendering of others' freedoms. The GPL explicitly states that anyone with a valid license is free to sell the work for profit, while the CPOL explicitly forbids it.

  • This does not restrict you from including the Work or any part of the Work inside a larger software distribution that itself is being sold. - not sure I follow here. To me this sounds exactly like what we're doing (although we're not selling RD) Oct 7, 2015 at 13:54
  • Good point @Mat'sMug. I had missed that piece.... IMO the CPOL just doesn't make much sense....
    – RubberDuck
    Oct 7, 2015 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.