added static build option

This commit is contained in:
Grant Limberg 2020-06-12 15:43:12 -07:00
parent b88000c349
commit 5166aa6913
No known key found for this signature in database
GPG key ID: 2BA62CCABBB4095A
2 changed files with 12 additions and 1 deletions

View file

@ -105,6 +105,7 @@ else(WIN32)
$<$<CONFIG:RELWITHDEBINFO>:-g>
)
option(BUILD_32BIT "Force building as 32-bit binary" OFF)
option(BUILD_STATIC "Build statically linked executable" OFF)
if(BUILD_32BIT)
set(CMAKE_SYSTEM_PROCESSOR "x86" CACHE STRING "system processor")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
@ -114,6 +115,11 @@ else(WIN32)
-m32
)
endif(BUILD_32BIT)
if(BUILD_STATIC)
add_link_options(
-static
)
endif(BUILD_STATIC)
endif(APPLE)
endif(WIN32)

7
Jenkinsfile vendored
View file

@ -55,7 +55,12 @@ def buildStaticBinaries() {
def runtime = docker.image("ztbuild/${distro}-${platform}:latest")
runtime.inside {
dir("build") {
sh 'make -j8 ZT_STATIC=1 all'
def cmakeFlags = 'CMAKE_ARGS="-DBUILD_STATIC=1"'
if (arch == "i386") {
cmakeFlags = 'CMAKE_ARGS="-DBUILD_32BIT=1 -DBUILD_STATIC=1"'
}
sh "${cmakeFlags} make -j8 ZT_STATIC=1 all"
dir("build") {
sh "mv zerotier zerotier-static-${platform}"
stash includes: 'zerotier-static-*', name: "static-${platform}"