-
Notifications
You must be signed in to change notification settings - Fork 186
/
Copy pathfind_gpu.cmake
30 lines (26 loc) · 946 Bytes
/
find_gpu.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# file name to find
set(FILENAME "gpu.h")
# Function to check for file existence up the directory hierarchy
function(find_project_root current_dir filename result_var)
set(found FALSE) # Flag to indicate if the file is found
set(current_check_dir "${current_dir}") # Start from the given directory
# using 1 is jsut to supress the cmane-format warning
foreach(i RANGE 0 2 1)
set(filepath "${current_check_dir}/${filename}")
if(EXISTS "${filepath}")
set(${result_var}
"${current_check_dir}"
PARENT_SCOPE)
set(found TRUE)
break()
endif()
# Move one level up
get_filename_component(current_check_dir "${current_check_dir}"
DIRECTORY)
endforeach()
if(NOT found)
set(${result_var}
""
PARENT_SCOPE) # Set to empty if not found
endif()
endfunction()