Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 98abedc

Browse files
committed
Upgraded header discoverability (by targets) check
1 parent ecaa1aa commit 98abedc

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

cmake/Platform/Sources/HeaderExistanceChecker.cmake

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,14 @@
88
#=============================================================================#
99
function(is_header_discoverable_by_target _header_we _target_name _return_var)
1010

11-
# Get target's direct include dirs
12-
get_target_property(target_include_dirs ${_target_name} INCLUDE_DIRECTORIES)
11+
get_target_include_directories(${_target_name} target_include_dirs)
1312

14-
# Get include dirs of targets linked to the given target
15-
get_target_property(target_linked_libs ${_target_name} LINK_LIBRARIES)
13+
get_header_file(${_header_we} ${target_include_dirs} header_found)
1614

17-
# Explictly add include dirs of all linked libraries (given they're valid cmake targets)
18-
foreach (linked_lib ${target_linked_libs})
19-
20-
if (NOT TARGET ${linked_lib})
21-
continue()
22-
endif ()
23-
24-
get_target_property(lib_include_dirs ${linked_lib} INCLUDE_DIRECTORIES)
25-
if (NOT "${lib_include_dirs}" MATCHES "NOTFOUND") # Library has include dirs
26-
list(APPEND include_dirs ${lib_include_dirs})
27-
endif ()
28-
29-
endforeach ()
30-
31-
if (NOT "${target_include_dirs}" MATCHES "NOTFOUND") # Target has direct include dirs
32-
list(APPEND include_dirs ${target_include_dirs})
15+
if (NOT header_found OR "${header_found}" MATCHES "NOTFOUND")
16+
set(_return_var FALSE PARENT_SCOPE)
17+
else ()
18+
set(_return_var TRUE PARENT_SCOPE)
3319
endif ()
3420

35-
_check_header_existance(${_header_we} ${include_dirs} header_found)
36-
37-
set(_return_var ${header_found} PARENT_SCOPE)
38-
3921
endfunction()

0 commit comments

Comments
 (0)