Automate running clang-format if it is available.

This commit is contained in:
Chris Marsh 2017-07-25 10:15:42 -07:00
parent 7a6172a300
commit fbd8d6897d
3 changed files with 30 additions and 6 deletions

View file

@ -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)

View file

@ -11,3 +11,5 @@ if(UNIX)
endif(UNIX)
target_include_directories(discord-rpc PRIVATE ${RAPIDJSON}/include)
add_dependencies(discord-rpc clangformat)

View file

@ -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)
{
}