Merge topic 'reduce-initial-checks'

1d21dd0f7c enable_language: Assume compiler works if ABI detection compiles
7a01250581 CMakeDetermineCompilerABI: Fold copy error into CMAKE_<LANG>_ABI_COMPILED

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4789
This commit is contained in:
Brad King 2020-05-26 13:26:01 +00:00 committed by Kitware Robot
commit 7c0e5fcf63
7 changed files with 280 additions and 273 deletions

View File

@ -65,10 +65,13 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
# Move result from cache to normal variable. # Move result from cache to normal variable.
set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED}) set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED})
unset(CMAKE_${lang}_ABI_COMPILED CACHE) unset(CMAKE_${lang}_ABI_COMPILED CACHE)
if(CMAKE_${lang}_ABI_COMPILED AND _copy_error)
set(CMAKE_${lang}_ABI_COMPILED 0)
endif()
set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED} PARENT_SCOPE) set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED} PARENT_SCOPE)
# Load the resulting information strings. # Load the resulting information strings.
if(CMAKE_${lang}_ABI_COMPILED AND NOT _copy_error) if(CMAKE_${lang}_ABI_COMPILED)
message(CHECK_PASS "done") message(CHECK_PASS "done")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Detecting ${lang} compiler ABI info compiled with the following output:\n${OUTPUT}\n\n") "Detecting ${lang} compiler ABI info compiled with the following output:\n${OUTPUT}\n\n")

View File

@ -21,6 +21,15 @@ endif()
# We now store this in CMakeCCompiler.cmake. # We now store this in CMakeCCompiler.cmake.
unset(CMAKE_C_COMPILER_WORKS CACHE) unset(CMAKE_C_COMPILER_WORKS CACHE)
# Try to identify the ABI and configure it into CMakeCCompiler.cmake
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
CMAKE_DETERMINE_COMPILER_ABI(C ${CMAKE_ROOT}/Modules/CMakeCCompilerABI.c)
if(CMAKE_C_ABI_COMPILED)
# The compiler worked so skip dedicated test below.
set(CMAKE_C_COMPILER_WORKS TRUE)
message(STATUS "Check for working C compiler: ${CMAKE_C_COMPILER} - skipped")
endif()
# This file is used by EnableLanguage in cmGlobalGenerator to # This file is used by EnableLanguage in cmGlobalGenerator to
# determine that that selected C compiler can actually compile # determine that that selected C compiler can actually compile
# and link the most basic of programs. If not, a fatal error # and link the most basic of programs. If not, a fatal error
@ -47,49 +56,41 @@ if(NOT CMAKE_C_COMPILER_WORKS)
# Move result from cache to normal variable. # Move result from cache to normal variable.
set(CMAKE_C_COMPILER_WORKS ${CMAKE_C_COMPILER_WORKS}) set(CMAKE_C_COMPILER_WORKS ${CMAKE_C_COMPILER_WORKS})
unset(CMAKE_C_COMPILER_WORKS CACHE) unset(CMAKE_C_COMPILER_WORKS CACHE)
set(C_TEST_WAS_RUN 1)
__TestCompiler_restoreTryCompileTargetType() __TestCompiler_restoreTryCompileTargetType()
if(NOT CMAKE_C_COMPILER_WORKS)
PrintTestCompilerResult(CHECK_FAIL "broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the C compiler works failed with "
"the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${__CMAKE_C_COMPILER_OUTPUT}")
message(FATAL_ERROR "The C compiler\n \"${CMAKE_C_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
endif()
PrintTestCompilerResult(CHECK_PASS "works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the C compiler works passed with "
"the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n")
endif() endif()
if(NOT CMAKE_C_COMPILER_WORKS) # Try to identify the compiler features
PrintTestCompilerResult(CHECK_FAIL "broken") include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log CMAKE_DETERMINE_COMPILE_FEATURES(C)
"Determining if the C compiler works failed with "
"the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${__CMAKE_C_COMPILER_OUTPUT}")
message(FATAL_ERROR "The C compiler\n \"${CMAKE_C_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(C_TEST_WAS_RUN)
PrintTestCompilerResult(CHECK_PASS "works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the C compiler works passed with "
"the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n")
endif()
# Try to identify the ABI and configure it into CMakeCCompiler.cmake # Re-configure to save learned information.
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) configure_file(
CMAKE_DETERMINE_COMPILER_ABI(C ${CMAKE_ROOT}/Modules/CMakeCCompilerABI.c) ${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in
# Try to identify the compiler features ${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) @ONLY
CMAKE_DETERMINE_COMPILE_FEATURES(C) )
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake)
# Re-configure to save learned information. if(CMAKE_C_SIZEOF_DATA_PTR)
configure_file( foreach(f ${CMAKE_C_ABI_FILES})
${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in include(${f})
${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake endforeach()
@ONLY unset(CMAKE_C_ABI_FILES)
)
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake)
if(CMAKE_C_SIZEOF_DATA_PTR)
foreach(f ${CMAKE_C_ABI_FILES})
include(${f})
endforeach()
unset(CMAKE_C_ABI_FILES)
endif()
endif() endif()
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE})

