diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-09-25 18:58:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-09-28 13:07:54 (GMT) |
commit | 90dead024c5adee57e5ea3f3c90aed297d41ce3a (patch) | |
tree | 421c29f6c1d89bd68f23b5ce8f7c7330396d2149 /Modules/CheckOBJCCompilerFlag.cmake | |
parent | 0cd1ef0932dfb4c0c2c7d0eaa5d91a8593b3a3d7 (diff) | |
download | CMake-90dead024c5adee57e5ea3f3c90aed297d41ce3a.zip CMake-90dead024c5adee57e5ea3f3c90aed297d41ce3a.tar.gz CMake-90dead024c5adee57e5ea3f3c90aed297d41ce3a.tar.bz2 |
CheckCompilerFlag: unified way to check compiler flags per language
Diffstat (limited to 'Modules/CheckOBJCCompilerFlag.cmake')
-rw-r--r-- | Modules/CheckOBJCCompilerFlag.cmake | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/Modules/CheckOBJCCompilerFlag.cmake b/Modules/CheckOBJCCompilerFlag.cmake index a98f429..df9d724 100644 --- a/Modules/CheckOBJCCompilerFlag.cmake +++ b/Modules/CheckOBJCCompilerFlag.cmake @@ -36,31 +36,8 @@ effect or even a specific one is beyond the scope of this module. include_guard(GLOBAL) include(CheckOBJCSourceCompiles) -include(CMakeCheckCompilerFlagCommonPatterns) +include(CheckCompilerFlag) macro (CHECK_OBJC_COMPILER_FLAG _FLAG _RESULT) - set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") - - # Normalize locale during test compilation. - set(_CheckOBJCCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) - foreach(v ${_CheckOBJCCompilerFlag_LOCALE_VARS}) - set(_CheckOBJCCompilerFlag_SAVED_${v} "$ENV{${v}}") - set(ENV{${v}} OBJC) - endforeach() - CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckOBJCCompilerFlag_COMMON_PATTERNS) - CHECK_OBJC_SOURCE_COMPILES("#ifndef __OBJC__\n# error \"Not an Objective-C compiler\"\n#endif\nint main(void) { return 0; }" ${_RESULT} - # Some compilers do not fail with a bad flag - FAIL_REGEX "command line option .* is valid for .* but not for Objective-C" # GNU - FAIL_REGEX "argument unused during compilation: .*" # Clang - ${_CheckOBJCCompilerFlag_COMMON_PATTERNS} - ) - foreach(v ${_CheckOBJCCompilerFlag_LOCALE_VARS}) - set(ENV{${v}} ${_CheckOBJCCompilerFlag_SAVED_${v}}) - unset(_CheckOBJCCompilerFlag_SAVED_${v}) - endforeach() - unset(_CheckOBJCCompilerFlag_LOCALE_VARS) - unset(_CheckOBJCCompilerFlag_COMMON_PATTERNS) - - set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") + check_compiler_flag(OBJC "${_FLAG}" ${_RESULT}) endmacro () |