summaryrefslogtreecommitdiff
path: root/cmake/Modules/EnableLanguageNolink.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/Modules/EnableLanguageNolink.cmake')
-rw-r--r--cmake/Modules/EnableLanguageNolink.cmake11
1 files changed, 11 insertions, 0 deletions
diff --git a/cmake/Modules/EnableLanguageNolink.cmake b/cmake/Modules/EnableLanguageNolink.cmake
new file mode 100644
index 000000000000..18668c6d0476
--- /dev/null
+++ b/cmake/Modules/EnableLanguageNolink.cmake
@@ -0,0 +1,11 @@
+macro(llvm_enable_language_nolink)
+ # Set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY to disable linking
+ # in the compiler sanity checks. When bootstrapping the toolchain,
+ # the toolchain itself is still incomplete and sanity checks that include
+ # linking may fail.
+ set(__SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+ enable_language(${ARGV})
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__SAVED_TRY_COMPILE_TARGET_TYPE})
+ unset(__SAVED_TRY_COMPILE_TARGET_TYPE)
+endmacro()