-
Notifications
You must be signed in to change notification settings - Fork 453
/
Copy pathO2NameTarget.cmake
63 lines (54 loc) · 1.9 KB
/
O2NameTarget.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 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.
include_guard()
#
# o2_name_target(baseName NAME var ...) gives a project specific name to the
# target of the given baseName. The computed name is retrieved in the variable
# "var".
#
# * NAME var: will contain the computed name of the target
# * IS_TEST: present to denote the target is a test executable
# * IS_BENCH: present to denote the target is a benchmark executable
# * IS_EXE: present to denote the target is an executable (and not a library)
#
function(o2_name_target baseTargetName)
cmake_parse_arguments(PARSE_ARGV
1
A
"IS_TEST;IS_BENCH;IS_EXE"
"NAME;COMPONENT_NAME"
"")
if(A_UNPARSED_ARGUMENTS)
message(
FATAL_ERROR "Unexpected unparsed arguments: ${A_UNPARSED_ARGUMENTS}")
endif()
if(NOT A_NAME)
message(FATAL_ERROR "Parameter NAME is mandatory")
endif()
# get the target "type" (lib or exe,test,bench)
if(A_IS_TEST)
set(targetType test)
elseif(A_IS_BENCHMARK)
set(targetType bench)
elseif(A_IS_EXE)
set(targetType exe)
else()
set(targetType lib)
endif()
# get the component part if present
if(A_COMPONENT_NAME)
string(TOLOWER ${A_COMPONENT_NAME} component)
set(comp -${component})
endif()
set(${A_NAME}
${PROJECT_NAME}${targetType}${comp}-${baseTargetName}
PARENT_SCOPE)
endfunction()