# qiBuild documentation

# Functions to create targets

This is the main qiBuild module. It encapsulates the creation of programs, scripts and libraries, handling dependencies and install rules, in an easy, elegant and standard way.

There can be different targets:

- bin : a program
- lib : a library
- script : a script

See also

- Using submodules

    qi_create_bin(name [<remaining args> ...]
        [NO_INSTALL]
        [NO_RPATH]
        [EXCLUDE_FROM_ALL]
        [WIN32]
        [MACOSX_BUNDLE]
        [SUBFOLDER <subfolder>]
        [SRC <src> ...]
        [DEPENDS <depends> ...]
        [SUBMODULE <submodule> ...]
    )

  Arguments: | name – the target name args (remaining) – source files, like the SRC group, argn and SRC will be merged NO_INSTALL – Do not create install rules for the target NO_RPATH – Do not try to fix rpath By default, qibuild runs chrpath on the targets so everything work even when project is installed to a non-standard location. Use this to prevent chrpath to be run. EXCLUDE_FROM_ALL – Do not include the target in the ‘all’ target, this target will not be build by default, you will have to compile the target explicitly. Warning: you will NOT be able to create install rules for this target. WIN32 – Build an executable with a WinMain entry point on windows. MACOSX_BUNDLE – Refer to the add_executable documentation. SUBFOLDER – The destination subfolder. The install rules generated will be sdk/bin/<subfolder> SRC – The list of source files DEPENDS – The list of source files SUBMODULE – The list of source files

  Create an executable. The target name should be unique.

Example

    ##
    ## target examples
    ##

    project(SampleTarget)

    #add_subdirectory(fooscript)
    add_subdirectory(foolib)
    add_subdirectory(foobin)

    qi_create_bin(myprog SRC main.cpp)
    qi_create_lib(mylib SRC mylib.h mylib.c)

    qi_create_script(name source [NO_INSTALL]
        [SUBFOLDER <subfolder>]
    )

  Arguments: | name – The name of the target script source – The source script, that will be copied in the sdk to bin/<name> NO_INSTALL – Do not generate install rule for the script SUBFOLDER – The subfolder in sdk/bin to install the script into. (sdk/bin/<subfolder>)

  Create a script. This will generate rules to install it in the sdk.

    qi_create_lib(name [<remaining args> ...]
        [STATIC]
        [SHARED]
        [MODULE]
        [NO_INSTALL]
        [EXCLUDE_FROM_ALL]
        [NO_RPATH]
        [NO_FPIC]
        [SUBFOLDER <subfolder>]
        [SRC <src> ...]
        [SUBMODULE <submodule> ...]
        [DEPENDS <depends> ...]
    )

  Arguments: | name – the target name args (remaining) – sources files, like the SRC group, argn and SRC will be merged STATIC – force a static library SHARED – force a shared library MODULE – build a module (library loadable at runtime) NO_INSTALL – Do not create install rules for the target EXCLUDE_FROM_ALL – Do not include the target in the ‘all’ target, This target will not be built by default, you will have to compile the target explicitly. Warning: you will NOT be able to create install rules for this target. NO_RPATH – Do not set a rpath to $ORIGIN/..lib when linking on linux. NO_FPIC – Do not set -fPIC on static libraries (will be set for shared lib by CMake anyway) SUBFOLDER – The destination subfolder. The install rules generated will be sdk/lib/<subfolder> SRC – The list of source files (private headers and sources) SUBMODULE – Submodule to include in the lib DEPENDS – List of dependencies

  Create a library or a module

  The target name should be unique.

  Static vs shared

  To build a module (library loaded at runtime), use:

      qi_create_lib(myLib MODULE SRC ....)

  If you need your library to be static, use:

      qi_create_lib(mylib STATIC SRC ....)

  If you need your library to be shared, use:

      qi_create_lib(mylib SHARED SRC ....)

  If you want to let the user choose, use:

      qi_create_lib(mylib SRC ....)

  The library will be:
    - built as a shared library on UNIX
    - built as a static library on windows

  But the user can set BUILD_SHARED_LIBS=OFF to compile everything in static by default.

  Warning ! This is quite not the standard CMake behavior

Example

    ##
    ## target examples
    ##

    project(SampleTarget)

    #add_subdirectory(fooscript)
    add_subdirectory(foolib)
    add_subdirectory(foobin)

    qi_create_bin(myprog SRC main.cpp)
    qi_create_lib(mylib SRC mylib.h mylib.c)

    qi_create_config_h(OUT_PATH source dest [<remaining args> ...]
    )

  Arguments: | OUT_PATH – Path to the generated file source – The source file dest – The destination args (remaining) – passed to the configure_file() called

  Create a configuration file

  Configures a header named ${dest} using the source file from ${source} using `configure_file` In addition:

  - Make sure the path where the header is generated is added to the include path
  - Create the necessary install rules

  If you need the header to be generated in a subdirectory (recommended), simply use something like:

      qi_create_config_h(_out config.h.in foo/config.h)

  Note that both arguments must be relative paths

Changelog CMake index Python index Index