forked from jrl-umi3218/jrl-cmakemodules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.cmake.in
154 lines (142 loc) · 5.69 KB
/
Config.cmake.in
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
@PACKAGE_INIT@
set(skip_this_file TRUE)
if(NOT @PROJECT_NAME@_FOUND)
set(skip_this_file FALSE)
endif()
if(skip_this_file)
foreach(component ${@PROJECT_NAME@_FIND_COMPONENTS})
if(NOT "@PROJECT_NAME@_${component}_FOUND")
set(skip_this_file FALSE)
endif()
endforeach()
endif()
if(skip_this_file)
return()
endif()
set("@PROJECT_NAME@_INCLUDE_DIRS" "@PACKAGE_INSTALL_FULL_INCLUDEDIR@")
set("@PROJECT_NAME_UPPER@_INCLUDE_DIRS" "@PACKAGE_INSTALL_FULL_INCLUDEDIR@")
set("@PROJECT_NAME@_DOXYGENDOCDIR" "${PACKAGE_PREFIX_DIR}/share/doc/@PROJECT_NAME@/doxygen-html")
set("@PROJECT_NAME_UPPER@_DOXYGENDOCDIR" "${PACKAGE_PREFIX_DIR}/share/doc/@PROJECT_NAME@/doxygen-html")
set("@PROJECT_NAME@_DEPENDENCIES" "@_PACKAGE_CONFIG_DEPENDENCIES_PROJECTS@")
set("@PROJECT_NAME@_PKG_CONFIG_DEPENDENCIES" "@_PKG_CONFIG_REQUIRES_LIST@")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} @_PACKAGE_CONFIG_DEPENDENCIES_FIND_EXTERNAL@)
# Find absolute library paths for all _PKG_CONFIG_LIBS as CMake expects full paths, while pkg-config does not.
set(_PACKAGE_CONFIG_LIBRARIES "")
set("_@PROJECT_NAME@_PKG_CONFIG_LIBDIR" "@_PKG_CONFIG_LIBDIR@")
set("_@PROJECT_NAME@_PKG_CONFIG_LIBS_LIST" "@_PKG_CONFIG_LIBS@")
if(_@PROJECT_NAME@_PKG_CONFIG_LIBS_LIST)
string(FIND ${_@PROJECT_NAME@_PKG_CONFIG_LIBS_LIST} ", " _is_comma_space)
while(_is_comma_space GREATER -1)
string(REPLACE ", " "," _@PROJECT_NAME@_PKG_CONFIG_LIBS_LIST "${_@PROJECT_NAME@_PKG_CONFIG_LIBS_LIST}")
string(FIND ${_@PROJECT_NAME@_PKG_CONFIG_LIBS_LIST} ", " _is_comma_space)
endwhile()
string(REPLACE " " ";" _@PROJECT_NAME@_PKG_CONFIG_LIBS_LIST "${_@PROJECT_NAME@_PKG_CONFIG_LIBS_LIST}")
set(LIBDIR_HINTS ${_@PROJECT_NAME@_PKG_CONFIG_LIBDIR})
foreach(component ${_@PROJECT_NAME@_PKG_CONFIG_LIBS_LIST})
string(STRIP ${component} component)
# If the component is a link directory ("-L/full/path"), append to LIBDIR_HINTS.
string(FIND ${component} "-L" _is_library_dir)
if(${_is_library_dir} EQUAL 0)
string(REGEX REPLACE "^-L" "" lib_path ${component})
list(APPEND LIBDIR_HINTS "${lib_path}")
continue()
endif()
# If the component is a library name
string(FIND ${component} "-l" _is_library_name)
if(${_is_library_name} EQUAL 0)
string(REGEX REPLACE "^-l" "" lib ${component})
find_library(abs_lib_${lib} ${lib} HINTS ${LIBDIR_HINTS})
if(NOT abs_lib_${lib})
IF(_LIBDIR_HINTS)
message(STATUS "${lib} searched on ${_LIBDIR_HINTS} not FOUND.")
ELSE()
message(STATUS "${lib} not FOUND.")
ENDIF()
else()
IF(_LIBDIR_HINTS)
message(STATUS "${lib} searched on ${_LIBDIR_HINTS} FOUND. ${lib} at ${abs_lib_${lib}}")
ELSE()
message(STATUS "${lib} FOUND. ${lib} at ${abs_lib_${lib}}")
ENDIF()
list(APPEND _PACKAGE_CONFIG_LIBRARIES "${abs_lib_${lib}}")
endif()
unset(abs_lib_${lib} CACHE)
continue()
endif()
# If the component contains a collection of additional arguments
string(FIND ${component} "," _is_collection)
if(${_is_collection} GREATER -1)
string(REPLACE "," ";" component_list "${component}")
list(GET component_list -1 lib_info)
set(options ${component})
list(REMOVE_AT options -1)
string(FIND ${lib_info} "-l" _is_library_name)
if(${_is_library_name} GREATER -1)
string(REGEX REPLACE "^-l" "" lib ${lib_info})
find_library(abs_lib_${lib} ${lib} HINTS ${LIBDIR_HINTS})
if(NOT abs_lib_${lib})
IF(_LIBDIR_HINTS)
message(STATUS "${lib} searched on ${_LIBDIR_HINTS} not FOUND.")
ELSE()
message(STATUS "${lib} not FOUND.")
ENDIF()
else()
IF(_LIBDIR_HINTS)
message(STATUS "${lib} searched on ${_LIBDIR_HINTS} FOUND. ${lib} at ${abs_lib_${lib}}")
ELSE()
message(STATUS "${lib} FOUND. ${lib} at ${abs_lib_${lib}}")
ENDIF()
list(APPEND _PACKAGE_CONFIG_LIBRARIES "${abs_lib_${lib}}")
endif()
unset(abs_lib_${lib} CACHE)
continue()
else() # This is an absolute lib
list(APPEND _PACKAGE_CONFIG_LIBRARIES "${component}")
endif()
continue()
endif()
# Else, this is just an absolute lib
if(EXISTS "${component}")
list(APPEND _PACKAGE_CONFIG_LIBRARIES "${component}")
endif()
endforeach()
endif(_@PROJECT_NAME@_PKG_CONFIG_LIBS_LIST)
set("@PROJECT_NAME@_LIBRARIES" ${_PACKAGE_CONFIG_LIBRARIES})
set("@PROJECT_NAME_UPPER@_LIBRARIES" ${_PACKAGE_CONFIG_LIBRARIES})
@INCLUDE_INSTALLED_JRL_FILES@
@PYTHON_EXPORT_DEPENDENCY_MACROS@
include(CMakeFindDependencyMacro)
if(${CMAKE_VERSION} VERSION_LESS "3.15.0")
@PACKAGE_DEPENDENCIES_FIND_PACKAGE@
else()
@PACKAGE_DEPENDENCIES_FIND_DEPENDENCY@
endif()
IF(COMMAND ADD_REQUIRED_DEPENDENCY)
FOREACH(pkgcfg_dep ${@PROJECT_NAME@_PKG_CONFIG_DEPENDENCIES})
# Avoid duplicated lookup.
LIST (FIND $_PKG_CONFIG_REQUIRES "${pkgcfg_dep}" _index)
IF(${_index} EQUAL -1)
ADD_REQUIRED_DEPENDENCY(${pkgcfg_dep})
ENDIF()
ENDFOREACH()
ENDIF(COMMAND ADD_REQUIRED_DEPENDENCY)
@INCLUDE_TARGETS_FILE@
foreach(component ${@PROJECT_NAME@_FIND_COMPONENTS})
set(comp_file "${CMAKE_CURRENT_LIST_DIR}/${component}Config.cmake")
if(EXISTS ${comp_file})
include(${comp_file})
else()
set(@PROJECT_NAME@_${component}_FOUND FALSE)
endif()
if(@PROJECT_NAME@_${component}_FOUND)
message(STATUS "@PROJECT_NAME@: ${component} found.")
else()
if(@PROJECT_NAME@_FIND_REQUIRED_${component})
message(FATAL_ERROR "@PROJECT_NAME@: ${component} not found.")
else()
message(STATUS "@PROJECT_NAME@: ${component} not found.")
endif()
endif()
endforeach()
check_required_components("@PROJECT_NAME@")
@PACKAGE_EXTRA_MACROS@