Design a site like this with
Get started

Useful CMake functions

CMake is a great tool, but I always keep searching on how to do this and that. Time to make a list again…

Checking the G++ compiler version:

     if (G++_VERSION VERSION_LESS 4.7)
          message(SEND_ERROR "You need at least G++ 4.7 to compile!")

Appending entries to a list:


Creating filters in Visual Studio projects:

source_group("" REGULAR_EXPRESSION \\/.*)

Custom install commands

To print a message during the install process add:

install(CODE "MESSAGE(\"Casting spell\")")

To run a shell command during the install process add:

install(CODE "execute_process(COMMAND 'echo Creating magic')")

Also see this. More CMake install info is here.


Published by HorstBaerbel

Software developer by trade and interest, but I venture into the electronics- and diy-world from time to time.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: