How it works

The check_<lang>_source_runs functions for C and C++ operate with the same general principles as check_<lang>_source_compiles, but add an extra step where the produced executable is actually run. As for check_<lang>_source_compiles, the execution of check_<lang>_source_runs can be directed by the following variables:

  • CMAKE_REQUIRED_FLAGS to set the compiler flags
  • CMAKE_REQUIRED_DEFINITIONS to set preprocessor macros
  • CMAKE_REQUIRED_INCLUDES to set the list of include directories
  • CMAKE_REQUIRED_LIBRARIES to set the list of libraries to link into the executable

Since we used the imported target as produced by pkg_search_module, it was only necessary to set CMAKE_REQUIRES_LIBRARIES to PkgConfig::UUID, to also get the include directories ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.