diff options
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | appveyor.yml | 36 | ||||
-rw-r--r-- | cmake/Dependencies.cmake | 37 | ||||
-rw-r--r-- | cmake/ModulePackage.cmake | 48 | ||||
-rw-r--r-- | conanfile.py | 33 |
5 files changed, 108 insertions, 55 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 51e1e99f..98a4eabe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -18,7 +18,7 @@ cmake_minimum_required(VERSION 2.8.12) | |||
18 | cmake_policy(VERSION 2.8.12) | 18 | cmake_policy(VERSION 2.8.12) |
19 | project(toxcore) | 19 | project(toxcore) |
20 | 20 | ||
21 | set(CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake) | 21 | list(APPEND CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake) |
22 | 22 | ||
23 | ################################################################################ | 23 | ################################################################################ |
24 | # | 24 | # |
@@ -115,6 +115,13 @@ option(NON_HERMETIC_TESTS "Whether to build and run tests that depend on an inte | |||
115 | option(BUILD_TOXAV "Whether to build the tox AV library" ON) | 115 | option(BUILD_TOXAV "Whether to build the tox AV library" ON) |
116 | option(MUST_BUILD_TOXAV "Fail the build if toxav cannot be built" OFF) | 116 | option(MUST_BUILD_TOXAV "Fail the build if toxav cannot be built" OFF) |
117 | 117 | ||
118 | if(MSVC) | ||
119 | option(MSVC_STATIC_SODIUM "Whether to link libsodium statically for MSVC" OFF) | ||
120 | if(MSVC_STATIC_SODIUM) | ||
121 | add_definitions(-DSODIUM_STATIC=1 -DSODIUM_EXPORT) | ||
122 | endif() | ||
123 | endif() | ||
124 | |||
118 | include(Dependencies) | 125 | include(Dependencies) |
119 | 126 | ||
120 | if(MUST_BUILD_TOXAV) | 127 | if(MUST_BUILD_TOXAV) |
diff --git a/appveyor.yml b/appveyor.yml index 08687595..f4a5970f 100644 --- a/appveyor.yml +++ b/appveyor.yml | |||
@@ -1,35 +1,23 @@ | |||
1 | --- | 1 | --- |
2 | cache: | 2 | cache: |
3 | - '%APPDATA%\downloads' | 3 | - '%USERPROFILE%\.conan' |
4 | 4 | ||
5 | install: | 5 | install: |
6 | # TODO(iphydf): Remove this when appveyor gets curl back, which it should | 6 | - set PATH=C:\Python38-x64\Scripts;%PATH% |
7 | # have according to https://www.appveyor.com/docs/how-to/download-file/. | 7 | - py -3 -m pip install conan |
8 | - choco install curl | 8 | - conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan |
9 | - refreshenv | ||
10 | - if not exist %APPDATA%\downloads mkdir %APPDATA%\downloads | ||
11 | - cd third_party | ||
12 | # libsodium | ||
13 | - mkdir libsodium && cd libsodium | ||
14 | - if not exist %APPDATA%\downloads\libsodium.zip curl -L https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-msvc.zip -o %APPDATA%\downloads\libsodium.zip | ||
15 | - unzip %APPDATA%\downloads\libsodium.zip | ||
16 | - cd .. | ||
17 | # pthreads-win32 | ||
18 | - mkdir pthreads-win32 && cd pthreads-win32 | ||
19 | - if not exist %APPDATA%\downloads\pthreads.zip curl -L ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip -o %APPDATA%\downloads\pthreads.zip | ||
20 | - unzip %APPDATA%\downloads\pthreads.zip | ||
21 | - cd ../.. | ||
22 | 9 | ||
23 | before_build: | 10 | before_build: |
24 | - cmake -B_build -H. -DBOOTSTRAP_DAEMON=OFF -DENABLE_SHARED=OFF -DBUILD_TOXAV=OFF -DTEST_TIMEOUT_SECONDS=120 -DAUTOTEST=ON | 11 | - ps: | |
12 | mkdir _build | ||
13 | cd _build | ||
14 | conan install .. | ||
25 | 15 | ||
26 | build: | 16 | build_script: |
27 | project: _build/INSTALL.vcxproj | 17 | - conan build .. --configure --build |
28 | 18 | ||
29 | test_script: | 19 | test_script: |
30 | - copy third_party\pthreads-win32\Pre-built.2\dll\x86\*.dll _build | ||
31 | - copy third_party\libsodium\Win32\Debug\v140\dynamic\libsodium.dll _build | ||
32 | - cd _build | ||
33 | # TODO(iphydf): Tests are unstable and slow on windows at the moment. | 20 | # TODO(iphydf): Tests are unstable and slow on windows at the moment. |
34 | - ctest -j50 --output-on-failure -C Debug & | 21 | - set CONAN_CPU_COUNT=50 |
22 | - conan build .. --test & | ||
35 | exit 0 | 23 | exit 0 |
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 8361e8e1..37eb40bd 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake | |||
@@ -16,8 +16,8 @@ find_library(SOCKET_LIBRARIES socket ) | |||
16 | pkg_use_module(LIBSODIUM libsodium ) | 16 | pkg_use_module(LIBSODIUM libsodium ) |
17 | 17 | ||
18 | # For toxav. | 18 | # For toxav. |
19 | pkg_use_module(OPUS opus ) | 19 | pkg_use_module(OPUS "opus;Opus" ) |
20 | pkg_use_module(VPX vpx ) | 20 | pkg_use_module(VPX "vpx;libvpx" ) |
21 | 21 | ||
22 | # For tox-bootstrapd. | 22 | # For tox-bootstrapd. |
23 | pkg_use_module(LIBCONFIG libconfig ) | 23 | pkg_use_module(LIBCONFIG libconfig ) |
@@ -38,18 +38,20 @@ pkg_use_module(MSGPACK msgpack ) | |||
38 | if(MSVC) | 38 | if(MSVC) |
39 | # libsodium | 39 | # libsodium |
40 | # --------- | 40 | # --------- |
41 | find_library(LIBSODIUM_LIBRARIES | 41 | if(NOT LIBSODIUM_FOUND) |
42 | NAMES sodium libsodium | 42 | find_library(LIBSODIUM_LIBRARIES |
43 | PATHS | 43 | NAMES sodium libsodium |
44 | "third_party/libsodium/Win32/Release/v140/dynamic" | 44 | PATHS |
45 | "third_party/libsodium/x64/Release/v140/dynamic" | 45 | "third_party/libsodium/Win32/Release/v140/dynamic" |
46 | ) | 46 | "third_party/libsodium/x64/Release/v140/dynamic" |
47 | if(LIBSODIUM_LIBRARIES) | 47 | ) |
48 | include_directories("third_party/libsodium/include") | 48 | if(LIBSODIUM_LIBRARIES) |
49 | set(LIBSODIUM_FOUND TRUE) | 49 | include_directories("third_party/libsodium/include") |
50 | message("libsodium: ${LIBSODIUM_LIBRARIES}") | 50 | set(LIBSODIUM_FOUND TRUE) |
51 | else() | 51 | message("libsodium: ${LIBSODIUM_LIBRARIES}") |
52 | message(FATAL_ERROR "libsodium libraries not found") | 52 | else() |
53 | message(FATAL_ERROR "libsodium libraries not found") | ||
54 | endif() | ||
53 | endif() | 55 | endif() |
54 | 56 | ||
55 | # pthreads | 57 | # pthreads |
@@ -66,7 +68,12 @@ if(MSVC) | |||
66 | add_definitions(-DHAVE_STRUCT_TIMESPEC) | 68 | add_definitions(-DHAVE_STRUCT_TIMESPEC) |
67 | message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}") | 69 | message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}") |
68 | else() | 70 | else() |
69 | message(FATAL_ERROR "libpthreads libraries not found") | 71 | find_package(pthreads4w) |
72 | if(NOT pthreads4w_FOUND) | ||
73 | message(FATAL_ERROR "libpthreads libraries not found") | ||
74 | endif() | ||
75 | include_directories(${pthreads4w_INCLUDE_DIR}) | ||
76 | link_libraries(${pthreads4w_LIBRARIES}) | ||
70 | endif() | 77 | endif() |
71 | endif() | 78 | endif() |
72 | endif() | 79 | endif() |
diff --git a/cmake/ModulePackage.cmake b/cmake/ModulePackage.cmake index 9cc21863..04dbf16d 100644 --- a/cmake/ModulePackage.cmake +++ b/cmake/ModulePackage.cmake | |||
@@ -21,21 +21,39 @@ endif() | |||
21 | 21 | ||
22 | find_package(PkgConfig) | 22 | find_package(PkgConfig) |
23 | 23 | ||
24 | function(pkg_use_module mod pkg) | 24 | function(pkg_use_module mod pkgs) |
25 | if(PKG_CONFIG_FOUND) | 25 | foreach(pkg IN ITEMS ${pkgs}) |
26 | pkg_search_module(${mod} ${pkg}) | 26 | if(PKG_CONFIG_FOUND) |
27 | endif() | 27 | pkg_search_module(${mod} ${pkg}) |
28 | if(${mod}_FOUND) | 28 | endif() |
29 | link_directories(${${mod}_LIBRARY_DIRS}) | 29 | if(NOT ${mod}_FOUND) |
30 | include_directories(${${mod}_INCLUDE_DIRS}) | 30 | find_package(${pkg} QUIET) |
31 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE) | 31 | # This is very very ugly, but the variables are sometimes used in this scope |
32 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE) | 32 | # and sometimes in the parent scope, so we have to set them to both places. |
33 | 33 | set(${mod}_FOUND ${${pkg}_FOUND}) | |
34 | foreach(dir ${${mod}_INCLUDE_DIRS}) | 34 | set(${mod}_FOUND ${${pkg}_FOUND} PARENT_SCOPE) |
35 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem ${dir}" PARENT_SCOPE) | 35 | set(${mod}_LIBRARIES ${${pkg}_LIBS}) |
36 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${dir}" PARENT_SCOPE) | 36 | set(${mod}_LIBRARIES ${${pkg}_LIBS} PARENT_SCOPE) |
37 | endforeach() | 37 | set(${mod}_LIBRARY_DIRS ${${pkg}_LIBRARY_DIRS}) |
38 | endif() | 38 | set(${mod}_LIBRARY_DIRS ${${pkg}_LIBRARY_DIRS} PARENT_SCOPE) |
39 | set(${mod}_INCLUDE_DIRS ${${pkg}_INCLUDE_DIRS}) | ||
40 | set(${mod}_INCLUDE_DIRS ${${pkg}_INCLUDE_DIRS} PARENT_SCOPE) | ||
41 | endif() | ||
42 | if(${mod}_FOUND) | ||
43 | link_directories(${${mod}_LIBRARY_DIRS}) | ||
44 | include_directories(${${mod}_INCLUDE_DIRS}) | ||
45 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE) | ||
46 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${mod}_CFLAGS_OTHER}" PARENT_SCOPE) | ||
47 | |||
48 | if(NOT MSVC) | ||
49 | foreach(dir ${${mod}_INCLUDE_DIRS}) | ||
50 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem ${dir}" PARENT_SCOPE) | ||
51 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${dir}" PARENT_SCOPE) | ||
52 | endforeach() | ||
53 | endif() | ||
54 | break() | ||
55 | endif() | ||
56 | endforeach() | ||
39 | endfunction() | 57 | endfunction() |
40 | 58 | ||
41 | function(add_module lib) | 59 | function(add_module lib) |
diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 00000000..2beee180 --- /dev/null +++ b/conanfile.py | |||
@@ -0,0 +1,33 @@ | |||
1 | # pylint: disable=not-callable | ||
2 | from conans import CMake | ||
3 | from conans import ConanFile | ||
4 | |||
5 | |||
6 | class ToxConan(ConanFile): | ||
7 | settings = "os", "compiler", "build_type", "arch" | ||
8 | requires = "libsodium/1.0.18", "opus/1.3.1", "libvpx/1.8.0@bincrafters/stable" | ||
9 | generators = "cmake_find_package" | ||
10 | |||
11 | def requirements(self): | ||
12 | if self.settings.os == "Windows": | ||
13 | self.requires("pthreads4w/3.0.0") | ||
14 | |||
15 | def source(self): | ||
16 | self.run("git clone https://github.com/toktok/c-toxcore.git") | ||
17 | |||
18 | def build(self): | ||
19 | cmake = CMake(self) | ||
20 | cmake.definitions["AUTOTEST"] = True | ||
21 | cmake.definitions["BUILD_MISC_TESTS"] = True | ||
22 | cmake.definitions["MUST_BUILD_TOXAV"] = True | ||
23 | if self.settings.compiler == "Visual Studio": | ||
24 | cmake.definitions["MSVC_STATIC_SODIUM"] = True | ||
25 | |||
26 | if self.should_configure: | ||
27 | cmake.configure() | ||
28 | |||
29 | if self.should_build: | ||
30 | cmake.build() | ||
31 | |||
32 | if self.should_test: | ||
33 | cmake.test() | ||