17 cmake_parse_arguments(PARSE_ARGV 1 vdlt
22 if (NOT DEFINED vdlt_PATH)
24 "The `PATH` argument is required.")
27 if (DEFINED vdlt_UNPARSED_ARGUMENTS)
30 "${vdlt_UNPARSED_ARGUMENTS}
")
35 "The `PATH` argument is empty.
")
38 set(vdlt_type UNKNOWN)
39 # Windows libraries all end with `.lib`. We need to detect the type based on
40 # the contents of the library. However, MinGW does use different extensions.
41 if (WIN32 AND NOT MINGW)
42 find_program(DUMPBIN_EXECUTABLE
44 DOC "Path to the dumpbin executable
")
45 mark_as_advanced(DUMPBIN_EXECUTABLE)
47 COMMAND "${DUMPBIN_EXECUTABLE}
"
50 OUTPUT_VARIABLE vdlt_out
51 ERROR_VARIABLE vdlt_err
52 RESULT_VARIABLE vdlt_res)
55 "Failed to run `dumpbin`
on ${vdlt_PATH}. Cannot determine
"
56 "shared/
static library
type: ${vdlt_err}
")
58 if (vdlt_out MATCHES "DLL
name :
")
65 string(LENGTH "${vdlt_PATH}
" vdlt_path_len)
67 string(LENGTH "${CMAKE_SHARED_LIBRARY_SUFFIX}
" vdlt_shared_suffix_len)
68 math(EXPR vdlt_shared_idx "${vdlt_path_len} - ${vdlt_shared_suffix_len}
")
69 string(SUBSTRING "${vdlt_PATH}
" "${vdlt_shared_idx}
" -1 vdlt_shared_check)
71 string(LENGTH "${CMAKE_STATIC_LIBRARY_SUFFIX}
" vdlt_static_suffix_len)
72 math(EXPR vdlt_static_idx "${vdlt_path_len} - ${vdlt_static_suffix_len}
")
73 string(SUBSTRING "${vdlt_PATH}
" "${vdlt_static_idx}
" -1 vdlt_static_check)
75 if (vdlt_shared_check STREQUAL CMAKE_SHARED_LIBRARY_SUFFIX)
77 elseif (vdlt_static_check STREQUAL CMAKE_STATIC_LIBRARY_SUFFIX)
81 # when import suffix != static suffix, we can disambiguate static and import
82 if (WIN32 AND NOT CMAKE_IMPORT_LIBRARY_SUFFIX STREQUAL CMAKE_STATIC_LIBRARY_SUFFIX)
83 string(LENGTH "${CMAKE_IMPORT_LIBRARY_SUFFIX}
" vdlt_import_suffix_len)
84 math(EXPR vdlt_import_idx "${vdlt_path_len} - ${vdlt_import_suffix_len}
")
85 string(SUBSTRING "${vdlt_PATH}
" "${vdlt_import_idx}
" -1 vdlt_import_check)
86 if (vdlt_import_check STREQUAL CMAKE_IMPORT_LIBRARY_SUFFIX)