-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathDownloadGenXrdPattern.cmake
More file actions
71 lines (58 loc) · 2.77 KB
/
DownloadGenXrdPattern.cmake
File metadata and controls
71 lines (58 loc) · 2.77 KB
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
# Written by Patrick S. Avery - 2018
# Downloads the executable if it doesn't already exist
macro(DownloadGenXrdPattern)
# Let's set the name. Windows likes to add '.exe' at the end
if(WIN32)
set(GENXRDPATTERN_NAME "genXrdPattern.exe")
else(WIN32)
set(GENXRDPATTERN_NAME "genXrdPattern")
endif(WIN32)
# If it already exists, don't download it again
if(NOT EXISTS ${CMAKE_BINARY_DIR}/bin/${GENXRDPATTERN_NAME} AND NOT USE_SYSTEM_GENXRDPATTERN)
set(GENXRDPATTERN_V "1.0-static")
# Linux
if(UNIX AND NOT APPLE)
set(GENXRDPATTERN_DOWNLOAD_LOCATION "https://github.com/psavery/genXrdPattern/releases/download/${GENXRDPATTERN_V}/linux64-genXrdPattern")
set(MD5 "e1b3c1d6b951ed83a037567490d75f1d")
# Apple
elseif(APPLE)
set(GENXRDPATTERN_DOWNLOAD_LOCATION "https://github.com/psavery/genXrdPattern/releases/download/${GENXRDPATTERN_V}/osx64-genXrdPattern")
set(MD5 "229b01c8efab981d812043684dae84fe")
# Windows
elseif(WIN32 AND NOT CYGWIN)
set(GENXRDPATTERN_DOWNLOAD_LOCATION "https://github.com/psavery/genXrdPattern/releases/download/${GENXRDPATTERN_V}/win64-genXrdPattern.exe")
set(MD5 "7b1a1e18a6044773c631189cbfd8b440")
else()
message(FATAL_ERROR
"GenXrdPattern is not supported with the current OS type!")
endif()
message("-- Downloading genXrdPattern executable from ${GENXRDPATTERN_DOWNLOAD_LOCATION}")
# Install to a temporary directory so we can copy and change file
# permissions
file(DOWNLOAD ${GENXRDPATTERN_DOWNLOAD_LOCATION}
"${CMAKE_BINARY_DIR}/tmp/${GENXRDPATTERN_NAME}"
SHOW_PROGRESS
EXPECTED_MD5 ${MD5})
# We need to change the permissions
file(COPY "${CMAKE_BINARY_DIR}/tmp/${GENXRDPATTERN_NAME}"
DESTINATION "${CMAKE_BINARY_DIR}/bin/"
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
# Now remove the temporary directory
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/tmp")
endif(NOT EXISTS ${CMAKE_BINARY_DIR}/bin/${GENXRDPATTERN_NAME} AND NOT USE_SYSTEM_GENXRDPATTERN)
# Only install it if we are not using system genXrdPattern
if(NOT USE_SYSTEM_GENXRDPATTERN)
set(GENXRDPATTERN_DESTINATION "bin")
# We need to put it in a slightly different place for apple
if(APPLE)
set(GENXRDPATTERN_DESTINATION "xtalopt.app/Contents/bin")
endif(APPLE)
install(FILES "${CMAKE_BINARY_DIR}/bin/${GENXRDPATTERN_NAME}"
DESTINATION "${GENXRDPATTERN_DESTINATION}"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
endif(NOT USE_SYSTEM_GENXRDPATTERN)
endmacro(DownloadGenXrdPattern)