From a1649d6cda4e2df82abd9c87483df9020d496c48 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 12 Jun 2020 15:58:00 -0700 Subject: [PATCH] trying again for static build. also add static go flags --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 867ca76ba..0c1b9cde0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,6 +119,8 @@ else(WIN32) add_link_options( -static ) + set(CMAKE_EXE_LINKER_FLAGS "-static ${CMAKE_EXE_LINKER_FLAGS}") + set(GOFLAGS "-a -tags netgo -ldflags '-w -extldflags \"-static\"") endif(BUILD_STATIC) endif(APPLE) endif(WIN32) @@ -149,7 +151,7 @@ file(GLOB go_src add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/zerotier_cgo.h ${CMAKE_BINARY_DIR}/zerotier_cgo.a - COMMAND ${GOARCH} CGO_ENABLED=1 ${GO} build -buildmode=c-archive -o ${CMAKE_BINARY_DIR}/zerotier_cgo.a ${CMAKE_SOURCE_DIR}/cmd/zerotier/zerotier.go + COMMAND ${GOARCH} CGO_ENABLED=1 ${GO} build -buildmode=c-archive ${GOFLAGS} -o ${CMAKE_BINARY_DIR}/zerotier_cgo.a ${CMAKE_SOURCE_DIR}/cmd/zerotier/zerotier.go IMPLICIT_DEPENDS ${go_src} COMMENT "Compiling Go Code..." )