Module implementing helper macros for declaring options in the ComputeAorta project under different conditions. This provides a consistent interface across the various layers of the project from Core implementations to API unit tests.
To bring the option macros exposed by this module into CMakeLists.txt
it
must be included like so:
include(CAOption)
The following CMake macros are defined by the module:
- ca_option
A CMake macro which handles all the different option variants we use in the ComputeAorta project. It will output a CMake message when the option is set to a value other than the default provided value.
There are a few cases the deprecated option logic has to handle:
If no deprecated option is provided, do the normal case (declare an option).
If a deprecated option is provided:
We check if the CMake command line argument contained a
-D
for both the original option and the deprecated one, and error if so.We check if just the deprecated option is set, and give a deprecation warning to use the replacement option.
Clear any cached version of option (we need to be able to differentiate between CMake command line
-D
and cached versions, and since there is no way to do this we do not record the actual option in the cache, and instead use${CA_OPTION_<OPTION>}
).Set the variable for option to be the value we stored in the cache.
Clear any previously cached value for the deprecated option. The last known value for the option was read from the cache and stored into our new cached variable anyway.
Implemented by wrapping CMake option for
BOOL
types, and for other types using set to write a defaultCACHE
value, outputting a message rather than overwriting if the value is non-default.- Arguments:
name
- The name of the option to declare.type
- The type of option (one ofFILEPATH
,PATH
,STRING
,BOOL
,INTERNAL
).description
- The string description of what the option is.default
- The default value of the option.
- ca_option_required
A CMake macro which declares an option that is required to be set for the ComputeAorta project. If the value of name is equal to the default, this macro will error out as we are requiring the option to be set to a value other than the default.
- Arguments:
name
- The name of the option to declare.type
- The type of option (one ofFILEPATH
,PATH
,STRING
,BOOL
,INTERNAL
).description
- The string description of what the option is.default
- The default value of the option.
- ca_option_windows
A CMake macro which declares an option that is only available for Windows.
- Arguments:
name
- The name of the option to declare.type
- The type of option (one ofFILEPATH
,PATH
,STRING
,BOOL
,INTERNAL
).description
- The string description of what the option is.default
- The default value of the option.
- ca_option_linux
A CMake macro which declares an option that is only available for Linux.
- Arguments:
name
- The name of the option to declare.type
- The type of option (one ofFILEPATH
,PATH
,STRING
,BOOL
,INTERNAL
).description
- The string description of what the option is.default
- The default value of the option.
- ca_immutable_option
A CMake macro which declares an option that cannot be changed once set. When an option controls the default values (and sometimes existence) of other options, then it is impossible for CMake to track the correct values of the dependent options across re-configurations. Preventing the root option from being changed prevents the build directory from going into an invalid state.
- Arguments:
target
Library or executable target to link OpenCL into.name
- The name of the option to declare.type
- The type of option (onlyBOOL
is currently supported).description
- The string description of what the option is.default
- The default value of the option.
Option Naming Conventions
Current oneAPI Construction Kit CMake Options exposed by the project
are prefixed with ‘CA_
’ to differentiate them from CMake or third-party
provided options. This convention should be followed when adding any new
options to the project. For boolean type options in particular we also try to
adhere to the form ‘CA_[COMPONENT_]ENABLE_<FEATURE>
’, conforming to this
format is preferred.