Add static libraries to Linux amalgamation (#3699)

This commit is contained in:
Bart Louwers
2025-08-02 01:05:01 +02:00
committed by GitHub
parent ca5f79c12d
commit 33e56f13e3
2 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
function(find_static_library result_var)
# Usage: find_static_library(VAR_NAME NAMES name1 [name2 ...])
set(options)
set(one_value_args)
set(multi_value_args NAMES)
cmake_parse_arguments(FSL "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
if(NOT FSL_NAMES)
message(FATAL_ERROR "find_static_library: NAMES argument required")
endif()
# Clear any previous cached result for this variable
unset(${result_var} CACHE)
# Temporarily force CMake to look only for .a
set(_old_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
# Invoke find_library using the caller's var name
find_library(${result_var} NAMES ${FSL_NAMES})
# Restore original suffix list
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_old_suffixes})
# Check result
if(NOT ${result_var})
message(FATAL_ERROR
"find_static_library: could not find any of [${FSL_NAMES}] as a .a")
endif()
message(STATUS
"find_static_library: Found static [${FSL_NAMES}] -> ${${result_var}}")
endfunction()