1
0
Fork 0

Use -Bstatic compiler option rather than find_library

This commit is contained in:
Ilya Fedin 2022-01-21 15:09:05 +04:00 committed by John Preston
parent 8e0b71c049
commit 8e0b1aa26c

View file

@ -16,17 +16,13 @@ function(target_link_static_libraries target_name)
if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE") if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE")
set(writing_now ${entry}) set(writing_now ${entry})
else() else()
find_library(static_lib_${entry} lib${entry}.a) set(link_option "-Wl,--push-state,-Bstatic,-l${entry},--pop-state")
set(full_path "${static_lib_${entry}}")
if (${full_path} STREQUAL static_lib_${entry}-NOTFOUND)
message(FATAL_ERROR "Could not find static library lib${entry}.a")
endif()
if ("${writing_now}" STREQUAL "PRIVATE") if ("${writing_now}" STREQUAL "PRIVATE")
list(APPEND private_libs ${full_path}) list(APPEND private_libs ${link_option})
elseif ("${writing_now}" STREQUAL "PUBLIC") elseif ("${writing_now}" STREQUAL "PUBLIC")
list(APPEND public_libs ${full_path}) list(APPEND public_libs ${link_option})
elseif ("${writing_now}" STREQUAL "INTERFACE") elseif ("${writing_now}" STREQUAL "INTERFACE")
list(APPEND interface_libs ${full_path}) list(APPEND interface_libs ${link_option})
else() else()
message(FATAL_ERROR "Unknown frameworks scope for target ${target_name}") message(FATAL_ERROR "Unknown frameworks scope for target ${target_name}")
endif() endif()