diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c8ba57859..7d0b606562 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,7 @@ option(ENABLE_GUI "Enable Qt-based GUI" OFF) option(ENABLE_DOCS "Build Doxygen documentation" OFF) option(ENABLE_TESTS "Build tests" OFF) option(LUPDATE "Update translation files" OFF) +option(STATIC_LIBS "Prefer static variants of system libraries" ${WIN32}) option(STATIC_RUNTIME "Link runtime statically" ${WIN32}) # CPU-dependent options @@ -251,6 +252,11 @@ if(APPLE) add_compile_options(-Wno-error=thread-safety-reference) endif() +if(STATIC_LIBS) + set(CMAKE_LINK_SEARCH_START_STATIC ON) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_STATIC_LIBRARY_SUFFIX}") +endif() + if(STATIC_RUNTIME) if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang)\$") list(APPEND RUNTIME_LIBS -static-libgcc -static-libstdc++)