2 # Function to compile a source file to identify the compiler ABI.
3 # This is used internally by CMake and should not be included by user
6 FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src)
7 IF(NOT DEFINED CMAKE_DETERMINE_${lang}_ABI_COMPILED)
8 MESSAGE(STATUS "Detecting ${lang} compiler info")
10 # Compile the ABI identification source.
11 SET(BIN "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeDetermineCompilerABI_${lang}.bin")
12 TRY_COMPILE(CMAKE_DETERMINE_${lang}_ABI_COMPILED
13 ${CMAKE_BINARY_DIR} ${src}
14 OUTPUT_VARIABLE OUTPUT
18 # Load the resulting information strings.
19 IF(CMAKE_DETERMINE_${lang}_ABI_COMPILED)
20 MESSAGE(STATUS "Detecting ${lang} compiler info - done")
21 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
22 "Detecting ${lang} compiler info compiled with the following output:\n${OUTPUT}\n\n")
23 FILE(STRINGS "${BIN}" ABI_STRINGS LIMIT_COUNT 2 REGEX "INFO:[^[]*\\[")
24 FOREACH(info ${ABI_STRINGS})
25 IF("${info}" MATCHES ".*INFO:sizeof_dptr\\[0*([^]]*)\\].*")
26 STRING(REGEX REPLACE ".*INFO:sizeof_dptr\\[0*([^]]*)\\].*" "\\1" ABI_SIZEOF_DPTR "${info}")
27 ENDIF("${info}" MATCHES ".*INFO:sizeof_dptr\\[0*([^]]*)\\].*")
28 IF("${info}" MATCHES ".*INFO:abi\\[([^]]*)\\].*")
29 STRING(REGEX REPLACE ".*INFO:abi\\[([^]]*)\\].*" "\\1" ABI_NAME "${info}")
30 ENDIF("${info}" MATCHES ".*INFO:abi\\[([^]]*)\\].*")
34 SET(CMAKE_${lang}_SIZEOF_DATA_PTR "${ABI_SIZEOF_DPTR}" PARENT_SCOPE)
35 SET(CMAKE_SIZEOF_VOID_P "${ABI_SIZEOF_DPTR}" PARENT_SCOPE)
36 ENDIF(ABI_SIZEOF_DPTR)
39 SET(CMAKE_${lang}_COMPILER_ABI "${ABI_NAME}" PARENT_SCOPE)
40 SET(CMAKE_INTERNAL_PLATFORM_ABI "${ABI_NAME}" PARENT_SCOPE)
43 ELSE(CMAKE_DETERMINE_${lang}_ABI_COMPILED)
44 MESSAGE(STATUS "Detecting ${lang} compiler info - failed")
45 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
46 "Detecting ${lang} compiler info failed to compile with the following output:\n${OUTPUT}\n\n")
47 ENDIF(CMAKE_DETERMINE_${lang}_ABI_COMPILED)
48 ENDIF(NOT DEFINED CMAKE_DETERMINE_${lang}_ABI_COMPILED)
49 ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ABI)