CheckLanguage¶
Check whether a language can be enabled by the enable_language()
or project() commands:
- check_language¶
check_language(<lang>)
Try enabling language
<lang>in a test project and record results in the cache:CMAKE_<LANG>_COMPILERIf the language can be enabled, this variable is set to the compiler that was found. If the language cannot be enabled, this variable is set to
NOTFOUND.If this variable is already set, either explicitly or cached by a previous call, the check is skipped.
CMAKE_<LANG>_HOST_COMPILERThis variable is set when
<lang>isCUDAorHIP.If the check detects an explicit host compiler that is required for compilation, this variable will be set to that compiler. If the check detects that no explicit host compiler is needed, this variable will be cleared.
If this variable is already set, its value is preserved only if
CMAKE_<LANG>_COMPILERis also set. Otherwise, the check runs and overwritesCMAKE_<LANG>_HOST_COMPILERwith a new result. Note thatCMAKE_<LANG>_HOST_COMPILERdocuments it should not be set without also settingCMAKE_<LANG>_COMPILERto a NVCC compiler.CMAKE_<LANG>_PLATFORMThis variable is set to the detected GPU platform when
<lang>isHIP.If the variable is already set its value is always preserved. Only compatible values will be considered for
CMAKE_<LANG>_COMPILER.
For example:
check_language(Fortran)
if(CMAKE_Fortran_COMPILER)
enable_language(Fortran)
else()
message(STATUS "No Fortran support")
endif()