diff options
author | Ankit Meel <ankitjmeel@gmail.com> | 2020-07-30 18:43:26 +0300 |
---|---|---|
committer | Ankit Meel <ankitjmeel@gmail.com> | 2020-07-30 18:43:26 +0300 |
commit | 27d50d6f67abd4ad2941b72d9dc15e8ba7b08050 (patch) | |
tree | dbf1313b934005c16dfdba20d592e98bf46d9471 /build_files | |
parent | 168653ed1de824f12f1ecc4780288e7b9f421717 (diff) |
Enable header auto-complete suggestions in Xcode
Description of `USER_HEADER_SEARCH_PATHS` build setting:
"
This is a list of paths to folders to be searched by the compiler
for included or imported user header files (those headers listed
in quotes) when compiling C, Objective-C, C++, or Objective-C++.
Paths are delimited by whitespace, so any paths with spaces in
them need to be properly quoted. See Always Search User Paths
(Deprecated) (ALWAYS_SEARCH_USER_PATHS) for more details
on how this setting is used. If the compiler doesn't support the
concept of user headers, then the search paths are prepended to
the any existing header search paths defined in Header Search
Paths (HEADER_SEARCH_PATHS).
"
http://help.apple.com/xcode/mac/current/#/itcaec37c2a6
Xcode doesn't use `HEADER_SEARCH_PATHS` for auto-complete. Only the
header files in the same directory as the current file are suggested.
CMake as of now correctly sets `SYSTEM_HEADER_SEARCH_PATHS` and lumps the
rest in `HEADER_SEARCH_PATHS`. The standard way is to use
`USER_HEADER_SEARCH_PATHS` & `SYSTEM_HEADER_SEARCH_PATHS` and let
`HEADER_SEARCH_PATHS` be used as a fallback for compilers which do not
distinguish between `<*.h>` and `"*.h"` syntax.
So set `USER_HEADER_SEARCH_PATHS` to the include paths specified
in the `CMakeLists.txt` files of all targets.
Diffstat (limited to 'build_files')
-rw-r--r-- | build_files/cmake/macros.cmake | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 708efc3d2f7..af9fb92e3ad 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -169,6 +169,26 @@ function(blender_include_dirs_sys include_directories(SYSTEM ${_ALL_INCS}) endfunction() +# Set include paths for header files included with "*.h" syntax. +# This enables auto-complete suggestions for user header files on Xcode. +# Build process is not affected since the include paths are the same +# as in HEADER_SEARCH_PATHS. +function(blender_user_header_search_paths + name + includes + ) + + if(XCODE) + set(_ALL_INCS "") + foreach(_INC ${includes}) + get_filename_component(_ABS_INC ${_INC} ABSOLUTE) + # _ALL_INCS is a space-separated string of file paths in quotes. + set(_ALL_INCS "${_ALL_INCS} \"${_ABS_INC}\"") + endforeach() + set_target_properties(${name} PROPERTIES XCODE_ATTRIBUTE_USER_HEADER_SEARCH_PATHS "${_ALL_INCS}") + endif() +endfunction() + function(blender_source_group name sources @@ -317,6 +337,7 @@ function(blender_add_lib__impl # works fine without having the includes # listed is helpful for IDE's (QtCreator/MSVC) blender_source_group("${name}" "${sources}") + blender_user_header_search_paths("${name}" "${includes}") list_assert_duplicates("${sources}") list_assert_duplicates("${includes}") |