2007-04-28 17:35:01 +04:00
|
|
|
|
2009-09-28 19:46:51 +04:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2007-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.)
|
|
|
|
|
2008-01-07 18:27:28 +03:00
|
|
|
# Function to compile a source file to identify the compiler. This is
|
2007-04-28 17:35:01 +04:00
|
|
|
# used internally by CMake and should not be included by user code.
|
2007-05-01 01:05:32 +04:00
|
|
|
# If successful, sets CMAKE_<lang>_COMPILER_ID and CMAKE_<lang>_PLATFORM_ID
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
|
2007-12-16 00:03:29 +03:00
|
|
|
# Make sure the compiler arguments are clean.
|
2012-08-13 21:47:32 +04:00
|
|
|
string(STRIP "${CMAKE_${lang}_COMPILER_ARG1}" CMAKE_${lang}_COMPILER_ID_ARG1)
|
|
|
|
string(REGEX REPLACE " +" ";" CMAKE_${lang}_COMPILER_ID_ARG1 "${CMAKE_${lang}_COMPILER_ID_ARG1}")
|
2007-12-16 00:03:29 +03:00
|
|
|
|
2007-04-28 17:35:01 +04:00
|
|
|
# Make sure user-specified compiler flags are used.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CMAKE_${lang}_FLAGS)
|
|
|
|
set(CMAKE_${lang}_COMPILER_ID_FLAGS ${CMAKE_${lang}_FLAGS})
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_${lang}_COMPILER_ID_FLAGS $ENV{${flagvar}})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2014-04-06 23:51:33 +04:00
|
|
|
string(REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}")
|
2007-04-28 17:35:01 +04:00
|
|
|
|
2008-01-07 18:27:28 +03:00
|
|
|
# Compute the directory in which to run the test.
|
2012-08-24 16:48:59 +04:00
|
|
|
set(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_PLATFORM_INFO_DIR}/CompilerId${lang})
|
2008-01-07 18:27:28 +03:00
|
|
|
|
|
|
|
# Try building with no extra flags and then try each set
|
|
|
|
# of helper flags. Stop when the compiler is identified.
|
2015-06-18 17:57:46 +03:00
|
|
|
foreach(flags ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS_FIRST}
|
|
|
|
""
|
|
|
|
${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS})
|
2015-06-18 18:24:54 +03:00
|
|
|
CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${flags}" "${src}")
|
2015-06-18 18:28:36 +03:00
|
|
|
CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR("${lang}" "${COMPILER_${lang}_PRODUCED_OUTPUT}")
|
|
|
|
if(CMAKE_${lang}_COMPILER_ID)
|
|
|
|
break()
|
|
|
|
endif()
|
2015-06-18 18:24:54 +03:00
|
|
|
foreach(file ${COMPILER_${lang}_PRODUCED_FILES})
|
|
|
|
CMAKE_DETERMINE_COMPILER_ID_CHECK("${lang}" "${CMAKE_${lang}_COMPILER_ID_DIR}/${file}" "${src}")
|
|
|
|
endforeach()
|
|
|
|
if(CMAKE_${lang}_COMPILER_ID)
|
|
|
|
break()
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2008-01-07 18:27:28 +03:00
|
|
|
|
2010-02-01 17:03:05 +03:00
|
|
|
# If the compiler is still unknown, try to query its vendor.
|
2013-10-22 21:59:56 +04:00
|
|
|
if(CMAKE_${lang}_COMPILER AND NOT CMAKE_${lang}_COMPILER_ID)
|
2010-02-01 17:03:05 +03:00
|
|
|
CMAKE_DETERMINE_COMPILER_ID_VENDOR(${lang})
|
2012-08-13 21:47:32 +04:00
|
|
|
endif()
|
2010-02-01 17:03:05 +03:00
|
|
|
|
2014-10-14 18:25:32 +04:00
|
|
|
if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU")
|
2014-01-20 20:57:40 +04:00
|
|
|
execute_process(
|
|
|
|
COMMAND "${CMAKE_${lang}_COMPILER}"
|
|
|
|
-V
|
|
|
|
OUTPUT_VARIABLE output ERROR_VARIABLE output
|
|
|
|
RESULT_VARIABLE result
|
|
|
|
TIMEOUT 10
|
|
|
|
)
|
|
|
|
if (output MATCHES "targets available")
|
|
|
|
set(CMAKE_${lang}_COMPILER_ID QCC)
|
|
|
|
# http://community.qnx.com/sf/discussion/do/listPosts/projects.community/discussion.qnx_momentics_community_support.topc3555?_pagenum=2
|
|
|
|
# The qcc driver does not itself have a version.
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2008-01-07 18:27:28 +03:00
|
|
|
# if the format is unknown after all files have been checked, put "Unknown" in the cache
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT CMAKE_EXECUTABLE_FORMAT)
|
|
|
|
set(CMAKE_EXECUTABLE_FORMAT "Unknown" CACHE INTERNAL "Executable file format")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-01-07 18:27:28 +03:00
|
|
|
|
2015-09-18 16:09:07 +03:00
|
|
|
if(CMAKE_GENERATOR STREQUAL "Ninja" AND MSVC_${lang}_ARCHITECTURE_ID)
|
|
|
|
CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX(${lang})
|
|
|
|
else()
|
|
|
|
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "")
|
|
|
|
endif()
|
|
|
|
|
2008-01-07 18:27:28 +03:00
|
|
|
# Display the final identification result.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CMAKE_${lang}_COMPILER_ID)
|
|
|
|
if(CMAKE_${lang}_COMPILER_VERSION)
|
|
|
|
set(_version " ${CMAKE_${lang}_COMPILER_VERSION}")
|
|
|
|
else()
|
|
|
|
set(_version "")
|
|
|
|
endif()
|
|
|
|
message(STATUS "The ${lang} compiler identification is "
|
2011-12-05 18:44:09 +04:00
|
|
|
"${CMAKE_${lang}_COMPILER_ID}${_version}")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message(STATUS "The ${lang} compiler identification is unknown")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-01-07 18:27:28 +03:00
|
|
|
|
2012-08-16 00:12:05 +04:00
|
|
|
# Check if compiler id detection gave us the compiler tool.
|
2013-10-27 18:06:42 +04:00
|
|
|
if(CMAKE_${lang}_COMPILER_ID_TOOL)
|
|
|
|
set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_ID_TOOL}" PARENT_SCOPE)
|
|
|
|
elseif(NOT CMAKE_${lang}_COMPILER)
|
|
|
|
set(CMAKE_${lang}_COMPILER "CMAKE_${lang}_COMPILER-NOTFOUND" PARENT_SCOPE)
|
2012-08-16 00:12:05 +04:00
|
|
|
endif()
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE)
|
|
|
|
set(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE)
|
|
|
|
set(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}"
|
2009-11-20 05:58:42 +03:00
|
|
|
PARENT_SCOPE)
|
2015-09-18 16:09:07 +03:00
|
|
|
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX}" PARENT_SCOPE)
|
2015-09-30 20:42:50 +03:00
|
|
|
set(CMAKE_${lang}_COMPILER_LINKS_STATICALLY "${CMAKE_${lang}_COMPILER_LINKS_STATICALLY}" PARENT_SCOPE)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE)
|
2013-10-04 18:10:22 +04:00
|
|
|
set(CMAKE_${lang}_SIMULATE_ID "${CMAKE_${lang}_SIMULATE_ID}" PARENT_SCOPE)
|
|
|
|
set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE)
|
2015-09-15 20:42:26 +03:00
|
|
|
set(CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT "${CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT}" PARENT_SCOPE)
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2008-01-07 18:27:28 +03:00
|
|
|
|
2014-04-23 12:33:16 +04:00
|
|
|
include(CMakeCompilerIdDetection)
|
2014-04-22 18:34:47 +04:00
|
|
|
|
2008-02-25 17:23:14 +03:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to write the compiler id source file.
|
2012-08-13 21:47:32 +04:00
|
|
|
function(CMAKE_DETERMINE_COMPILER_ID_WRITE lang src)
|
2013-11-16 19:53:26 +04:00
|
|
|
find_file(src_in ${src}.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
|
2013-10-25 00:20:31 +04:00
|
|
|
file(READ ${src_in} ID_CONTENT_IN)
|
2014-04-22 18:34:47 +04:00
|
|
|
|
2014-04-23 12:46:47 +04:00
|
|
|
compiler_id_detection(CMAKE_${lang}_COMPILER_ID_CONTENT ${lang}
|
|
|
|
ID_STRING
|
|
|
|
VERSION_STRINGS
|
2014-04-23 14:10:04 +04:00
|
|
|
PLATFORM_DEFAULT_COMPILER
|
2014-04-23 12:46:47 +04:00
|
|
|
)
|
2014-04-22 18:34:47 +04:00
|
|
|
|
2013-10-25 00:20:31 +04:00
|
|
|
unset(src_in CACHE)
|
2012-08-13 21:47:32 +04:00
|
|
|
string(CONFIGURE "${ID_CONTENT_IN}" ID_CONTENT_OUT @ONLY)
|
|
|
|
file(WRITE ${CMAKE_${lang}_COMPILER_ID_DIR}/${src} "${ID_CONTENT_OUT}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2008-02-25 17:23:14 +03:00
|
|
|
|
2008-01-07 18:27:28 +03:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to build the compiler id source file and look for output
|
|
|
|
# files.
|
2012-08-13 21:47:32 +04:00
|
|
|
function(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags src)
|
2008-01-07 18:27:28 +03:00
|
|
|
# Create a clean working directory.
|
2012-08-13 21:47:32 +04:00
|
|
|
file(REMOVE_RECURSE ${CMAKE_${lang}_COMPILER_ID_DIR})
|
|
|
|
file(MAKE_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR})
|
2008-02-25 17:23:14 +03:00
|
|
|
CMAKE_DETERMINE_COMPILER_ID_WRITE("${lang}" "${src}")
|
2007-04-28 17:35:01 +04:00
|
|
|
|
2008-01-07 18:27:28 +03:00
|
|
|
# Construct a description of this test case.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(COMPILER_DESCRIPTION
|
2008-02-25 17:23:14 +03:00
|
|
|
"Compiler: ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_COMPILER_ID_ARG1}
|
|
|
|
Build flags: ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}
|
|
|
|
Id flags: ${testflags}
|
|
|
|
")
|
2008-01-07 18:27:28 +03:00
|
|
|
|
2007-04-28 17:35:01 +04:00
|
|
|
# Compile the compiler identification source.
|
2013-10-19 14:30:57 +04:00
|
|
|
if(CMAKE_GENERATOR STREQUAL "Visual Studio 6" AND
|
|
|
|
lang STREQUAL "Fortran")
|
|
|
|
set(CMAKE_${lang}_COMPILER_ID_RESULT 1)
|
|
|
|
set(CMAKE_${lang}_COMPILER_ID_OUTPUT "No Intel Fortran in VS 6")
|
|
|
|
elseif("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)")
|
2012-08-17 00:23:16 +04:00
|
|
|
set(vs_version ${CMAKE_MATCH_1})
|
2013-08-05 14:57:58 +04:00
|
|
|
set(id_platform ${CMAKE_VS_PLATFORM_NAME})
|
2012-08-17 00:23:16 +04:00
|
|
|
set(id_lang "${lang}")
|
|
|
|
set(id_cl cl.exe)
|
2014-06-10 19:30:28 +04:00
|
|
|
if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
|
|
|
|
set(v NsightTegra)
|
|
|
|
set(ext vcxproj)
|
|
|
|
if(lang STREQUAL CXX)
|
|
|
|
set(id_gcc g++)
|
|
|
|
set(id_clang clang++)
|
|
|
|
else()
|
|
|
|
set(id_gcc gcc)
|
|
|
|
set(id_clang clang)
|
|
|
|
endif()
|
|
|
|
elseif(lang STREQUAL Fortran)
|
2013-10-11 21:40:43 +04:00
|
|
|
set(v Intel)
|
|
|
|
set(ext vfproj)
|
|
|
|
set(id_cl ifort.exe)
|
|
|
|
elseif(NOT "${vs_version}" VERSION_LESS 10)
|
2012-08-17 00:23:16 +04:00
|
|
|
set(v 10)
|
|
|
|
set(ext vcxproj)
|
|
|
|
elseif(NOT "${vs_version}" VERSION_LESS 7)
|
|
|
|
set(id_version ${vs_version}.00)
|
|
|
|
set(v 7)
|
|
|
|
set(ext vcproj)
|
|
|
|
else()
|
|
|
|
set(v 6)
|
|
|
|
set(ext dsp)
|
|
|
|
endif()
|
2013-08-05 14:57:58 +04:00
|
|
|
if("${id_platform}" STREQUAL "Itanium")
|
|
|
|
set(id_platform ia64)
|
2012-08-17 00:23:16 +04:00
|
|
|
endif()
|
|
|
|
if(CMAKE_VS_PLATFORM_TOOLSET)
|
2014-06-10 19:30:28 +04:00
|
|
|
if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
|
|
|
|
set(id_toolset "<NdkToolchainVersion>${CMAKE_VS_PLATFORM_TOOLSET}</NdkToolchainVersion>")
|
|
|
|
else()
|
|
|
|
set(id_toolset "<PlatformToolset>${CMAKE_VS_PLATFORM_TOOLSET}</PlatformToolset>")
|
|
|
|
if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "Intel")
|
|
|
|
set(id_cl icl.exe)
|
|
|
|
endif()
|
2013-10-09 21:50:59 +04:00
|
|
|
endif()
|
2012-08-17 00:23:16 +04:00
|
|
|
else()
|
|
|
|
set(id_toolset "")
|
|
|
|
endif()
|
2014-07-28 22:27:59 +04:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone")
|
|
|
|
set(id_system "<ApplicationType>Windows Phone</ApplicationType>")
|
|
|
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
|
|
|
set(id_system "<ApplicationType>Windows Store</ApplicationType>")
|
|
|
|
else()
|
|
|
|
set(id_system "")
|
|
|
|
endif()
|
|
|
|
if(id_system AND CMAKE_SYSTEM_VERSION)
|
|
|
|
set(id_system_version "<ApplicationTypeRevision>${CMAKE_SYSTEM_VERSION}</ApplicationTypeRevision>")
|
|
|
|
else()
|
|
|
|
set(id_system_version "")
|
|
|
|
endif()
|
2015-09-30 23:22:43 +03:00
|
|
|
if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
|
|
|
|
set(id_WindowsTargetPlatformVersion "<WindowsTargetPlatformVersion>${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}</WindowsTargetPlatformVersion>")
|
|
|
|
endif()
|
2014-08-05 22:44:12 +04:00
|
|
|
if(id_platform STREQUAL ARM)
|
|
|
|
set(id_WindowsSDKDesktopARMSupport "<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>")
|
|
|
|
else()
|
|
|
|
set(id_WindowsSDKDesktopARMSupport "")
|
|
|
|
endif()
|
2012-11-20 16:37:50 +04:00
|
|
|
if(CMAKE_VS_WINCE_VERSION)
|
2012-11-30 18:15:06 +04:00
|
|
|
set(id_entrypoint "mainACRTStartup")
|
2013-09-25 07:25:07 +04:00
|
|
|
if("${vs_version}" VERSION_LESS 9)
|
|
|
|
set(id_subsystem 9)
|
|
|
|
else()
|
|
|
|
set(id_subsystem 8)
|
|
|
|
endif()
|
2012-11-30 17:14:27 +04:00
|
|
|
else()
|
|
|
|
set(id_subsystem 1)
|
2012-11-20 16:37:50 +04:00
|
|
|
endif()
|
2012-08-17 00:23:16 +04:00
|
|
|
set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR})
|
2015-06-25 22:15:17 +03:00
|
|
|
set(id_src "${src}")
|
2012-08-17 00:23:16 +04:00
|
|
|
configure_file(${CMAKE_ROOT}/Modules/CompilerId/VS-${v}.${ext}.in
|
2013-11-13 12:50:56 +04:00
|
|
|
${id_dir}/CompilerId${lang}.${ext} @ONLY)
|
2013-12-04 19:36:18 +04:00
|
|
|
if(CMAKE_VS_MSBUILD_COMMAND AND NOT lang STREQUAL "Fortran")
|
|
|
|
set(command "${CMAKE_VS_MSBUILD_COMMAND}" "CompilerId${lang}.${ext}"
|
|
|
|
"/p:Configuration=Debug" "/p:Platform=${id_platform}" "/p:VisualStudioVersion=${vs_version}.0"
|
|
|
|
)
|
|
|
|
elseif(CMAKE_VS_DEVENV_COMMAND)
|
|
|
|
set(command "${CMAKE_VS_DEVENV_COMMAND}" "CompilerId${lang}.${ext}" "/build" "Debug")
|
|
|
|
elseif(CMAKE_VS_MSDEV_COMMAND)
|
|
|
|
set(command "${CMAKE_VS_MSDEV_COMMAND}" "CompilerId${lang}.${ext}" "/make")
|
|
|
|
else()
|
|
|
|
set(command "")
|
|
|
|
endif()
|
|
|
|
if(command)
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${command}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}
|
|
|
|
OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
|
|
|
|
ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
|
|
|
|
RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
set(CMAKE_${lang}_COMPILER_ID_RESULT 1)
|
|
|
|
set(CMAKE_${lang}_COMPILER_ID_OUTPUT "VS environment not known to support ${lang}")
|
|
|
|
endif()
|
2012-08-17 00:23:16 +04:00
|
|
|
# Match the compiler location line printed out.
|
|
|
|
if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "CMAKE_${lang}_COMPILER=([^%\r\n]+)[\r\n]")
|
2013-09-03 21:58:42 +04:00
|
|
|
# Strip VS diagnostic output from the end of the line.
|
|
|
|
string(REGEX REPLACE " \\(TaskId:[0-9]*\\)$" "" _comp "${CMAKE_MATCH_1}")
|
2012-08-17 00:23:16 +04:00
|
|
|
if(EXISTS "${_comp}")
|
|
|
|
file(TO_CMAKE_PATH "${_comp}" _comp)
|
|
|
|
set(CMAKE_${lang}_COMPILER_ID_TOOL "${_comp}" PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
elseif("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
2012-08-16 00:21:50 +04:00
|
|
|
set(id_lang "${lang}")
|
|
|
|
set(id_type ${CMAKE_${lang}_COMPILER_XCODE_TYPE})
|
|
|
|
set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR})
|
2015-06-25 22:15:17 +03:00
|
|
|
set(id_src "${src}")
|
2012-12-20 19:16:57 +04:00
|
|
|
if(CMAKE_XCODE_PLATFORM_TOOLSET)
|
|
|
|
set(id_toolset "GCC_VERSION = ${CMAKE_XCODE_PLATFORM_TOOLSET};")
|
|
|
|
else()
|
|
|
|
set(id_toolset "")
|
|
|
|
endif()
|
2014-04-29 17:21:00 +04:00
|
|
|
if(CMAKE_OSX_DEPLOYMENT_TARGET)
|
|
|
|
set(id_deployment_target
|
|
|
|
"MACOSX_DEPLOYMENT_TARGET = \"${CMAKE_OSX_DEPLOYMENT_TARGET}\";")
|
|
|
|
else()
|
|
|
|
set(id_deployment_target "")
|
|
|
|
endif()
|
2014-10-22 17:37:28 +04:00
|
|
|
set(id_product_type "com.apple.product-type.tool")
|
2014-04-29 17:21:00 +04:00
|
|
|
if(CMAKE_OSX_SYSROOT)
|
|
|
|
set(id_sdkroot "SDKROOT = \"${CMAKE_OSX_SYSROOT}\";")
|
2014-10-22 17:37:28 +04:00
|
|
|
if(CMAKE_OSX_SYSROOT MATCHES "(^|/)[Ii][Pp][Hh][Oo][Nn][Ee]")
|
|
|
|
set(id_product_type "com.apple.product-type.bundle.unit-test")
|
|
|
|
endif()
|
2014-04-29 17:21:00 +04:00
|
|
|
else()
|
|
|
|
set(id_sdkroot "")
|
|
|
|
endif()
|
2012-08-16 00:21:50 +04:00
|
|
|
if(NOT ${XCODE_VERSION} VERSION_LESS 3)
|
|
|
|
set(v 3)
|
|
|
|
set(ext xcodeproj)
|
|
|
|
elseif(NOT ${XCODE_VERSION} VERSION_LESS 2)
|
|
|
|
set(v 2)
|
|
|
|
set(ext xcodeproj)
|
|
|
|
else()
|
|
|
|
set(v 1)
|
|
|
|
set(ext xcode)
|
|
|
|
endif()
|
|
|
|
configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-${v}.pbxproj.in
|
2013-11-13 12:50:56 +04:00
|
|
|
${id_dir}/CompilerId${lang}.${ext}/project.pbxproj @ONLY)
|
2012-09-24 22:44:07 +04:00
|
|
|
unset(_ENV_MACOSX_DEPLOYMENT_TARGET)
|
|
|
|
if(DEFINED ENV{MACOSX_DEPLOYMENT_TARGET})
|
|
|
|
set(_ENV_MACOSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}")
|
|
|
|
set(ENV{MACOSX_DEPLOYMENT_TARGET} "")
|
|
|
|
endif()
|
2012-08-16 00:21:50 +04:00
|
|
|
execute_process(COMMAND xcodebuild
|
|
|
|
WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}
|
|
|
|
OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
|
|
|
|
ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
|
|
|
|
RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT
|
|
|
|
)
|
2012-09-24 22:44:07 +04:00
|
|
|
if(DEFINED _ENV_MACOSX_DEPLOYMENT_TARGET)
|
|
|
|
set(ENV{MACOSX_DEPLOYMENT_TARGET} "${_ENV_MACOSX_DEPLOYMENT_TARGET}")
|
|
|
|
endif()
|
2012-08-16 00:21:50 +04:00
|
|
|
|
2015-06-29 18:19:15 +03:00
|
|
|
if(DEFINED CMAKE_${lang}_COMPILER_ID_TOOL_MATCH_REGEX)
|
|
|
|
if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "${CMAKE_${lang}_COMPILER_ID_TOOL_MATCH_REGEX}")
|
|
|
|
set(_comp "${CMAKE_MATCH_${CMAKE_${lang}_COMPILER_ID_TOOL_MATCH_INDEX}}")
|
|
|
|
if(EXISTS "${_comp}")
|
|
|
|
set(CMAKE_${lang}_COMPILER_ID_TOOL "${_comp}" PARENT_SCOPE)
|
|
|
|
endif()
|
2012-08-16 00:21:50 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2015-09-18 16:13:32 +03:00
|
|
|
execute_process(
|
|
|
|
COMMAND "${CMAKE_${lang}_COMPILER}"
|
|
|
|
${CMAKE_${lang}_COMPILER_ID_ARG1}
|
|
|
|
${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}
|
|
|
|
${testflags}
|
|
|
|
"${src}"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}
|
|
|
|
OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
|
|
|
|
ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
|
|
|
|
RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT
|
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-04-28 17:35:01 +04:00
|
|
|
|
|
|
|
# Check the result of compilation.
|
2013-10-11 18:40:18 +04:00
|
|
|
if(CMAKE_${lang}_COMPILER_ID_RESULT
|
|
|
|
# Intel Fortran warns and ignores preprocessor lines without /fpp
|
|
|
|
OR CMAKE_${lang}_COMPILER_ID_OUTPUT MATCHES "Bad # preprocessor line"
|
|
|
|
)
|
2007-04-28 17:35:01 +04:00
|
|
|
# Compilation failed.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(MSG
|
2008-02-25 17:23:14 +03:00
|
|
|
"Compiling the ${lang} compiler identification source file \"${src}\" failed.
|
|
|
|
${COMPILER_DESCRIPTION}
|
|
|
|
The output was:
|
|
|
|
${CMAKE_${lang}_COMPILER_ID_RESULT}
|
|
|
|
${CMAKE_${lang}_COMPILER_ID_OUTPUT}
|
|
|
|
|
|
|
|
")
|
2012-08-13 21:47:32 +04:00
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "${MSG}")
|
|
|
|
#if(NOT CMAKE_${lang}_COMPILER_ID_ALLOW_FAIL)
|
|
|
|
# message(FATAL_ERROR "${MSG}")
|
2012-08-13 21:50:14 +04:00
|
|
|
#endif()
|
2008-01-07 18:27:28 +03:00
|
|
|
|
|
|
|
# No output files should be inspected.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(COMPILER_${lang}_PRODUCED_FILES)
|
2015-06-18 18:28:36 +03:00
|
|
|
set(COMPILER_${lang}_PRODUCED_OUTPUT)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2007-04-28 17:35:01 +04:00
|
|
|
# Compilation succeeded.
|
2012-08-13 21:47:32 +04:00
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
2008-02-25 17:23:14 +03:00
|
|
|
"Compiling the ${lang} compiler identification source file \"${src}\" succeeded.
|
|
|
|
${COMPILER_DESCRIPTION}
|
|
|
|
The output was:
|
|
|
|
${CMAKE_${lang}_COMPILER_ID_RESULT}
|
|
|
|
${CMAKE_${lang}_COMPILER_ID_OUTPUT}
|
|
|
|
|
|
|
|
")
|
2007-04-28 17:35:01 +04:00
|
|
|
|
2008-01-07 18:27:28 +03:00
|
|
|
# Find the executable produced by the compiler, try all files in the
|
|
|
|
# binary dir.
|
2012-08-16 00:12:05 +04:00
|
|
|
file(GLOB files
|
2008-02-25 17:23:14 +03:00
|
|
|
RELATIVE ${CMAKE_${lang}_COMPILER_ID_DIR}
|
2014-10-22 17:37:28 +04:00
|
|
|
|
|
|
|
# normal case
|
|
|
|
${CMAKE_${lang}_COMPILER_ID_DIR}/*
|
|
|
|
|
|
|
|
# com.apple.package-type.bundle.unit-test
|
|
|
|
${CMAKE_${lang}_COMPILER_ID_DIR}/*.xctest/*
|
|
|
|
)
|
2012-08-16 00:12:05 +04:00
|
|
|
list(REMOVE_ITEM files "${src}")
|
|
|
|
set(COMPILER_${lang}_PRODUCED_FILES "")
|
|
|
|
foreach(file ${files})
|
|
|
|
if(NOT IS_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}/${file})
|
|
|
|
list(APPEND COMPILER_${lang}_PRODUCED_FILES ${file})
|
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
|
|
|
"Compilation of the ${lang} compiler identification source \""
|
|
|
|
"${src}\" produced \"${file}\"\n\n")
|
|
|
|
endif()
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2008-01-03 00:52:12 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT COMPILER_${lang}_PRODUCED_FILES)
|
2007-05-25 23:22:22 +04:00
|
|
|
# No executable was found.
|
2012-08-13 21:47:32 +04:00
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2007-04-28 17:35:01 +04:00
|
|
|
"Compilation of the ${lang} compiler identification source \""
|
2008-02-25 17:23:14 +03:00
|
|
|
"${src}\" did not produce an executable in \""
|
2008-01-07 18:27:28 +03:00
|
|
|
"${CMAKE_${lang}_COMPILER_ID_DIR}\".\n\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2015-06-18 18:28:36 +03:00
|
|
|
|
|
|
|
set(COMPILER_${lang}_PRODUCED_OUTPUT "${CMAKE_${lang}_COMPILER_ID_OUTPUT}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-05-17 18:07:51 +04:00
|
|
|
|
2008-01-07 18:27:28 +03:00
|
|
|
# Return the files produced by the compilation.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(COMPILER_${lang}_PRODUCED_FILES "${COMPILER_${lang}_PRODUCED_FILES}" PARENT_SCOPE)
|
2015-06-18 18:28:36 +03:00
|
|
|
set(COMPILER_${lang}_PRODUCED_OUTPUT "${COMPILER_${lang}_PRODUCED_OUTPUT}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to extract the compiler id from compiler output.
|
|
|
|
function(CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR lang output)
|
|
|
|
foreach(vendor ${CMAKE_${lang}_COMPILER_ID_MATCH_VENDORS})
|
|
|
|
if(output MATCHES "${CMAKE_${lang}_COMPILER_ID_MATCH_VENDOR_REGEX_${vendor}}")
|
|
|
|
set(CMAKE_${lang}_COMPILER_ID "${vendor}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
set(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE)
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2008-01-07 18:27:28 +03:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to extract the compiler id from an executable.
|
2012-08-13 21:47:32 +04:00
|
|
|
function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
|
2008-01-07 18:27:28 +03:00
|
|
|
# Look for a compiler id if not yet known.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT CMAKE_${lang}_COMPILER_ID)
|
2008-01-07 18:27:28 +03:00
|
|
|
# Read the compiler identification string from the executable file.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(COMPILER_ID)
|
|
|
|
set(COMPILER_VERSION)
|
2015-02-17 21:24:31 +03:00
|
|
|
set(COMPILER_VERSION_MAJOR 0)
|
|
|
|
set(COMPILER_VERSION_MINOR 0)
|
|
|
|
set(COMPILER_VERSION_PATCH 0)
|
|
|
|
set(COMPILER_VERSION_TWEAK 0)
|
|
|
|
set(HAVE_COMPILER_VERSION_MAJOR 0)
|
|
|
|
set(HAVE_COMPILER_VERSION_MINOR 0)
|
|
|
|
set(HAVE_COMPILER_VERSION_PATCH 0)
|
|
|
|
set(HAVE_COMPILER_VERSION_TWEAK 0)
|
|
|
|
set(DIGIT_VALUE_1 1)
|
|
|
|
set(DIGIT_VALUE_2 10)
|
|
|
|
set(DIGIT_VALUE_3 100)
|
|
|
|
set(DIGIT_VALUE_4 1000)
|
|
|
|
set(DIGIT_VALUE_5 10000)
|
|
|
|
set(DIGIT_VALUE_6 100000)
|
|
|
|
set(DIGIT_VALUE_7 1000000)
|
|
|
|
set(DIGIT_VALUE_8 10000000)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(PLATFORM_ID)
|
2013-10-04 18:07:08 +04:00
|
|
|
set(ARCHITECTURE_ID)
|
2013-10-04 18:10:22 +04:00
|
|
|
set(SIMULATE_ID)
|
|
|
|
set(SIMULATE_VERSION)
|
2012-08-13 21:47:32 +04:00
|
|
|
file(STRINGS ${file}
|
2015-02-17 21:24:31 +03:00
|
|
|
CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 38 REGEX "INFO:[A-Za-z0-9_]+\\[[^]]*\\]")
|
2013-10-04 18:07:08 +04:00
|
|
|
set(COMPILER_ID_TWICE)
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach(info ${CMAKE_${lang}_COMPILER_ID_STRINGS})
|
2014-04-11 20:17:46 +04:00
|
|
|
if("${info}" MATCHES "INFO:compiler\\[([^]\"]*)\\]")
|
2012-08-13 21:47:32 +04:00
|
|
|
if(COMPILER_ID)
|
|
|
|
set(COMPILER_ID_TWICE 1)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2014-04-06 23:30:00 +04:00
|
|
|
set(COMPILER_ID "${CMAKE_MATCH_1}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2014-04-11 20:17:46 +04:00
|
|
|
if("${info}" MATCHES "INFO:platform\\[([^]\"]*)\\]")
|
2014-04-06 23:30:00 +04:00
|
|
|
set(PLATFORM_ID "${CMAKE_MATCH_1}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2014-04-11 20:17:46 +04:00
|
|
|
if("${info}" MATCHES "INFO:arch\\[([^]\"]*)\\]")
|
2014-04-06 23:30:00 +04:00
|
|
|
set(ARCHITECTURE_ID "${CMAKE_MATCH_1}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2014-04-11 20:17:46 +04:00
|
|
|
if("${info}" MATCHES "INFO:compiler_version\\[([^]\"]*)\\]")
|
2014-04-06 23:30:00 +04:00
|
|
|
string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${CMAKE_MATCH_1}")
|
2012-08-13 21:47:32 +04:00
|
|
|
string(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION "${COMPILER_VERSION}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2015-02-17 21:24:31 +03:00
|
|
|
foreach(comp MAJOR MINOR PATCH TWEAK)
|
|
|
|
foreach(digit 1 2 3 4 5 6 7 8 9)
|
|
|
|
if("${info}" MATCHES "INFO:compiler_version_${comp}_digit_${digit}\\[([0-9])\\]")
|
|
|
|
set(value ${CMAKE_MATCH_1})
|
|
|
|
math(EXPR COMPILER_VERSION_${comp} "${COMPILER_VERSION_${comp}} + ${value} * ${DIGIT_VALUE_${digit}}")
|
|
|
|
set(HAVE_COMPILER_VERSION_${comp} 1)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endforeach()
|
2014-04-11 20:17:46 +04:00
|
|
|
if("${info}" MATCHES "INFO:simulate\\[([^]\"]*)\\]")
|
2013-10-04 18:10:22 +04:00
|
|
|
set(SIMULATE_ID "${CMAKE_MATCH_1}")
|
|
|
|
endif()
|
2014-04-11 20:17:46 +04:00
|
|
|
if("${info}" MATCHES "INFO:simulate_version\\[([^]\"]*)\\]")
|
2014-04-06 23:30:00 +04:00
|
|
|
string(REGEX REPLACE "^0+([0-9])" "\\1" SIMULATE_VERSION "${CMAKE_MATCH_1}")
|
2013-10-04 18:10:22 +04:00
|
|
|
string(REGEX REPLACE "\\.0+([0-9])" ".\\1" SIMULATE_VERSION "${SIMULATE_VERSION}")
|
|
|
|
endif()
|
2015-01-14 18:28:59 +03:00
|
|
|
if("${info}" MATCHES "INFO:qnxnto\\[\\]")
|
2014-01-20 20:57:40 +04:00
|
|
|
set(COMPILER_QNXNTO 1)
|
|
|
|
endif()
|
2015-09-15 20:42:26 +03:00
|
|
|
if("${info}" MATCHES "INFO:dialect_default\\[([^]\"]*)\\]")
|
|
|
|
set(CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT "${CMAKE_MATCH_1}")
|
|
|
|
endif()
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2008-01-07 18:27:28 +03:00
|
|
|
|
2015-02-17 21:24:31 +03:00
|
|
|
# Construct compiler version from components if needed.
|
|
|
|
if(NOT DEFINED COMPILER_VERSION AND HAVE_COMPILER_VERSION_MAJOR)
|
|
|
|
set(COMPILER_VERSION "${COMPILER_VERSION_MAJOR}")
|
|
|
|
if(HAVE_COMPILER_VERSION_MINOR)
|
|
|
|
set(COMPILER_VERSION "${COMPILER_VERSION}.${COMPILER_VERSION_MINOR}")
|
|
|
|
if(HAVE_COMPILER_VERSION_PATCH)
|
|
|
|
set(COMPILER_VERSION "${COMPILER_VERSION}.${COMPILER_VERSION_PATCH}")
|
|
|
|
if(HAVE_COMPILER_VERSION_TWEAK)
|
|
|
|
set(COMPILER_VERSION "${COMPILER_VERSION}.${COMPILER_VERSION_TWEAK}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2013-08-05 22:04:44 +04:00
|
|
|
# Detect the exact architecture from the PE header.
|
|
|
|
if(WIN32)
|
|
|
|
# The offset to the PE signature is stored at 0x3c.
|
|
|
|
file(READ ${file} peoffsethex LIMIT 1 OFFSET 60 HEX)
|
|
|
|
string(SUBSTRING "${peoffsethex}" 0 1 peoffsethex1)
|
|
|
|
string(SUBSTRING "${peoffsethex}" 1 1 peoffsethex2)
|
|
|
|
set(peoffsetexpression "${peoffsethex1} * 16 + ${peoffsethex2}")
|
|
|
|
string(REPLACE "a" "10" peoffsetexpression "${peoffsetexpression}")
|
|
|
|
string(REPLACE "b" "11" peoffsetexpression "${peoffsetexpression}")
|
|
|
|
string(REPLACE "c" "12" peoffsetexpression "${peoffsetexpression}")
|
|
|
|
string(REPLACE "d" "13" peoffsetexpression "${peoffsetexpression}")
|
|
|
|
string(REPLACE "e" "14" peoffsetexpression "${peoffsetexpression}")
|
|
|
|
string(REPLACE "f" "15" peoffsetexpression "${peoffsetexpression}")
|
|
|
|
math(EXPR peoffset "${peoffsetexpression}")
|
|
|
|
|
|
|
|
file(READ ${file} peheader LIMIT 6 OFFSET ${peoffset} HEX)
|
|
|
|
if(peheader STREQUAL "50450000a201")
|
|
|
|
set(ARCHITECTURE_ID "SH3")
|
|
|
|
elseif(peheader STREQUAL "50450000a301")
|
|
|
|
set(ARCHITECTURE_ID "SH3DSP")
|
|
|
|
elseif(peheader STREQUAL "50450000a601")
|
|
|
|
set(ARCHITECTURE_ID "SH4")
|
|
|
|
elseif(peheader STREQUAL "50450000a801")
|
|
|
|
set(ARCHITECTURE_ID "SH5")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-09-30 20:42:50 +03:00
|
|
|
if(UNIX)
|
|
|
|
execute_process(COMMAND file "${file}" OUTPUT_VARIABLE out ERROR_VARIABLE out)
|
|
|
|
if(out MATCHES "statically linked")
|
|
|
|
set(CMAKE_${lang}_COMPILER_LINKS_STATICALLY 1 PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2008-01-07 18:27:28 +03:00
|
|
|
# Check if a valid compiler and platform were found.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(COMPILER_ID AND NOT COMPILER_ID_TWICE)
|
|
|
|
set(CMAKE_${lang}_COMPILER_ID "${COMPILER_ID}")
|
|
|
|
set(CMAKE_${lang}_PLATFORM_ID "${PLATFORM_ID}")
|
|
|
|
set(MSVC_${lang}_ARCHITECTURE_ID "${ARCHITECTURE_ID}")
|
|
|
|
set(CMAKE_${lang}_COMPILER_VERSION "${COMPILER_VERSION}")
|
2013-10-04 18:10:22 +04:00
|
|
|
set(CMAKE_${lang}_SIMULATE_ID "${SIMULATE_ID}")
|
|
|
|
set(CMAKE_${lang}_SIMULATE_VERSION "${SIMULATE_VERSION}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-01-07 18:27:28 +03:00
|
|
|
|
|
|
|
# Check the compiler identification string.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CMAKE_${lang}_COMPILER_ID)
|
2008-01-07 18:27:28 +03:00
|
|
|
# The compiler identification was found.
|
2012-08-13 21:47:32 +04:00
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
2008-01-07 18:27:28 +03:00
|
|
|
"The ${lang} compiler identification is ${CMAKE_${lang}_COMPILER_ID}, found in \""
|
|
|
|
"${file}\"\n\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2008-01-07 18:27:28 +03:00
|
|
|
# The compiler identification could not be found.
|
2012-08-13 21:47:32 +04:00
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2008-01-07 18:27:28 +03:00
|
|
|
"The ${lang} compiler identification could not be found in \""
|
|
|
|
"${file}\"\n\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2008-01-07 18:27:28 +03:00
|
|
|
|
|
|
|
# try to figure out the executable format: ELF, COFF, Mach-O
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT CMAKE_EXECUTABLE_FORMAT)
|
|
|
|
file(READ ${file} CMAKE_EXECUTABLE_MAGIC LIMIT 4 HEX)
|
2008-01-07 18:27:28 +03:00
|
|
|
|
|
|
|
# ELF files start with 0x7f"ELF"
|
2012-08-13 21:47:32 +04:00
|
|
|
if("${CMAKE_EXECUTABLE_MAGIC}" STREQUAL "7f454c46")
|
|
|
|
set(CMAKE_EXECUTABLE_FORMAT "ELF" CACHE INTERNAL "Executable file format")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-01-07 18:27:28 +03:00
|
|
|
|
|
|
|
# # COFF (.exe) files start with "MZ"
|
2012-08-13 21:47:32 +04:00
|
|
|
# if("${CMAKE_EXECUTABLE_MAGIC}" MATCHES "4d5a....")
|
|
|
|
# set(CMAKE_EXECUTABLE_FORMAT "COFF" CACHE STRING "Executable file format")
|
2012-08-13 21:50:14 +04:00
|
|
|
# endif()
|
2008-01-07 18:27:28 +03:00
|
|
|
#
|
|
|
|
# # Mach-O files start with CAFEBABE or FEEDFACE, according to http://radio.weblogs.com/0100490/2003/01/28.html
|
2012-08-13 21:47:32 +04:00
|
|
|
# if("${CMAKE_EXECUTABLE_MAGIC}" MATCHES "cafebabe")
|
|
|
|
# set(CMAKE_EXECUTABLE_FORMAT "MACHO" CACHE STRING "Executable file format")
|
2012-08-13 21:50:14 +04:00
|
|
|
# endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
# if("${CMAKE_EXECUTABLE_MAGIC}" MATCHES "feedface")
|
|
|
|
# set(CMAKE_EXECUTABLE_FORMAT "MACHO" CACHE STRING "Executable file format")
|
2012-08-13 21:50:14 +04:00
|
|
|
# endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT DEFINED CMAKE_EXECUTABLE_FORMAT)
|
|
|
|
set(CMAKE_EXECUTABLE_FORMAT)
|
|
|
|
endif()
|
2008-01-07 18:27:28 +03:00
|
|
|
# Return the information extracted.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE)
|
|
|
|
set(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE)
|
|
|
|
set(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}"
|
2009-11-20 05:58:42 +03:00
|
|
|
PARENT_SCOPE)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE)
|
2013-10-04 18:10:22 +04:00
|
|
|
set(CMAKE_${lang}_SIMULATE_ID "${CMAKE_${lang}_SIMULATE_ID}" PARENT_SCOPE)
|
|
|
|
set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE)
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE)
|
2014-01-20 20:57:40 +04:00
|
|
|
set(COMPILER_QNXNTO "${COMPILER_QNXNTO}" PARENT_SCOPE)
|
2015-09-15 20:42:26 +03:00
|
|
|
set(CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT "${CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT}" PARENT_SCOPE)
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2010-02-01 17:03:05 +03:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Function to query the compiler vendor.
|
|
|
|
# This uses a table with entries of the form
|
|
|
|
# list(APPEND CMAKE_${lang}_COMPILER_ID_VENDORS ${vendor})
|
|
|
|
# set(CMAKE_${lang}_COMPILER_ID_VENDOR_FLAGS_${vendor} -some-vendor-flag)
|
|
|
|
# set(CMAKE_${lang}_COMPILER_ID_VENDOR_REGEX_${vendor} "Some Vendor Output")
|
|
|
|
# We try running the compiler with the flag for each vendor and
|
|
|
|
# matching its regular expression in the output.
|
2012-08-13 21:47:32 +04:00
|
|
|
function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang)
|
2010-08-15 18:36:38 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT CMAKE_${lang}_COMPILER_ID_DIR)
|
2010-08-15 18:36:38 +04:00
|
|
|
# We get here when this function is called not from within CMAKE_DETERMINE_COMPILER_ID()
|
|
|
|
# This is done e.g. for detecting the compiler ID for assemblers.
|
|
|
|
# Compute the directory in which to run the test and Create a clean working directory.
|
2012-08-24 16:48:59 +04:00
|
|
|
set(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_PLATFORM_INFO_DIR}/CompilerId${lang})
|
2012-08-13 21:47:32 +04:00
|
|
|
file(REMOVE_RECURSE ${CMAKE_${lang}_COMPILER_ID_DIR})
|
|
|
|
file(MAKE_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2010-08-15 18:36:38 +04:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach(vendor ${CMAKE_${lang}_COMPILER_ID_VENDORS})
|
|
|
|
set(flags ${CMAKE_${lang}_COMPILER_ID_VENDOR_FLAGS_${vendor}})
|
|
|
|
set(regex ${CMAKE_${lang}_COMPILER_ID_VENDOR_REGEX_${vendor}})
|
|
|
|
execute_process(
|
2013-10-22 22:05:23 +04:00
|
|
|
COMMAND "${CMAKE_${lang}_COMPILER}"
|
2010-02-01 17:03:05 +03:00
|
|
|
${CMAKE_${lang}_COMPILER_ID_ARG1}
|
|
|
|
${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}
|
|
|
|
${flags}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}
|
|
|
|
OUTPUT_VARIABLE output ERROR_VARIABLE output
|
|
|
|
RESULT_VARIABLE result
|
2010-08-17 23:40:45 +04:00
|
|
|
TIMEOUT 10
|
2010-02-01 17:03:05 +03:00
|
|
|
)
|
2011-03-01 23:41:02 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if("${output}" MATCHES "${regex}")
|
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
2010-02-01 17:03:05 +03:00
|
|
|
"Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
|
|
|
|
"matched \"${regex}\":\n${output}")
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_${lang}_COMPILER_ID "${vendor}" PARENT_SCOPE)
|
|
|
|
break()
|
|
|
|
else()
|
|
|
|
if("${result}" MATCHES "timeout")
|
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2010-08-17 23:40:45 +04:00
|
|
|
"Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
|
|
|
|
"terminated after 10 s due to timeout.")
|
2012-08-13 21:47:32 +04:00
|
|
|
else()
|
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2010-08-17 23:40:45 +04:00
|
|
|
"Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
|
|
|
|
"did not match \"${regex}\":\n${output}")
|
2012-08-13 21:47:32 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|
2015-09-18 16:09:07 +03:00
|
|
|
|
|
|
|
function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang)
|
|
|
|
# Run this MSVC-compatible compiler to detect what the /showIncludes
|
|
|
|
# option displays. We can use a C source even with the C++ compiler
|
|
|
|
# because MSVC-compatible compilers handle both and show the same output.
|
|
|
|
set(showdir ${CMAKE_BINARY_DIR}/CMakeFiles/ShowIncludes)
|
|
|
|
file(WRITE ${showdir}/foo.h "\n")
|
|
|
|
file(WRITE ${showdir}/main.c "#include \"foo.h\" \nint main(){}\n")
|
|
|
|
execute_process(
|
|
|
|
COMMAND "${CMAKE_${lang}_COMPILER}"
|
|
|
|
${CMAKE_${lang}_COMPILER_ID_ARG1}
|
|
|
|
${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}
|
|
|
|
/nologo /showIncludes /c main.c
|
|
|
|
WORKING_DIRECTORY ${showdir}
|
|
|
|
OUTPUT_VARIABLE out
|
|
|
|
ERROR_VARIABLE err
|
|
|
|
RESULT_VARIABLE res
|
|
|
|
)
|
|
|
|
if(res EQUAL 0 AND "${out}" MATCHES "\n([^:]*:[^:]*:[ \t]*)")
|
|
|
|
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_MATCH_1}" PARENT_SCOPE)
|
|
|
|
else()
|
|
|
|
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "" PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endfunction()
|