-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary_hints.cmake
More file actions
100 lines (88 loc) · 3.87 KB
/
Copy pathlibrary_hints.cmake
File metadata and controls
100 lines (88 loc) · 3.87 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# =============================================================================
# library_hints.cmake — shared/static import path helpers
# =============================================================================
## @brief Construct a platform-appropriate shared-library filename hint.
## @param[out] out_var Variable name to set in the parent scope with the
## constructed name.
## @param[in] lib_name Base library name without prefix/suffix (for
## example: avcodec).
## @param[in] prefix_path Optional directory prefix to prepend before the
## library filename (no trailing separator expected).
## @param[in] subdir Optional (4th argument) subdirectory relative to
## `prefix_path` (for example `recursive/cmake`). Empty or
## omitted keeps the legacy layout under `prefix_path` itself.
## @note On WIN32 uses `CMAKE_IMPORT_LIBRARY_PREFIX`/
## `CMAKE_IMPORT_LIBRARY_SUFFIX` and '/' separators. On
## other platforms uses shared library prefix/suffix and '/'. When
## `prefix_path` is provided it is prepended before the platform
## prefix. `subdir` is inserted between `prefix_path` and the
## filename when non-empty.
function(_bm_lib_import_hint _out_var _lib_name _prefix_path)
_bm_log_message(CORE LOWLEVEL "Entering _bm_lib_import_hint")
if(ARGC LESS 3 OR ARGC GREATER 4)
_bm_log_message(CORE FATAL "_bm_lib_import_hint requires output variable name, library name, prefix and optional subdir.")
endif()
set(_subdir "")
if(ARGC EQUAL 4)
set(_subdir "${ARGV3}")
endif()
if(WIN32)
set(_pfx "${CMAKE_IMPORT_LIBRARY_PREFIX}")
set(_suffix "${CMAKE_IMPORT_LIBRARY_SUFFIX}")
else()
set(_pfx "${CMAKE_SHARED_LIBRARY_PREFIX}")
set(_suffix "${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()
set(_base "${_prefix_path}")
if(NOT _subdir STREQUAL "")
if(NOT _base STREQUAL "")
set(_base "${_base}/${_subdir}")
else()
set(_base "${_subdir}")
endif()
endif()
if(NOT _base STREQUAL "")
set(_pfx "${_base}/${_pfx}")
endif()
set(${_out_var} "${_pfx}${_lib_name}${_suffix}" PARENT_SCOPE)
_bm_log_message(CORE LOWLEVEL "Exiting _bm_lib_import_hint")
endfunction()
## @brief Construct a static-library filename hint for importing/linking.
## @param[out] out_var Variable name to set in the parent scope with the
## constructed name.
## @param[in] lib_name Base library name without prefix/suffix.
## @param[in] prefix_path Optional directory prefix to prepend before the
## library filename (no trailing separator expected).
## @param[in] subdir Optional (4th argument) subdirectory relative to
## `prefix_path` (for example `recursive/cmake`). Empty or
## omitted keeps the legacy layout under `prefix_path` itself.
## @note Uses `CMAKE_STATIC_LIBRARY_PREFIX` and
## `CMAKE_STATIC_LIBRARY_SUFFIX`. If `prefix_path` is provided it
## is prepended with a '/' separator. `subdir` is inserted between
## `prefix_path` and the filename when non-empty.
function(_bm_lib_import_static_hint _out_var _lib_name _prefix_path)
_bm_log_message(CORE LOWLEVEL "Entering _bm_lib_import_static_hint")
if(ARGC LESS 3 OR ARGC GREATER 4)
_bm_log_message(CORE FATAL "_bm_lib_import_static_hint requires output variable name, library name, prefix and optional subdir.")
endif()
set(_subdir "")
if(ARGC EQUAL 4)
set(_subdir "${ARGV3}")
endif()
set(_separator "/")
set(_base "${_prefix_path}")
if(NOT _subdir STREQUAL "")
if(NOT _base STREQUAL "")
set(_base "${_base}${_separator}${_subdir}")
else()
set(_base "${_subdir}")
endif()
endif()
if(NOT _base STREQUAL "")
set(_prefix "${_base}${_separator}${CMAKE_STATIC_LIBRARY_PREFIX}")
else()
set(_prefix "${CMAKE_STATIC_LIBRARY_PREFIX}")
endif()
set(${_out_var} "${_prefix}${_lib_name}${CMAKE_STATIC_LIBRARY_SUFFIX}" PARENT_SCOPE)
_bm_log_message(CORE LOWLEVEL "Exiting _bm_lib_import_static_hint")
endfunction()