From 95be02d4cef15a44ab8d95d29a4e81add14911a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Wed, 15 Nov 2017 20:04:42 +0100 Subject: [PATCH] Add Travis CI support --- .travis.yml | 41 +++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 7 ++++--- src/CMakeLists.txt | 3 ++- 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a8e2756 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,41 @@ +language: cpp + +addons: + apt: + sources: + - llvm-toolchain-trusty-5.0 + packages: + - clang-format-5.0 # needed for formatting + +env: + global: + - CLANG_FORMAT_SUFFIX="-5.0" + +matrix: + include: + - os: linux + env: MATRIX_EVAL="CC=gcc-5 && CXX=g++-5" + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-5 + - os: linux + env: MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0" + addons: + apt: + sources: + - llvm-toolchain-trusty-4.0 + packages: + - clang-4.0 # note this is *NOT* the same version as clang-format + +# prevent Travis from overwriting our CXX variables +before_install: + - eval "${MATRIX_EVAL}" + +script: + - mkdir build + - cd build + - cmake -DCLANG_FORMAT_SUFFIX=$CLANG_FORMAT_SUFFIX --config Release .. + - cmake --build . -- -j2 diff --git a/CMakeLists.txt b/CMakeLists.txt index ab21a54..b78ff32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.7.0) +cmake_minimum_required (VERSION 3.2.0) project (DiscordRPC) include(GNUInstallDirs) @@ -12,12 +12,13 @@ file(GLOB_RECURSE ALL_SOURCE_FILES src/*.cpp src/*.h src/*.c ) -find_program(CLANG_FORMAT_CMD clang-format) +# Set CLANG_FORMAT_SUFFIX if you are using custom clang-format, e.g. clang-format-5.0 +find_program(CLANG_FORMAT_CMD clang-format${CLANG_FORMAT_SUFFIX}) if (CLANG_FORMAT_CMD) add_custom_target( clangformat - COMMAND clang-format + COMMAND ${CLANG_FORMAT_CMD} -i -style=file -fallback-style=none ${ALL_SOURCE_FILES} DEPENDS diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2dc988d..3c02746 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,8 @@ include_directories(${PROJECT_SOURCE_DIR}/include) option(ENABLE_IO_THREAD "Start up a separate I/O thread, otherwise I'd need to call an update function" ON) option(USE_STATIC_CRT "Use /MT[d] for dynamic library" OFF) +set(CMAKE_CXX_STANDARD 14) + set(BASE_RPC_SRC ${PROJECT_SOURCE_DIR}/include/discord-rpc.h discord-rpc.cpp @@ -83,7 +85,6 @@ if(UNIX) -Wno-exit-time-destructors # not sure about these -Wno-global-constructors ) - target_compile_options(discord-rpc PRIVATE $<$:-std=c++14>) if (${BUILD_SHARED_LIBS}) target_compile_options(discord-rpc PRIVATE -fPIC)