View File

@ -14,6 +14,15 @@ include(CMakeTestCompilerCommon)
# We now store this in CMakeCUDACompiler.cmake. # We now store this in CMakeCUDACompiler.cmake.
unset(CMAKE_CUDA_COMPILER_WORKS CACHE) unset(CMAKE_CUDA_COMPILER_WORKS CACHE)
# Try to identify the ABI and configure it into CMakeCUDACompiler.cmake
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
CMAKE_DETERMINE_COMPILER_ABI(CUDA ${CMAKE_ROOT}/Modules/CMakeCUDACompilerABI.cu)
if(CMAKE_CUDA_ABI_COMPILED)
# The compiler worked so skip dedicated test below.
set(CMAKE_CUDA_COMPILER_WORKS TRUE)
message(STATUS "Check for working CUDA compiler: ${CMAKE_CUDA_COMPILER} - skipped")
endif()
# This file is used by EnableLanguage in cmGlobalGenerator to # This file is used by EnableLanguage in cmGlobalGenerator to
# determine that the selected cuda compiler can actually compile # determine that the selected cuda compiler can actually compile
# and link the most basic of programs. If not, a fatal error # and link the most basic of programs. If not, a fatal error
@ -34,65 +43,56 @@ if(NOT CMAKE_CUDA_COMPILER_WORKS)
# Move result from cache to normal variable. # Move result from cache to normal variable.
set(CMAKE_CUDA_COMPILER_WORKS ${CMAKE_CUDA_COMPILER_WORKS}) set(CMAKE_CUDA_COMPILER_WORKS ${CMAKE_CUDA_COMPILER_WORKS})
unset(CMAKE_CUDA_COMPILER_WORKS CACHE) unset(CMAKE_CUDA_COMPILER_WORKS CACHE)
set(CUDA_TEST_WAS_RUN 1) if(NOT CMAKE_CUDA_COMPILER_WORKS)
endif() PrintTestCompilerResult(CHECK_FAIL "broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
if(NOT CMAKE_CUDA_COMPILER_WORKS) "Determining if the CUDA compiler works failed with "
PrintTestCompilerResult(CHECK_FAIL "broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the CUDA compiler works failed with "
"the following output:\n${__CMAKE_CUDA_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${__CMAKE_CUDA_COMPILER_OUTPUT}")
message(FATAL_ERROR "The CUDA compiler\n \"${CMAKE_CUDA_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(CUDA_TEST_WAS_RUN)
PrintTestCompilerResult(CHECK_PASS "works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the CUDA compiler works passed with "
"the following output:\n${__CMAKE_CUDA_COMPILER_OUTPUT}\n\n") "the following output:\n${__CMAKE_CUDA_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${__CMAKE_CUDA_COMPILER_OUTPUT}")
message(FATAL_ERROR "The CUDA compiler\n \"${CMAKE_CUDA_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
endif() endif()
PrintTestCompilerResult(CHECK_PASS "works")
# Try to identify the ABI and configure it into CMakeCUDACompiler.cmake file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) "Determining if the CUDA compiler works passed with "
CMAKE_DETERMINE_COMPILER_ABI(CUDA ${CMAKE_ROOT}/Modules/CMakeCUDACompilerABI.cu) "the following output:\n${__CMAKE_CUDA_COMPILER_OUTPUT}\n\n")
# Try to identify the compiler features
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake)
CMAKE_DETERMINE_COMPILE_FEATURES(CUDA)
if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
set(CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES}")
set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}")
endif()
# Filter out implicit link libraries that should not be passed unconditionally.
# See CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE in CMakeDetermineCUDACompiler.
list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES ${CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE})
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
# Remove the CUDA Toolkit include directories from the set of
# implicit system include directories.
# This resolves the issue that NVCC doesn't specify these
# includes as SYSTEM includes when compiling device code, and sometimes
# they contain headers that generate warnings, so let users mark them
# as SYSTEM explicitly
if(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES)
list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
endif()
endif()
# Re-configure to save learned information.
configure_file(
${CMAKE_ROOT}/Modules/CMakeCUDACompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeCUDACompiler.cmake
@ONLY
)
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCUDACompiler.cmake)
endif() endif()
# Try to identify the compiler features
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake)
CMAKE_DETERMINE_COMPILE_FEATURES(CUDA)
if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
set(CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES}")
set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}")
endif()
# Filter out implicit link libraries that should not be passed unconditionally.
# See CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE in CMakeDetermineCUDACompiler.
list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES ${CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES_EXCLUDE})
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
# Remove the CUDA Toolkit include directories from the set of
# implicit system include directories.
# This resolves the issue that NVCC doesn't specify these
# includes as SYSTEM includes when compiling device code, and sometimes
# they contain headers that generate warnings, so let users mark them
# as SYSTEM explicitly
if(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES)
list(REMOVE_ITEM CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
endif()
endif()
# Re-configure to save learned information.
configure_file(
${CMAKE_ROOT}/Modules/CMakeCUDACompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeCUDACompiler.cmake
@ONLY
)
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCUDACompiler.cmake)
unset(__CMAKE_CUDA_COMPILER_OUTPUT) unset(__CMAKE_CUDA_COMPILER_OUTPUT)

