O'Reilly logo

CMake Cookbook by Roberto Di Remigio, Radovan Bast

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it

Once again, the root CMakeLists.txt file is unchanged with respect to the previous recipe. Moving onto the leaf directory src containing our sources:

  1. We need to find the UUID library and we can re-use the code used in previous recipes:
# Search for pkg-config and UUIDfind_package(PkgConfig QUIET)if(PKG_CONFIG_FOUND)  pkg_search_module(UUID uuid IMPORTED_TARGET)  if(TARGET PkgConfig::UUID)    message(STATUS "Found libuuid")    set(UUID_FOUND TRUE)  endif()endif()
  1. Next, we set up our shared library target and generate the export header, as shown in the previous recipe:
add_library(message-shared SHARED "")include(GenerateExportHeader)generate_export_header(message-shared  BASE_NAME "message"  EXPORT_MACRO_NAME "message_EXPORT" EXPORT_FILE_NAME ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required