-
Notifications
You must be signed in to change notification settings - Fork 490
Expand file tree
/
Copy pathO2DataFile.cmake
More file actions
62 lines (54 loc) · 2.04 KB
/
O2DataFile.cmake
File metadata and controls
62 lines (54 loc) · 2.04 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
# Copyright 2019-2020 CERN and copyright holders of ALICE O2.
# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
# All rights not expressly granted are reserved.
#
# This software is distributed under the terms of the GNU General Public
# License v3 (GPL Version 3), copied verbatim in the file "COPYING".
#
# In applying this license CERN does not waive the privileges and immunities
# granted to it by virtue of its status as an Intergovernmental Organization
# or submit itself to any jurisdiction.
#
# o2_data_file(COPY src DESTINATION dest) is a convenience function to copy and
# install src into dest in a single command. dest should be a relative path.
#
# The install occurs only in the installation phase (if any) and puts src into
# ${CMAKE_INSTALL_DATADIR}/dest
#
# The copy always happens at configure time and puts src into
# ${CMAKE_BINARY_DIR}/stage/{CMAKE_INSTALL_DATADIR}/dest
#
# Note that when src denotes directories src and src/ means different things :
#
# o2_add_file(COPY src/ DESTINATION dest) will copy the _content_ of src into
# dest, while o2_add_file(COPY src DESTINATION dest) will copy the directory src
# into dest.
#
function(o2_data_file)
cmake_parse_arguments(PARSE_ARGV
0
A
""
"DESTINATION"
"COPY")
if(A_UNPARSED_ARGUMENTS)
message(
FATAL_ERROR "Unexpected unparsed arguments: ${A_UNPARSED_ARGUMENTS}")
endif()
if(IS_ABSOLUTE ${A_DESTINATION})
message(FATAL_ERROR "DESTINATION should be a relative path")
endif()
foreach(D IN LISTS A_COPY)
get_filename_component(adir ${D} ABSOLUTE)
if(IS_DIRECTORY ${adir})
install(DIRECTORY ${D}
DESTINATION ${CMAKE_INSTALL_DATADIR}/${A_DESTINATION})
else()
install(FILES ${D} DESTINATION ${CMAKE_INSTALL_DATADIR}/${A_DESTINATION})
endif()
endforeach()
file(
COPY ${A_COPY}
DESTINATION
${CMAKE_BINARY_DIR}/stage/${CMAKE_INSTALL_DATADIR}/${A_DESTINATION})
endfunction()