Skip to content

Commit

Permalink
build: CMake: Add option to prefer static libs
Browse files Browse the repository at this point in the history
Enabled by default on Windows.
  • Loading branch information
CyberTailor committed Jan 28, 2024
1 parent b617435 commit 1376180
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++)
Expand Down

0 comments on commit 1376180

Please sign in to comment.