2005-12-14 21:51:08 +03:00
|
|
|
|
2009-09-28 19:46:51 +04:00
|
|
|
#=============================================================================
|
2012-08-24 17:10:34 +04:00
|
|
|
# Copyright 2003-2012 Kitware, Inc.
|
2009-09-28 19:46:51 +04:00
|
|
|
#
|
|
|
|
# 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-24 17:10:34 +04:00
|
|
|
if(CMAKE_C_COMPILER_FORCED)
|
|
|
|
# The compiler configuration was forced by the user.
|
|
|
|
# Assume the user has configured all compiler information.
|
|
|
|
set(CMAKE_C_COMPILER_WORKS TRUE)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include(CMakeTestCompilerCommon)
|
2010-02-12 22:32:20 +03:00
|
|
|
|
2012-08-24 17:10:34 +04:00
|
|
|
# Remove any cached result from an older CMake version.
|
|
|
|
# We now store this in CMakeCCompiler.cmake.
|
|
|
|
unset(CMAKE_C_COMPILER_WORKS CACHE)
|
|
|
|
|
2003-01-21 20:50:48 +03:00
|
|
|
# This file is used by EnableLanguage in cmGlobalGenerator to
|
|
|
|
# determine that that selected C compiler can actually compile
|
2003-08-28 00:02:37 +04:00
|
|
|
# and link the most basic of programs. If not, a fatal error
|
2003-01-21 20:50:48 +03:00
|
|
|
# is set and cmake stops processing commands and will not generate
|
|
|
|
# any makefiles or projects.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT CMAKE_C_COMPILER_WORKS)
|
2010-02-12 22:32:20 +03:00
|
|
|
PrintTestCompilerStatus("C" "")
|
2012-08-13 21:47:32 +04:00
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c
|
2004-01-21 23:11:48 +03:00
|
|
|
"#ifdef __cplusplus\n"
|
|
|
|
"# error \"The CMAKE_C_COMPILER is set to a C++ compiler\"\n"
|
|
|
|
"#endif\n"
|
2006-07-26 22:10:14 +04:00
|
|
|
"#if defined(__CLASSIC_C__)\n"
|
|
|
|
"int main(argc, argv)\n"
|
|
|
|
" int argc;\n"
|
|
|
|
" char* argv[];\n"
|
|
|
|
"#else\n"
|
|
|
|
"int main(int argc, char* argv[])\n"
|
|
|
|
"#endif\n"
|
2009-06-22 18:02:51 +04:00
|
|
|
"{ (void)argv; return argc-1;}\n")
|
2012-08-13 21:47:32 +04:00
|
|
|
try_compile(CMAKE_C_COMPILER_WORKS ${CMAKE_BINARY_DIR}
|
2006-06-14 20:28:32 +04:00
|
|
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c
|
2011-12-15 17:29:43 +04:00
|
|
|
OUTPUT_VARIABLE __CMAKE_C_COMPILER_OUTPUT)
|
2012-08-24 17:10:34 +04:00
|
|
|
# Move result from cache to normal variable.
|
|
|
|
set(CMAKE_C_COMPILER_WORKS ${CMAKE_C_COMPILER_WORKS})
|
|
|
|
unset(CMAKE_C_COMPILER_WORKS CACHE)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(C_TEST_WAS_RUN 1)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2003-01-22 20:29:37 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT CMAKE_C_COMPILER_WORKS)
|
2010-02-12 22:32:20 +03:00
|
|
|
PrintTestCompilerStatus("C" " -- broken")
|
2012-08-13 21:47:32 +04:00
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2003-12-01 21:06:35 +03:00
|
|
|
"Determining if the C compiler works failed with "
|
2011-12-15 17:29:43 +04:00
|
|
|
"the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n")
|
2012-08-13 21:47:32 +04:00
|
|
|
message(FATAL_ERROR "The C compiler \"${CMAKE_C_COMPILER}\" "
|
2003-08-05 01:08:41 +04:00
|
|
|
"is not able to compile a simple test program.\nIt fails "
|
2011-12-15 17:29:43 +04:00
|
|
|
"with the following output:\n ${__CMAKE_C_COMPILER_OUTPUT}\n\n"
|
2003-07-11 22:14:03 +04:00
|
|
|
"CMake will not be able to correctly generate this project.")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
if(C_TEST_WAS_RUN)
|
2010-02-12 22:32:20 +03:00
|
|
|
PrintTestCompilerStatus("C" " -- works")
|
2012-08-13 21:47:32 +04:00
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
2005-01-20 20:30:03 +03:00
|
|
|
"Determining if the C compiler works passed with "
|
2011-12-15 17:29:43 +04:00
|
|
|
"the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-01-22 02:30:17 +03:00
|
|
|
|
2012-08-24 17:10:34 +04:00
|
|
|
# Try to identify the ABI and configure it into CMakeCCompiler.cmake
|
|
|
|
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
|
|
|
|
CMAKE_DETERMINE_COMPILER_ABI(C ${CMAKE_ROOT}/Modules/CMakeCCompilerABI.c)
|
2013-11-04 04:15:43 +04:00
|
|
|
# Try to identify the compiler features
|
|
|
|
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake)
|
|
|
|
CMAKE_DETERMINE_COMPILE_FEATURES(C)
|
2012-08-24 17:10:34 +04:00
|
|
|
|
|
|
|
# Re-configure to save learned information.
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in
|
|
|
|
${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake
|
2013-11-13 12:50:56 +04:00
|
|
|
@ONLY
|
2012-08-24 17:10:34 +04:00
|
|
|
)
|
|
|
|
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CMAKE_C_SIZEOF_DATA_PTR)
|
|
|
|
foreach(f ${CMAKE_C_ABI_FILES})
|
|
|
|
include(${f})
|
|
|
|
endforeach()
|
|
|
|
unset(CMAKE_C_ABI_FILES)
|
|
|
|
endif()
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2005-11-14 22:21:39 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
unset(__CMAKE_C_COMPILER_OUTPUT)
|