Using options

qi_add_optional_package

qi_add_optional_package(NAME DESCRIPTION
)
Arguments:
  • NAME – Name of the package, a WITH_${NAME} option will be created
  • DESCRIPTION – The description of the option (will be shown in cmake gui)

Add optional dependency to a package

Example:

# Create a WITH_FOO option if FOO_PACKAGE is found
qi_add_optional_package(FOO)

# Add some foo-dependent sources when buidling bar library:
set(bar_srcs
      bar_spam.cpp
      bar_eggs.cpp
)
if(WITH_FOO)
   list(APPEND bar_srcs bar_foo.cpp)
endif()

qi_create_bin(bar ${bar_srcs})
qi_use_lib(bar SPAM EGGS)
if(WITH_FOO)
   qi_use_lib(bar FOO)
endif()

Note

if the foo package is found, WITH_FOO will automatically be set to true. however, there are a few cases where you would like to NOT use the features of the FOO library even if it is found, in this case, we let the user set -DWITH_FOO=OFF from the command line.