diff --git a/CMakeLists.txt b/CMakeLists.txt index ab9572cad..a9ae6476e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 + $<$:-g> + $<$:-O0> + $<$:-O3> + $<$:-fstackprotector> + $<$:-fPIE> + $<$:-O3> + $<$:-fstackprotector> + $<$:-fPIE> + $<$:-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}) \ No newline at end of file +target_link_libraries(${PROJECT_NAME} ${libs}) diff --git a/node/CMakeLists.txt b/node/CMakeLists.txt index cec018abb..c52b0da3b 100644 --- a/node/CMakeLists.txt +++ b/node/CMakeLists.txt @@ -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}) \ No newline at end of file +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) diff --git a/osdep/CMakeLists.txt b/osdep/CMakeLists.txt index 1988de21f..f9741a611 100644 --- a/osdep/CMakeLists.txt +++ b/osdep/CMakeLists.txt @@ -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})