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 <LIST_NAME>
     bla.h
)
  • Creating filters in Visual Studio projects:
source_group("<FILTER_NAME>" REGULAR_EXPRESSION <FOLDER_NAME>\\/.*)

Comments