View File

@ -21,6 +21,15 @@ endif()
# We now store this in CMakeCXXCompiler.cmake. # We now store this in CMakeCXXCompiler.cmake.
unset(CMAKE_CXX_COMPILER_WORKS CACHE) unset(CMAKE_CXX_COMPILER_WORKS CACHE)
# Try to identify the ABI and configure it into CMakeCXXCompiler.cmake
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
CMAKE_DETERMINE_COMPILER_ABI(CXX ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp)
if(CMAKE_CXX_ABI_COMPILED)
# The compiler worked so skip dedicated test below.
set(CMAKE_CXX_COMPILER_WORKS TRUE)
message(STATUS "Check for working CXX compiler: ${CMAKE_CXX_COMPILER} - skipped")
endif()
# This file is used by EnableLanguage in cmGlobalGenerator to # This file is used by EnableLanguage in cmGlobalGenerator to
# determine that the selected C++ compiler can actually compile # determine that the selected C++ compiler can actually compile
# and link the most basic of programs. If not, a fatal error # and link the most basic of programs. If not, a fatal error
@ -40,49 +49,41 @@ if(NOT CMAKE_CXX_COMPILER_WORKS)
# Move result from cache to normal variable. # Move result from cache to normal variable.
set(CMAKE_CXX_COMPILER_WORKS ${CMAKE_CXX_COMPILER_WORKS}) set(CMAKE_CXX_COMPILER_WORKS ${CMAKE_CXX_COMPILER_WORKS})
unset(CMAKE_CXX_COMPILER_WORKS CACHE) unset(CMAKE_CXX_COMPILER_WORKS CACHE)
set(CXX_TEST_WAS_RUN 1)
__TestCompiler_restoreTryCompileTargetType() __TestCompiler_restoreTryCompileTargetType()
if(NOT CMAKE_CXX_COMPILER_WORKS)
PrintTestCompilerResult(CHECK_FAIL "broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the CXX compiler works failed with "
"the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${__CMAKE_CXX_COMPILER_OUTPUT}")
message(FATAL_ERROR "The C++ compiler\n \"${CMAKE_CXX_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
endif()
PrintTestCompilerResult(CHECK_PASS "works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the CXX compiler works passed with "
"the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n")
endif() endif()
if(NOT CMAKE_CXX_COMPILER_WORKS) # Try to identify the compiler features
PrintTestCompilerResult(CHECK_FAIL "broken") include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log CMAKE_DETERMINE_COMPILE_FEATURES(CXX)
"Determining if the CXX compiler works failed with "
"the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${__CMAKE_CXX_COMPILER_OUTPUT}")
message(FATAL_ERROR "The C++ compiler\n \"${CMAKE_CXX_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(CXX_TEST_WAS_RUN)
PrintTestCompilerResult(CHECK_PASS "works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the CXX compiler works passed with "
"the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n")
endif()
# Try to identify the ABI and configure it into CMakeCXXCompiler.cmake # Re-configure to save learned information.
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) configure_file(
CMAKE_DETERMINE_COMPILER_ABI(CXX ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp) ${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in
# Try to identify the compiler features ${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) @ONLY
CMAKE_DETERMINE_COMPILE_FEATURES(CXX) )
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake)
# Re-configure to save learned information. if(CMAKE_CXX_SIZEOF_DATA_PTR)
configure_file( foreach(f ${CMAKE_CXX_ABI_FILES})
${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in include(${f})
${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake endforeach()
@ONLY unset(CMAKE_CXX_ABI_FILES)
)
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake)
if(CMAKE_CXX_SIZEOF_DATA_PTR)
foreach(f ${CMAKE_CXX_ABI_FILES})
include(${f})
endforeach()
unset(CMAKE_CXX_ABI_FILES)
endif()
endif() endif()
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE})

