Staging targets

This module make libraries and executables build in this projects available to others projects.


             
              qi_stage_lib(target [DEPRECATED <deprecated> ...]
    [DEPENDS <depends> ...]
    [INCLUDE_DIRS <include_dirs> ...]
    [PATH_SUFFIXES <path_suffixes> ...]
)

             
            
Arguments:
  • target – a target created with qi_create_lib
  • DEPRECATED – specify a deprecated message. This message will be displayed each time another project use that lib.
  • DEPENDS – if not given, ${TARGET}_DEPENDS will be guessed from the previous calls to qi_use_lib(). Use this (with care!) to override this behavior. One should list all the (public) “direct” dependencies and their (public) dependencies.
  • INCLUDE_DIRS – if not given, ${TARGET}_INCLUDE_DIRS will be guessed from the previous calls to include_directories() Use this (with care!) to override this behavior.
  • PATH_SUFFIXES – when your header is installed in foo/bar.h, but you still need to do #include <bar.h>, you can set PATH_SUFFIXES to ‘foo’. Be careful to test the install rules of your headers if you choose to do so.

Generate a ‘name’-config.cmake, allowing other project to find the library. Usage of the various arguments are a bit tricky, so please read Using qi_stage_lib before using them


             
              qi_stage_header_only_lib(name [DEPRECATED <deprecated> ...]
    [DEPENDS <depends> ...]
    [INCLUDE_DIRS <include_dirs> ...]
    [PATH_SUFFIXES <path_suffixes> ...]
)

             
            
Arguments:
  • name – the name of the library, clients of the library can use qi_use_lib(... NAME)
  • DEPRECATED – specify a deprecated message. This message will be displayed each time another project use that lib.
  • DEPENDS – if not given, ${NAME}_DEPENDS will be empty the previous calls to qi_use_lib().
  • INCLUDE_DIRS – if not given, ${NAME}_INCLUDE_DIRS will be guessed from the previous calls to include_directories() Use this (with care!) to override this behavior.
  • PATH_SUFFIXES – when your header is installed in foo/bar.h, but you still need to do #include <bar.h>, you can set PATH_SUFFIXES to ‘foo’. Be careful to test the install rules of your headers if you choose to do so.

Generate a ‘name’-config.cmake, allowing other projects to find the header-only library. If the library has some dependencies, use something like:


             
              find_package(FOO)
include_directories(${FOO_INCLUDE_DIRS})
qi_stage_header_only_lib(bar DEPENDS FOO)

             
            

             
              qi_stage_bin(target)

             
            
Arguments:
  • target – the name of a target

Generate a ‘name’-config.cmake, allowing other projects to find the binary

Example


             
              # in foo/CMakeLists.txt
qi_create_bin(foo foo.cpp)
qi_stage_bin(foo)

# in bar/CMakeLists.txt:
find_package(foo)
# Do something with ${FOO_EXECUTABLE}

             
            

             
              qi_stage_cmake(module)

             
            
Arguments:
  • module – path to the module file, relative to CMAKE_CURRENT_SOURCE_DIR

stage a cmake file For instance, assuming you have a foo-config.cmake file containing my_awesome_function, you can do:


             
              qi_stage_cmake("foo-config.cmake")

             
            

Then later, (in an other project, or in the same project):


             
              find_package(foo)
my_awesome_function()

             
            

             
              qi_stage_script(file_name [TRAMPOLINE]
    [PYTHON]
    [DEPENDS <depends> ...]
)

             
            
Arguments:
  • file_name – Path to the script in source dir.
  • TRAMPOLINE – If set, will generate a trampoline script in sdk binary dir. Use this flag if your script uses any element that is built.
  • PYTHON – set if script is written in python
  • DEPENDS – list of target or packages this script depends on. Used for trampoline script generation only.

Stage an executable script

Will stage a cmake file so that others can locate the script. Use like this:


             
              qi_stage_script(src/myscript)

             
            

And in other projects:


             
              find_package(myscript)
use_script_in_function(${MYSCRIPT_EXECUTABLE})

             
            

             
              qi_use_lib(name [<remaining args> ...]
    [ASSUME_SYSTEM_INCLUDE]
)

             
            
Arguments:
  • name – The target to add dependencies to.
  • args ( remaining ) – dependencies
  • ASSUME_SYSTEM_INCLUDE – Use -isystem for including dependencies. Useful for instance to ignore warnings coming from 3rd party headers.

Handles dependencies between projects.

Call find_package for you, then do all the include_directories and target_link_libraries that are needed.

Note

The name must be an existing target, so you must call qi_use_lib after qi_create_bin or qi_create_lib

You can however call qi_use_lib several times, for instance:


             
              qi_create_bin(foo)

# ...

qi_use_lib(foo bar)
if(UNIX)
   qi_use_lib(foo PTHREAD)
endif()

             
            

             
              qi_stage_dir(directory)

             
            
Arguments:
  • directory

    (optional): the directory to register, relative to CMAKE_CURRENT_SOURCE_DIR. Defaults to CMAKE_CURRENT_SOURCE_DIR

    Make sure configuration and data files in the given directory can be found by qi::findData() in this project or any dependency

For this to work, configuration files should be in etc and data files in share

Note that this function does not create any install rule, so you should call qi_install_data(share/... ) for the files to be found after your project is installed.

See Managing data


             
              qi_add_bin_sdk(path)

             
            
Arguments:
  • path – : the path to the pre-compiled SDK

Register the given path as a CMAKE_PREFIX_PATH.

Used when pre-compiled binaries are put under version control.

Note that the pre-compiled SDK must have the following layout:


             
              lib
  libfoo.so
include
  foo
    foo.h
share
  cmake
    foo
      foo-config.cmake