2019-06-20 23:13:52 +00:00
|
|
|
# CMake build script for ZeroTier One
|
2017-12-13 22:55:17 +00:00
|
|
|
|
2019-06-21 19:54:53 +00:00
|
|
|
cmake_minimum_required (VERSION 3.8)
|
2017-12-13 22:55:17 +00:00
|
|
|
|
2019-08-16 00:29:33 +00:00
|
|
|
if(${CMAKE_VERSION} VERSION_LESS 3.15)
|
|
|
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
|
|
|
else()
|
|
|
|
cmake_policy(VERSION 3.15)
|
|
|
|
endif()
|
|
|
|
|
2019-08-12 22:28:30 +00:00
|
|
|
if(WIN32)
|
|
|
|
# If building on Windows, set minimum target to Windows 7
|
|
|
|
set(CMAKE_SYSTEM_VERSION "7" CACHE STRING INTERNAL FORCE)
|
|
|
|
endif(WIN32)
|
|
|
|
|
2019-08-12 19:43:28 +00:00
|
|
|
# ZeroTier One Version Config
|
|
|
|
|
2019-08-16 00:29:33 +00:00
|
|
|
set(ZEROTIER_ONE_VERSION_MAJOR 1 CACHE INTERNAL "")
|
2019-08-16 23:49:30 +00:00
|
|
|
set(ZEROTIER_ONE_VERSION_MINOR 9 CACHE INTERNAL "")
|
|
|
|
set(ZEROTIER_ONE_VERSION_REVISION 0 CACHE INTERNAL "")
|
2019-08-16 00:29:33 +00:00
|
|
|
set(ZEROTIER_ONE_VERSION_BUILD 0 CACHE INTERNAL "")
|
2019-08-12 19:43:28 +00:00
|
|
|
|
2019-06-21 22:16:20 +00:00
|
|
|
# Set a default build type if none was specified
|
|
|
|
set(default_build_type "Release")
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|
|
|
set(default_build_type "Debug")
|
|
|
|
endif()
|
2019-08-16 23:49:30 +00:00
|
|
|
|
2019-06-21 22:16:20 +00:00
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
|
|
|
|
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
|
|
|
|
STRING "Choose the type of build." FORCE)
|
|
|
|
# Set the possible values of build type for cmake-gui
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
|
|
|
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
|
|
|
endif()
|
|
|
|
|
2019-06-20 23:13:52 +00:00
|
|
|
option(BUILD_CENTRAL_CONTROLLER "Build ZeroTier Central Controller" OFF)
|
2019-08-16 00:29:33 +00:00
|
|
|
option(ZT_TRACE "Trace Messages" OFF)
|
|
|
|
option(ZT_DEBUG_TRACE "Debug Trace Messages" OFF)
|
2017-12-13 22:55:17 +00:00
|
|
|
|
2019-06-20 23:13:52 +00:00
|
|
|
if (BUILD_CENTRAL_CONTROLLER)
|
|
|
|
find_package(PostgreSQL REQUIRED)
|
|
|
|
set(ENABLE_SSL_SUPPORT OFF)
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
set(BUILD_EXAMPLES OFF)
|
|
|
|
set(BUILD_TOOLS OFF)
|
|
|
|
set(BUILD_TESTS OFF)
|
|
|
|
set(BUILD_API_DOCS OFF)
|
|
|
|
add_subdirectory("ext/librabbitmq")
|
|
|
|
endif(BUILD_CENTRAL_CONTROLLER)
|
|
|
|
|
2019-08-01 22:58:32 +00:00
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X Deployment Version")
|
2019-06-21 22:16:20 +00:00
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2019-06-20 23:13:52 +00:00
|
|
|
add_definitions(-DZT_TRACE)
|
2019-06-21 22:16:20 +00:00
|
|
|
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2019-06-20 23:13:52 +00:00
|
|
|
|
2019-08-16 00:29:33 +00:00
|
|
|
project(zerotier-one
|
|
|
|
DESCRIPTION "ZeroTier One"
|
|
|
|
LANGUAGES CXX C)
|
|
|
|
|
2019-06-20 23:13:52 +00:00
|
|
|
if(WIN32)
|
|
|
|
add_definitions(-DNOMINMAX)
|
2019-06-21 22:16:20 +00:00
|
|
|
else(WIN32)
|
|
|
|
if(APPLE)
|
2019-08-16 00:40:21 +00:00
|
|
|
message("Setting macOS Compiler Flags ${CMAKE_BUILD_TYPE}")
|
|
|
|
add_compile_options(
|
|
|
|
-Wall
|
|
|
|
-Wno-deprecated
|
2019-08-16 18:42:43 +00:00
|
|
|
-maes
|
|
|
|
-mpclmul
|
|
|
|
-msse
|
|
|
|
-msse2
|
|
|
|
-msse3
|
2019-08-16 00:40:21 +00:00
|
|
|
$<$<CONFIG:Debug>:-g>
|
|
|
|
$<$<CONFIG:DEBUG>:-O0>
|
2019-08-16 23:49:30 +00:00
|
|
|
$<$<CONFIG:RELEASE>:-Ofast>
|
|
|
|
$<$<CONFIG:RELEASE>:-fstack-protector-strong>
|
2019-08-16 00:40:21 +00:00
|
|
|
$<$<CONFIG:RELEASE>:-fPIE>
|
2019-08-16 23:49:30 +00:00
|
|
|
$<$<CONFIG:RELWITHDEBINFO>:-Ofast>
|
|
|
|
$<$<CONFIG:RELWITHDEBINFO>:-fstack-protector-strong>
|
2019-08-16 00:40:21 +00:00
|
|
|
$<$<CONFIG:RELWITHDEBINFO>:-fPIE>
|
|
|
|
$<$<CONFIG:RELWITHDEBINFO>:-g>
|
|
|
|
)
|
2019-06-21 22:16:20 +00:00
|
|
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
message("Setting Linux Compiler Flags ${CMAKE_BUILD_TYPE}")
|
|
|
|
add_compile_options(
|
|
|
|
-Wall
|
|
|
|
-Wno-deprecated
|
2019-08-16 18:42:43 +00:00
|
|
|
-maes
|
|
|
|
-mpclmul
|
|
|
|
-msse
|
|
|
|
-msse2
|
|
|
|
-msse3
|
2019-06-21 22:16:20 +00:00
|
|
|
$<$<CONFIG:Debug>:-g>
|
|
|
|
$<$<CONFIG:DEBUG>:-O0>
|
|
|
|
$<$<CONFIG:RELEASE>:-O3>
|
2019-08-16 00:29:33 +00:00
|
|
|
$<$<CONFIG:RELEASE>:-fstack-protector>
|
2019-06-21 22:16:20 +00:00
|
|
|
$<$<CONFIG:RELEASE>:-fPIE>
|
|
|
|
$<$<CONFIG:RELWITHDEBINFO>:-O3>
|
2019-08-16 00:29:33 +00:00
|
|
|
$<$<CONFIG:RELWITHDEBINFO>:-fstack-protector>
|
2019-06-21 22:16:20 +00:00
|
|
|
$<$<CONFIG:RELWITHDEBINFO>:-fPIE>
|
|
|
|
$<$<CONFIG:RELWITHDEBINFO>:-g>
|
|
|
|
)
|
|
|
|
endif(APPLE)
|
2019-06-20 23:13:52 +00:00
|
|
|
endif(WIN32)
|
|
|
|
|
2019-08-16 00:29:33 +00:00
|
|
|
if(ZT_TRACE)
|
|
|
|
add_definitions(-DZT_TRACE)
|
|
|
|
endif()
|
|
|
|
if(ZT_DEBUG_TRACE)
|
|
|
|
add_definitions(-DZT_DEBUG_TRACE)
|
|
|
|
endif()
|
2019-06-20 23:13:52 +00:00
|
|
|
|
|
|
|
add_subdirectory(node)
|
|
|
|
add_subdirectory(controller)
|
|
|
|
add_subdirectory(osdep)
|
|
|
|
add_subdirectory(service)
|
|
|
|
|
|
|
|
if(WIN32)
|
2019-06-21 19:54:53 +00:00
|
|
|
add_subdirectory("windows/WinUI")
|
|
|
|
add_subdirectory("windows/copyutil")
|
2019-06-20 23:13:52 +00:00
|
|
|
add_definitions(-DNOMINMAX)
|
|
|
|
endif(WIN32)
|
|
|
|
|
|
|
|
set(libs
|
|
|
|
zt_service
|
2019-06-21 22:16:20 +00:00
|
|
|
zt_osdep
|
|
|
|
zt_core
|
|
|
|
zt_controller
|
2019-06-20 23:13:52 +00:00
|
|
|
)
|
|
|
|
|
2019-08-12 19:43:28 +00:00
|
|
|
configure_file(
|
2019-08-16 00:29:33 +00:00
|
|
|
${CMAKE_SOURCE_DIR}/version.h.in
|
|
|
|
${CMAKE_BINARY_DIR}/version.h
|
2019-08-12 19:43:28 +00:00
|
|
|
)
|
|
|
|
|
2019-06-20 23:13:52 +00:00
|
|
|
set(src
|
|
|
|
one.cpp
|
|
|
|
"ext/http-parser/http_parser.c"
|
|
|
|
)
|
|
|
|
set(headers
|
|
|
|
"ext/http-parser/http_parser.h"
|
|
|
|
)
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
set(libs ${libs} wsock32 ws2_32 rpcrt4 iphlpapi)
|
|
|
|
set(src
|
|
|
|
${src}
|
|
|
|
"windows/ZeroTierOne/ServiceBase.cpp"
|
|
|
|
"windows/ZeroTierOne/ServiceInstaller.cpp"
|
|
|
|
"windows/ZeroTierOne/ZeroTierOneService.cpp"
|
|
|
|
"windows/ZeroTierOne/ZeroTierOne.rc"
|
|
|
|
)
|
|
|
|
set(headers
|
|
|
|
${headers}
|
|
|
|
"windows/ZeroTierOne/ServiceBase.h"
|
|
|
|
"windows/ZeroTierOne/ServiceInstaller.h"
|
|
|
|
"windows/ZeroTierOne/ZeroTierOneService.h"
|
|
|
|
)
|
2019-06-21 22:16:20 +00:00
|
|
|
else(WIN32)
|
2019-08-16 23:49:30 +00:00
|
|
|
set(libs ${libs} pthread resolv)
|
2019-06-20 23:13:52 +00:00
|
|
|
endif(WIN32)
|
|
|
|
|
|
|
|
if(BUILD_CENTRAL_CONTROLLER)
|
|
|
|
set(libs ${libs} rabbitmq-static ${PostgreSQL_LIBRARIES})
|
|
|
|
endif(BUILD_CENTRAL_CONTROLLER)
|
|
|
|
|
2019-08-16 00:29:33 +00:00
|
|
|
|
2019-06-20 23:13:52 +00:00
|
|
|
add_executable(${PROJECT_NAME} ${src} ${headers})
|
2019-06-21 22:16:20 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME} ${libs})
|
2019-08-16 00:29:33 +00:00
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR})
|
2019-08-12 20:25:14 +00:00
|
|
|
|
|
|
|
add_executable(zerotier-selftest selftest.cpp)
|
|
|
|
target_link_libraries(zerotier-selftest ${libs})
|