Skip to content

Commit

Permalink
Added possibility to generate full static builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Bendr0id committed Dec 4, 2023
1 parent ed233d3 commit 48e4233
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ option(WITH_DEBUG_LOG "Enable debug log output" OFF)
option(WITH_HTTP "HTTP protocol support (client/server)" ON)
option(WITH_TLS "Enable OpenSSL support" ON)
option(WITH_ENV_VARS "Enable environment variables support in config file" ON)

option(BUILD_STATIC "Build static binary" OFF)

include (CheckIncludeFile)
include (cmake/os.cmake)
Expand Down
7 changes: 7 additions & 0 deletions cmake/flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()

if (BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()

elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
set(CMAKE_C_FLAGS_RELEASE "/MT /O2 /Oi /DNDEBUG /GL")
set(CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Oi /DNDEBUG /GL")
Expand All @@ -52,4 +56,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-overloaded-virtual")

if (BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()
endif()

0 comments on commit 48e4233

Please sign in to comment.