-
Notifications
You must be signed in to change notification settings - Fork 47
/
sdformat.cmake
57 lines (56 loc) · 1.41 KB
/
sdformat.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
#
# Copyright 2021-2024 INRIA
#
# Author: Rohan Budhiraja
#
# SEARCH_FOR_SDFORMAT
# ----------------------------------
# Try to quietly find SDFormat, and when found, add the dependency. REQUIRED
# (Optional): if REQUIRED is given as an argument, and SDFormat is not found,
# FATAL_ERROR is generated.
#
macro(SEARCH_FOR_SDFORMAT)
set(
SDF_VERSIONS
"14"
"13"
"12"
"11"
"10"
"9"
)
list(APPEND SDF_VERSIONS "")
set(P_REQUIRED False)
set(variadic_args ${ARGN})
list(LENGTH variadic_args variadic_count)
if(${variadic_count} GREATER 0)
list(GET variadic_args 0 optional_arg)
if(${optional_arg} STREQUAL "REQUIRED")
set(P_REQUIRED True)
else()
message(
STATUS
"Got an unknown optional arg: ${optional_arg}. Only REQUIRED is recognized."
)
endif()
endif()
foreach(version IN LISTS SDF_VERSIONS)
find_package(SDFormat${version} QUIET)
if(SDFormat${version}_FOUND)
set(SDFormat_FOUND True)
add_project_dependency(SDFormat${version})
message(STATUS "SDFormat${version} Found")
break()
endif()
endforeach(version)
if(NOT SDFormat_FOUND)
if(P_REQUIRED)
message(
FATAL_ERROR
"SDFormat required but not found. Accepted versions: ${SDF_VERSIONS}"
)
else()
message(STATUS "SDFormat not found. Accepted versions: ${SDF_VERSIONS}")
endif()
endif()
endmacro(SEARCH_FOR_SDFORMAT)