pull/652/head
taoxudonghaha 4 years ago
parent 39562e8154
commit a2b6270dc4

@ -3,11 +3,16 @@
name - find the library name
path - find the library path
#]]
function(find_module module name path)
function(find_module module name)
if (TARGET ${module})
return()
endif()
add_library(${module} INTERFACE)
set(options)
set(oneValueArgs)
set(multiValueArgs)
cmake_parse_arguments(MODULE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(path ${MODULE_UNPARSED_ARGUMENTS})
find_library(${module}_LIBRARY_DIR NAMES ${name} NAMES_PER_DIR PATHS ${path}
PATH_SUFFIXES lib
)
@ -16,5 +21,9 @@ function(find_module module name path)
if ("${${module}_LIBRARY_DIR}" STREQUAL "${module}_LIBRARY_DIR-NOTFOUND")
message(FATAL_ERROR "${name} not found in ${path}")
endif()
target_link_libraries(${module} INTERFACE ${${module}_LIBRARY_DIR})
add_library(${module} SHARED IMPORTED)
set_target_properties(${module} PROPERTIES
IMPORTED_LOCATION ${${module}_LIBRARY_DIR}
)
endfunction()

Loading…
Cancel
Save