CetCMakeUtils¶
General functions and macros.
-
cet_passthrough
¶ - Synopsis:
cet_passthrough([FLAG|ARMOR] [KEYWORD <keyword>] [EMPTY_KEYWORD <empty-keyword>] <in_var> IN_PLACE|<out-var>) cet_passthrough([FLAG|ARMOR] VALUES [<val>...] KEYWORD <keyword> <out-var> [EMPTY_KEYWORD <empty-keyword>] <out-var>)
Turn a flag or option value into something that can be passed on to another function or macro.
- Options:
ARMOR
Apply an extra `layer of armor' ("\" -> "\\") to enable the result to be passed to another function without quoting in order to preserve empty-list semantics. See
cet_armor_string()
for details.EMPTY_KEYWORD <empty-keyword>
If
<in-var>
orVALUES
evaluates to the empty string, the result is<empty-keyword>
FLAG
If
<in-var>
orVALUES
evaluates toTRUE
, the result is<keyword>
(or seeKEYWORD
, below). Otherwise the result will be the empty string (or seeEMPTY_KEWORD
, above).IN_PLACE
If
<in-var>
is specified this option signifies that the result will be placed in<in-var>
. In this case<out-var>
must then not be present.KEYWORD <keyword>
If specified, the option keyword will be
<keyword>
. Otherwise, if<in-var>
is specified, then it will be the name "<in-var>
" with any leading<prefix>_
stripped off the front. Failing that, the name "<out-var>
" will be used as the default.VALUES <val>...
The values to be passed through to another function or macro may be specified as
<val>...
rather than as<in-var>
. In this case, :option:<out-var>` is required andIN_PLACE
is not permitted.- Non-option arguments:
<in-var>
The name of a variable holding the values to be passed through.
<in-var>
must not be present ifVALUES
is specified.<out-var>
The name of a variable to hold the values in passthrough form. If
IN_PLACE
and<in-var>
are both specified, than<out-var>
must not be present.- Examples
set(MYOPTS_VERBOSE TRUE) cet_passthrough(FLAG IN_PLACE MYOPTS_VERBOSE)
MYOPTS_VERBOSE
will have the value "VERBOSE" in the calling function or macro.cet_passthrough(FLAG VALUES "NOTFOUND" USE_MYPACKAGE)
USE_MYPACKAGE
will be empty in the calling function or macro.cet_passthrough(FLAG VALUES "MYTEXT" USE_MYPACKAGE)
USE_MYPACKAGE
will have the valueUSE_MYPACKAGE
in the calling function or macro.cet_passthrough(IN_PLACE VALUES "Mary had a little lamb; Its fleece was white as snow" KEYWORD RHYME MARY_LAMB)
The list
MARY_LAMB
will consist of the three elements:"RHYME" "Mary had a little lamb" "Its fleece was white as snow"
in the calling function or macro. Note the lack of whitespace at the beginning of the third element of the list.
cet_passthrough(VALUES "Mary had a little lamb\\\\; Its fleece was white as snow" KEYWORD RHYME MARY_LAMB)
The list
MARY_LAMB
will consist of the two elements:"RHYME" "Mary had a little lamb; Its fleece was white as snow"
in the calling function or macro.
-
cet_source_file_extensions
¶ Produce an ordered list of source file extensions for enabled languages.
- Synopsis:
cet_source_file_extensions(<out-var>)
Non-option arguments:
Note
Prescribed order of enabled languages:
CUDA
CXX
C
Fortran
<lang>...
ASM
-
cet_exclude_files_from
¶ Remove duplicates and other files from a list, specifically or by regular expression.
- Synopsis:
cet_exclude_files_from(<sources-var> [REGEX <regex>...] [NOP] <file>...)
Options:
NOP
Optional separator between a list option and non-option arguments; no other effect.
REGEX
Entries in
<sources-var>
matching<regex>...
will be removed.Non-option arguments:
<sources-var>
The name of a variable containing a list of files to be pruned.
<file>...
Files to be removed from
<sources-var>
(exact matches only).Note
Relative paths are interpreted relative to
${CMAKE_CURRENT_SOURCE_DIR}
.
-
cet_timestamp
¶ Generate a current timestamp.
- Synopsis:
cet_timestamp(<out-var> [<fmt>])
Non-option arguments:
<out-var>
Variable in which to store the formatted timestamp.
<fmt>
The desired format of the timestamp, using
%
placeholders according to string(TIMESTAMP) or the system date(1) command.- Examples:
cet_timestamp(RESULT) message(STATUS "${RESULT}")
-- Sun Jan 01 23:59:59 CST 1970
cet_timestamp(RESULT "%Y-%m-%d %H:%M:%S %z") message(STATUS "${RESULT}")
-- 1970-01-01 23:59:59 -0600
Changed in version 2.07.00: prior to version 2.07.00,
%Y
was missing from the default format.
-
cet_find_simple_package
¶ find_package()
for packages without generated CMake config files or aFind<name>.cmake
module.Deprecated since version 2.0: if no
FindXXX.cmake
module or CMake config file is available for<name>
, write your own find module or request one from the SciSoft team.See also
- Synopsis:
find_simple_package([HEADERS <header>...] [INCPATH_SUFFIXES <dir>...] [INCPATH_VAR <var>] [LIB_VAR <var>] [LIBNAMES <libname>...] [LIBPATH_SUFFIXES <dir>...] <name>)
Options:
HEADERS <header>...
Look for
<header>...
to ascertain the include path. If not specified, use<name>.{h,hh,H,hxx,hpp}
INCPATH_SUFFIXES <dir>...
Add
<suffix>...
to paths when searching for headers (defaults to "include").INCPATH_VAR <var>
Store the found include path in
<var>
. If not specified, we invokeinclude_directories()
with the found include path.LIB_VAR <var>
Store the found library as
<var>
. If not specified, use<name>
as converted to an upper case identifier.LIBNAMES <libname>...
Look for
<libname>...
as a library in addition toname
.LIBPATH_SUFFIXES <dir>...
Add
<dir>...
to paths when searching for libraries.Non-option arguments:
<name>
The primary name of the library (without prefix or suffix) or headers to be found.
Variables controlling behavior:
WANT_INCLUDE_DIRECTORIES
-
cet_localize_pv
¶ Ensure that specified path-type
project variables
are absolute in the current directory scope for in-tree project<project>
.- Synopsis:
cet_localize_pv(<project> [<project-var-name>]) cet_localize_pv(<project> ALL)
- Non-option arguments:
<project>
The name of a CMake project in the current source tree.
<project-var-name>
The name of a project variable (without a
<project>_
prefix).
-
cet_localize_pv_all
¶ - Synopsis:
cet_localize_pv_all(<project>)
Equivalent to
cet_localize_pv(<project> ALL)
.
-
cet_cmake_module_directories
¶ - Synopsis:
cet_cmake_module_directories([NO_CONFIG] [NO_LOCAL] [PROJECT <project>] <dir>...)
- Options:
NO_CONFIG
Do not add these directories to
CMAKE_MODULE_PATH
in the CMake config file for<project>
.NO_LOCAL
Do not add these directories to
CMAKE_MODULE_PATH
in the current scope. Implied if<project>
is not equal toCETMODULES_CURRENT_PROJECT_NAME
PROJECT <project>
Specify the project to which these module directories belong. If not specifed,
<project>
defaults toCETMODULES_CURRENT_PROJECT_NAME
.- Non-option arguments:
<dir>...
Directories containing CMake modules.