View File

@ -15,6 +15,15 @@ include(CMakeTestCompilerCommon)
# We now store this in CMakeFortranCompiler.cmake. # We now store this in CMakeFortranCompiler.cmake.
unset(CMAKE_Fortran_COMPILER_WORKS CACHE) unset(CMAKE_Fortran_COMPILER_WORKS CACHE)
# Try to identify the ABI and configure it into CMakeFortranCompiler.cmake
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
CMAKE_DETERMINE_COMPILER_ABI(Fortran ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F)
if(CMAKE_Fortran_ABI_COMPILED)
# The compiler worked so skip dedicated test below.
set(CMAKE_Fortran_COMPILER_WORKS TRUE)
message(STATUS "Check for working Fortran compiler: ${CMAKE_Fortran_COMPILER} - skipped")
endif()
# This file is used by EnableLanguage in cmGlobalGenerator to # This file is used by EnableLanguage in cmGlobalGenerator to
# determine that the selected Fortran compiler can actually compile # determine that the selected Fortran compiler can actually compile
# and link the most basic of programs. If not, a fatal error # and link the most basic of programs. If not, a fatal error
@ -33,70 +42,61 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS)
# Move result from cache to normal variable. # Move result from cache to normal variable.
set(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_Fortran_COMPILER_WORKS}) set(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_Fortran_COMPILER_WORKS})
unset(CMAKE_Fortran_COMPILER_WORKS CACHE) unset(CMAKE_Fortran_COMPILER_WORKS CACHE)
set(FORTRAN_TEST_WAS_RUN 1) if(NOT CMAKE_Fortran_COMPILER_WORKS)
endif() PrintTestCompilerResult(CHECK_FAIL "broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
if(NOT CMAKE_Fortran_COMPILER_WORKS) "Determining if the Fortran compiler works failed with "
PrintTestCompilerResult(CHECK_FAIL "broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the Fortran compiler works failed with "
"the following output:\n${OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${OUTPUT}")
message(FATAL_ERROR "The Fortran compiler\n \"${CMAKE_Fortran_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(FORTRAN_TEST_WAS_RUN)
PrintTestCompilerResult(CHECK_PASS "works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the Fortran compiler works passed with "
"the following output:\n${OUTPUT}\n\n") "the following output:\n${OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${OUTPUT}")
message(FATAL_ERROR "The Fortran compiler\n \"${CMAKE_Fortran_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
endif() endif()
PrintTestCompilerResult(CHECK_PASS "works")
# Try to identify the ABI and configure it into CMakeFortranCompiler.cmake file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) "Determining if the Fortran compiler works passed with "
CMAKE_DETERMINE_COMPILER_ABI(Fortran ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F) "the following output:\n${OUTPUT}\n\n")
endif()
# Test for Fortran 90 support by using an f90-specific construct.
if(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) # Test for Fortran 90 support by using an f90-specific construct.
message(CHECK_START "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") if(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90)
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 " message(CHECK_START "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90")
PROGRAM TESTFortran90 file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 "
integer stop ; stop = 1 ; do while ( stop .eq. 0 ) ; end do PROGRAM TESTFortran90
END PROGRAM TESTFortran90 integer stop ; stop = 1 ; do while ( stop .eq. 0 ) ; end do
") END PROGRAM TESTFortran90
try_compile(CMAKE_Fortran_COMPILER_SUPPORTS_F90 ${CMAKE_BINARY_DIR} ")
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 try_compile(CMAKE_Fortran_COMPILER_SUPPORTS_F90 ${CMAKE_BINARY_DIR}
OUTPUT_VARIABLE OUTPUT) ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90
if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) OUTPUT_VARIABLE OUTPUT)
message(CHECK_PASS "yes") if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log message(CHECK_PASS "yes")
"Determining if the Fortran compiler supports Fortran 90 passed with " file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"the following output:\n${OUTPUT}\n\n") "Determining if the Fortran compiler supports Fortran 90 passed with "
set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1) "the following output:\n${OUTPUT}\n\n")
else() set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1)
message(CHECK_FAIL "no") else()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log message(CHECK_FAIL "no")
"Determining if the Fortran compiler supports Fortran 90 failed with " file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"the following output:\n${OUTPUT}\n\n") "Determining if the Fortran compiler supports Fortran 90 failed with "
set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 0) "the following output:\n${OUTPUT}\n\n")
endif() set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 0)
unset(CMAKE_Fortran_COMPILER_SUPPORTS_F90 CACHE) endif()
endif() unset(CMAKE_Fortran_COMPILER_SUPPORTS_F90 CACHE)
endif()
# Re-configure to save learned information.
configure_file( # Re-configure to save learned information.
${CMAKE_ROOT}/Modules/CMakeFortranCompiler.cmake.in configure_file(
${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake ${CMAKE_ROOT}/Modules/CMakeFortranCompiler.cmake.in
@ONLY ${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake
) @ONLY
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake) )
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeFortranCompiler.cmake)
if(CMAKE_Fortran_SIZEOF_DATA_PTR)
foreach(f ${CMAKE_Fortran_ABI_FILES}) if(CMAKE_Fortran_SIZEOF_DATA_PTR)
include(${f}) foreach(f ${CMAKE_Fortran_ABI_FILES})
endforeach() include(${f})
unset(CMAKE_Fortran_ABI_FILES) endforeach()
endif() unset(CMAKE_Fortran_ABI_FILES)
endif() endif()

