CppMicroServices

C++ Micro Services: CMake Functions
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CMake Functions

This category includes CMake utility functions for external projects. More...

Functions

 usFunctionEmbedResources (src_var)
 Embed resources into a shared library or executable. More...
 
 usFunctionGenerateModuleInit (src_var)
 Generate a source file which handles proper initialization of a module. More...
 
 usFunctionGenerateExecutableInit (src_var)
 Generate a source file which handles proper initialization of an executable. More...
 

Detailed Description

This category includes CMake utility functions for external projects.

External projects can include the CMake scripts provided by the CppMicroServices library to automatically generate module initialization code and to embed external resources into a modules shared library.

Function Documentation

usFunctionEmbedResources ( src_var  )

Embed resources into a shared library or executable.

This CMake function uses an external command line program to generate a source file containing data from external resources such as text files or images. The path to the generated source file is appended to the src_var variable.

Each module can call this function (at most once) to embed resources and make them available at runtime through the Module class. Resources can also be embedded into executables, using the EXECUTABLE_NAME argument instead of LIBRARY_NAME.

Example usage:

* set(module_srcs )
* LIBRARY_NAME "mylib"
* ROOT_DIR resources
* FILES config.properties logo.png
* )
*
Parameters
LIBRARY_NAME(required if EXECUTABLE_NAME is empty) The library name of the module which will include the generated source file, without extension.
EXECUTABLE_NAME(required if LIBRARY_NAME is empty) The name of the executable which will include the generated source file.
COMPRESSION_LEVEL(optional) The zip compression level. Defaults to the default zip level. Level 0 disables compression.
COMPRESSION_THRESHOLD(optional) The compression threshold ranging from 0 to 100 for actually compressing the resource data. The default threshold is 30, meaning a size reduction of 30 percent or better results in the resource data being compressed.
ROOT_DIR(optional) The root path for all resources listed after the FILES argument. If no or a relative path is given, it is considered relativ to the current CMake source directory.
FILES(optional) A list of resources (paths to external files in the file system) relative to the ROOT_DIR argument or the current CMake source directory if ROOT_DIR is empty.

The ROOT_DIR and FILES arguments may be repeated any number of times to merge files from different root directories into the embedded resource tree (hence the relative file paths after the FILES argument must be unique).

usFunctionGenerateExecutableInit ( src_var  )

Generate a source file which handles proper initialization of an executable.

This CMake function will store the path to a generated source file in the src_var variable, which should be compiled into an executable. Example usage:

* set(executable_srcs )
* IDENTIFIER "MyExecutable"
* )
* add_executable(MyExecutable ${executable_srcs})
*
Parameters
src_var(required) The name of a list variable to which the path of the generated source file will be appended.
IDENTIFIER(required) A valid C identifier for the executable.
See Also
usFunctionGenerateModuleInit
Auto Loading Modules
usFunctionGenerateModuleInit ( src_var  )

Generate a source file which handles proper initialization of a module.

This CMake function will store the path to a generated source file in the src_var variable, which should be compiled into a module. Example usage:

* set(module_srcs )
* NAME "My Module"
* LIBRARY_NAME "mylib"
* )
* add_library(mylib ${module_srcs})
*
Parameters
src_var(required) The name of a list variable to which the path of the generated source file will be appended.
NAME(required) A human-readable name for the module.
LIBRARY_NAME(optional) The name of the module, without extension. If empty, the NAME argument will be used.
See Also
usFunctionGenerateExecutableInit
Auto Loading Modules