diff options
-rw-r--r-- | CMakeLists.txt | 169 | ||||
-rw-r--r-- | appveyor.yml | 13 | ||||
-rw-r--r-- | cmake/Dependencies.cmake | 56 | ||||
-rw-r--r-- | cmake/ModulePackage.cmake | 8 | ||||
-rw-r--r-- | toxcore/network.h | 8 |
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 @@ | |||
1 | cmake_minimum_required(VERSION 2.8.6) | 1 | cmake_minimum_required(VERSION 2.8.6) |
2 | cmake_policy(VERSION 2.8.6) | ||
2 | project(toxcore) | 3 | project(toxcore) |
3 | include(CTest) | 4 | include(CTest) |
4 | 5 | ||
@@ -41,7 +42,6 @@ include(ApiDsl) | |||
41 | include(CheckCCompilerFlag) | 42 | include(CheckCCompilerFlag) |
42 | include(CheckCXXCompilerFlag) | 43 | include(CheckCXXCompilerFlag) |
43 | include(MacRpath) | 44 | include(MacRpath) |
44 | include(ModulePackage) | ||
45 | 45 | ||
46 | set(CMAKE_MACOSX_RPATH ON) | 46 | set(CMAKE_MACOSX_RPATH ON) |
47 | 47 | ||
@@ -76,77 +76,79 @@ macro(add_flag flag) | |||
76 | add_cxxflag(${flag}) | 76 | add_cxxflag(${flag}) |
77 | endmacro() | 77 | endmacro() |
78 | 78 | ||
79 | # Set standard version for compiler. | 79 | if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") |
80 | add_cflag("-std=c99") | 80 | # Set standard version for compiler. |
81 | add_cxxflag("-std=c++11") | 81 | add_cflag("-std=c99") |
82 | 82 | add_cxxflag("-std=c++11") | |
83 | # Warn on non-ISO C. | 83 | |
84 | add_cflag("-pedantic") | 84 | # Warn on non-ISO C. |
85 | 85 | add_cflag("-pedantic") | |
86 | option(WARNINGS "Enable additional compiler warnings" ON) | 86 | |
87 | if(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") |
136 | endif() | 136 | add_cxxflag("-Wno-vla-extension") |
137 | endif() | ||
137 | 138 | ||
138 | option(ERROR_ON_WARNING "Make compilation error on a warning" OFF) | 139 | option(ERROR_ON_WARNING "Make compilation error on a warning" OFF) |
139 | if(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") |
144 | endif() | 145 | endif() |
145 | 146 | ||
146 | option(DEBUG "Enable assertions and other debugging facilities" OFF) | 147 | option(DEBUG "Enable assertions and other debugging facilities" OFF) |
147 | if(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() | ||
150 | endif() | 152 | endif() |
151 | 153 | ||
152 | option(TRACE "Enable TRACE level logging (expensive, for network debugging)" OFF) | 154 | option(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}") |
167 | endif() | 169 | endif() |
168 | 170 | ||
169 | find_package(Threads REQUIRED) | 171 | include(Dependencies) |
170 | |||
171 | find_library(NCURSES_LIBRARIES ncurses ) | ||
172 | find_library(UTIL_LIBRARIES util ) | ||
173 | find_library(RT_LIBRARIES rt ) | ||
174 | |||
175 | # For toxcore. | ||
176 | pkg_use_module(LIBSODIUM REQUIRED libsodium ) | ||
177 | |||
178 | # For toxav. | ||
179 | pkg_use_module(OPUS opus ) | ||
180 | pkg_use_module(VPX vpx ) | ||
181 | |||
182 | # For tox-bootstrapd. | ||
183 | pkg_use_module(LIBCONFIG libconfig ) | ||
184 | |||
185 | # For auto tests. | ||
186 | pkg_use_module(CHECK check ) | ||
187 | |||
188 | # For tox-spectest. | ||
189 | pkg_use_module(MSGPACK msgpack ) | ||
190 | |||
191 | # For av_test. | ||
192 | pkg_use_module(OPENCV opencv ) | ||
193 | pkg_use_module(PORTAUDIO portaudio-2.0 ) | ||
194 | pkg_use_module(SNDFILE sndfile ) | ||
195 | 172 | ||
196 | if(OPUS_FOUND AND VPX_FOUND) | 173 | if(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 @@ | |||
1 | install: | ||
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 | |||
5 | before_build: | ||
6 | - cmake . -DBOOTSTRAP_DAEMON=OFF | ||
7 | |||
8 | build: | ||
9 | project: INSTALL.vcxproj | ||
10 | |||
11 | branches: | ||
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 | |||
7 | include(ModulePackage) | ||
8 | |||
9 | find_package(Threads REQUIRED) | ||
10 | |||
11 | find_library(NCURSES_LIBRARIES ncurses ) | ||
12 | find_library(UTIL_LIBRARIES util ) | ||
13 | find_library(RT_LIBRARIES rt ) | ||
14 | |||
15 | # For toxcore. | ||
16 | pkg_use_module(LIBSODIUM libsodium ) | ||
17 | |||
18 | # For toxav. | ||
19 | pkg_use_module(OPUS opus ) | ||
20 | pkg_use_module(VPX vpx ) | ||
21 | |||
22 | # For tox-bootstrapd. | ||
23 | pkg_use_module(LIBCONFIG libconfig ) | ||
24 | |||
25 | # For auto tests. | ||
26 | pkg_use_module(CHECK check ) | ||
27 | |||
28 | # For tox-spectest. | ||
29 | pkg_use_module(MSGPACK msgpack ) | ||
30 | |||
31 | # For av_test. | ||
32 | pkg_use_module(OPENCV opencv ) | ||
33 | pkg_use_module(PORTAUDIO portaudio-2.0) | ||
34 | pkg_use_module(SNDFILE sndfile ) | ||
35 | |||
36 | ############################################################################### | ||
37 | # | ||
38 | # :: For Windows and other systems lacking pkg-config. | ||
39 | # | ||
40 | ############################################################################### | ||
41 | |||
42 | if(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}") | ||
56 | endif() | ||
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) |
11 | endif() | 11 | endif() |
12 | 12 | ||
13 | find_package(PkgConfig REQUIRED) | 13 | find_package(PkgConfig) |
14 | 14 | ||
15 | if(COMPILE_AS_CXX) | 15 | if(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}) |
35 | endfunction() | 35 | endfunction() |
36 | 36 | ||
37 | function(pkg_use_module mod) | 37 | function(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 | ||
164 | typedef struct { | 170 | typedef 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 | }; |