-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmakeConfig.cmake.in
70 lines (60 loc) · 2.46 KB
/
cmakeConfig.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
include(GNUInstallDirs)
# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(build_type "release")
else ()
set(build_type "debug")
endif ()
message(STATUS "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}, using ${build_type} config.")
set(lib_path "${_IMPORT_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(shared_lib_name "${CMAKE_SHARED_LIBRARY_PREFIX}@x_LIB_NAME@${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(static_lib_name "${CMAKE_STATIC_LIBRARY_PREFIX}@x_LIB_NAME@${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(static_lib_path "${lib_path}/${static_lib_name}")
set(shared_lib_path "${lib_path}/${shared_lib_name}")
if(EXISTS ${shared_lib_path})
set(lib_path ${shared_lib_path})
elseif(EXISTS ${static_lib_path})
set(lib_path ${static_lib_path})
else()
message(FATAL_ERROR "@CRATE_NAME@ library (${shared_lib_name} or ${static_lib_name}) not found in ${lib_path}!")
endif()
set(include_path ${_IMPORT_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/)
if(NOT EXISTS ${include_path})
message(FATAL_ERROR "@CRATE_NAME@ headers not found in ${include_path}!")
endif()
if(NOT TARGET @CRATE_NAME@::@CRATE_NAME@)
add_library(@CRATE_NAME@::@CRATE_NAME@ STATIC IMPORTED GLOBAL)
if(EXISTS ${_IMPORT_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${static_lib_name})
if (APPLE)
# on apple we need to link Security
find_library(Security Security)
find_package_handle_standard_args(@CRATE_NAME@
REQUIRED_VARS Security
)
set_target_properties(@CRATE_NAME@::@CRATE_NAME@ PROPERTIES
INTERFACE_LINK_LIBRARIES ${Security}
)
elseif (UNIX)
# on Linux we need to link pthread
target_link_libraries(@CRATE_NAME@::@CRATE_NAME@ INTERFACE
pthread
-Wl,--no-as-needed
dl
)
else ()
message(ERROR "You've built static lib, it may not link on this platform. Come here and fix.")
endif ()
endif()
set_target_properties(@CRATE_NAME@::@CRATE_NAME@ PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${include_path}
IMPORTED_LOCATION ${lib_path}
)
endif()
unset(shared_lib_name)
unset(static_lib_name)
unset(shared_lib_path)
unset(static_lib_path)
unset(lib_path)
unset(include_path)
check_required_components(@CRATE_NAME@)