Skip to content

Commit

Permalink
build: Improve install
Browse files Browse the repository at this point in the history
  • Loading branch information
flagarde committed Jan 18, 2022
1 parent c181574 commit b5c02cb
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 20 deletions.
7 changes: 7 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,abseil-*,altera-*,android-*,boost-*,bugprone-*,cert-*,concurrency-*,cppcoreguidelines-*,darwin-*,google-*,hicpp-*,linuxkernel-*,llvm-*,misc-*,modernize-*,mpi-*,objc-*,openmp-*,performance-*,portability-*,readability-*,zircon-*,-modernize-use-trailing-return-type,-bugprone-easily-swappable-parameters'
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none
UseColor: true
...
8 changes: 4 additions & 4 deletions .github/workflows/Docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ jobs:
with:
python-version: '3.x'

- name: '🟨 Install required packages with brew'
- name: '🍺 Install packages with brew'
run: brew install doxygen mscgen dia graphviz texlive inkscape

- name: '🟨 Install required packages with pip'
- name: '🟨 Install packages with pip'
run: |
python -m pip install --upgrade pip
pip install sphinx sphinx-rtd-theme sphinx-sitemap sphinxcontrib-moderncmakedomain breathe
Expand All @@ -58,8 +58,8 @@ jobs:

- name: '📥 Install'
run: cmake --install ${{ env.CMAKE_BUILD_PREFIX }} --prefix ${{ env.CMAKE_INSTALL_PREFIX }} --strip
&& mv ${{ env.CMAKE_INSTALL_PREFIX }}/share/YAODAQ/pdf/YAODAQ_Manual.pdf ${{ env.CMAKE_INSTALL_PREFIX }}/share/YAODAQ/html/YAODAQ_Manual.pdf
&& touch ${{ env.CMAKE_INSTALL_PREFIX }}/share/YAODAQ/html/.nojekyll
&& mv ${{ env.CMAKE_INSTALL_PREFIX }}/share/doc/YAODAQ/pdf/YAODAQ_Manual.pdf ${{ env.CMAKE_INSTALL_PREFIX }}/share/doc/YAODAQ/html/YAODAQ_Manual.pdf
&& touch ${{ env.CMAKE_INSTALL_PREFIX }}/share/doc/YAODAQ/html/.nojekyll

- name: '🎉 Deploy'
uses: JamesIves/github-pages-deploy-action@releases/v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/MacOS-Clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
cmake-version: '${{env.CMAKE_VERSION}}'
github-api-token: ${{ secrets.GITHUB_TOKEN }}

- name: '🟨 Install packages'
- name: '🍺 Install packages with brew'
if: ${{ env.INSTALL_PACKAGES != '' }}
run: brew install ${{env.INSTALL_PACKAGES}}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/MacOS-GCC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
cmake-version: '${{env.CMAKE_VERSION}}'
github-api-token: ${{ secrets.GITHUB_TOKEN }}

- name: '🟨 Install packages'
- name: '🍺 Install packages with brew'
if: ${{ env.INSTALL_PACKAGES != '' }}
run: brew install ${{env.INSTALL_PACKAGES}}

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: pre-commit
on:
pull_request:
push:
paths-ignore:
- 'docs/**'
branches: [main]

jobs:
Expand Down
3 changes: 2 additions & 1 deletion include/yaodaq/Class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ enum class Class : std::int_least16_t
Module = 0,
Browser = 100,

