diff --git a/CMakeLists.txt b/CMakeLists.txt index 7df6b8a0e..867ca76ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,6 +105,7 @@ else(WIN32) $<$:-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) diff --git a/Jenkinsfile b/Jenkinsfile index 58a0de118..15fa39df6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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}"