-
Notifications
You must be signed in to change notification settings - Fork 0
/
MeImport.cmake
44 lines (42 loc) · 1.58 KB
/
MeImport.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
function(me_try_import_project project search_dir)
me_parse_project(${project} name version libname)
if(ME_STANDALONE)
# TODO: Use pkg_check_modules to find the library and create imported targets.
message(FATAL_ERROR "Standalone projects are currently not supported.")
return()
endif()
if(EXISTS ${search_dir}/CMakeLists.txt)
add_subdirectory(
${search_dir}
${CMAKE_BINARY_DIR}/${name}-${version}
)
if(TARGET ${project})
message(STATUS "Importing ${search_dir}")
endif()
endif()
endfunction(me_try_import_project)
function(me_import_project project)
me_parse_project(${project} name version libname)
me_try_import_project(${project} ${ME_ROOT_DIR}/${name}/${version})
me_try_import_project(${project} ${ME_ROOT_DIR}/3rd/${name}/${version})
endfunction(me_import_project)
function(me_import)
foreach(project ${ARGN})
if(NOT TARGET ${project} AND project MATCHES -)
me_import_project(${project})
endif()
endforeach()
set(ME_IMPORTED_INCLUDES)
foreach(project ${ARGN})
if(TARGET ${project})
get_target_property(includes ${project} INCLUDE_DIRECTORIES)
if(NOT includes STREQUAL includes-NOTFOUND)
list(APPEND ME_IMPORTED_INCLUDES ${includes})
endif()
if(ME_IMPORTED_INCLUDES)
list(REMOVE_DUPLICATES ME_IMPORTED_INCLUDES)
endif()
endif()
endforeach()
set(ME_IMPORTED_INCLUDES ${ME_IMPORTED_INCLUDES} PARENT_SCOPE)
endfunction(me_import)