-
Notifications
You must be signed in to change notification settings - Fork 0
/
EflGetModules
78 lines (67 loc) · 2.14 KB
/
EflGetModules
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
73
74
75
76
77
78
include_guard(DIRECTORY)
include(FetchContent)
macro(__efl_propagate __var)
set(${__var} ${${__var}} PARENT_SCOPE)
endmacro()
function(__efl_find_perl)
if(DEFINED PERL_VERSION AND DEFINED PERL_EXECUTABLE)
return()
endif()
find_package(Perl REQUIRED)
set(PERL_VERSION ${PERL_VERSION_STRING})
__efl_assert_propagate(PERL_VERSION)
__efl_assert_propagate(PERL_EXECUTABLE)
endfunction()
##=== Locate Implementation =================================##
macro(Efl_Getmodules)
__efl_set_install_prefix()
foreach(__tgt ${ARGN})
if(TARGET ${__tgt})
continue()
endif()
__efl_parse_target(${__tgt})
__efl_get_target(${__tgt})
message("[efl::core] Found ${__tgt}")
endforeach()
endmacro()
macro(__efl_set_install_prefix)
if(NOT DEFINED EFL_INSTALL_PREFIX)
if(WIN32)
set(EFL_INSTALL_PREFIX "C:/Eightforge")
else()
set(EFL_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/Eightforge")
endif()
endif()
endmacro()
macro(__efl_parse_target __tgt)
string(REGEX REPLACE "::" "-" __EFL_TGT_NAME "${__tgt}")
if(__EFL_TGT_NAME MATCHES "(([_a-zA-Z-]+)-([_a-zA-Z-]+))$")
set(__EFL_TGT_DIR "${CMAKE_MATCH_2}/${CMAKE_MATCH_3}")
else()
set(__EFL_TGT_DIR "${__EFL_TGT_NAME}")
endif()
set(__EFL_TGT_URL "https://github.com/eightforge/${__EFL_TGT_NAME}.git")
endmacro()
macro(__efl_get_target __tgt)
set(__EFL_TGT_CURR "${__EFL_TGT_NAME}-tgt")
set(__EFL_TGT_SRC "${EFL_INSTALL_PREFIX}/${__EFL_TGT_DIR}")
if(NOT ${__EFL_TGT_CURR}_ADDED OR EFL_FORCE_FETCH)
FetchContent_Declare(${__EFL_TGT_CURR}
GIT_REPOSITORY ${__EFL_TGT_URL}
GIT_TAG main
SOURCE_DIR ${__EFL_TGT_SRC}
)
FetchContent_GetProperties(${__EFL_TGT_CURR}
SOURCE_DIR ${__EFL_TGT_CURR}_SOURCE_DIR
BINARY_DIR ${__EFL_TGT_CURR}_BINARY_DIR
)
if(NOT ${__EFL_TGT_CURR}_POPULATED)
FetchContent_Populate(${__EFL_TGT_CURR})
set(${__EFL_TGT_CURR}_BINARY_DIR ${${__EFL_TGT_CURR}_BINARY_DIR}
CACHE FILEPATH "" FORCE)
endif()
endif()
add_subdirectory(${__EFL_TGT_SRC} ${__EFL_TGT_CURR}_BINARY_DIR)
set(${__EFL_TGT_CURR}_ADDED ON
CACHE BOOL "If the target has already been added.")
endmacro()