diff options
Diffstat (limited to 'Modules/CheckLanguage.cmake')
-rw-r--r-- | Modules/CheckLanguage.cmake | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake index 87a401813..1ea91d2d0 100644 --- a/Modules/CheckLanguage.cmake +++ b/Modules/CheckLanguage.cmake @@ -1,32 +1,35 @@ -# - Check if a language can be enabled +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# CheckLanguage +# ------------- +# +# Check if a language can be enabled +# # Usage: -# check_language(<lang>) +# +# :: +# +# check_language(<lang>) +# # where <lang> is a language that may be passed to enable_language() # such as "Fortran". If CMAKE_<lang>_COMPILER is already defined the # check does nothing. Otherwise it tries enabling the language in a # test project. The result is cached in CMAKE_<lang>_COMPILER as the -# compiler that was found, or NOTFOUND if the language cannot be enabled. +# compiler that was found, or NOTFOUND if the language cannot be +# enabled. # # Example: -# check_language(Fortran) -# if(CMAKE_Fortran_COMPILER) -# enable_language(Fortran) -# else() -# message(STATUS "No Fortran support") -# endif() - -#============================================================================= -# Copyright 2009-2012 Kitware, Inc. # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. +# :: # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) +# check_language(Fortran) +# if(CMAKE_Fortran_COMPILER) +# enable_language(Fortran) +# else() +# message(STATUS "No Fortran support") +# endif() macro(check_language lang) if(NOT DEFINED CMAKE_${lang}_COMPILER) @@ -34,7 +37,7 @@ macro(check_language lang) message(STATUS ${_desc}) file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/CMakeLists.txt" - "cmake_minimum_required(VERSION 2.8) + "cmake_minimum_required(VERSION ${CMAKE_VERSION}) project(Check${lang} ${lang}) file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" \"set(CMAKE_${lang}_COMPILER \\\"\${CMAKE_${lang}_COMPILER}\\\")\\n\" @@ -43,6 +46,8 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" execute_process( WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang} COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR} + -A "${CMAKE_GENERATOR_PLATFORM}" + -T "${CMAKE_GENERATOR_TOOLSET}" OUTPUT_VARIABLE output ERROR_VARIABLE output RESULT_VARIABLE result |