Ryan Prichard | f6283ab | 2022-01-13 17:30:19 -0800 | [diff] [blame] | 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 | # file Copyright.txt or https://cmake.org/licensing for details. |
| 3 | |
| 4 | #[=======================================================================[.rst: |
| 5 | CheckOBJCCompilerFlag |
| 6 | --------------------- |
| 7 | |
| 8 | .. versionadded:: 3.16 |
| 9 | |
| 10 | Check whether the Objective-C compiler supports a given flag. |
| 11 | |
| 12 | .. command:: check_objc_compiler_flag |
| 13 | |
| 14 | .. code-block:: cmake |
| 15 | |
| 16 | check_objc_compiler_flag(<flag> <var>) |
| 17 | |
| 18 | Check that the ``<flag>`` is accepted by the compiler without |
| 19 | a diagnostic. Stores the result in an internal cache entry |
| 20 | named ``<var>``. |
| 21 | |
| 22 | This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable |
| 23 | and calls the ``check_objc_source_compiles`` macro from the |
| 24 | :module:`CheckOBJCSourceCompiles` module. See documentation of that |
| 25 | module for a listing of variables that can otherwise modify the build. |
| 26 | |
| 27 | A positive result from this check indicates only that the compiler did not |
| 28 | issue a diagnostic message when given the flag. Whether the flag has any |
| 29 | effect or even a specific one is beyond the scope of this module. |
| 30 | |
| 31 | .. note:: |
| 32 | Since the :command:`try_compile` command forwards flags from variables |
| 33 | like :variable:`CMAKE_OBJC_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags |
| 34 | in such variables may cause a false negative for this check. |
| 35 | #]=======================================================================] |
| 36 | |
| 37 | include_guard(GLOBAL) |
| 38 | include(CheckOBJCSourceCompiles) |
| 39 | include(Internal/CheckCompilerFlag) |
| 40 | |
| 41 | macro (CHECK_OBJC_COMPILER_FLAG _FLAG _RESULT) |
| 42 | cmake_check_compiler_flag(OBJC "${_FLAG}" ${_RESULT}) |
| 43 | endmacro () |