diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..7c73364 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,55 @@ +* text=auto eol=lf + +# Source and build files +*.c text eol=lf +*.cc text eol=lf +*.cpp text eol=lf +*.cxx text eol=lf +*.h text eol=lf +*.hh text eol=lf +*.hpp text eol=lf +*.hxx text eol=lf +*.inl text eol=lf +*.ipp text eol=lf +CMakeLists.txt text eol=lf +*.cmake text eol=lf +CMakePresets.json text eol=lf +CTestPresets.json text eol=lf + +# Project and config files +*.txt text eol=lf +*.md text eol=lf +*.json text eol=lf +*.yml text eol=lf +*.yaml text eol=lf +*.toml text eol=lf +*.ini text eol=lf +*.cfg text eol=lf +*.conf text eol=lf +*.clang-format text eol=lf +*.clang-tidy text eol=lf +*.clangd text eol=lf +.gitignore text eol=lf +.gitattributes text eol=lf +.gitmodules text eol=lf +.editorconfig text eol=lf +Dockerfile text eol=lf +Doxyfile.in text eol=lf + +# Scripts +*.sh text eol=lf +*.bash text eol=lf +*.py text eol=lf +*.bat text eol=crlf +*.cmd text eol=crlf +*.ps1 text eol=crlf + +# Binary assets +*.png binary +*.gif binary +*.jpg binary +*.jpeg binary +*.ico binary +*.zip binary +*.gz binary +*.7z binary diff --git a/.github/workflows/build-system.yml b/.github/workflows/build-system.yml index 10822fd..58a7ba9 100644 --- a/.github/workflows/build-system.yml +++ b/.github/workflows/build-system.yml @@ -5,9 +5,6 @@ on: push: branches: master -env: - EXTERNAL_ROOT: /home/runner/3party - jobs: build: runs-on: ubuntu-latest @@ -22,17 +19,20 @@ jobs: BUILD_TYPE: ${{ matrix.build_type }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Add Boost repository - shell: bash - run: sudo apt-add-repository ppa:mhier/libboost-latest + - name: Setup vcpkg (with binary caching) + uses: lukka/run-vcpkg@v11 + with: + runVcpkgInstall: false + vcpkgDirectory: "${{ github.workspace }}/.vcpkg" + vcpkgGitCommitId: "58950f88544e4637524dbd6a01d0317cf4cb77fc" - - name: Install latest Boost + - name: Install dependencies shell: bash - run: sudo apt install libboost1.74-dev + run: $VCPKG_ROOT/vcpkg install boost-asio - name: Create Build Environment run: cmake -E make_directory ${{runner.workspace}}/serverpp/build @@ -40,7 +40,7 @@ jobs: - name: Configure CMake shell: bash working-directory: ${{runner.workspace}}/serverpp/build - run: cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PREFIX_PATH=$EXTERNAL_ROOT + run: cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake - name: Build shell: bash @@ -50,4 +50,4 @@ jobs: - name: Test working-directory: ${{runner.workspace}}/serverpp/build shell: bash - run: ctest -C $BUILD_TYPE + run: ctest -C $BUILD_TYPE --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index 775a7d0..31cb822 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,13 +44,22 @@ endif() add_library(serverpp) add_library(KazDragon::serverpp ALIAS serverpp) +set(SERVERPP_GENERATED_INCLUDE_DIR + "${PROJECT_BINARY_DIR}/generated/include") +set(SERVERPP_GENERATED_EXPORT_HEADER + "${SERVERPP_GENERATED_INCLUDE_DIR}/serverpp/detail/export.hpp") +set(SERVERPP_GENERATED_VERSION_HEADER + "${SERVERPP_GENERATED_INCLUDE_DIR}/serverpp/version.hpp") + +file(MAKE_DIRECTORY "${SERVERPP_GENERATED_INCLUDE_DIR}/serverpp/detail") + target_sources(serverpp PRIVATE src/tcp_server.cpp src/tcp_socket.cpp include/serverpp/tcp_server.hpp include/serverpp/tcp_socket.hpp - include/serverpp/version.hpp + ${SERVERPP_GENERATED_VERSION_HEADER} ) target_link_libraries(serverpp @@ -61,6 +70,7 @@ target_link_libraries(serverpp target_include_directories(serverpp PUBLIC + $ $ $ ) @@ -90,12 +100,12 @@ target_compile_options(serverpp target_compile_features(serverpp PUBLIC cxx_std_20) generate_export_header(serverpp - EXPORT_FILE_NAME "${PROJECT_SOURCE_DIR}/include/serverpp/detail/export.hpp" + EXPORT_FILE_NAME "${SERVERPP_GENERATED_EXPORT_HEADER}" ) configure_file( ${PROJECT_SOURCE_DIR}/include/serverpp/version.hpp.in - ${PROJECT_SOURCE_DIR}/include/serverpp/version.hpp + ${SERVERPP_GENERATED_VERSION_HEADER} @ONLY) include(GNUInstallDirs) @@ -151,6 +161,20 @@ install( include/serverpp-${SERVERPP_VERSION} ) +install( + FILES + "${SERVERPP_GENERATED_EXPORT_HEADER}" + DESTINATION + include/serverpp-${SERVERPP_VERSION}/serverpp/detail +) + +install( + FILES + "${SERVERPP_GENERATED_VERSION_HEADER}" + DESTINATION + include/serverpp-${SERVERPP_VERSION}/serverpp +) + install( FILES "${CMAKE_CURRENT_BINARY_DIR}/serverpp-config.cmake" diff --git a/cmake/serverpp-config.cmake.in b/cmake/serverpp-config.cmake.in index 7863e3f..e0ffc1d 100644 --- a/cmake/serverpp-config.cmake.in +++ b/cmake/serverpp-config.cmake.in @@ -1,4 +1,9 @@ @PACKAGE_INIT@ +include(CMakeFindDependencyMacro) + +find_dependency(Boost 1.69.0) +find_dependency(Threads) + include(${CMAKE_CURRENT_LIST_DIR}/serverpp-targets.cmake) check_required_components(serverpp)