2005-12-14 13:51:08 -05:00
|
|
|
|
2009-09-28 11:46:51 -04:00
|
|
|
#=============================================================================
|
2012-08-24 09:10:34 -04:00
|
|
|
# Copyright 2003-2012 Kitware, Inc.
|
2009-09-28 11: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-06 17:48:47 -07:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 11:46:51 -04:00
|
|
|
# License text for the above reference.)
|
|
|
|
|
2012-08-24 09: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 13:47:32 -04:00
|
|
|
include(CMakeTestCompilerCommon)
|
2010-02-12 14:32:20 -05:00
|
|
|
|
2012-08-24 09: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 12:50:48 -05:00
|
|
|
# This file is used by EnableLanguage in cmGlobalGenerator to
|
|
|
|
# determine that that selected C compiler can actually compile
|
2003-08-27 16:02:37 -04:00
|
|
|
# and link the most basic of programs. If not, a fatal error
|
2003-01-21 12:50:48 -05:00
|
|
|
# is set and cmake stops processing commands and will not generate
|
|
|
|
# any makefiles or projects.
|
2012-08-13 13:47:32 -04:00
|
|
|
if(NOT CMAKE_C_COMPILER_WORKS)
|
2010-02-12 14:32:20 -05:00
|
|
|
PrintTestCompilerStatus("C" "")
|
2012-08-13 13:47:32 -04:00
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c
|
2004-01-21 15:11:48 -05:00
|
|
|
"#ifdef __cplusplus\n"
|
|
|
|
"# error \"The CMAKE_C_COMPILER is set to a C++ compiler\"\n"
|
|
|
|
"#endif\n"
|
2006-07-26 14: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 10:02:51 -04:00
|
|
|
"{ (void)argv; return argc-1;}\n")
|
2012-08-13 13:47:32 -04:00
|
|
|
try_compile(CMAKE_C_COMPILER_WORKS ${CMAKE_BINARY_DIR}
|
2006-06-14 12:28:32 -04:00
|
|
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c
|
2011-12-15 08:29:43 -05:00
|
|
|
OUTPUT_VARIABLE __CMAKE_C_COMPILER_OUTPUT)
|
2012-08-24 09: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 13:47:32 -04:00
|
|
|
set(C_TEST_WAS_RUN 1)
|
2012-08-13 13:50:14 -04:00
|
|
|
endif()
|
2003-01-22 12:29:37 -05:00
|
|
|
|
2012-08-13 13:47:32 -04:00
|
|
|
if(NOT CMAKE_C_COMPILER_WORKS)
|
2010-02-12 14:32:20 -05:00
|
|
|
PrintTestCompilerStatus("C" " -- broken")
|
2012-08-13 13:47:32 -04:00
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2003-12-01 13:06:35 -05:00
|
|
|
"Determining if the C compiler works failed with "
|
2011-12-15 08:29:43 -05:00
|
|
|
"the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n")
|
2012-08-13 13:47:32 -04:00
|
|
|
message(FATAL_ERROR "The C compiler \"${CMAKE_C_COMPILER}\" "
|
2003-08-04 17:08:41 -04:00
|
|
|
"is not able to compile a simple test program.\nIt fails "
|
2011-12-15 08:29:43 -05:00
|
|
|
"with the following output:\n ${__CMAKE_C_COMPILER_OUTPUT}\n\n"
|
2003-07-11 14:14:03 -04:00
|
|
|
"CMake will not be able to correctly generate this project.")
|
2012-08-13 13:50:14 -04:00
|
|
|
else()
|
2012-08-13 13:47:32 -04:00
|
|
|
if(C_TEST_WAS_RUN)
|
2010-02-12 14:32:20 -05:00
|
|
|
PrintTestCompilerStatus("C" " -- works")
|
2012-08-13 13:47:32 -04:00
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
2005-01-20 12:30:03 -05:00
|
|
|
"Determining if the C compiler works passed with "
|
2011-12-15 08:29:43 -05:00
|
|
|
"the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n")
|
2012-08-13 13:50:14 -04:00
|
|
|
endif()
|
2008-01-21 18:30:17 -05:00
|
|
|
|
2012-08-24 09: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)
|
|
|
|
|
|
|
|
# Re-configure to save learned information.
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in
|
|
|
|
${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake
|
2013-11-13 09:50:56 +01:00
|
|
|
@ONLY
|
2012-08-24 09:10:34 -04:00
|
|
|
)
|
|
|
|
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake)
|
|
|
|
|
2012-08-13 13: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 13:50:14 -04:00
|
|
|
endif()
|
2005-11-14 14:21:39 -05:00
|
|
|
|
2012-08-13 13:47:32 -04:00
|
|
|
unset(__CMAKE_C_COMPILER_OUTPUT)
|