diff --git a/CMakeLists.txt b/CMakeLists.txt index c2de1a6..9b42038 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,38 @@ cmake_minimum_required (VERSION 3.7.0) project (DiscordRPCExample) +# format +file(GLOB_RECURSE ALL_SOURCE_FILES + examples/*.cpp examples/*.h examples/*.c + include/*.h + src/*.cpp src/*.h src/*.c +) + +find_program(CLANG_FORMAT_CMD clang-format) + +if (CLANG_FORMAT_CMD) + add_custom_target( + clangformat + COMMAND clang-format + -i -style=file -fallback-style=none + ${ALL_SOURCE_FILES} + DEPENDS + ${ALL_SOURCE_FILES} + ) +else(CLANG_FORMAT_CMD) + add_custom_target( + clangformat + COMMENT "no clang format" + ) +endif(CLANG_FORMAT_CMD) + +# thirdparty stuff execute_process( COMMAND mkdir ${CMAKE_SOURCE_DIR}/thirdparty ERROR_QUIET ) find_file(RAPIDJSON NAMES rapidjson rapidjson-1.1.0 PATHS ${CMAKE_SOURCE_DIR}/thirdparty) - if (NOT RAPIDJSON) message("no rapidjson, download") set(RJ_TAR_FILE ${CMAKE_SOURCE_DIR}/thirdparty/v1.1.0.tar.gz) @@ -18,8 +43,9 @@ if (NOT RAPIDJSON) ) file(REMOVE ${RJ_TAR_FILE}) endif(NOT RAPIDJSON) - add_library(rapidjson STATIC IMPORTED ${RAPIDJSON}) +# add subdirs + add_subdirectory(src) add_subdirectory(examples/send-presence) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 560914b..56e18ae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,3 +11,5 @@ if(UNIX) endif(UNIX) target_include_directories(discord-rpc PRIVATE ${RAPIDJSON}/include) + +add_dependencies(discord-rpc clangformat) diff --git a/src/connection_unix.cpp b/src/connection_unix.cpp index 50e5199..ff7f30f 100644 --- a/src/connection_unix.cpp +++ b/src/connection_unix.cpp @@ -31,17 +31,14 @@ struct RpcConnectionUnix : public RpcConnection { void RpcConnection::Open() { - } void RpcConnection::Close() { - } void RpcConnection::Write(const void* data, size_t length) { - } RpcMessageFrame* RpcConnection::Read() @@ -59,5 +56,4 @@ RpcMessageFrame* RpcConnection::GetNextFrame() void RpcConnection::WriteFrame(RpcMessageFrame* frame) { - }