Utilities implementated by the CMake modules. More...
Files | |
file | CheckPublicHeaders.cmake |
CMake script used to check whether public headers were added/removed. | |
file | ConfigureIncludeFiles.cmake |
CMake script used to configure and copy the public header files. | |
file | ExecuteProcess.cmake |
Execute process using CMake script mode. | |
file | TopologicalSort.cmake |
CMake implementation of topological sorting algorithm. | |
Functions | |
function | add_executable (in TARGET, in ARGN) |
Add executable target. | |
function | add_library (in TARGET, in ARGN) |
Add library target. | |
function | basis_add_custom_finalize () |
Finalize addition of custom targets. | |
function | basis_add_executable_target (in TARGET_NAME, in ARGN) |
Adds an executable target built from C++ source code. | |
function | basis_add_imported_target (in TARGET, in TYPE) |
Add imported target. | |
function | basis_add_library_target (in TARGET_NAME, in ARGN) |
Add build target for library built from C++ source code. | |
function | basis_add_mcc_target (in TARGET_NAME, in ARGN) |
Add MATLAB Compiler target. | |
function | basis_add_mcc_target_finalize (in TARGET_UID) |
Finalize addition of MATLAB Compiler target. | |
function | basis_add_mex_target (in TARGET_NAME, in ARGN) |
Add MEX target. | |
function | basis_add_mex_target_finalize (in TARGET_UID) |
Finalize addition of MEX target. | |
function | basis_add_script (in TARGET_NAME, in ARGN) |
Add script target. | |
function | basis_add_script_finalize (in TARGET_UID) |
Finalize addition of script. | |
function | basis_add_tests_of_default_options (in TARGET_NAME) |
Add tests of default options for given executable. | |
function | basis_add_uninstall () |
Add uninstall target. | |
macro | basis_buildtree_asserts (in ARGN) |
Ensure certain requirements on build tree. | |
function | basis_check_target_name (in TARGET_NAME) |
Checks whether a given name is a valid target name. | |
function | basis_check_test_name (in TEST_NAME) |
Checks whether a given name is a valid test name. | |
function | basis_configure_auxiliary_modules () |
Configure auxiliary modules for scripting languages. | |
function | basis_configure_auxiliary_sources (in SOURCES, in HEADERS, in PUBLIC_HEADERS) |
Configure auxiliary C++ source files. | |
function | basis_configure_ExecutableTargetInfo () |
Configure ExecutibleTargetInfo modules. | |
function | basis_configure_public_headers () |
Configure public header files. | |
macro | basis_configure_root_documentation_files () |
Configure root documentation files. | |
function | basis_configure_sources (in LIST_NAME, in ARGN) |
Configure .in source files. | |
function | basis_create_addpaths_mfile () |
This function writes a MATLAB M-file with addpath() statements. | |
function | basis_default_doxygen_filters (in FILTER_PATTERNS) |
Get default Doxygen filter patterns. | |
function | basis_disable_testing_if_no_tests () |
Disable testing if project does not implement any tests. | |
function | basis_dump_variables (in RESULT_FILE) |
Output current CMake variables to file. | |
function | basis_export_build_properties (in CODE) |
Add code to set properties of imported targets for build tree. | |
function | basis_export_footer (in CODE) |
Add footer of exports file. | |
function | basis_export_header (in CODE) |
Generate header of exports file. | |
function | basis_export_import_targets (in CODE) |
Add code to add import targets. | |
function | basis_export_install_properties (in CODE) |
Add code to set properties of imported targets for installation. | |
function | basis_export_prefix (in CODE) |
Add code to compute prefix relative to INSTALL_CONFIG_DIR . | |
function | basis_export_targets () |
Export all targets added by basis_add_* commands. | |
macro | basis_find_packages () |
Find packages this project depends on. | |
function | basis_get_build_timestamp (in TIMESTAMP) |
Get build time stamp. | |
function | basis_get_full_matlab_version (in VERSION) |
Determine version of MATLAB installation. | |
function | basis_get_fully_qualified_target_uid (in TARGET_UID, in TARGET_NAME) |
Get fully-qualified target name. | |
macro | basis_get_fully_qualified_test_uid (in TEST_UID, in TEST_NAME) |
Get "global" test name, i.e., actual CTest test name. | |
function | basis_get_matlab_release (in ARGN) |
Determine release version of MATLAB installation. | |
function | basis_get_matlab_version (in ARGN) |
Determine version of MATLAB installation. | |
function | basis_get_project_property (in VARIABLE, in ARGN) |
Get project-global property value. | |
function | basis_get_soname (in SONAME, in OBJFILE) |
Get soname of object file. | |
function | basis_get_source_language (in LANGUAGE, in ARGN) |
Detect programming language of given source code files. | |
function | basis_get_source_target_name (in TARGET_NAME, in SOURCE_FILE, in COMPONENT) |
Derive target name from source file name. | |
function | basis_get_target_location (in VAR, in TARGET_NAME, in PART) |
Get location of build target output file. | |
function | basis_get_target_name (in TARGET_NAME, in TARGET_UID) |
Get "local" target name, i.e., BASIS target name. | |
function | basis_get_target_namespace (in TARGET_NS, in TARGET_UID) |
Get namespace of build target. | |
function | basis_get_target_type (in TYPE, in TARGET_NAME) |
Get type name of target. | |
function | basis_get_target_uid (in TARGET_UID, in TARGET_NAME) |
Get "global" target name, i.e., actual CMake target name. | |
macro | basis_get_test_name (in TEST_NAME, in TEST_UID) |
Get "local" test name, i.e., BASIS test name. | |
macro | basis_get_test_namespace (in TEST_NS, in TEST_UID) |
Get namespace of test. | |
macro | basis_get_test_uid (in TEST_UID, in TEST_NAME) |
Get "global" test name, i.e., actual CTest test name. | |
macro | basis_initialize_settings () |
Initialize project settings. | |
function | basis_install_links () |
Adds installation rules to create default symbolic links. | |
macro | basis_installtree_asserts (in ARGN) |
Ensure certain requirements on install tree. | |
function | basis_list_to_delimited_string (in STR, in DELIM, in ARGN) |
Concatenates all list elements into a single delimited string. | |
macro | basis_list_to_regex (in REGEX, in ARGN) |
Convert list into regular expression. | |
function | basis_list_to_string (in STR, in ARGN) |
Concatenates all list elements into a single string. | |
macro | basis_make_target_uid (in TARGET_UID, in TARGET_NAME) |
Make target UID from given target name. | |
macro | basis_make_test_uid (in TEST_UID, in TEST_NAME) |
Make test UID from given test name. | |
function | basis_mexext (in ARGN) |
Determine extension of MEX-files for this architecture. | |
function | basis_normalize_name (in OUT, in STR) |
Convert string to lowercase only or mixed case. | |
function | basis_process_generator_expressions (in ARGS, in ARGN) |
Process generator expressions in arguments. | |
macro | basis_project_finalize () |
Finalize build configuration of project. | |
macro | basis_project_initialize () |
Initialize project, calls CMake's project() command. | |
macro | basis_project_modules () |
Initialize project modules. | |
macro | basis_sanitize_for_regex (in OUT, in STR) |
Sanitize string variable for use in regular expression. | |
macro | basis_set_if_empty (in VAR, in ARGN) |
Set value of variable only if variable is not set already. | |
macro | basis_set_if_not_set (in VAR, in ARGN) |
Set value of variable only if variable is not defined yet. | |
function | basis_set_or_update_cache (in VAR) |
Set variable. | |
function | basis_set_project_property () |
Set project-global property. | |
function | basis_string_to_list (in LST, in STR) |
Splits a string at space characters into a list. | |
function | basis_svn_get_last_changed_revision (in URL, in REV) |
Get revision number when directory or file was last changed. | |
function | basis_svn_get_revision (in URL, in REV) |
Get current revision of file or directory. | |
function | basis_svn_status (in URL, in STATUS) |
Get status of revision controlled file. | |
function | basis_update_cache (in VAR) |
Update cache variable. | |
function | basis_update_imported_location (in TARGET, in PROPERTY, in LOCATION) |
Update location of imported target. | |
function | basis_update_imported_type (in TARGET, in TYPE) |
Update type of imported target. | |
function | basis_use_auxiliary_sources (in SOURCES_LIST, in HEADERS_LIST) |
Add include directories of auxiliary sources to search path. | |
function | basis_version_numbers (in VERSION, in MAJOR, in MINOR, in PATCH) |
Extract version numbers from version string. | |
function | get_filename_component (in ARGN) |
Fixes CMake's get_filename_component() command. | |
macro | include_directories (in ARGN) |
Add directories to search path for include files. | |
macro | link_directories (in ARGN) |
Add directories to search path for libraries. | |
function | set_target_properties (in ARGN) |
Set target property. | |
Variables | |
BASIS_DOXYGEN_DOXYFILE | |
Default Doxygen configuration. | |
CONFIG_FILE | |
Name of the CMake package configuration file. | |
CONFIG_PREFIX | |
Package name. | |
CUSTOM_EXPORTS_FILE | |
Name of the CMake target exports file for custom targets. | |
EXPORTS_FILE | |
Name of the CMake target exports file. | |
USE_FILE | |
Name of the CMake package use file. | |
VERSION_FILE | |
Name of the CMake package version file. |
Utilities implementated by the CMake modules.
function add_executable | ( | in | TARGET, |
in | ARGN | ||
) |
Add executable target.
This BASIS function overwrites CMake's add_executable() command in order to store information of imported targets which is in particular used to generate the source code of the ExecutableTargetInfo modules which are part of the BASIS utilities.
[in] | TARGET | Name of the target. |
[in] | ARGN | Further arguments of CMake's add_executable(). |
function add_library | ( | in | TARGET, |
in | ARGN | ||
) |
Add library target.
This BASIS function overwrites CMake's add_library() command in order to store information of imported targets.
[in] | TARGET | Name of the target. |
[in] | ARGN | Further arguments of CMake's add_library(). |
function basis_add_custom_finalize | ( | ) |
Finalize addition of custom targets.
This function is called by basis_add_project_finalize() to finalize the addition of the custom build targets such as, for example, build targets to build script files, MATLAB Compiler targets, and MEX script generated MEX-files.
function basis_add_executable_target | ( | in | TARGET_NAME, |
in | ARGN | ||
) |
Adds an executable target built from C++ source code.
This function adds an executable target for the build of an executable from C++ source code files. Refer to the documentation of basis_add_executable() for a description of general options for adding an executable target.
By default, the BASIS C++ utilities library is added as link dependency of the executable target. If none of the BASIS C++ utilities are used by the executable, the option NO_BASIS_UTILITIES can be given. To enable this option by default, set the variable BASIS_NO_BASIS_UTILITIES
to TRUE before the basis_add_executable() commands, i.e., best in the Settings.cmake file located in the PROJECT_CONFIG_DIR
. Note, however, that the utilities library is a static library and thus the linker would simply not include any of the BASIS utilities object code in the final binary executable file if not used.
CXX
(i.e., C/C++).[in] | TARGET_NAME | Name of the target. If a source file is given as first argument, the build target name is derived from the name of this source file. |
[in] | ARGN | This argument list is parsed and the following arguments are extracted, all other arguments are considered to be source code files and simply passed on to CMake's add_executable() command. |
DESTINATION dir | Installation directory relative to INSTALL_PREFIX . If "none" (the case is ignored) is given as argument, no installation rules are added for this executable target. Default: INSTALL_RUNTIME_DIR or INSTALL_LIBEXEC_DIR (if LIBEXEC is given). |
COMPONENT name | Name of the component. Default: BASIS_RUNTIME_COMPONENT . |
LIBEXEC | Specifies that the built executable is an auxiliary executable which is only called by other executable. |
NO_BASIS_UTILITIES | Do not add the BASIS C++ utilities as link dependency. |
NO_EXPORT | Do not export the target. |
function basis_add_imported_target | ( | in | TARGET, |
in | TYPE | ||
) |
Add imported target.
Imported targets are only valid in the scope where they were imported. In order to be able to add the information of the imported executable targets to the ExecutableTargetInfo modules of the BASIS utilities which are configured during the finalization of the (top-level) project, the information of imported targets has to be stored in the global scope. Therefore, internal cache variables prefixed by the name of the project are used (see basis_set_project_property()):
IMPORTED_TARGETS | List of imported targets. |
IMPORTED_TYPES | Types of imported targets. |
IMPORTED_LOCATIONS | Locations of imported target files. |
IMPORTED_RANKS | Rank of current imported locations. This rank value is used to decide whether the current location takes precedence over another imported location. For example, IMPORTED_LOCATION_<a>, may be preferred over IMPORTED_LOCATION_<b>. |
[in] | TARGET | Name (UID) of the imported target. |
[in] | TYPE | Type of the imported target. |
function basis_add_library_target | ( | in | TARGET_NAME, |
in | ARGN | ||
) |
Add build target for library built from C++ source code.
This function adds a library target which builds a library from C++ source code files. Refer to the documentation of basis_add_library() for a description of the general options for adding a library target.
CXX
(i.e., C/C++) and the option MEX
is not given.[in] | TARGET_NAME | Name of the target. If a source file is given as first argument, the build target name is derived from the name of this source file. |
[in] | ARGN | This argument list is parsed and the following arguments are extracted. All other arguments are considered to be source code files and simply passed on to CMake's add_library() command. |
STATIC|SHARED|MODULE | Type of the library. |
DESTINATION dir | Installation directory for runtime and library component relative to INSTALL_PREFIX . See RUNTIME_DESTINATION and LIBRARY_DESTINATION . |
RUNTIME_DESTINATION dir | Installation directory of the runtime component relative to INSTALL_PREFIX . If "none" (case ignored) is given as argument, no installation rule for the runtime library is not added. Default: INSTALL_LIBRARY_DIR on Unix or INSTALL_RUNTIME_DIR on Windows. |
LIBRARY_DESTINATION dir | Installation directory of the library component relative to INSTALL_PREFIX . If "none" (case ignored) is given as argument, no installation rule for the library component is added. Default: INSTALL_ARCHIVE_DIR . |
COMPONENT name | Name of the component. Default: BASIS_LIBRARY_COMPONENT . |
RUNTIME_COMPONENT name | Name of runtime component. Default: COMPONENT if specified or BASIS_RUNTIME_COMPONENT , otherwise. |
LIBRARY_COMPONENT name | Name of library component. Default: COMPONENT if specified or BASIS_LIBRARY_COMPONENT , otherwise. |
NO_EXPORT | Do not export build target. |
function basis_add_mcc_target | ( | in | TARGET_NAME, |
in | ARGN | ||
) |
Add MATLAB Compiler target.
This function is used to add an executable or library target which is built using the MATLAB Compiler (MCC). It is invoked by basis_add_executable() or basis_add_library(), respectively, when at least one M-file is given as source file. Thus, it is recommended to use these functions instead.
An install command for the added executable or library target is added by this function as well. The executable will be installed as part of the RUNTIME_COMPONENT
in the directory INSTALL_RUNTIME_DIR
. The runtime library will be installed as part of the RUNTIME_COMPONENT
in the directory INSTALL_LIBRARY_DIR
on UNIX systems and INSTALL_RUNTIME_DIR
on Windows. Static/import libraries will be installed as part of the LIBRARY_COMPONENT
in the directory INSTALL_ARCHIVE_DIR
.
OUTPUT_NAME
of the custom target can be still modified.PROJECT_TESTING_DIR
, the built executable is output to the BINARY_TESTING_DIR
directory tree instead. Moreover, no installation rules are added. Test executables are further not exported, regardless of whether NO_EXPORT is given or not.[in] | TARGET_NAME | Name of the target. If a source file is given as first argument, the build target name is derived from the name of this source file. |
[in] | ARGN | Remaining arguments such as in particular the input source files. Moreover, the following arguments are parsed: |
TYPE type | Type of the target. Either EXECUTABLE (default) or LIBRARY . |
COMPONENT name | Name of the component. Default: BASIS_RUNTIME_COMPONENT if TYPE is EXECUTABLE or BASIS_LIBRARY_COMPONENT , otherwise. |
RUNTIME_COMPONENT name | Name of runtime component. Default: COMPONENT if specified or BASIS_RUNTIME_COMPONENT , otherwise. |
LIBRARY_COMPONENT name | Name of library component. Default: COMPONENT if specified or BASIS_LIBRARY_COMPONENT , otherwise. |
LIBEXEC | Specifies that the built executable is an auxiliary executable called by other executables only. |
NO_EXPORT | Do not export the target. |
TYPE
argument either an executable or a shared library using the MATLAB Compiler.function basis_add_mcc_target_finalize | ( | in | TARGET_UID | ) |
Finalize addition of MATLAB Compiler target.
This function uses the properties of the custom MATLAB Compiler target added by basis_add_mcc_target() to create the custom build command and adds this build command as dependency of this added target.
[in] | TARGET_UID | "Global" target name. If this function is used within the same project as basis_add_mcc_target(), the "local" target name may be given alternatively. |
TARGET_UID
.function basis_add_mex_target | ( | in | TARGET_NAME, |
in | ARGN | ||
) |
Add MEX target.
This function is used to add a shared library target which is built using the MATLAB MEX script (mex). It is invoked by basis_add_library(). Thus, it is recommended to use this function instead.
An install command for the added library target is added by this function as well. The MEX-file will be installed as part of the COMPONENT
in the directory INSTALL_LIBRARY_DIR on UNIX systems and INSTALL_RUNTIME_DIR on Windows.
[in] | TARGET_NAME | Name of the target. If a source file is given as first argument, the build target name is derived from the name of this source file. |
[in] | ARGN | Remaining arguments such as in particular the input source files. Moreover, the following arguments are parsed: |
COMPONENT name | Name of the component. Default: BASIS_LIBRARY_COMPONENT . |
MFILE file | MATLAB source file with function prototype and documentation of MEX-file. |
NO_EXPORT | Do not export the target. |
function basis_add_mex_target_finalize | ( | in | TARGET_UID | ) |
Finalize addition of MEX target.
This function uses the properties of the custom MEX-file target added by basis_add_mex_target() to create the custom build command and adds this build command as dependency of this added target.
[in] | TARGET_UID | "Global" target name. If this function is used within the same project as basis_add_mex_target(), the "local" target name may be given alternatively. |
function basis_add_script | ( | in | TARGET_NAME, |
in | ARGN | ||
) |
Add script target.
If the script name ends in ".in", the ".in" suffix is removed from the output name. Further, the extension of the script such as .sh or .py is removed from the output filename of executable scripts. On Unix, a shebang directive is added to executable scripts at the top of the script files instead if such directive is not given yet. In order to enable the convenient execution of Python and Perl scripts on Windows as well, some Batch code is added at the top and bottom of executable Python and Perl scripts which calls the Python or Perl interpreter with the script file and the given script arguments as command-line arguments. The file name extension of such modified scripts is by default set to .cmd
, the common extension for Windows NT Command Scripts. Scripts in other languages are not specifically modified. In case of script modules, the script file name extension is preserved in any case. When the WITH_EXT
option is given, executable scripts are not modified as described and their file name extension is preserved.
Example:
basis_add_script (MyShellScript.sh.in) basis_add_script (Script Script1.sh)
Certain CMake variables within the script are replaced during the configure step. See Prerequisits and Build Steps for details.
Note that this function only configures the script file if it ends in the ".in" suffix and adds a custom target which stores all information required to setup the actual custom build command as properties. The custom build command itself is added by basis_add_script_finalize(), which is supposed to be called once at the end of the root CMakeLists.txt file. This way properties such as the OUTPUT_NAME
can still be modified after adding the script target.
PROJECT_TESTING_DIR
, the built executable is output to the BINARY_TESTING_DIR
directory tree instead. Moreover, no installation rules are added. Test executables are further not exported, regardless of whether NO_EXPORT is given or not.[in] | TARGET_NAME | Name of the target. If the target is build from a single source file, the file path of this source file can be given as first argument. The build target name is then derived from the name of the source file. |
[in] | ARGN | This argument list is parsed and the following arguments are extracted: |
COMPONENT name | Name of the component. Default: BASIS_RUNTIME_COMPONENT for executable scripts or BASIS_LIBRARY_COMPONENT for modules. |
CONFIG config | Additional script configuration given directly as string argument. This string is included in the CMake build script before configuring the script file after the script configuration files have been included. |
CONFIG_FILE file | Additional script configuration file. This file is included after the default script configuration file of BASIS and after the default script configuration file which is located in PROJECT_BINARY_DIR , but before the script configuration code given by CONFIG . |
DESTINATION dir | The installation directory relative to INSTALL_PREFIX . Default: INSTALL_RUNTIME_DIR or INSTALL_LIBEXEC_DIR if the LIBEXEC option is given or INSTALL_LIBRARY_DIR if the MODULE option is given. |
LIBEXEC | Specifies that the built executable is an auxiliary executable which is only called by other executable. |
MODULE | Specifies that the script is a module file which is included by other scripts. Implies Note that this option can also be used for arbitrary text files which are used as input to a program, not only actual modules written in a scripting language. |
WITH_PATH | Preserve relative path of module. Required for example for Python and Perl packages where the directory hierarchy is important. |
WITH_EXT | Specify that the existing filename extension should be kept also in case of an executable script. No shebang directive is added to the top of the script automatically if this option is given. On Windows, on the other side, this prevents the addition of Batch code to execute the script and no .cmd file name extension is used for executable scripts build with this option. |
NO_EXPORT | Do not export build target. |
COMPILE | NOCOMPILE | Enable/disable compilation of script if supported by scripting language as well as BASIS. In particular, Python modules can be compiled. If a script could be compiled by BASIS, only the compiled file is installed. Default: BASIS_COMPILE_SCRIPTS |
TARGET_NAME
. In order to add the custom target that actually builds the script file, basis_add_script_finalize() has to be invoked.function basis_add_script_finalize | ( | in | TARGET_UID | ) |
Finalize addition of script.
This function uses the properties of the custom script target added by basis_add_script() to create the custom build command and adds this build command as dependency of this added target.
[in] | TARGET_UID | "Global" target name. If this function is used within the same project as basis_add_script(), the "local" target name may be given alternatively. |
TARGET_UID
added by basis_add_script().function basis_add_tests_of_default_options | ( | in | TARGET_NAME | ) |
Add tests of default options for given executable.
--helpshort | Short help. The output has to match the regular expression "[Uu]sage:\n\s*\<executable name\>", where <executable name> is the name of the tested executable. |
--help, -h | Help screen. Simply tests if the option is accepted. |
--version | Version information. Output has to include the project version string. |
--verbose, -v | Increase verbosity of output messages. Simply tests if the option is accepted. |
[in] | TARGET_NAME | Name of executable or script target. |
function basis_add_uninstall | ( | ) |
Add uninstall target.
uninstall
and code to cmake_install.cmake
to install an uninstaller. macro basis_buildtree_asserts | ( | in | ARGN | ) |
Ensure certain requirements on build tree.
Requirements:
[in] | ARGN | Not used. |
function basis_check_target_name | ( | in | TARGET_NAME | ) |
Checks whether a given name is a valid target name.
Displays fatal error message when target name is invalid.
[in] | TARGET_NAME | Desired target name. |
function basis_check_test_name | ( | in | TEST_NAME | ) |
Checks whether a given name is a valid test name.
Displays fatal error message when test name is invalid.
[in] | TEST_NAME | Desired test name. |
function basis_configure_auxiliary_sources | ( | in | SOURCES, |
in | HEADERS, | ||
in | PUBLIC_HEADERS | ||
) |
Configure auxiliary C++ source files.
This function configures the following default auxiliary source files which can be used by the projects which are making use of BASIS.
basis.h | Main include file which includes all the header files of the BASIS utilities including both, non-project specific utilities which are installed as part of BASIS, and project specific utilities configured by this function. |
config.h | This file is intended to be included by all source files. Hence, other projects will indirectly include this file when they use a library of this project. Therefore, it is important to avoid potential name conflicts. |
config.cxx | Definition of constants declared in config.h file. In particular, the paths of the installation directories relative to the executables are defined by this file. These constants are used by the auxiliary functions implemented in stdaux.h. |
stdaux.h | Declares auxiliary functions such as functions to get absolute path to the subdirectories of the installation. |
stdaux.cxx | Definition of auxiliary functions declared in stdaux.h. |
ExecutableTargetInfo.h | Declares ExecutableTargetInfo class which can be used at runtime to obtain information about an executable using the name of the corresponding BASIS/CMake build target. |
ExecutableTargetInfo.cxx | Definition of ExecutableTargetInfo class. The constructor of this singleton class is created during the configuration step of CMake by the function basis_configure_ExecutableTargetInfo(). |
[out] | SOURCES | Configured auxiliary source files. |
[out] | HEADERS | Configured auxiliary header files. |
[out] | PUBLIC_HEADERS | Auxiliary headers that should be installed. |
[out] parameters. function basis_configure_ExecutableTargetInfo | ( | ) |
Configure ExecutibleTargetInfo modules.
This function generates the initialization code of the ExecutableTargetInfo module for different supported programming languages. In case of C++, the source file has been configured and copied to the binary tree in a first configuration pass such that it could be used in basis_add_*() commands which check the existence of the arguments immediately. As the generation of the initialization code requires a complete list of build targets (cached in BASIS_TARGETS
), this function has to be called after all targets have been added and finalized (in case of custom targets).
function basis_configure_public_headers | ( | ) |
Configure public header files.
Configure public header files whose file name ends with the .in. Moreover, if BASIS_COPY_INCLUDES_TO_BINARY_DIR
is TRUE
, this function copies all other files to the build tree as well, using the same relative paths as will be used for the installation.
macro basis_configure_root_documentation_files | ( | ) |
Configure root documentation files.
The root documentation files are located in the top-level directory of the project's source tree. These are, in particular, the AUTHORS.txt
file with information on the authors of the software, COPYING.txt
file with copyright and licensing information, README.txt
file, INSTALL.txt
file with build and installation instructions, WELCOME.txt
file with text used as welcome text of the installer. where the top-level project requires all of these files except of the WELCOME.txt
file which defaults to the readme file. Modules of a project usually do not include any of these files. Otherwise, the content of the module's documentation file is appended to the corresponding file of the top-level project.
function basis_configure_sources | ( | in | LIST_NAME, |
in | ARGN | ||
) |
Configure .in source files.
This function configures each source file in the given argument list with a .in file name suffix and stores the configured file in the build tree with the same relative directory as the template source file itself. The first argument names the CMake variable of the list of configured source files where each list item is the absolute file path of the corresponding (configured) source file.
[out] | LIST_NAME | Name of output list. |
[in] | ARGN | These arguments are parsed and the following options recognized. All remaining arguments are considered to be source file paths. |
BINARY_DIRECTORY | Explicitly specify directory in build tree where configured source files should be written to. |
KEEP_DOT_IN_SUFFIX | By default, after a source file with the .in extension has been configured, the .in suffix is removed from the file name. This can be omitted by giving this option. |
function basis_create_addpaths_mfile | ( | ) |
This function writes a MATLAB M-file with addpath() statements.
This function writes an MATLAB M-file into the top directory of the build tree which contains an addpath() statement for each directory that was added via basis_include_directories().
function basis_default_doxygen_filters | ( | in | FILTER_PATTERNS | ) |
Get default Doxygen filter patterns.
[out] | FILTER_PATTERNS | List of default Doxygen filter patterns. |
function basis_disable_testing_if_no_tests | ( | ) |
Disable testing if project does not implement any tests.
This function checks if there are test/ subdirectories in the project and disables and hides the BUILD_TESTING option if none are found.
function basis_get_build_timestamp | ( | in | TIMESTAMP | ) |
Get build time stamp.
The build time stamp is used as an alternative to the version and revision information in PROJECT_VERSION_AND_REVISION
if version is invalid, i.e., set to 0.0.0 as is the case for development branches, and now revision from a revision control system is available.
function basis_get_full_matlab_version | ( | in | VERSION | ) |
Determine version of MATLAB installation.
[out] | VERSION | Value returned by the "version" command of MATLAB or an empty string if execution of MATLAB failed. |
VERSION
to the full MATLAB version. function basis_get_fully_qualified_target_uid | ( | in | TARGET_UID, |
in | TARGET_NAME | ||
) |
Get fully-qualified target name.
This function always returns a fully-qualified target UID, no matter if the option BASIS_USE_FULLY_QUALIFIED_UIDS
is OFF
. Note that if this option is ON
, the returned target UID is may not be the actual name of a CMake target.
[out] | TARGET_UID | Fully-qualified target UID. |
[in] | TARGET_NAME | Target name used as argument to BASIS CMake functions. |
macro basis_get_fully_qualified_test_uid | ( | in | TEST_UID, |
in | TEST_NAME | ||
) |
Get "global" test name, i.e., actual CTest test name.
This function always returns a fully-qualified test UID, no matter if the option BASIS_USE_FULLY_QUALIFIED_UIDS
is OFF
. Note that if this option is ON
, the returned test UID may not be the actual name of a CMake test.
[out] | TEST_UID | Fully-qualified test UID. |
[in] | TEST_NAME | Test name used as argument to BASIS CMake functions. |
function basis_get_matlab_release | ( | in | ARGN | ) |
Determine release version of MATLAB installation.
[out] | ARGN | The first argument ARGV0 is set to the release version of the MATLAB installation, i.e., "R2009b", for example, or an empty string if execution of MATLAB failed. If no output variable name is specified, the variable MATLAB_RELEASE is added to the cache if not present yet. Note that if no output variable is given and MATLAB_RELEASE is already set, nothing is done. |
function basis_get_matlab_version | ( | in | ARGN | ) |
Determine version of MATLAB installation.
[out] | ARGN | The first argument ARGV0 is set to the version of the MATLAB installation, i.e., "7.9.0", for example, or an empty string if execution of MATLAB failed. If no output variable name is specified, the variable MATLAB_VERSION is added to the cache if not present yet. Note that if no output variable is given and MATLAB_VERSION is already set, nothing is done. |
function basis_get_project_property | ( | in | VARIABLE, |
in | ARGN | ||
) |
Get project-global property value.
Example:
basis_get_project_property(TARGETS) basis_get_project_property(TARGETS ${PROJECT_NAME}) basis_get_project_property(TARGETS ${PROJECT_NAME} TARGETS) basis_get_project_property(TARGETS PROPERTY TARGETS)
[out] | VARIABLE | Name of result variable. |
[in] | ARGN | See the example uses. The optional second argument is either the name of the project similar to CMake's get_target_property() command or the keyword PROPERTY followed by the name of the property. |
function basis_get_soname | ( | in | SONAME, |
in | OBJFILE | ||
) |
Get soname of object file.
This function extracts the soname from object files in the ELF format on systems where the objdump command is available. On all other systems, an empty string is returned.
[out] | SONAME | The soname of the object file. |
[in] | OBJFILE | Object file in ELF format. |
function basis_get_source_language | ( | in | LANGUAGE, |
in | ARGN | ||
) |
Detect programming language of given source code files.
This function determines the programming language in which the given source code files are written. If no common programming language could be determined, "AMBIGUOUS" is returned. If none of the following programming languages could be determined, "UNKNOWN" is returned: CXX (i.e., C++), JAVA, JAVASCRIPT, PYTHON, PERL, BASH, BATCH, MATLAB.
[out] | LANGUAGE | Detected programming language. |
[in] | ARGN | List of source code files. |
function basis_get_source_target_name | ( | in | TARGET_NAME, |
in | SOURCE_FILE, | ||
in | COMPONENT | ||
) |
Derive target name from source file name.
[out] | TARGET_NAME | Target name. |
[in] | SOURCE_FILE | Source file. |
[in] | COMPONENT | Third argument to get_filename_component(). |
SOURCE_FILE
. function basis_get_target_location | ( | in | VAR, |
in | TARGET_NAME, | ||
in | PART | ||
) |
Get location of build target output file.
This convenience function can be used to get the full path of the output file generated by a given build target. It is similar to the read-only LOCATION
property of CMake targets and should be used instead of reading this porperty.
[out] | VAR | Path of build target output file. |
[in] | TARGET_NAME | Name of build target. |
[in] | PART | Which file name component of the LOCATION property to return. See get_filename_component(). If POST_INSTALL_RELATIVE is given as argument, VAR is set to the path of the installed file relative to the installation prefix. Similarly, POST_INSTALL sets VAR to the absolute path of the installed file post installation. |
LOCATION
property of CMake targets.function basis_get_target_name | ( | in | TARGET_NAME, |
in | TARGET_UID | ||
) |
Get "local" target name, i.e., BASIS target name.
[out] | TARGET_NAME | Target name used as argument to BASIS functions. |
[in] | TARGET_UID | "Global" target name, i.e., actual CMake target name. |
TARGET_NAME
to the name of the build target with UID TARGET_UID
.function basis_get_target_namespace | ( | in | TARGET_NS, |
in | TARGET_UID | ||
) |
Get namespace of build target.
[out] | TARGET_NS | Namespace part of target UID. |
[in] | TARGET_UID | Target UID/name. |
function basis_get_target_type | ( | in | TYPE, |
in | TARGET_NAME | ||
) |
Get type name of target.
[out] | TYPE | The target's type name or NOTFOUND. |
[in] | TARGET_NAME | The name of the target. |
function basis_get_target_uid | ( | in | TARGET_UID, |
in | TARGET_NAME | ||
) |
Get "global" target name, i.e., actual CMake target name.
In order to ensure that CMake target names are unique across modules of a BASIS project, the target name given to the BASIS CMake functions is converted by basis_make_target_uid() into a so-called target UID which is used as actual CMake target name. This function can be used to get for a given target name or UID the closest match of a known target UID.
In particular, if this project is a module of another BASIS project, the namespace given by PROJECT_NAMESPACE_CMAKE
is used as prefix, where the namespace prefix and the build target name are separated by a dot (.). Otherwise, if this project is the top-level project, no namespace prefix is used and if the project's namespace is given as prefix, it will be removed. When the target is exported, however, the namespace of this project will be prefixed again. This is done by the basis_export_targets() function.
Note that names of imported targets are not prefixed in any case.
The counterpart basis_get_target_name() can be used to convert the target UID back to the target name without namespace prefix.
[out] | TARGET_UID | "Global" target name, i.e., actual CMake target name. |
[in] | TARGET_NAME | Target name used as argument to BASIS CMake functions. |
TARGET_UID
to the UID of the build target TARGET_NAME
.macro basis_get_test_name | ( | in | TEST_NAME, |
in | TEST_UID | ||
) |
Get "local" test name, i.e., BASIS test name.
[out] | TEST_NAME | Test name used as argument to BASIS functions. |
[in] | TEST_UID | "Global" test name, i.e., actual CTest test name. |
TEST_NAME
to the name of the test with UID TEST_UID
.macro basis_get_test_namespace | ( | in | TEST_NS, |
in | TEST_UID | ||
) |
Get namespace of test.
[out] | TEST_NS | Namespace part of test UID. If TEST_UID is no UID, i.e., does not contain a namespace part, the namespace of this project is returned. |
[in] | TEST_UID | Test UID/name. |
macro basis_get_test_uid | ( | in | TEST_UID, |
in | TEST_NAME | ||
) |
Get "global" test name, i.e., actual CTest test name.
In order to ensure that CTest test names are unique across BASIS projects, the test name used by a developer of a BASIS project is converted by this function into another test name which is used as acutal CTest test name.
The function basis_get_test_name() can be used to convert the unique test name, the test UID, back to the original test name passed to this function.
[out] | TEST_UID | "Global" test name, i.e., actual CTest test name. |
[in] | TEST_NAME | Test name used as argument to BASIS CMake functions. |
TEST_UID
to the UID of the test TEST_NAME
.function basis_install_links | ( | ) |
Adds installation rules to create default symbolic links.
This function creates for each main executable a symbolic link directly in the directory INSTALL_PREFIX/bin
if INSTALL_SINFIX
is TRUE and the software is installed on a Unix-like system, i.e., one which supports the creation of symbolic links.
macro basis_installtree_asserts | ( | in | ARGN | ) |
Ensure certain requirements on install tree.
Requirements:
[in] | ARGN | Not used. |
function basis_list_to_delimited_string | ( | in | STR, |
in | DELIM, | ||
in | ARGN | ||
) |
Concatenates all list elements into a single delimited string.
[out] | STR | Output string. |
[in] | DELIM | Delimiter used to separate list elements. Each element which contains the delimiter as substring is surrounded by double quotes (") in the output string. |
[in] | ARGN | Input list. |
STR
to the resulting string. macro basis_list_to_regex | ( | in | REGEX, |
in | ARGN | ||
) |
Convert list into regular expression.
This function is in particular used to convert a list of property names such as <CONFIG>_OUTPUT_NAME, e.g., the list BASIS_PROPERTIES_ON_TARGETS
, into a regular expression which can be used in pattern matches.
[out] | REGEX | Name of variable for resulting regular expression. |
[in] | ARGN | List of patterns which may contain placeholders in the form of "<this is a placeholder>". These are replaced by the regular expression "[^ ]+". |
function basis_list_to_string | ( | in | STR, |
in | ARGN | ||
) |
Concatenates all list elements into a single string.
The list elements are concatenated without any delimiter in between. Use basis_list_to_delimited_string() to specify a delimiter such as a whitespace character or comma (,) as delimiter.
[out] | STR | Output string. |
[in] | ARGN | Input list. |
STR
to the resulting string.macro basis_make_target_uid | ( | in | TARGET_UID, |
in | TARGET_NAME | ||
) |
Make target UID from given target name.
This function is intended for use by the basis_add_*() functions only.
[out] | TARGET_UID | "Global" target name, i.e., actual CMake target name. |
[in] | TARGET_NAME | Target name used as argument to BASIS CMake functions. |
TARGET_UID
to the UID of the build target TARGET_NAME
.macro basis_make_test_uid | ( | in | TEST_UID, |
in | TEST_NAME | ||
) |
Make test UID from given test name.
This function is intended for use by the basis_add_test() only.
[out] | TEST_UID | "Global" test name, i.e., actual CTest test name. |
[in] | TEST_NAME | Test name used as argument to BASIS CMake functions. |
TEST_UID
to the UID of the test TEST_NAME
.function basis_mexext | ( | in | ARGN | ) |
Determine extension of MEX-files for this architecture.
[out] | ARGN | The first argument ARGV0 is set to the extension of MEX-files (excluding '.'). If the CMake variable MEX_EXT is set, its value is returned. Otherwise, this function tries to determine it from the system information. If the extension could not be determined, an empty string is returned. If no argument is given, the extension is cached as the variable MEX_EXT. |
function basis_normalize_name | ( | in | OUT, |
in | STR | ||
) |
Convert string to lowercase only or mixed case.
Strings in all uppercase or all lowercase are converted to all lowercase letters because these are usually used for acronymns. All other strings are returned unmodified with the one exception that the first letter has to be uppercase for mixed case strings.
This function is in particular used to normalize the project name for use in installation directory paths and namespaces.
[out] | OUT | String in CamelCase. |
[in] | STR | String. |
function basis_process_generator_expressions | ( | in | ARGS, |
in | ARGN | ||
) |
Process generator expressions in arguments.
This command evaluates the $<TARGET_FILE:tgt> and related generator expressions also for custom targets such as scripts and MATLAB Compiler targets. For other generator expressions whose argument is a target name, this function replaces the target name by the target UID, i.e., the actual CMake target name such that the expression can be evaluated by CMake. The following generator expressions are directly evaluated by this function:
$<TARGET_FILE:tgt> | Absolute file path of built target. |
$<TARGET_FILE_POST_INSTALL:tgt> | Absolute path of target file after installation using the current INSTALL_PREFIX . |
$<TARGET_FILE_POST_INSTALL_RELATIVE:tgt> | Path of target file after installation relative to INSTALL_PREFIX . |
Additionally, the suffix _NAME
or _DIR
can be appended to the name of each of these generator expressions to get only the basename of the target file including the extension or the corresponding directory path, respectively.
Generator expressions are in particular supported by basis_add_test().
[out] | ARGS | Name of output list variable. |
[in] | ARGN | List of arguments to process. |
macro basis_project_finalize | ( | ) |
Finalize build configuration of project.
This macro has to be called at the end of the root CMakeLists.txt file of each BASIS project initialized by basis_project().
The project configuration files are generated by including the CMake script PROJECT_CONFIG_DIR/GenerateConfig.cmake when this file exists or using the default script of BASIS.
macro basis_project_initialize | ( | ) |
Initialize project, calls CMake's project() command.
PROJECT_NAME_LOWER | Project name in all lowercase letters. |
PROJECT_NAME_UPPER | Project name in all uppercase letters. |
PROJECT_NAME_INFIX | Project name used as infix for installation directories and namespace identifiers. In particular, the project name in either all lowercase or mixed case starting with an uppercase letter depending on whether the PROJECT_NAME has mixed case or not. |
PROJECT_REVISION | Revision number of Subversion controlled source tree or 0 if the source tree is not under revision control. |
PROJECT_VERSION_AND_REVISION | A string of project version and revision that can be used for the output of version information. The format of this string is either one of the following:
|
macro basis_project_modules | ( | ) |
Initialize project modules.
Most parts of this macro were copied from the ITK4 project (http://www.vtk.org/Wiki/ITK_Release_4), in particular, the top-level CMakeLists.txt file. This file does not state any specific license, but the ITK package itself is released under the Apache License Version 2.0, January 2004 (http://www.apache.org/licenses/).
CMAKE_CURRENT_SOURCE_DIR
instead of PROJECT_SOURCE_DIR
. macro basis_sanitize_for_regex | ( | in | OUT, |
in | STR | ||
) |
Sanitize string variable for use in regular expression.
[out] | OUT | String that can be used in regular expression. |
[in] | STR | String to sanitize. |
macro basis_set_if_empty | ( | in | VAR, |
in | ARGN | ||
) |
Set value of variable only if variable is not set already.
[out] | VAR | Name of variable. |
[in] | ARGN | Arguments to set() command excluding variable name. |
VAR
if its value was not valid before. macro basis_set_if_not_set | ( | in | VAR, |
in | ARGN | ||
) |
Set value of variable only if variable is not defined yet.
[out] | VAR | Name of variable. |
[in] | ARGN | Arguments to set() command excluding variable name. |
VAR
if it was not defined before. function basis_set_or_update_cache | ( | in | VAR | ) |
Set variable.
If the variable is cached, this function will update the cache value, otherwise, it simply sets the CMake variable uncached to the given value(s).
function basis_set_project_property | ( | ) |
Set project-global property.
Set property associated with current project/module. The property is in fact just a cached variable whose name is prefixed by the project's name.
function basis_string_to_list | ( | in | LST, |
in | STR | ||
) |
Splits a string at space characters into a list.
[out] | LST | Output list. |
[in] | STR | Input string. |
LST
to the resulting CMake list. function basis_svn_get_last_changed_revision | ( | in | URL, |
in | REV | ||
) |
Get revision number when directory or file was last changed.
[in] | URL | Absolute path of directory or file. May also be a URL to the directory or file in the repository. A leading "file://" is automatically removed such that the svn command treats it as a local path. |
[out] | REV | Revision number when URL was last modified. If URL is not under Subversion control or Subversion_SVN_EXECUTABLE is invalid, "0" is returned. |
REV
to revision number at which the working copy/repository specified by the URL URL
was last modified. function basis_svn_get_revision | ( | in | URL, |
in | REV | ||
) |
Get current revision of file or directory.
[in] | URL | Absolute path of directory or file. May also be a URL to the directory or file in the repository. A leading "file://" is automatically removed such that the svn command treats it as a local path. |
[out] | REV | The revision number of URL. If URL is not under revision control or Subversion_SVN_EXECUTABLE is invalid, "0" is returned. |
REV
to the revision of the working copy/repository at URL URL
. function basis_svn_status | ( | in | URL, |
in | STATUS | ||
) |
Get status of revision controlled file.
[in] | URL | Absolute path of directory or file. May also be a URL to the directory or file in the repository. A leading "file://" will be removed such that the svn command treats it as a local path. |
[out] | STATUS | The status of URL as returned by 'svn status'. If the local directory or file is unmodified, an empty string is returned. An empty string is also returned when Subversion_SVN_EXECUTABLE is invalid. |
STATUS
to the output of the svn info
command. function basis_update_imported_location | ( | in | TARGET, |
in | PROPERTY, | ||
in | LOCATION | ||
) |
Update location of imported target.
[in] | TARGET | Name (UID) of the imported target. |
[in] | PROPERTY | Target location property. Either IMPORTED_LOCATION or IMPORTED_LOCATION_<config>, where <config> is one of the imported build configurations. This argument is used to decide whether to keep the current target information or to replace it by the new one. |
[in] | LOCATION | Location of imported target. |
function basis_update_imported_type | ( | in | TARGET, |
in | TYPE | ||
) |
Update type of imported target.
This function is in particular called in basis_set_target_properties() if the BASIS_TYPE property of custom BASIS targets is set after the imported target was added with the initial type UNKNOWN.
[in] | TARGET | Name (UID) of the imported target. |
[in] | TYPE | Type of imported target. |
function basis_use_auxiliary_sources | ( | in | SOURCES_LIST, |
in | HEADERS_LIST | ||
) |
Add include directories of auxiliary sources to search path.
[in] | SOURCES_LIST | Name of list of source files. |
[in] | HEADERS_LIST | Name of list of header files. |
function basis_version_numbers | ( | in | VERSION, |
in | MAJOR, | ||
in | MINOR, | ||
in | PATCH | ||
) |
Extract version numbers from version string.
[in] | VERSION | Version string in the format "MAJOR[.MINOR[.PATCH]]". |
[out] | MAJOR | Major version number if given or 0. |
[out] | MINOR | Minor version number if given or 0. |
[out] | PATCH | Patch number if given or 0. |
[out] parameters. function get_filename_component | ( | in | ARGN | ) |
Fixes CMake's get_filename_component() command.
The get_filename_component() command of CMake returns the entire portion after the first period (.) [including the period] as extension. However, only the component following the last period (.) [including the period] should be considered to be the extension.
[in,out] | ARGN | Arguments as accepted by get_filename_component(). |
macro include_directories | ( | in | ARGN | ) |
Add directories to search path for include files.
Overwrites CMake's include_directories() command. This is required because the basis_include_directories() function is not used by other projects in their package use files. Therefore, this macro is an alias for basis_include_directories().
[in] | ARGN | List of arguments for basis_include_directories(). |
macro link_directories | ( | in | ARGN | ) |
Add directories to search path for libraries.
Overwrites CMake's link_directories() command. This is required because the basis_link_directories() function is not used by other projects in their package use files. Therefore, this macro is an alias for basis_link_directories().
[in] | ARGN | List of arguments for basis_link_directories(). |
function set_target_properties | ( | in | ARGN | ) |
Set target property.
This function is overwritten by BASIS in order to update the information about imported build targets.
PROPERTIES
keyword, only properties listed in BASIS_PROPERTIES_ON_TARGETS
can be set.[in] | ARGN | List of arguments for set_target_properties(). |