-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.cmake
33 lines (25 loc) · 1.05 KB
/
functions.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
function("download_extract" folder url extension)
file(DOWNLOAD "${url}" "${CMAKE_CURRENT_SOURCE_DIR}/${folder}.${extension}")
execute_process(
COMMAND "${CMAKE_COMMAND}" -E tar xzf "${folder}.${extension}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/${folder}.${extension}")
endfunction("download_extract")
function("download_extract_tar" folder url)
download_extract("${folder}" "${url}" "tar.gz")
endfunction("download_extract_tar")
function("download_extract_zip" folder url)
download_extract("${folder}" "${url}" "zip")
endfunction("download_extract_zip")
function("add_external_tar" folder url cmake)
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${folder}")
download_extract_tar("${folder}" "${url}")
endif()
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/${folder}/${cmake}")
endfunction("add_external_tar")
function("download_file" file url)
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
file(DOWNLOAD "${url}" "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
endif()
endfunction("download_file")