Browse Source

add

tags/v1.2.0
taoxudonghaha 3 years ago
parent
commit
a2b6270dc4
1 changed files with 12 additions and 3 deletions
  1. +12
    -3
      cmake/FindModule.cmake

+ 12
- 3
cmake/FindModule.cmake View File

@@ -3,11 +3,16 @@
name - find the library name name - find the library name
path - find the library path path - find the library path
#]] #]]
function(find_module module name path)
function(find_module module name)
if (TARGET ${module}) if (TARGET ${module})
return() return()
endif() 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} find_library(${module}_LIBRARY_DIR NAMES ${name} NAMES_PER_DIR PATHS ${path}
PATH_SUFFIXES lib PATH_SUFFIXES lib
) )
@@ -16,5 +21,9 @@ function(find_module module name path)
if ("${${module}_LIBRARY_DIR}" STREQUAL "${module}_LIBRARY_DIR-NOTFOUND") if ("${${module}_LIBRARY_DIR}" STREQUAL "${module}_LIBRARY_DIR-NOTFOUND")
message(FATAL_ERROR "${name} not found in ${path}") message(FATAL_ERROR "${name} not found in ${path}")
endif() 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() endfunction()

Loading…
Cancel
Save