-
Notifications
You must be signed in to change notification settings - Fork 2
/
LZHLConfig.cmake
55 lines (49 loc) · 1.75 KB
/
LZHLConfig.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
cmake_minimum_required(VERSION 3.19)
set(LZHL_known_comps static shared)
set(LZHL_comp_static NO)
set(LZHL_comp_shared NO)
foreach(LZHL_comp IN LISTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
if(LZHL_comp IN_LIST LZHL_known_comps)
set(LZHL_comp_${LZHL_comp} YES)
else()
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "LZHL does not recognize component `${LZHL_comp}`.")
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif()
endforeach()
if(LZHL_comp_static AND LZHL_comp_shared)
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "LZHL `static` and `shared` components are mutually exclusive.")
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif()
set(LZHL_static_targets "${CMAKE_CURRENT_LIST_DIR}/LZHL-static-targets.cmake")
set(LZHL_shared_targets "${CMAKE_CURRENT_LIST_DIR}/LZHL-shared-targets.cmake")
macro(LZHL_load_targets type)
if(NOT EXISTS "${LZHL_${type}_targets}")
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "LZHL `${type}` libraries were requested but not found.")
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif()
include("${LZHL_${type}_targets}")
endmacro()
if(LZHL_comp_static)
LZHL_load_targets(static)
elseif(LZHL_comp_shared)
LZHL_load_targets(shared)
elseif(DEFINED LZHL_SHARED_LIBS AND LZHL_SHARED_LIBS)
LZHL_load_targets(shared)
elseif(DEFINED LZHL_SHARED_LIBS AND NOT LZHL_SHARED_LIBS)
LZHL_load_targets(static)
elseif(BUILD_SHARED_LIBS)
if(EXISTS "${LZHL_shared_targets}")
LZHL_load_targets(shared)
else()
LZHL_load_targets(static)
endif()
else()
if(EXISTS "${LZHL_static_targets}")
LZHL_load_targets(static)
else ()
LZHL_load_targets(shared)
endif()
endif()