View File

@ -21,6 +21,15 @@ endif()
# We now store this in CMakeCCompiler.cmake. # We now store this in CMakeCCompiler.cmake.
unset(CMAKE_OBJC_COMPILER_WORKS CACHE) unset(CMAKE_OBJC_COMPILER_WORKS CACHE)
# Try to identify the ABI and configure it into CMakeOBJCCompiler.cmake
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
CMAKE_DETERMINE_COMPILER_ABI(OBJC ${CMAKE_ROOT}/Modules/CMakeOBJCCompilerABI.m)
if(CMAKE_OBJC_ABI_COMPILED)
# The compiler worked so skip dedicated test below.
set(CMAKE_OBJC_COMPILER_WORKS TRUE)
message(STATUS "Check for working OBJC compiler: ${CMAKE_OBJC_COMPILER} - skipped")
endif()
# This file is used by EnableLanguage in cmGlobalGenerator to # This file is used by EnableLanguage in cmGlobalGenerator to
# determine that that selected Objective-C compiler can actually compile # determine that that selected Objective-C compiler can actually compile
# and link the most basic of programs. If not, a fatal error # and link the most basic of programs. If not, a fatal error
@ -44,49 +53,41 @@ if(NOT CMAKE_OBJC_COMPILER_WORKS)
# Move result from cache to normal variable. # Move result from cache to normal variable.
set(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_OBJC_COMPILER_WORKS}) set(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_OBJC_COMPILER_WORKS})
unset(CMAKE_OBJC_COMPILER_WORKS CACHE) unset(CMAKE_OBJC_COMPILER_WORKS CACHE)
set(OBJC_TEST_WAS_RUN 1)
__TestCompiler_restoreTryCompileTargetType() __TestCompiler_restoreTryCompileTargetType()
if(NOT CMAKE_OBJC_COMPILER_WORKS)
PrintTestCompilerResult(CHECK_FAIL "broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the Objective-C compiler works failed with "
"the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${__CMAKE_OBJC_COMPILER_OUTPUT}")
message(FATAL_ERROR "The Objective-C compiler\n \"${CMAKE_OBJC_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
endif()
PrintTestCompilerResult(CHECK_PASS "works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the Objective-C compiler works passed with "
"the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n")
endif() endif()
if(NOT CMAKE_OBJC_COMPILER_WORKS) # Try to identify the compiler features
PrintTestCompilerResult(CHECK_FAIL "broken") include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log CMAKE_DETERMINE_COMPILE_FEATURES(OBJC)
"Determining if the Objective-C compiler works failed with "
"the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${__CMAKE_OBJC_COMPILER_OUTPUT}")
message(FATAL_ERROR "The Objective-C compiler\n \"${CMAKE_OBJC_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(OBJC_TEST_WAS_RUN)
PrintTestCompilerResult(CHECK_PASS "works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the Objective-C compiler works passed with "
"the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n")
endif()
# Try to identify the ABI and configure it into CMakeOBJCCompiler.cmake # Re-configure to save learned information.
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) configure_file(
CMAKE_DETERMINE_COMPILER_ABI(OBJC ${CMAKE_ROOT}/Modules/CMakeOBJCCompilerABI.m) ${CMAKE_ROOT}/Modules/CMakeOBJCCompiler.cmake.in
# Try to identify the compiler features ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) @ONLY
CMAKE_DETERMINE_COMPILE_FEATURES(OBJC) )
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake)
# Re-configure to save learned information. if(CMAKE_OBJC_SIZEOF_DATA_PTR)
configure_file( foreach(f ${CMAKE_OBJC_ABI_FILES})
${CMAKE_ROOT}/Modules/CMakeOBJCCompiler.cmake.in include(${f})
${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake endforeach()
@ONLY unset(CMAKE_OBJC_ABI_FILES)
)
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake)
if(CMAKE_OBJC_SIZEOF_DATA_PTR)
foreach(f ${CMAKE_OBJC_ABI_FILES})
include(${f})
endforeach()
unset(CMAKE_OBJC_ABI_FILES)
endif()
endif() endif()
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE})

