summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt48
-rw-r--r--cmake/CompileGTest.cmake49
-rwxr-xr-xother/astyle/format-source7
-rw-r--r--third_party/.gitignore1
-rw-r--r--third_party/README.md6
5 files changed, 78 insertions, 33 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9450ab74..e6d9e2a2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,8 +14,8 @@
14# 14#
15################################################################################ 15################################################################################
16 16
17cmake_minimum_required(VERSION 2.8.6) 17cmake_minimum_required(VERSION 3.1.0)
18cmake_policy(VERSION 2.8.6) 18cmake_policy(VERSION 3.1.0)
19project(toxcore) 19project(toxcore)
20 20
21set(CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake) 21set(CMAKE_MODULE_PATH ${toxcore_SOURCE_DIR}/cmake)
@@ -66,11 +66,16 @@ enable_testing()
66 66
67set(CMAKE_MACOSX_RPATH ON) 67set(CMAKE_MACOSX_RPATH ON)
68 68
69if(NOT MSVC) 69# Set standard version for compiler.
70 # Set standard version for compiler. 70set(CMAKE_C_STANDARD 99)
71 add_cflag("-std=c99") 71set(CMAKE_CXX_STANDARD 11)
72 add_cxxflag("-std=c++11") 72set(CMAKE_C_EXTENSIONS OFF)
73set(CMAKE_CXX_EXTENSIONS OFF)
74
75message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}")
76message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}")
73 77
78if(NOT MSVC)
74 # Warn on non-ISO C. 79 # Warn on non-ISO C.
75 add_cflag("-pedantic") 80 add_cflag("-pedantic")
76 81
@@ -436,35 +441,13 @@ install_module(toxcore DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tox)
436# 441#
437################################################################################ 442################################################################################
438 443
439# Compile the GTest library. 444include(CompileGTest)
440#
441if(EXISTS "/usr/src/gtest/src/gtest-all.cc")
442 add_library(gtest
443 /usr/src/gtest/src/gtest-all.cc
444 /usr/src/gtest/src/gtest_main.cc)
445 include_directories(/usr/src/gtest/include)
446 target_include_directories(gtest PRIVATE /usr/src/gtest)
447 check_cxx_compiler_flag("-w" HAVE_CXX_W QUIET)
448 check_cxx_compiler_flag("-Wno-global-constructors" HAVE_CXX_W_NO_GLOBAL_CONSTRUCTORS QUIET)
449 check_cxx_compiler_flag("-Wno-zero-as-null-pointer-constant" HAVE_CXX_W_NO_ZERO_AS_NULL_POINTER_CONSTANT QUIET)
450 if(HAVE_CXX_W)
451 set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-w")
452 endif()
453 set(HAVE_GTEST TRUE)
454endif()
455 445
456function(unit_test subdir target) 446function(unit_test subdir target)
457 if(HAVE_GTEST) 447 if(HAVE_GTEST)
458 add_executable(unit_${target}_test ${subdir}/${target}_test.cpp) 448 add_executable(unit_${target}_test ${subdir}/${target}_test.cpp)
459 target_link_modules(unit_${target}_test ${toxcore_SUBLIBS} gtest) 449 target_link_modules(unit_${target}_test ${toxcore_SUBLIBS} gtest)
460 set(gtest_CFLAGS "") 450 set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS}")
461 if(HAVE_CXX_W_NO_GLOBAL_CONSTRUCTORS)
462 set(gtest_CFLAGS "${gtest_CFLAGS} -Wno-global-constructors")
463 endif()
464 if(HAVE_CXX_W_NO_ZERO_AS_NULL_POINTER_CONSTANT)
465 set(gtest_CFLAGS "${gtest_CFLAGS} -Wno-zero-as-null-pointer-constant")
466 endif()
467 set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${gtest_CFLAGS}")
468 add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test) 451 add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test)
469 endif() 452 endif()
470endfunction() 453endfunction()
@@ -518,10 +501,11 @@ if(BUILD_TOXAV)
518 auto_tests/monolith_test.cpp 501 auto_tests/monolith_test.cpp
519 ${ANDROID_CPU_FEATURES}) 502 ${ANDROID_CPU_FEATURES})
520 target_link_modules(auto_monolith_test 503 target_link_modules(auto_monolith_test
521 ${toxcore_PKGCONFIG_LIBS}
522 ${LIBSODIUM_LIBRARIES} 504 ${LIBSODIUM_LIBRARIES}
523 ${OPUS_LIBRARIES} 505 ${OPUS_LIBRARIES}
524 ${VPX_LIBRARIES}) 506 ${VPX_LIBRARIES}
507 ${toxcore_PKGCONFIG_LIBS}
508 )
525 add_test(NAME monolith COMMAND ${CROSSCOMPILING_EMULATOR} auto_monolith_test) 509 add_test(NAME monolith COMMAND ${CROSSCOMPILING_EMULATOR} auto_monolith_test)
526 510
527 if(ANDROID_CPU_FEATURES) 511 if(ANDROID_CPU_FEATURES)
diff --git a/cmake/CompileGTest.cmake b/cmake/CompileGTest.cmake
new file mode 100644
index 00000000..520ca06a
--- /dev/null
+++ b/cmake/CompileGTest.cmake
@@ -0,0 +1,49 @@
1# Find and compile the GTest library.
2
3message(STATUS "Checking for gtest")
4
5# Look for the sources.
6find_file(GTEST_ALL_CC gtest-all.cc PATHS
7 ${CMAKE_SOURCE_DIR}/third_party/googletest/googletest/src
8 /usr/src/gtest/src
9 NO_DEFAULT_PATH
10)
11
12if(GTEST_ALL_CC)
13 # ../.. from the source file is the source root.
14 get_filename_component(GTEST_SRC_DIR ${GTEST_ALL_CC} DIRECTORY)
15 get_filename_component(GTEST_SRC_ROOT ${GTEST_SRC_DIR} DIRECTORY)
16
17 # Look for the header file.
18 include(CheckIncludeFileCXX)
19 include_directories(SYSTEM ${GTEST_SRC_ROOT}/include)
20 check_include_file_cxx("gtest/gtest.h" HAVE_GTEST_GTEST_H)
21
22 if(HAVE_GTEST_GTEST_H)
23 message(STATUS "Found gtest: ${GTEST_SRC_ROOT}")
24
25 add_library(gtest
26 ${GTEST_SRC_DIR}/gtest-all.cc
27 ${GTEST_SRC_DIR}/gtest_main.cc)
28 target_include_directories(gtest PRIVATE ${GTEST_SRC_ROOT})
29
30 # Ignore all warnings for gtest. We don't care about their implementation.
31 check_cxx_compiler_flag("-w" HAVE_CXX_W QUIET)
32 if(HAVE_CXX_W)
33 set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-w")
34 endif()
35
36 set(HAVE_GTEST TRUE)
37 set(TEST_CXX_FLAGS "")
38
39 check_cxx_compiler_flag("-Wno-global-constructors" HAVE_CXX_W_NO_GLOBAL_CONSTRUCTORS QUIET)
40 if(HAVE_CXX_W_NO_GLOBAL_CONSTRUCTORS)
41 set(TEST_CXX_FLAGS "${TEST_CXX_FLAGS} -Wno-global-constructors")
42 endif()
43
44 check_cxx_compiler_flag("-Wno-zero-as-null-pointer-constant" HAVE_CXX_W_NO_ZERO_AS_NULL_POINTER_CONSTANT QUIET)
45 if(HAVE_CXX_W_NO_ZERO_AS_NULL_POINTER_CONSTANT)
46 set(TEST_CXX_FLAGS "${TEST_CXX_FLAGS} -Wno-zero-as-null-pointer-constant")
47 endif()
48 endif()
49endif()
diff --git a/other/astyle/format-source b/other/astyle/format-source
index 3757561b..cf190982 100755
--- a/other/astyle/format-source
+++ b/other/astyle/format-source
@@ -45,7 +45,12 @@ if grep '<unresolved>' */*.h; then
45 exit 1 45 exit 1
46fi 46fi
47 47
48SOURCES=`find . "-(" -name "*.[ch]" -or -name "*.cpp" "-)" -and -not -name "*.api.h" -and -not -wholename "*crypto_pwhash*" -and -not -wholename "./super_donators/*"` 48SOURCES=`find . \
49 "-(" -name "*.[ch]" -or -name "*.cpp" "-)" \
50 -and -not -name "*.api.h" \
51 -and -not -wholename "./super_donators/*" \
52 -and -not -wholename "./third_party/*" \
53 -and -not -wholename "./toxencryptsave/crypto_pwhash*"`
49 54
50$ASTYLE -n --options=other/astyle/astylerc $SOURCES 55$ASTYLE -n --options=other/astyle/astylerc $SOURCES
51 56
diff --git a/third_party/.gitignore b/third_party/.gitignore
new file mode 100644
index 00000000..355164c1
--- /dev/null
+++ b/third_party/.gitignore
@@ -0,0 +1 @@
*/
diff --git a/third_party/README.md b/third_party/README.md
new file mode 100644
index 00000000..11546589
--- /dev/null
+++ b/third_party/README.md
@@ -0,0 +1,6 @@
1# Third party dependencies
2
3All toxcore dependencies you want to build yourself should end up here, not in
4the source root. This directory is exempt from code style checks.
5
6TODO(iphydf): Change appveyor.yml to unpack dependencies here.