CMake: Improve adding external libraries to wx-config

Don't add -l to libraries already containing it (for example -lpthread).
Change libraries with format libName.so or libName.a to -lName,
configure also uses -l for these libraries. Account for possible invalid
libraries (Name-NOTFOUND) which could happen with imported libraries,
for example OpenGL::OpenGL.

Closes https://github.com/wxWidgets/wxWidgets/pull/2359
This commit is contained in:
Maarten Bent 2021-05-04 21:30:29 +02:00 committed by Vadim Zeitlin
parent 4b71e50094
commit 9814d58415

View File

@ -42,7 +42,13 @@ macro(wx_get_dependencies var lib)
else()
get_filename_component(dep_name ${dep} NAME)
endif()
wx_string_append(${var} "-l${dep_name} ")
if(dep_name MATCHES "^-l(.*)" OR dep_name STREQUAL "libc.so")
wx_string_append(${var} "${dep_name} ")
elseif(dep_name MATCHES "^lib(.*)(.so|.a)")
wx_string_append(${var} "-l${CMAKE_MATCH_1} ")
elseif(dep_name)
wx_string_append(${var} "-l${dep_name} ")
endif()
endforeach()
string(STRIP ${${var}} ${var})
endif()