|
|
@@ -2,6 +2,8 @@
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
|
macro(__determine_compiler_id_test testflags_var userflags_var)
|
|
|
+ set(_CMAKE_${lang}_COMPILER_ID_LOG "")
|
|
|
+
|
|
|
separate_arguments(testflags UNIX_COMMAND "${${testflags_var}}")
|
|
|
CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${testflags}" "${${userflags_var}}" "${src}")
|
|
|
CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR("${lang}" "${COMPILER_${lang}_PRODUCED_OUTPUT}")
|
|
|
@@ -11,6 +13,9 @@ macro(__determine_compiler_id_test testflags_var userflags_var)
|
|
|
CMAKE_DETERMINE_COMPILER_ID_CHECK("${lang}" "${CMAKE_${lang}_COMPILER_ID_DIR}/${file}" "${src}")
|
|
|
endforeach()
|
|
|
endif()
|
|
|
+
|
|
|
+ message(CONFIGURE_LOG "${_CMAKE_${lang}_COMPILER_ID_LOG}")
|
|
|
+ unset(_CMAKE_${lang}_COMPILER_ID_LOG)
|
|
|
endmacro()
|
|
|
|
|
|
# Function to compile a source file to identify the compiler. This is
|
|
|
@@ -85,8 +90,6 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
|
|
|
# If the compiler is still unknown, fallback to GHS
|
|
|
if(NOT CMAKE_${lang}_COMPILER_ID AND "${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI")
|
|
|
set(CMAKE_${lang}_COMPILER_ID GHS)
|
|
|
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
|
|
- "The ${lang} compiler identification is falling back to GHS.\n\n")
|
|
|
endif()
|
|
|
|
|
|
# CUDA < 7.5 is missing version macros
|
|
|
@@ -116,7 +119,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
|
|
|
RESULT_VARIABLE result
|
|
|
TIMEOUT 10
|
|
|
)
|
|
|
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
|
|
+ message(CONFIGURE_LOG
|
|
|
"Running the ${lang} compiler: \"${CMAKE_${lang}_COMPILER}\" -version\n"
|
|
|
"${output}\n"
|
|
|
)
|
|
|
@@ -140,7 +143,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
|
|
|
RESULT_VARIABLE result
|
|
|
TIMEOUT 10
|
|
|
)
|
|
|
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
|
|
+ message(CONFIGURE_LOG
|
|
|
"Running the ${lang} compiler: \"${CMAKE_${lang}_COMPILER}\" -version\n"
|
|
|
"${output}\n"
|
|
|
)
|
|
|
@@ -160,7 +163,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
|
|
|
RESULT_VARIABLE result
|
|
|
TIMEOUT 10
|
|
|
)
|
|
|
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
|
|
+ message(CONFIGURE_LOG
|
|
|
"Running the ${lang} compiler: \"${CMAKE_${lang}_COMPILER}\" --version\n"
|
|
|
"${output}\n"
|
|
|
)
|
|
|
@@ -724,7 +727,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
|
|
|
OR CMAKE_${lang}_COMPILER_ID_OUTPUT MATCHES "warning #5117: Bad # preprocessor line"
|
|
|
)
|
|
|
# Compilation failed.
|
|
|
- string(APPEND _CMAKE_DETERMINE_COMPILER_ID_BUILD_MSG
|
|
|
+ set(MSG
|
|
|
"Compiling the ${lang} compiler identification source file \"${src}\" failed.
|
|
|
${COMPILER_DESCRIPTION}
|
|
|
The output was:
|
|
|
@@ -734,14 +737,16 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
|
|
|
")
|
|
|
# Log the output unless we recognize it as a known-bad case.
|
|
|
if(NOT CMAKE_${lang}_COMPILER_ID_OUTPUT MATCHES "warning #5117: Bad # preprocessor line")
|
|
|
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "${MSG}")
|
|
|
+ string(APPEND _CMAKE_${lang}_COMPILER_ID_LOG "${MSG}")
|
|
|
endif()
|
|
|
|
|
|
+ string(APPEND _CMAKE_DETERMINE_COMPILER_ID_BUILD_MSG "${MSG}")
|
|
|
+
|
|
|
# Some languages may know the correct/desired set of flags and want to fail right away if they don't work.
|
|
|
# This is currently only used by CUDA.
|
|
|
if(__compiler_id_require_success)
|
|
|
message(FATAL_ERROR "${_CMAKE_DETERMINE_COMPILER_ID_BUILD_MSG}")
|
|
|
- else()
|
|
|
+ elseif(CMAKE_${lang}_COMPILER_ID_REQUIRE_SUCCESS)
|
|
|
# Build up the outputs for compiler detection attempts so that users
|
|
|
# can see all set of flags tried, instead of just last
|
|
|
set(_CMAKE_DETERMINE_COMPILER_ID_BUILD_MSG "${_CMAKE_DETERMINE_COMPILER_ID_BUILD_MSG}" PARENT_SCOPE)
|
|
|
@@ -752,7 +757,7 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
|
|
|
set(COMPILER_${lang}_PRODUCED_OUTPUT)
|
|
|
else()
|
|
|
# Compilation succeeded.
|
|
|
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
|
|
+ string(APPEND _CMAKE_${lang}_COMPILER_ID_LOG
|
|
|
"Compiling the ${lang} compiler identification source file \"${src}\" succeeded.
|
|
|
${COMPILER_DESCRIPTION}
|
|
|
The output was:
|
|
|
@@ -781,7 +786,7 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
|
|
|
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
|
|
|
+ string(APPEND _CMAKE_${lang}_COMPILER_ID_LOG
|
|
|
"Compilation of the ${lang} compiler identification source \""
|
|
|
"${src}\" produced \"${file}\"\n\n")
|
|
|
endif()
|
|
|
@@ -789,7 +794,7 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
|
|
|
|
|
|
if(NOT COMPILER_${lang}_PRODUCED_FILES)
|
|
|
# No executable was found.
|
|
|
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
|
|
+ string(APPEND _CMAKE_${lang}_COMPILER_ID_LOG
|
|
|
"Compilation of the ${lang} compiler identification source \""
|
|
|
"${src}\" did not produce an executable in \""
|
|
|
"${CMAKE_${lang}_COMPILER_ID_DIR}\".\n\n")
|
|
|
@@ -801,6 +806,7 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
|
|
|
# Return the files produced by the compilation.
|
|
|
set(COMPILER_${lang}_PRODUCED_FILES "${COMPILER_${lang}_PRODUCED_FILES}" PARENT_SCOPE)
|
|
|
set(COMPILER_${lang}_PRODUCED_OUTPUT "${COMPILER_${lang}_PRODUCED_OUTPUT}" PARENT_SCOPE)
|
|
|
+ set(_CMAKE_${lang}_COMPILER_ID_LOG "${_CMAKE_${lang}_COMPILER_ID_LOG}" PARENT_SCOPE)
|
|
|
|
|
|
endfunction()
|
|
|
|
|
|
@@ -994,15 +1000,16 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
|
|
|
# Check the compiler identification string.
|
|
|
if(CMAKE_${lang}_COMPILER_ID)
|
|
|
# The compiler identification was found.
|
|
|
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
|
|
- "The ${lang} compiler identification is ${CMAKE_${lang}_COMPILER_ID}, found in \""
|
|
|
- "${file}\"\n\n")
|
|
|
+ string(APPEND _CMAKE_${lang}_COMPILER_ID_LOG
|
|
|
+ "The ${lang} compiler identification is ${CMAKE_${lang}_COMPILER_ID}, found in:\n"
|
|
|
+ " ${file}\n\n")
|
|
|
else()
|
|
|
# The compiler identification could not be found.
|
|
|
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
|
|
- "The ${lang} compiler identification could not be found in \""
|
|
|
- "${file}\"\n\n")
|
|
|
+ string(APPEND _CMAKE_${lang}_COMPILER_ID_LOG
|
|
|
+ "The ${lang} compiler identification could not be found in:\n"
|
|
|
+ " ${file}\n\n")
|
|
|
endif()
|
|
|
+ set(_CMAKE_${lang}_COMPILER_ID_LOG "${_CMAKE_${lang}_COMPILER_ID_LOG}" PARENT_SCOPE)
|
|
|
endif()
|
|
|
|
|
|
# try to figure out the executable format: ELF, COFF, Mach-O
|
|
|
@@ -1089,7 +1096,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang userflags)
|
|
|
)
|
|
|
|
|
|
if("${output}" MATCHES "${regex}")
|
|
|
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
|
|
+ message(CONFIGURE_LOG
|
|
|
"Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
|
|
|
"matched \"${regex}\":\n${output}")
|
|
|
set(CMAKE_${lang}_COMPILER_ID "${vendor}" PARENT_SCOPE)
|
|
|
@@ -1098,11 +1105,11 @@ function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang userflags)
|
|
|
break()
|
|
|
else()
|
|
|
if("${result}" MATCHES "timeout")
|
|
|
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
|
|
+ message(CONFIGURE_LOG
|
|
|
"Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
|
|
|
"terminated after 10 s due to timeout.")
|
|
|
else()
|
|
|
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
|
|
+ message(CONFIGURE_LOG
|
|
|
"Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
|
|
|
"did not match \"${regex}\":\n${output}")
|
|
|
endif()
|