summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAlexander Grund <alexander.grund@tu-dresden.de>2019-12-09 08:42:40 (GMT)
committerBrad King <brad.king@kitware.com>2019-12-09 16:39:12 (GMT)
commitb35926e2606272ceac4191b207f51c531e0116a8 (patch)
tree396d172bb5b11f92d6b162a52588ddb8b6e093f4 /Source
parent2a5e5b25ba4d6eb68dbee29381774562c98e228f (diff)
downloadCMake-b35926e2606272ceac4191b207f51c531e0116a8.zip
CMake-b35926e2606272ceac4191b207f51c531e0116a8.tar.gz
CMake-b35926e2606272ceac4191b207f51c531e0116a8.tar.bz2
Check for support before adding bigtoc linker flag
Fixes: #20076
Diffstat (limited to 'Source')
-rw-r--r--Source/Modules/CheckCXXLinkerFlag.cmake25
1 files changed, 25 insertions, 0 deletions
diff --git a/Source/Modules/CheckCXXLinkerFlag.cmake b/Source/Modules/CheckCXXLinkerFlag.cmake
new file mode 100644
index 0000000..9ad2ad6
--- /dev/null
+++ b/Source/Modules/CheckCXXLinkerFlag.cmake
@@ -0,0 +1,25 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+include_guard(GLOBAL)
+include(CheckCXXSourceCompiles)
+include(CMakeCheckCompilerFlagCommonPatterns)
+
+function(check_cxx_linker_flag _flag _var)
+ set(CMAKE_REQUIRED_LIBRARIES "${_flag}")
+
+ # Normalize locale during test compilation.
+ set(_locale_vars LC_ALL LC_MESSAGES LANG)
+ foreach(v IN LISTS _locale_vars)
+ set(_locale_vars_saved_${v} "$ENV{${v}}")
+ set(ENV{${v}} C)
+ endforeach()
+ check_compiler_flag_common_patterns(_common_patterns)
+ check_cxx_source_compiles("int main() { return 0; }" ${_var}
+ ${_common_patterns}
+ )
+ foreach(v IN LISTS _locale_vars)
+ set(ENV{${v}} ${_locale_vars_saved_${v}})
+ endforeach()
+ set(${_var} "${${_var}}" PARENT_SCOPE)
+endfunction()