Design a site like this with WordPress.com
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:

execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE G++_VERSION)
     if (G++_VERSION VERSION_LESS 4.7)
          message(SEND_ERROR "You need at least G++ 4.7 to compile!")
endif()

Appending entries to a list:

LIST(APPEND 
     bla.h
) 

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.

Advertisement

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:

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

%d bloggers like this: