CMake force linking static libs
CMake by default searches for shared libs before static libs.
Sometimes a project needs to specifically link external or internal static libs, even if shared libs are present.
A simple cross-platform way to do this is to set
CMAKE_FIND_LIBRARY_SUFFIXES
before any find_library() or find_package():
set(CMAKE_FIND_LIBRARY_SUFFIXES .a .lib)This takes advantage of de facto static library extensions for macOS, Windows and Linux, using CMake system variables.
The default values for CMAKE_FIND_LIBRARY_SUFFIXES are set by (depending on platform and compiler) CMake
Modules/CMakeGenericSystem.cmake
Modules/Compiler/
Modules/Platform/