Skip to content

Commit

Permalink
Reorganize project
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenke committed May 26, 2024
1 parent f16aba1 commit 1b972a9
Show file tree
Hide file tree
Showing 24 changed files with 379 additions and 426 deletions.
51 changes: 34 additions & 17 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,66 +1,83 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
# Google C/C++ Code Style settings
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
# Author: Kehan Xue, kehan.xue (at) gmail.com

Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: DontAlign
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AlignOperands: Align
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never # To avoid conflict, set this "Never" and each "if statement" should include brace when coding
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterStruct: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
BreakBeforeBinaryOperators: NonAssignment
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 120
CompactNamespaces: false
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false # Make sure the * or & align on the left
EmptyLineBeforeAccessModifier: LogicalBlock
FixNamespaceComments: true
IncludeBlocks: Preserve
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PointerAlignment: Right
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Left
ReflowComments: false
SpaceAfterCStyleCast: true
SeparateDefinitionBlocks: Always # Only support since clang-format 14
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++20
TabWidth: 4
UseTab: ForContinuationAndIndentation
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (${BUILD_TEST})
include(Catch)
endif ()

add_subdirectory(common)
add_subdirectory(mumble_protocol)

if (${BUILD_CLIENT})
add_subdirectory(client)
Expand Down
66 changes: 9 additions & 57 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,67 +1,17 @@

add_library(
mumble_client
SHARED
lib/client.cpp
lib/client.hpp
)
generate_export_header(mumble_client)

set_target_properties(
mumble_client
PROPERTIES
CXX_STANDARD 23
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
POSITION_INDEPENDENT_CODE ON
INTERPROCEDURAL_OPTIMIZATION ${LTO_SUPPORTED}
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
SOVERSION 0
)

target_include_directories(
mumble_client
PUBLIC lib
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
)

target_compile_definitions(
mumble_client
PUBLIC ASIO_NO_DEPRECATED
)

find_package(asio CONFIG REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(Threads REQUIRED)

target_link_libraries(
mumble_client
PUBLIC mumble_protocol_common
PRIVATE asio::asio
PRIVATE OpenSSL::SSL
PRIVATE OpenSSL::Crypto
PRIVATE spdlog::spdlog
PRIVATE Threads::Threads
)

add_executable(
mumble_client_app
app/main.cpp
mumble_client
src/main.cpp
)
if (WIN32)
target_sources(
mumble_client_app
mumble_client
PUBLIC
app/application.manifest
src/application.manifest
)
endif ()

set_target_properties(
mumble_client_app
mumble_client
PROPERTIES
CXX_STANDARD 23
CXX_STANDARD_REQUIRED ON
Expand All @@ -71,9 +21,11 @@ set_target_properties(
find_package(Boost ${BOOST_REQUIRED_VERSION} REQUIRED COMPONENTS program_options)
pkg_check_modules(Opus REQUIRED IMPORTED_TARGET opus)
find_package(RtAudio CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)

target_link_libraries(
mumble_client_app
PRIVATE mumble_client
mumble_client
PRIVATE mumble_protocol
PRIVATE Boost::boost
PRIVATE Boost::program_options
PRIVATE PkgConfig::Opus
Expand Down
File renamed without changes.
16 changes: 8 additions & 8 deletions client/app/main.cpp → client/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <iostream>
#include <thread>

auto main(int argc, char *argv[]) -> int {
auto main(int argc, char* argv[]) -> int {
using namespace std::chrono_literals;
using namespace libmumble_protocol::client;

Expand All @@ -24,20 +24,20 @@ auto main(int argc, char *argv[]) -> int {
boost::program_options::options_description description{"libmumble_client example application"};
description.add_options()("help,h", "display help message");
description.add_options()("server,s", boost::program_options::value<std::string>(&server_name),
"server to connect to");
"server to connect to");
description.add_options()(
"port,p", boost::program_options::value<std::uint16_t>(&port)->default_value(MumbleClient::defaultPort),
"port number to use");
description.add_options()("username,u", boost::program_options::value<std::string>(&user_name),
"user name to connect as");
"user name to connect as");
description.add_options()("ignore-cert", boost::program_options::bool_switch(&ignore_server_cert),
"do not validate the TLS server certificate");
"do not validate the TLS server certificate");

boost::program_options::variables_map variablesMap;
boost::program_options::store(boost::program_options::parse_command_line(argc, argv, description), variablesMap);
boost::program_options::notify(variablesMap);
boost::program_options::variables_map variables_map;
boost::program_options::store(boost::program_options::parse_command_line(argc, argv, description), variables_map);
boost::program_options::notify(variables_map);

if (variablesMap.count("help") != 0U) {
if (variables_map.count("help") != 0U) {
std::cout << description << '\n';
return EXIT_SUCCESS;
}
Expand Down
36 changes: 0 additions & 36 deletions common/src/pimpl_impl.hpp

This file was deleted.

34 changes: 23 additions & 11 deletions common/CMakeLists.txt → mumble_protocol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ find_package(Protobuf REQUIRED)
find_package(Threads REQUIRED)

add_library(
mumble_protocol_common
mumble_protocol
STATIC
src/Mumble.proto
src/MumbleUDP.proto
Expand All @@ -13,11 +13,15 @@ add_library(
src/pimpl_impl.hpp
src/util.cpp
src/util.hpp
src/client.cpp
src/client.hpp
src/server.cpp
src/server.hpp
)
protobuf_generate(
TARGET mumble_protocol_common
TARGET mumble_protocol
)
generate_export_header(mumble_protocol_common)
generate_export_header(mumble_protocol)

# Disable specific compiler warnings for generated file (because we cannot fix the warnings)
set_source_files_properties(
Expand All @@ -28,7 +32,7 @@ set_source_files_properties(
)

set_target_properties(
mumble_protocol_common
mumble_protocol
PROPERTIES
CXX_STANDARD 23
CXX_STANDARD_REQUIRED ON
Expand All @@ -38,37 +42,45 @@ set_target_properties(
)

target_include_directories(
mumble_protocol_common
mumble_protocol
PUBLIC src
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/src
)

if (WIN32)
target_compile_definitions(
mumble_protocol
PUBLIC
_WIN32_WINNT=0x0A00
)
endif ()

target_link_libraries(
mumble_protocol_common
mumble_protocol
PUBLIC protobuf::libprotobuf
PUBLIC Threads::Threads
)

if (${BUILD_TEST})
# These tests can use the Catch2-provided main
add_executable(
mumble_protocol_common_test
mumble_protocol_test
test/util.cpp
)

set_target_properties(
mumble_protocol_common_test
mumble_protocol_test
PROPERTIES
CXX_STANDARD 23
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)

target_link_libraries(
mumble_protocol_common_test
PRIVATE mumble_protocol_common
mumble_protocol_test
PRIVATE mumble_protocol
PRIVATE Catch2::Catch2WithMain
)
catch_discover_tests(mumble_protocol_common_test)
catch_discover_tests(mumble_protocol_test)
endif ()
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 1b972a9

Please sign in to comment.