summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt169
-rw-r--r--appveyor.yml13
-rw-r--r--cmake/Dependencies.cmake56
-rw-r--r--cmake/ModulePackage.cmake8
-rw-r--r--toxcore/network.h8
5 files changed, 154 insertions, 100 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3e436d35..52a52dee 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,5 @@
1cmake_minimum_required(VERSION 2.8.6) 1cmake_minimum_required(VERSION 2.8.6)
2cmake_policy(VERSION 2.8.6)
2project(toxcore) 3project(toxcore)
3include(CTest) 4include(CTest)
4 5
@@ -41,7 +42,6 @@ include(ApiDsl)
41include(CheckCCompilerFlag) 42include(CheckCCompilerFlag)
42include(CheckCXXCompilerFlag) 43include(CheckCXXCompilerFlag)
43include(MacRpath) 44include(MacRpath)
44include(ModulePackage)
45 45
46set(CMAKE_MACOSX_RPATH ON) 46set(CMAKE_MACOSX_RPATH ON)
47 47
@@ -76,77 +76,79 @@ macro(add_flag flag)
76 add_cxxflag(${flag}) 76 add_cxxflag(${flag})
77endmacro() 77endmacro()
78 78
79# Set standard version for compiler. 79if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
80add_cflag("-std=c99") 80 # Set standard version for compiler.
81add_cxxflag("-std=c++11") 81 add_cflag("-std=c99")
82 82 add_cxxflag("-std=c++11")
83# Warn on non-ISO C. 83
84add_cflag("-pedantic") 84 # Warn on non-ISO C.
85 85 add_cflag("-pedantic")
86option(WARNINGS "Enable additional compiler warnings" ON) 86
87if(WARNINGS) 87 option(WARNINGS "Enable additional compiler warnings" ON)
88 # Add all warning flags we can. 88 if(WARNINGS)
89 add_flag("-Wall") 89 # Add all warning flags we can.
90 add_flag("-Wextra") 90 add_flag("-Wall")
91 add_flag("-Weverything") 91 add_flag("-Wextra")
92 92 add_flag("-Weverything")
93 # Disable specific warning flags for both C and C++. 93
94 add_flag("-Wno-cast-align") 94 # Disable specific warning flags for both C and C++.
95 add_flag("-Wno-conversion") 95 add_flag("-Wno-cast-align")
96 add_flag("-Wno-covered-switch-default") 96 add_flag("-Wno-conversion")
97 add_flag("-Wno-documentation-deprecated-sync") 97 add_flag("-Wno-covered-switch-default")
98 add_flag("-Wno-format-nonliteral") 98 add_flag("-Wno-documentation-deprecated-sync")
99 add_flag("-Wno-missing-field-initializers") 99 add_flag("-Wno-format-nonliteral")
100 add_flag("-Wno-missing-prototypes") 100 add_flag("-Wno-missing-field-initializers")
101 add_flag("-Wno-padded") 101 add_flag("-Wno-missing-prototypes")
102 add_flag("-Wno-parentheses") 102 add_flag("-Wno-padded")
103 add_flag("-Wno-return-type") 103 add_flag("-Wno-parentheses")
104 add_flag("-Wno-sign-compare") 104 add_flag("-Wno-return-type")
105 add_flag("-Wno-sign-conversion") 105 add_flag("-Wno-sign-compare")
106 add_flag("-Wno-tautological-constant-out-of-range-compare") 106 add_flag("-Wno-sign-conversion")
107 add_flag("-Wno-type-limits") 107 add_flag("-Wno-tautological-constant-out-of-range-compare")
108 add_flag("-Wno-undef") 108 add_flag("-Wno-type-limits")
109 add_flag("-Wno-unreachable-code") 109 add_flag("-Wno-undef")
110 add_flag("-Wno-unused-macros") 110 add_flag("-Wno-unreachable-code")
111 add_flag("-Wno-unused-parameter") 111 add_flag("-Wno-unused-macros")
112 add_flag("-Wno-vla") 112 add_flag("-Wno-unused-parameter")
113 113 add_flag("-Wno-vla")
114 # Disable specific warning flags for C. 114
115 add_cflag("-Wno-assign-enum") 115 # Disable specific warning flags for C.
116 add_cflag("-Wno-bad-function-cast") 116 add_cflag("-Wno-assign-enum")
117 add_cflag("-Wno-double-promotion") 117 add_cflag("-Wno-bad-function-cast")
118 add_cflag("-Wno-gnu-zero-variadic-macro-arguments") 118 add_cflag("-Wno-double-promotion")
119 add_cflag("-Wno-packed") 119 add_cflag("-Wno-gnu-zero-variadic-macro-arguments")
120 add_cflag("-Wno-reserved-id-macro") 120 add_cflag("-Wno-packed")
121 add_cflag("-Wno-shadow") 121 add_cflag("-Wno-reserved-id-macro")
122 add_cflag("-Wno-shorten-64-to-32") 122 add_cflag("-Wno-shadow")
123 add_cflag("-Wno-unreachable-code-return") 123 add_cflag("-Wno-shorten-64-to-32")
124 add_cflag("-Wno-unused-but-set-variable") 124 add_cflag("-Wno-unreachable-code-return")
125 add_cflag("-Wno-used-but-marked-unused") 125 add_cflag("-Wno-unused-but-set-variable")
126 126 add_cflag("-Wno-used-but-marked-unused")
127 # Disable specific warning flags for C++. 127
128 add_cxxflag("-Wno-c++11-compat") 128 # Disable specific warning flags for C++.
129 add_cxxflag("-Wno-c++11-extensions") 129 add_cxxflag("-Wno-c++11-compat")
130 add_cxxflag("-Wno-c++11-narrowing") 130 add_cxxflag("-Wno-c++11-extensions")
131 add_cxxflag("-Wno-c99-extensions") 131 add_cxxflag("-Wno-c++11-narrowing")
132 add_cxxflag("-Wno-narrowing") 132 add_cxxflag("-Wno-c99-extensions")
133 add_cxxflag("-Wno-old-style-cast") 133 add_cxxflag("-Wno-narrowing")
134 add_cxxflag("-Wno-variadic-macros") 134 add_cxxflag("-Wno-old-style-cast")
135 add_cxxflag("-Wno-vla-extension") 135 add_cxxflag("-Wno-variadic-macros")
136endif() 136 add_cxxflag("-Wno-vla-extension")
137 endif()
137 138
138option(ERROR_ON_WARNING "Make compilation error on a warning" OFF) 139 option(ERROR_ON_WARNING "Make compilation error on a warning" OFF)
139if(ERROR_ON_WARNING) 140 if(ERROR_ON_WARNING)
140 # Set error-on-warn for C compilation. C++ compilation can't use this because 141 # Set error-on-warn for C compilation. C++ compilation can't use this because
141 # treating 'c' input as 'c++' when in C++ mode is deprecated in clang and 142 # treating 'c' input as 'c++' when in C++ mode is deprecated in clang and
142 # there is no way to turn off that warning. 143 # there is no way to turn off that warning.
143 add_cflag("-Werror") 144 add_cflag("-Werror")
144endif() 145 endif()
145 146
146option(DEBUG "Enable assertions and other debugging facilities" OFF) 147 option(DEBUG "Enable assertions and other debugging facilities" OFF)
147if(DEBUG) 148 if(DEBUG)
148 set(MIN_LOGGER_LEVEL DEBUG) 149 set(MIN_LOGGER_LEVEL DEBUG)
149 add_cflag("-g3") 150 add_cflag("-g3")
151 endif()
150endif() 152endif()
151 153
152option(TRACE "Enable TRACE level logging (expensive, for network debugging)" OFF) 154option(TRACE "Enable TRACE level logging (expensive, for network debugging)" OFF)
@@ -166,32 +168,7 @@ if(ASAN)
166 set(CMAKE_REQUIRED_LIBRARIES "${SAFE_CMAKE_REQUIRED_LIBRARIES}") 168 set(CMAKE_REQUIRED_LIBRARIES "${SAFE_CMAKE_REQUIRED_LIBRARIES}")
167endif() 169endif()
168 170
169find_package(Threads REQUIRED) 171include(Dependencies)
170
171find_library(NCURSES_LIBRARIES ncurses )
172find_library(UTIL_LIBRARIES util )
173find_library(RT_LIBRARIES rt )
174
175# For toxcore.
176pkg_use_module(LIBSODIUM REQUIRED libsodium )
177
178# For toxav.
179pkg_use_module(OPUS opus )
180pkg_use_module(VPX vpx )
181
182# For tox-bootstrapd.
183pkg_use_module(LIBCONFIG libconfig )
184
185# For auto tests.
186pkg_use_module(CHECK check )
187
188# For tox-spectest.
189pkg_use_module(MSGPACK msgpack )
190
191# For av_test.
192pkg_use_module(OPENCV opencv )
193pkg_use_module(PORTAUDIO portaudio-2.0 )
194pkg_use_module(SNDFILE sndfile )
195 172
196if(OPUS_FOUND AND VPX_FOUND) 173if(OPUS_FOUND AND VPX_FOUND)
197 set(BUILD_TOXAV TRUE) 174 set(BUILD_TOXAV TRUE)
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 00000000..879ebc10
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,13 @@
1install:
2- curl https://download.libsodium.org/libsodium/releases/libsodium-1.0.11-msvc.zip -o libsodium-1.0.11-msvc.zip
3- unzip libsodium-1.0.11-msvc.zip
4
5before_build:
6- cmake . -DBOOTSTRAP_DAEMON=OFF
7
8build:
9 project: INSTALL.vcxproj
10
11branches:
12 only:
13 - master
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
new file mode 100644
index 00000000..338a4193
--- /dev/null
+++ b/cmake/Dependencies.cmake
@@ -0,0 +1,56 @@
1###############################################################################
2#
3# :: For UNIX-like systems that have pkg-config.
4#
5###############################################################################
6
7include(ModulePackage)
8
9find_package(Threads REQUIRED)
10
11find_library(NCURSES_LIBRARIES ncurses )
12find_library(UTIL_LIBRARIES util )
13find_library(RT_LIBRARIES rt )
14
15# For toxcore.
16pkg_use_module(LIBSODIUM libsodium )
17
18# For toxav.
19pkg_use_module(OPUS opus )
20pkg_use_module(VPX vpx )
21
22# For tox-bootstrapd.
23pkg_use_module(LIBCONFIG libconfig )
24
25# For auto tests.
26pkg_use_module(CHECK check )
27
28# For tox-spectest.
29pkg_use_module(MSGPACK msgpack )
30
31# For av_test.
32pkg_use_module(OPENCV opencv )
33pkg_use_module(PORTAUDIO portaudio-2.0)
34pkg_use_module(SNDFILE sndfile )
35
36###############################################################################
37#
38# :: For Windows and other systems lacking pkg-config.
39#
40###############################################################################
41
42if(NOT LIBSODIUM_FOUND)
43 include_directories(include)
44 find_library(LIBSODIUM_LIBRARIES
45 NAMES
46 sodium
47 libsodium
48 PATHS
49 Win32/Release/v140/static
50 x64/Release/v140/static
51 )
52 if(LIBSODIUM_LIBRARIES)
53 set(LIBSODIUM_FOUND TRUE)
54 endif()
55 message("libsodium: ${LIBSODIUM_LIBRARIES}")
56endif()
diff --git a/cmake/ModulePackage.cmake b/cmake/ModulePackage.cmake
index 38f841ba..3a4eb9b9 100644
--- a/cmake/ModulePackage.cmake
+++ b/cmake/ModulePackage.cmake
@@ -10,7 +10,7 @@ if(NOT ENABLE_SHARED AND NOT ENABLE_STATIC)
10 set(ENABLE_SHARED ON) 10 set(ENABLE_SHARED ON)
11endif() 11endif()
12 12
13find_package(PkgConfig REQUIRED) 13find_package(PkgConfig)
14 14
15if(COMPILE_AS_CXX) 15if(COMPILE_AS_CXX)
16 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS=1") 16 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS=1")
@@ -34,8 +34,10 @@ function(add_c_executable exec)
34 add_executable(${exec} ${ARGN}) 34 add_executable(${exec} ${ARGN})
35endfunction() 35endfunction()
36 36
37function(pkg_use_module mod) 37function(pkg_use_module mod pkg)
38 pkg_search_module(${mod} ${ARGN}) 38 if(PKG_CONFIG_FOUND)
39 pkg_search_module(${mod} ${pkg})
40 endif()
39 if(${mod}_FOUND) 41 if(${mod}_FOUND)
40 link_directories(${${mod}_LIBRARY_DIRS}) 42 link_directories(${${mod}_LIBRARY_DIRS})
41 include_directories(${${mod}_INCLUDE_DIRS}) 43 include_directories(${${mod}_INCLUDE_DIRS})
diff --git a/toxcore/network.h b/toxcore/network.h
index e0122b5d..26126a22 100644
--- a/toxcore/network.h
+++ b/toxcore/network.h
@@ -24,6 +24,12 @@
24#ifndef NETWORK_H 24#ifndef NETWORK_H
25#define NETWORK_H 25#define NETWORK_H
26 26
27#if defined(__GNUC__)
28#define GNU_EXTENSION __extension__
29#else
30#define GNU_EXTENSION
31#endif
32
27#ifdef PLAN9 33#ifdef PLAN9
28#include <u.h> // Plan 9 requires this is imported first 34#include <u.h> // Plan 9 requires this is imported first
29// Comment line here to avoid reordering by source code formatters. 35// Comment line here to avoid reordering by source code formatters.
@@ -163,7 +169,7 @@ IP6;
163 169
164typedef struct { 170typedef struct {
165 uint8_t family; 171 uint8_t family;
166 __extension__ union { 172 GNU_EXTENSION union {
167 IP4 ip4; 173 IP4 ip4;
168 IP6 ip6; 174 IP6 ip6;
169 }; 175 };