mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 04:57:53 +00:00
Linux build with CMake
This commit is contained in:
parent
d3b33e5512
commit
4d599e2f9f
@ -3,6 +3,21 @@
|
||||
cmake_minimum_required (VERSION 3.8)
|
||||
project (zerotier-one)
|
||||
|
||||
# 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()
|
||||
|
||||
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()
|
||||
|
||||
option(BUILD_CENTRAL_CONTROLLER "Build ZeroTier Central Controller" OFF)
|
||||
|
||||
if (BUILD_CENTRAL_CONTROLLER)
|
||||
@ -17,15 +32,33 @@ if (BUILD_CENTRAL_CONTROLLER)
|
||||
add_subdirectory("ext/librabbitmq")
|
||||
endif(BUILD_CENTRAL_CONTROLLER)
|
||||
|
||||
if(CMAKE_BUILD_TYPE EQUAL "Debug")
|
||||
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_definitions(-DZT_TRACE)
|
||||
endif(CMAKE_BUILD_TYPE EQUAL "Debug")
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DNOMINMAX)
|
||||
if(CMAKE_BUILD_TYPE EQUAL "Debug")
|
||||
add_definitions(-DZT_WIN_RUN_IN_CONSOLE)
|
||||
endif(CMAKE_BUILD_TYPE EQUAL "Debug")
|
||||
else(WIN32)
|
||||
if(APPLE)
|
||||
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
message("Setting Linux Compiler Flags ${CMAKE_BUILD_TYPE}")
|
||||
add_compile_options(
|
||||
-Wall
|
||||
-Wno-deprecated
|
||||
$<$<CONFIG:Debug>:-g>
|
||||
$<$<CONFIG:DEBUG>:-O0>
|
||||
$<$<CONFIG:RELEASE>:-O3>
|
||||
$<$<CONFIG:RELEASE>:-fstackprotector>
|
||||
$<$<CONFIG:RELEASE>:-fPIE>
|
||||
$<$<CONFIG:RELWITHDEBINFO>:-O3>
|
||||
$<$<CONFIG:RELWITHDEBINFO>:-fstackprotector>
|
||||
$<$<CONFIG:RELWITHDEBINFO>:-fPIE>
|
||||
$<$<CONFIG:RELWITHDEBINFO>:-g>
|
||||
)
|
||||
endif(APPLE)
|
||||
endif(WIN32)
|
||||
|
||||
|
||||
@ -41,10 +74,10 @@ if(WIN32)
|
||||
endif(WIN32)
|
||||
|
||||
set(libs
|
||||
zt_controller
|
||||
zt_core
|
||||
zt_osdep
|
||||
zt_service
|
||||
zt_osdep
|
||||
zt_core
|
||||
zt_controller
|
||||
)
|
||||
|
||||
set(src
|
||||
@ -70,6 +103,8 @@ if(WIN32)
|
||||
"windows/ZeroTierOne/ServiceInstaller.h"
|
||||
"windows/ZeroTierOne/ZeroTierOneService.h"
|
||||
)
|
||||
else(WIN32)
|
||||
set(libs ${libs} pthread)
|
||||
endif(WIN32)
|
||||
|
||||
if(BUILD_CENTRAL_CONTROLLER)
|
||||
@ -77,4 +112,4 @@ if(BUILD_CENTRAL_CONTROLLER)
|
||||
endif(BUILD_CENTRAL_CONTROLLER)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${src} ${headers})
|
||||
target_link_libraries(${PROJECT_NAME} ${libs})
|
||||
target_link_libraries(${PROJECT_NAME} ${libs})
|
||||
|
@ -7,4 +7,15 @@ endif(WIN32)
|
||||
|
||||
file(GLOB core_headers *.hpp)
|
||||
file(GLOB core_src *.cpp)
|
||||
add_library(${PROJECT_NAME} STATIC ${core_src} ${core_headers})
|
||||
add_library(${PROJECT_NAME} STATIC ${core_src} ${core_headers})
|
||||
|
||||
if(UNIX)
|
||||
set_source_files_properties(
|
||||
Salsa20.cpp
|
||||
SHA512.cpp
|
||||
C25519.cpp
|
||||
Poly1305.cpp
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-Wall -O3"
|
||||
)
|
||||
endif(UNIX)
|
||||
|
@ -41,10 +41,10 @@ elseif(UNIX)
|
||||
set(headers ${headers} freebsd_getifmaddrs.h)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME EQUAL "Linux")
|
||||
set(src ${src} LinuxEthernetTap.cpp)
|
||||
set(headers ${headers} LinuxEthernetTap.hpp)
|
||||
endif(CMAKE_SYSTEM_NAME EQUAL "Linux")
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
set(src ${src} LinuxEthernetTap.cpp LinuxNetLink.cpp)
|
||||
set(headers ${headers} LinuxEthernetTap.hpp LinuxNetLink.hpp)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
endif(WIN32)
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC ${src} ${headers})
|
||||
|
Loading…
Reference in New Issue
Block a user