2008-01-22 02:30:17 +03:00
|
|
|
|
2009-09-28 19:46:51 +04:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2008-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-22 02:30:17 +03:00
|
|
|
# Function to compile a source file to identify the compiler ABI.
|
|
|
|
# This is used internally by CMake and should not be included by user
|
|
|
|
# code.
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake)
|
2009-07-23 18:07:25 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
function(CMAKE_DETERMINE_COMPILER_ABI lang src)
|
2012-08-24 23:15:14 +04:00
|
|
|
if(NOT DEFINED CMAKE_${lang}_ABI_COMPILED)
|
2012-08-13 21:47:32 +04:00
|
|
|
message(STATUS "Detecting ${lang} compiler ABI info")
|
2008-01-22 02:30:17 +03:00
|
|
|
|
|
|
|
# Compile the ABI identification source.
|
2012-08-24 16:48:59 +04:00
|
|
|
set(BIN "${CMAKE_PLATFORM_INFO_DIR}/CMakeDetermineCompilerABI_${lang}.bin")
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_FLAGS )
|
|
|
|
if(DEFINED CMAKE_${lang}_VERBOSE_FLAG)
|
|
|
|
set(CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}")
|
|
|
|
endif()
|
2013-05-19 21:18:01 +04:00
|
|
|
if(CMAKE_${lang}_COMPILER_TARGET)
|
|
|
|
set(CMAKE_FLAGS "${CMAKE_FLAGS} -DCMAKE_${lang}_COMPILER_TARGET=${CMAKE_${lang}_COMPILER_TARGET}")
|
|
|
|
endif()
|
2012-08-24 23:15:14 +04:00
|
|
|
try_compile(CMAKE_${lang}_ABI_COMPILED
|
2008-01-22 02:30:17 +03:00
|
|
|
${CMAKE_BINARY_DIR} ${src}
|
2010-07-12 23:48:51 +04:00
|
|
|
CMAKE_FLAGS "${CMAKE_FLAGS}"
|
2009-07-23 18:07:25 +04:00
|
|
|
"-DCMAKE_${lang}_STANDARD_LIBRARIES="
|
2010-09-17 01:49:37 +04:00
|
|
|
# We need ignore these warnings because some platforms need
|
|
|
|
# CMAKE_${lang}_STANDARD_LIBRARIES to link properly and we
|
|
|
|
# don't care when we are just determining the ABI.
|
|
|
|
"--no-warn-unused-cli"
|
2008-01-22 02:30:17 +03:00
|
|
|
OUTPUT_VARIABLE OUTPUT
|
|
|
|
COPY_FILE "${BIN}"
|
|
|
|
)
|
2012-08-24 23:15:14 +04:00
|
|
|
# Move result from cache to normal variable.
|
|
|
|
set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED})
|
|
|
|
unset(CMAKE_${lang}_ABI_COMPILED CACHE)
|
|
|
|
set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED} PARENT_SCOPE)
|
2008-01-22 02:30:17 +03:00
|
|
|
|
|
|
|
# Load the resulting information strings.
|
2012-08-24 23:15:14 +04:00
|
|
|
if(CMAKE_${lang}_ABI_COMPILED)
|
2012-08-13 21:47:32 +04:00
|
|
|
message(STATUS "Detecting ${lang} compiler ABI info - done")
|
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
2008-04-14 23:25:57 +04:00
|
|
|
"Detecting ${lang} compiler ABI info compiled with the following output:\n${OUTPUT}\n\n")
|
2012-08-13 21:47:32 +04:00
|
|
|
file(STRINGS "${BIN}" ABI_STRINGS LIMIT_COUNT 2 REGEX "INFO:[^[]*\\[")
|
|
|
|
foreach(info ${ABI_STRINGS})
|
|
|
|
if("${info}" MATCHES ".*INFO:sizeof_dptr\\[0*([^]]*)\\].*")
|
|
|
|
string(REGEX REPLACE ".*INFO:sizeof_dptr\\[0*([^]]*)\\].*" "\\1" ABI_SIZEOF_DPTR "${info}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
if("${info}" MATCHES ".*INFO:abi\\[([^]]*)\\].*")
|
|
|
|
string(REGEX REPLACE ".*INFO:abi\\[([^]]*)\\].*" "\\1" ABI_NAME "${info}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2008-01-22 02:30:17 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(ABI_SIZEOF_DPTR)
|
|
|
|
set(CMAKE_${lang}_SIZEOF_DATA_PTR "${ABI_SIZEOF_DPTR}" PARENT_SCOPE)
|
|
|
|
elseif(CMAKE_${lang}_SIZEOF_DATA_PTR_DEFAULT)
|
|
|
|
set(CMAKE_${lang}_SIZEOF_DATA_PTR "${CMAKE_${lang}_SIZEOF_DATA_PTR_DEFAULT}" PARENT_SCOPE)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-01-22 02:30:17 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(ABI_NAME)
|
|
|
|
set(CMAKE_${lang}_COMPILER_ABI "${ABI_NAME}" PARENT_SCOPE)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2008-01-22 02:30:17 +03:00
|
|
|
|
2009-07-23 18:07:25 +04:00
|
|
|
# Parse implicit linker information for this language, if available.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(implicit_dirs "")
|
|
|
|
set(implicit_libs "")
|
2012-12-05 22:46:04 +04:00
|
|
|
set(implicit_fwks "")
|
2012-12-05 20:49:13 +04:00
|
|
|
if(CMAKE_${lang}_VERBOSE_FLAG)
|
2012-12-05 22:46:04 +04:00
|
|
|
CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs implicit_fwks log
|
2010-12-10 01:07:34 +03:00
|
|
|
"${CMAKE_${lang}_IMPLICIT_OBJECT_REGEX}")
|
2012-08-13 21:47:32 +04:00
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
2009-10-06 23:16:12 +04:00
|
|
|
"Parsed ${lang} implicit link information from above output:\n${log}\n\n")
|
2012-08-13 21:47:32 +04:00
|
|
|
endif()
|
2011-09-09 01:42:49 +04:00
|
|
|
# for VS IDE Intel Fortran we have to figure out the
|
|
|
|
# implicit link path for the fortran run time using
|
|
|
|
# a try-compile
|
2012-08-13 21:47:32 +04:00
|
|
|
if("${lang}" MATCHES "Fortran"
|
2011-09-09 01:42:49 +04:00
|
|
|
AND "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_desc "Determine Intel Fortran Compiler Implicit Link Path")
|
|
|
|
message(STATUS "${_desc}")
|
2011-09-09 01:42:49 +04:00
|
|
|
# Build a sample project which reports symbols.
|
2012-08-13 21:47:32 +04:00
|
|
|
try_compile(IFORT_LIB_PATH_COMPILED
|
2011-09-09 01:42:49 +04:00
|
|
|
${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath
|
2011-09-14 21:49:40 +04:00
|
|
|
${CMAKE_ROOT}/Modules/IntelVSImplicitPath
|
2011-09-09 01:42:49 +04:00
|
|
|
IntelFortranImplicit
|
|
|
|
CMAKE_FLAGS
|
|
|
|
"-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}"
|
|
|
|
OUTPUT_VARIABLE _output)
|
2012-08-13 21:47:32 +04:00
|
|
|
file(WRITE
|
2011-09-09 01:42:49 +04:00
|
|
|
"${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/output.txt"
|
|
|
|
"${_output}")
|
2012-08-13 21:47:32 +04:00
|
|
|
include(${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/output.cmake OPTIONAL)
|
|
|
|
set(_desc "Determine Intel Fortran Compiler Implicit Link Path -- done")
|
|
|
|
message(STATUS "${_desc}")
|
|
|
|
endif()
|
2011-09-09 01:42:49 +04:00
|
|
|
|
2012-12-05 20:49:13 +04:00
|
|
|
# Implicit link libraries cannot be used explicitly for multiple
|
|
|
|
# OS X architectures, so we skip it.
|
|
|
|
if(DEFINED CMAKE_OSX_ARCHITECTURES)
|
|
|
|
if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ";")
|
|
|
|
set(implicit_libs "")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES "${implicit_libs}" PARENT_SCOPE)
|
|
|
|
set(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE)
|
2012-12-05 22:46:04 +04:00
|
|
|
set(CMAKE_${lang}_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${implicit_fwks}" PARENT_SCOPE)
|
2009-07-23 18:07:25 +04:00
|
|
|
|
2011-06-08 16:46:31 +04:00
|
|
|
# Detect library architecture directory name.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(CMAKE_LIBRARY_ARCHITECTURE_REGEX)
|
|
|
|
foreach(dir ${implicit_dirs})
|
|
|
|
if("${dir}" MATCHES "/lib/${CMAKE_LIBRARY_ARCHITECTURE_REGEX}$")
|
|
|
|
get_filename_component(arch "${dir}" NAME)
|
|
|
|
set(CMAKE_${lang}_LIBRARY_ARCHITECTURE "${arch}" PARENT_SCOPE)
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2011-06-08 16:46:31 +04:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message(STATUS "Detecting ${lang} compiler ABI info - failed")
|
|
|
|
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
2008-04-14 23:25:57 +04:00
|
|
|
"Detecting ${lang} compiler ABI info failed to compile with the following output:\n${OUTPUT}\n\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endfunction()
|