This repository has been archived by the owner on Jul 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
iCDumpConfig.cmake.in
70 lines (63 loc) · 2.14 KB
/
iCDumpConfig.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
# Process known components
set(iCDump_known_comps STATIC SHARED)
set(iCDump_comp_STATIC NO)
set(iCDump_comp_SHARED NO)
foreach(_comp ${iCDump_FIND_COMPONENTS})
if(";${iCDump_known_comps};" MATCHES ";${_comp};")
set(iCDump_comp_${_comp} YES)
else()
set(iCDump_NOT_FOUND_MESSAGE
"iCDump does not recognize component `${_comp}`.")
set(iCDump_FOUND FALSE)
return()
endif()
endforeach()
# Validate component selection makes sense
if(iCDump_comp_STATIC AND iCDump_comp_SHARED)
set(iCDump_NOT_FOUND_MESSAGE
"iCDump `STATIC` and `SHARED` components are mutually exclusive.")
set(iCDump_FOUND FALSE)
return()
endif()
# These files are generated by CMake and hold the iCDump library target(s).
set(iCDump_static_export "${CMAKE_CURRENT_LIST_DIR}/iCDumpExport-static.cmake")
set(iCDump_shared_export "${CMAKE_CURRENT_LIST_DIR}/iCDumpExport-shared.cmake")
# Helper macro to load the requested targets, where `lib_type` is `static` or
# `shared`
macro(iCDump_load_targets lib_type)
if(NOT EXISTS "${iCDump_${lib_type}_export}")
set(iCDump_NOT_FOUND_MESSAGE
"iCDump `${lib_type}` libraries were requested but not found.")
set(iCDump_FOUND FALSE)
return()
endif ()
# Include the respective targets file
include("${iCDump_${lib_type}_export}")
endmacro()
# Run the logic to choose static or shared libraries
# 1. Check components
if(iCDump_comp_STATIC)
iCDump_load_targets("static")
elseif(iCDump_comp_SHARED)
iCDump_load_targets("shared")
# 2. Check iCDump-only library selection
elseif(DEFINED iCDump_SHARED_LIBS AND iCDump_SHARED_LIBS)
iCDump_load_targets("shared")
elseif(DEFINED iCDump_SHARED_LIBS AND NOT iCDump_SHARED_LIBS)
iCDump_load_targets("static")
# 3. Check CMake build type and choose what's available
elseif(BUILD_SHARED_LIBS)
if(EXISTS "${iCDump_shared_export}")
iCDump_load_targets("shared")
else()
iCDump_load_targets("static")
endif()
else()
if(EXISTS "${iCDump_static_export}")
iCDump_load_targets("static")
else()
iCDump_load_targets("shared")
endif()
endif()
set(iCDump_LIBRARIES iCDump::iCDump)
get_target_property(iCDump_INCLUDE_DIRS iCDump::iCDump INTERFACE_INCLUDE_DIRECTORIES)