View File

@ -21,6 +21,15 @@ endif()
# We now store this in CMakeOBJCXXCompiler.cmake. # We now store this in CMakeOBJCXXCompiler.cmake.
unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE) unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE)
# Try to identify the ABI and configure it into CMakeOBJCXXCompiler.cmake
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
CMAKE_DETERMINE_COMPILER_ABI(OBJCXX ${CMAKE_ROOT}/Modules/CMakeOBJCXXCompilerABI.mm)
if(CMAKE_OBJCXX_ABI_COMPILED)
# The compiler worked so skip dedicated test below.
set(CMAKE_OBJCXX_COMPILER_WORKS TRUE)
message(STATUS "Check for working OBJCXX compiler: ${CMAKE_OBJCXX_COMPILER} - skipped")
endif()
# This file is used by EnableLanguage in cmGlobalGenerator to # This file is used by EnableLanguage in cmGlobalGenerator to
# determine that the selected Objective-C++ compiler can actually compile # determine that the selected Objective-C++ compiler can actually compile
# and link the most basic of programs. If not, a fatal error # and link the most basic of programs. If not, a fatal error
@ -43,49 +52,41 @@ if(NOT CMAKE_OBJCXX_COMPILER_WORKS)
# Move result from cache to normal variable. # Move result from cache to normal variable.
set(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_OBJCXX_COMPILER_WORKS}) set(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_OBJCXX_COMPILER_WORKS})
unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE) unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE)
set(OBJCXX_TEST_WAS_RUN 1)
__TestCompiler_restoreTryCompileTargetType() __TestCompiler_restoreTryCompileTargetType()
if(NOT CMAKE_OBJCXX_COMPILER_WORKS)
PrintTestCompilerResult(CHECK_FAIL "broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the Objective-C++ compiler works failed with "
"the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${__CMAKE_OBJCXX_COMPILER_OUTPUT}")
message(FATAL_ERROR "The Objective-C++ compiler\n \"${CMAKE_OBJCXX_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
endif()
PrintTestCompilerResult(CHECK_PASS "works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the Objective-C++ compiler works passed with "
"the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n")
endif() endif()
if(NOT CMAKE_OBJCXX_COMPILER_WORKS) # Try to identify the compiler features
PrintTestCompilerResult(CHECK_FAIL "broken") include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log CMAKE_DETERMINE_COMPILE_FEATURES(OBJCXX)
"Determining if the Objective-C++ compiler works failed with "
"the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n")
string(REPLACE "\n" "\n " _output "${__CMAKE_OBJCXX_COMPILER_OUTPUT}")
message(FATAL_ERROR "The Objective-C++ compiler\n \"${CMAKE_OBJCXX_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(OBJCXX_TEST_WAS_RUN)
PrintTestCompilerResult(CHECK_PASS "works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the Objective-C++ compiler works passed with "
"the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n")
endif()
# Try to identify the ABI and configure it into CMakeOBJCXXCompiler.cmake # Re-configure to save learned information.
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) configure_file(
CMAKE_DETERMINE_COMPILER_ABI(OBJCXX ${CMAKE_ROOT}/Modules/CMakeOBJCXXCompilerABI.mm) ${CMAKE_ROOT}/Modules/CMakeOBJCXXCompiler.cmake.in
# Try to identify the compiler features ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) @ONLY
CMAKE_DETERMINE_COMPILE_FEATURES(OBJCXX) )
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake)
# Re-configure to save learned information. if(CMAKE_OBJCXX_SIZEOF_DATA_PTR)
configure_file( foreach(f ${CMAKE_OBJCXX_ABI_FILES})
${CMAKE_ROOT}/Modules/CMakeOBJCXXCompiler.cmake.in include(${f})
${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake endforeach()
@ONLY unset(CMAKE_OBJCXX_ABI_FILES)
)
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake)
if(CMAKE_OBJCXX_SIZEOF_DATA_PTR)
foreach(f ${CMAKE_OBJCXX_ABI_FILES})
include(${f})
endforeach()
unset(CMAKE_OBJCXX_ABI_FILES)
endif()
endif() endif()
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE})