diff options
Diffstat (limited to 'Modules/CheckCXXSourceCompiles.cmake')
-rw-r--r-- | Modules/CheckCXXSourceCompiles.cmake | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake index 734c0839b..e54d09e61 100644 --- a/Modules/CheckCXXSourceCompiles.cmake +++ b/Modules/CheckCXXSourceCompiles.cmake @@ -1,33 +1,34 @@ -# - Check if given C++ source compiles and links into an executable +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# CheckCXXSourceCompiles +# ---------------------- +# +# Check if given C++ source compiles and links into an executable +# # CHECK_CXX_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>]) -# <code> - source code to try to compile, must define 'main' -# <var> - variable to store whether the source code compiled -# <fail-regex> - fail if test output matches this regex -# The following variables may be set before calling this macro to -# modify the way the check is run: # -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -#============================================================================= -# Copyright 2005-2009 Kitware, Inc. +# :: # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. +# <code> - source code to try to compile, must define 'main' +# <var> - variable to store whether the source code compiled +# Will be created as an internal cache variable. +# <fail-regex> - fail if test output matches this regex # -# 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.) - - +# The following variables may be set before calling this macro to modify +# the way the check is run: +# +# :: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link +# CMAKE_REQUIRED_QUIET = execute quietly without messages macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) - if("${VAR}" MATCHES "^${VAR}$") + if(NOT DEFINED "${VAR}") set(_FAIL_REGEX) set(_key) foreach(arg ${ARGN}) @@ -57,7 +58,9 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx" "${SOURCE}\n") - message(STATUS "Performing Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() try_compile(${VAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx @@ -75,13 +78,17 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) if(${VAR}) set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - message(STATUS "Performing Test ${VAR} - Success") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Performing C++ SOURCE FILE Test ${VAR} succeded with the following output:\n" + "Performing C++ SOURCE FILE Test ${VAR} succeeded with the following output:\n" "${OUTPUT}\n" "Source file was:\n${SOURCE}\n") else() - message(STATUS "Performing Test ${VAR} - Failed") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() set(${VAR} "" CACHE INTERNAL "Test ${VAR}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n" |