WebSocketServer = Module + 1,
WebsocketServer = Module + 1,
WebsocketClient = Module + 2,
};

} // namespace yaodaq
Expand Down
3 changes: 2 additions & 1 deletion include/yaodaq/Identifier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ class Identifier
{
public:
Identifier() = default;
Identifier(const Class& aClass, std::string type, std::string name);
Identifier(const Class& aClass, const std::string& type, const std::string& name);
[[nodiscard]] std::string getClass() const;
[[nodiscard]] std::string getType() const;
[[nodiscard]] std::string getName() const;
[[nodiscard]] Class getClassId() const;
[[nodiscard]] std::string get() const;

private:
Class m_Class{Class::Unknown};
Expand Down
37 changes: 29 additions & 8 deletions src/yaodaq/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
include(MagicEnum)
include(IXWebSocket)
include(Spdlog)
include(Nlohmann)

add_library(LoggerHandler LoggerHandler.cpp)
target_include_directories(LoggerHandler PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(LoggerHandler PROPERTIES PUBLIC_HEADER "${YAODAQ_INCLUDES_DIR}/LoggerHandler.hpp")
target_link_libraries(LoggerHandler PUBLIC spdlog::spdlog)
add_library(YAODAQ::LoggerHandler ALIAS LoggerHandler)

add_library(Identifier Identifier.cpp)
target_include_directories(Identifier PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(Identifier PROPERTIES PUBLIC_HEADER "${YAODAQ_INCLUDES_DIR}/Identifier.hpp;${YAODAQ_INCLUDES_DIR}/Class.hpp")
target_link_libraries(Identifier PRIVATE magic_enum::magic_enum)
target_link_libraries(Identifier PRIVATE magic_enum::magic_enum fmt::fmt)
add_library(YAODAQ::Identifier ALIAS Identifier)

add_library(WebsocketServer WebsocketServer.cpp)
target_include_directories(WebsocketServer PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(WebsocketServer PROPERTIES PUBLIC_HEADER "${YAODAQ_INCLUDES_DIR}/WebsocketServer.hpp")
target_link_libraries(WebsocketServer PRIVATE Identifier ixwebsocket::ixwebsocket)
add_library(YAODAQ::WebsocketServer ALIAS WebsocketServer)

add_library(WebsocketClient WebsocketClient.cpp)
target_include_directories(WebsocketClient PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(WebsocketClient PROPERTIES PUBLIC_HEADER "${YAODAQ_INCLUDES_DIR}/WebsocketClient.hpp")
target_link_libraries(WebsocketClient PRIVATE Identifier ixwebsocket::ixwebsocket)
add_library(YAODAQ::WebsocketClient ALIAS WebsocketClient)

# Install
install(TARGETS Identifier
EXPORT YAODAQTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/yaodaq/"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/yaodaq/")
install(TARGETS Identifier WebsocketServer WebsocketClient LoggerHandler spdlog
EXPORT YAODAQTargets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/yaodaq/"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/yaodaq/")
5 changes: 4 additions & 1 deletion src/yaodaq/Identifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

#include "yaodaq/Class.hpp"

#include <fmt/color.h>
#include <magic_enum.hpp>
#include <string>

namespace yaodaq
{

Identifier::Identifier(const Class& aClass, std::string type, std::string name) : m_Class(aClass), m_Type(std::move(type)), m_Name(std::move(name)) {}
Identifier::Identifier(const Class& aClass, const std::string& type, const std::string& name) : m_Class(aClass), m_Type(type), m_Name(name) {}

std::string Identifier::getClass() const { return std::string(magic_enum::enum_name(m_Class)); }

Expand All @@ -22,4 +23,6 @@ std::string Identifier::getName() const { return m_Name; }

Class Identifier::getClassId() const { return m_Class; }

std::string Identifier::get() const { return fmt::format("{0}/{1}/{2}", getClass(), getType(), getName()); }

}; // namespace yaodaq
6 changes: 6 additions & 0 deletions tests/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,abseil-*,altera-*,android-*,boost-*,bugprone-*,cert-*,concurrency-*,cppcoreguidelines-*,darwin-*,google-*,hicpp-*,linuxkernel-*,llvm-*,misc-*,modernize-*,mpi-*,objc-*,openmp-*,performance-*,portability-*,readability-*,zircon-*,-modernize-use-trailing-return-type,-bugprone-easily-swappable-parameters,-cert-err58-cpp'
AnalyzeTemporaryDtors: true
FormatStyle: none
UseColor: true
...
6 changes: 5 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ set(YAODAQ_INSTALL_TESTDIR "${CMAKE_INSTALL_BINDIR}/tests")

add_executable(Identifier.test Identifier.test.cpp)
target_link_libraries(Identifier.test PRIVATE YAODAQ::Identifier doctest_with_main)
doctest_discover_tests(Identifier.test COMMAND IdentifierTest)
doctest_discover_tests(Identifier.test)

add_executable(LoggerHandler.test LoggerHandler.test.cpp)
target_link_libraries(LoggerHandler.test PRIVATE YAODAQ::LoggerHandler doctest_with_main)
doctest_discover_tests(LoggerHandler.test)

install(TARGETS Identifier.test
RUNTIME DESTINATION "${YAODAQ_INSTALL_TESTDIR}")
5 changes: 3 additions & 2 deletions tests/Identifier.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

TEST_CASE("Identifier")
{
yaodaq::Identifier id(yaodaq::Class::WebSocketServer, "MyType", "MyName");
yaodaq::Identifier id(yaodaq::Class::WebsocketServer, "MyType", "MyName");
CHECK_EQ(id.getName(), "MyName");
CHECK_EQ(id.getType(), "MyType");
CHECK_EQ(id.getClass(), "WebSocketServer");
CHECK_EQ(id.getClassId(), yaodaq::Class::WebSocketServer);
CHECK_EQ(id.getClassId(), yaodaq::Class::WebsocketServer);
CHECK_EQ(id.get(), "WebSocketServer/MyType/MyName");
}

0 comments on commit b5c02cb

Please sign in to comment.