summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCompilerId.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/CMakeDetermineCompilerId.cmake')
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake30
1 files changed, 24 insertions, 6 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 4a800a8..bf78a5b 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -9,7 +9,7 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
-# (To distributed this file outside of CMake, substitute the full
+# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# Function to compile a source file to identify the compiler. This is
@@ -63,7 +63,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
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}"
+ SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}"
PARENT_SCOPE)
ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID)
@@ -247,7 +247,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
# Return the information extracted.
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}"
+ SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}"
PARENT_SCOPE)
SET(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE)
ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang)
@@ -261,6 +261,17 @@ ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang)
# We try running the compiler with the flag for each vendor and
# matching its regular expression in the output.
FUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang)
+
+ IF(NOT CMAKE_${lang}_COMPILER_ID_DIR)
+ # 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.
+ SET(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CompilerId${lang})
+ FILE(REMOVE_RECURSE ${CMAKE_${lang}_COMPILER_ID_DIR})
+ FILE(MAKE_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR})
+ ENDIF(NOT CMAKE_${lang}_COMPILER_ID_DIR)
+
+
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}})
@@ -272,6 +283,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang)
WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}
OUTPUT_VARIABLE output ERROR_VARIABLE output
RESULT_VARIABLE result
+ TIMEOUT 10
)
IF("${output}" MATCHES "${regex}")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
@@ -280,9 +292,15 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang)
SET(CMAKE_${lang}_COMPILER_ID "${vendor}" PARENT_SCOPE)
BREAK()
ELSE()
- FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
- "did not match \"${regex}\":\n${output}")
+ IF("${result}" MATCHES "timeout")
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.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
+ "Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
+ "did not match \"${regex}\":\n${output}")
+ ENDIF()
ENDIF()
ENDFOREACH()
ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR)