-
Notifications
You must be signed in to change notification settings - Fork 1
/
Config.cmake.in
66 lines (57 loc) · 2.93 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
if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FOUND)
set(${CMAKE_FIND_PACKAGE_NAME}_VERSION @PROJECT_VERSION@ CACHE INTERNAL "${CMAKE_FIND_PACKAGE_NAME} version")
@PACKAGE_INIT@
function(maybe_message type message)
if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY )
message(${type} "${message}")
endif()
endfunction()
macro(load_targets type)
if (NOT EXISTS "${${CMAKE_FIND_PACKAGE_NAME}_${type}_targets}")
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
"${CMAKE_FIND_PACKAGE_NAME} `${type}` libraries were requested but not found.")
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif ()
include("${${CMAKE_FIND_PACKAGE_NAME}_${type}_targets}")
endmacro()
include(CMakeFindDependencyMacro)
maybe_message(STATUS "Finding dependency rmn for ${CMAKE_FIND_PACKAGE_NAME}")
find_dependency(rmn REQUIRED PATHS $ENV{rmn_DIR} ${rmn_ROOT})
set(${CMAKE_FIND_PACKAGE_NAME}_static_targets "${CMAKE_CURRENT_LIST_DIR}/${CMAKE_FIND_PACKAGE_NAME}-static-targets.cmake")
set(${CMAKE_FIND_PACKAGE_NAME}_shared_targets "${CMAKE_CURRENT_LIST_DIR}/${CMAKE_FIND_PACKAGE_NAME}-shared-targets.cmake")
# Ensure every requested component is valid and that static and shared
# were not both specified
set(${CMAKE_FIND_PACKAGE_NAME}_known_comps static shared)
set(${CMAKE_FIND_PACKAGE_NAME}_comp_static NO)
set(${CMAKE_FIND_PACKAGE_NAME}_comp_shared NO)
set(_shared_or_static static)
foreach (comp IN LISTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
if (comp IN_LIST ${CMAKE_FIND_PACKAGE_NAME}_known_comps)
set(${CMAKE_FIND_PACKAGE_NAME}_comp_${comp} YES)
set(_shared_or_static ${comp})
else ()
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
"${CMAKE_FIND_PACKAGE_NAME} does not recognize component `${comp}`")
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif ()
endforeach ()
if (${CMAKE_FIND_PACKAGE_NAME}_comp_static AND ${CMAKE_FIND_PACKAGE_NAME}_comp_shared)
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
"${CMAKE_FIND_PACKAGE_NAME} `static` and `shared` components are mutually exclusive")
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif ()
load_targets(static)
load_targets(shared)
add_library(${CMAKE_FIND_PACKAGE_NAME}::${CMAKE_FIND_PACKAGE_NAME} ALIAS ${CMAKE_FIND_PACKAGE_NAME}::${CMAKE_FIND_PACKAGE_NAME}-${_shared_or_static})
if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY )
message(STATUS "Found ${CMAKE_FIND_PACKAGE_NAME} ${${CMAKE_FIND_PACKAGE_NAME}_VERSION} in ${PACKAGE_PREFIX_DIR}")
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
message(STATUS "Components ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS}")
endif()
message(STATUS "Imported targets for ${_shared_or_static} libraries: ${CMAKE_FIND_PACKAGE_NAME}::${CMAKE_FIND_PACKAGE_NAME}")
endif()
unset(_shared_or_static)
endif()