-
Notifications
You must be signed in to change notification settings - Fork 985
Open
Description
The current implementation of the custom helper function 'find_link_library' is
function(find_link_library libname outlibname)
check_linker_flag(C "-l${libname}" mi_has_lib${libname})
if (mi_has_lib${libname})
message(VERBOSE "link library: -l${libname}")
set(${outlibname} ${libname} PARENT_SCOPE)
else()
find_library(MI_LIBPATH libname)
if (MI_LIBPATH)
message(VERBOSE "link library ${libname} at ${MI_LIBPATH}")
set(${outlibname} ${MI_LIBPATH} PARENT_SCOPE)
else()
message(VERBOSE "link library not found: ${libname}")
set(${outlibname} "" PARENT_SCOPE)
endif()
endif()
endfunction()
As it currently stands, it is 100% broken in the event the linker flag check fails, this is because it passes "libname" instead of "${libname}" to find_library AND will silently abort if MI_LIBPATH is set to a library path already (in a previous call).
To fix this, obviously "libname" -> "${libname}" is required, but one of two solutions can be deployed for the variable situation:
- Explicitly set "MI_LIBPATH" to the value "MI_LIBPATH-NOTFOUND" to force find_library to run, this can be a normal variable.
- Do what the linker flag check does and append "${libname}" to the test variable: "MI_LIBPATH" -> "MI_LIBPATH${libname}".
Markdown is hiding underscores in the suggested fixes for the MI_LIBPATH variable.
Metadata
Metadata
Assignees
Labels
No labels