enable -DPACKAGE_STATIC=1 builds

Only configures the project for packaging of the statically built binary placed in build/
This commit is contained in:
Grant Limberg 2020-06-22 13:50:35 -07:00
parent 7c6f5e2c37
commit 09a8b66d3b
No known key found for this signature in database
GPG key ID: 2BA62CCABBB4095A

View file

@ -17,13 +17,13 @@ project(zerotier
DESCRIPTION "ZeroTier Network Hypervisor" DESCRIPTION "ZeroTier Network Hypervisor"
LANGUAGES CXX C) LANGUAGES CXX C)
if(${CMAKE_VERSION} VERSION_LESS 3.15) if(${CMAKE_VERSION} VERSION_LESS 3.15)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else() else()
cmake_policy(VERSION 3.15) cmake_policy(VERSION 3.15)
endif() endif()
if(NOT PACKAGE_STATIC)
find_program( find_program(
GO go GO go
HINTS "/usr/local/go/bin" "C:/go/bin" HINTS "/usr/local/go/bin" "C:/go/bin"
@ -234,8 +234,16 @@ add_custom_target(
COMMENT "Compiling Go Code..." COMMENT "Compiling Go Code..."
) )
add_dependencies(zerotier zt_osdep zt_core zt_controller zt_service_io_core) add_dependencies(zerotier zt_osdep zt_core zt_controller zt_service_io_core)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/zerotier DESTINATION bin) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/zerotier DESTINATION bin)
else(NOT PACKAGE_STATIC)
set(STATIC_BINARY ${CMAKE_BINARY_DIR}/zerotier)
set(IMPORTED_LOCATION ${CMAKE_BINARY_DIR})
add_executable(zerotier IMPORTED GLOBAL)
install(PROGRAMS ${STATIC_BINARY} DESTINATION bin)
endif(NOT PACKAGE_STATIC)
if("${CMAKE_SYSTEM_NAME}" EQUAL "Linux") if("${CMAKE_SYSTEM_NAME}" EQUAL "Linux")
if(IS_DIRECTORY /lib/systemd/system) if(IS_DIRECTORY /lib/systemd/system)
install( install(