-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparseDependencies.cmake
72 lines (51 loc) · 2.45 KB
/
parseDependencies.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function (parse_dependencies)
# Parse arguments
set(options )
set(oneValueArgs DEPENDENCIES_NESTED)
set(multiValueArgs DEPENDENCIES_LIST)
cmake_parse_arguments(PARSE_DEPENDENCIES "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN})
foreach (dependency ${PARSE_DEPENDENCIES_DEPENDENCIES_LIST})
# Parse element from above "dependency" list, converting each element into
# a string, i.e. replacing all instances of "%" with ";" (which, in cmake,
# separate the list elements)
string(REPLACE "%" ";" dependency ${dependency})
list(LENGTH dependency len)
# Get each element from the list into different variables
list(GET dependency 0 dependency_name)
find_file(full_path_${dependency_name} NAMES Dependencies_${dependency_name}${SHIPPABLE_SUFFIX}.cmake PATHS "$ENV{CMAKE_MACROS}/external")
if (full_path_${dependency_name})
LIST (APPEND PARSE_DEPENDENCIES_DEPENDENCIES_NESTED ${dependency_name})
endif()
endforeach(dependency)
set (${DEPENDENCIES_NESTED} ${PARSE_DEPENDENCIES_DEPENDENCIES_NESTED} PARENT_SCOPE)
endfunction()
function (find_dependencies)
# Parse arguments
set(options )
set(multiValueArgs DEPENDENCIES_LIST)
cmake_parse_arguments(PARSE_DEPENDENCIES "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN})
foreach (dependency ${PARSE_DEPENDENCIES_DEPENDENCIES_LIST})
# Parse element from above "dependency" list, converting each element into
# a string, i.e. replacing all instances of "%" with ";" (which, in cmake,
# separate the list elements)
string(REPLACE "%" ";" dependency ${dependency})
list(LENGTH dependency len)
# Get each element from the list into different variables
list(GET dependency 0 dependency_name)
string(TOUPPER ${dependency_name} tmp)
# Try to find the above libraries
if (${len} STREQUAL "1")
libfind_detect (${tmp}
FIND_LIBRARY ${dependency_name} LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/lib
NO_DEFAULT_PATH ${CMAKE_NO_DEFAULT_PATH})
elseif (${len} STREQUAL "2")
list(GET dependency 1 dependency_header)
libfind_detect (${tmp}
FIND_PATH ${dependency_header} INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include/${dependency_name}
FIND_LIBRARY ${dependency_name} LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/lib
NO_DEFAULT_PATH ${CMAKE_NO_DEFAULT_PATH})
endif (${len} STREQUAL "1")
endforeach(dependency)
endfunction()