2005-12-14 21:51:08 +03:00
|
|
|
# - Test CXX compiler for a flag
|
2002-11-21 20:52:54 +03:00
|
|
|
# Check if the CXX compiler accepts a flag
|
|
|
|
#
|
2005-12-14 21:51:08 +03:00
|
|
|
# Macro CHECK_CXX_ACCEPTS_FLAG(FLAGS VARIABLE) -
|
|
|
|
# checks if the function exists
|
|
|
|
# FLAGS - the flags to try
|
|
|
|
# VARIABLE - variable to store the result
|
2002-11-21 20:52:54 +03:00
|
|
|
#
|
|
|
|
|
2009-09-28 19:46:51 +04:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2002-2009 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.
|
|
|
|
#=============================================================================
|
2010-08-07 04:48:47 +04:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 19:46:51 +04:00
|
|
|
# License text for the above reference.)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
macro(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE)
|
|
|
|
if(NOT DEFINED ${VARIABLE})
|
|
|
|
message(STATUS "Checking to see if CXX compiler accepts flag ${FLAGS}")
|
|
|
|
try_compile(${VARIABLE}
|
2004-10-27 01:23:20 +04:00
|
|
|
${CMAKE_BINARY_DIR}
|
|
|
|
${CMAKE_ROOT}/Modules/DummyCXXFile.cxx
|
|
|
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${FLAGS}
|
2012-08-13 21:42:58 +04:00
|
|
|
OUTPUT_VARIABLE OUTPUT)
|
2012-08-13 21:47:32 +04:00
|
|
|
if(${VARIABLE})
|
|
|
|
message(STATUS "Checking to see if CXX compiler accepts flag ${FLAGS} - yes")
|
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
2004-10-27 01:23:20 +04:00
|
|
|
"Determining if the CXX compiler accepts the flag ${FLAGS} passed with "
|
|
|
|
"the following output:\n${OUTPUT}\n\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message(STATUS "Checking to see if CXX compiler accepts flag ${FLAGS} - no")
|
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2004-10-27 01:23:20 +04:00
|
|
|
"Determining if the CXX compiler accepts the flag ${FLAGS} failed with "
|
|
|
|
"the following output:\n${OUTPUT}\n\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endmacro()
|