Skip to content

Commit

Permalink
Merge pull request #15 from 5cript/devel
Browse files Browse the repository at this point in the history
Cleaned up dependency management.
  • Loading branch information
5cript authored Oct 10, 2023
2 parents 8b17311 + ca45733 commit 7886b9a
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 59 deletions.
39 changes: 36 additions & 3 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ jobs:
platform: x64

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}} -G"Ninja" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNUI_BUILD_EXAMPLES=off -DCMAKE_CXX_EXTENSIONS=on -DCMAKE_CXX_COMPILER=c++ -DCMAKE_C_COMPILER=cc -DCMAKE_CXX_STANDARD=20
run: cmake -B ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}} -G"Ninja" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_EXTENSIONS=on -DCMAKE_CXX_COMPILER=c++ -DCMAKE_C_COMPILER=cc -DCMAKE_CXX_STANDARD=20
env:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}

- name: Build
run: cmake --build ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}} --config ${{env.BUILD_TYPE}}


windows-msys2:
runs-on: windows-2022
defaults:
Expand All @@ -95,7 +94,41 @@ jobs:
run: echo "WSPACE=$(cygpath '${{github.workspace}}')" >> $GITHUB_ENV

- name: Configure CMake
run: cmake -B ${{env.WSPACE}}/build/clang_${{env.BUILD_TYPE}} -G"Ninja" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNUI_BUILD_EXAMPLES=off -DCMAKE_CXX_EXTENSIONS=on -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_LINKER=lld -DCMAKE_CXX_STANDARD=20
run: cmake -B ${{env.WSPACE}}/build/clang_${{env.BUILD_TYPE}} -G"Ninja" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_EXTENSIONS=on -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_LINKER=lld -DCMAKE_CXX_STANDARD=20

- name: Build
run: cmake --build ${{env.WSPACE}}/build/clang_${{env.BUILD_TYPE}} --config ${{env.BUILD_TYPE}}

macos:
runs-on: macos-13

steps:
- uses: actions/checkout@v3

- run: brew install ninja boost cryptopp curl llvm@16

- name: Get Brew Prefix
run: |
echo "BREW_PREFIX=$(brew --prefix)" >> $GITHUB_ENV
- name: Set Env Vars
run: |
echo "export LDFLAGS=-L$BREW_PREFIX/lib" >> $GITHUB_ENV
echo "export CPPFLAGS=-I$BREW_PREFIX/include" >> $GITHUB_ENV
- name: Configure CMake
run: >
cmake
-DCMAKE_C_COMPILER=$BREW_PREFIX/opt/llvm@16/bin/clang
-DCMAKE_CXX_COMPILER=$BREW_PREFIX/opt/llvm@16/bin/clang++
-DCMAKE_LINKER=$BREW_PREFIX/opt/llvm@16/bin/lld
-S ${{github.workspace}}
-B ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}}
-G"Ninja"
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DBREW_PREFIX="$BREW_PREFIX"
-DCMAKE_CXX_EXTENSIONS=on
-DCMAKE_CXX_STANDARD=20
- name: Build
run: cmake --build ${{github.workspace}}/build/clang_${{env.BUILD_TYPE}} --config ${{env.BUILD_TYPE}}
18 changes: 12 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ if(PROJECT_IS_TOP_LEVEL)
endif()
endif()

include (./cmake/warnings.cmake)
include (./cmake/example_target.cmake)
include (./cmake/options.cmake)

include (./cmake/xhawk18_promise.cmake)
include(./cmake/warnings.cmake)
include(./cmake/example_target.cmake)
include(./cmake/options.cmake)
include(./cmake/brew.cmake)

# Deps
include(./cmake/dependencies/boost.cmake)
include(./cmake/dependencies/ssl.cmake)
include(./cmake/dependencies/curl.cmake)
include(./cmake/dependencies/cryptopp.cmake)
include(./cmake/dependencies/xhawk18_promise.cmake)

if (${ROAR_ENABLE_NLOHMANN_JSON})
include(./cmake/nlohmann_json.cmake)
include(./cmake/dependencies/nlohmann_json.cmake)
endif()

add_subdirectory(src/roar)
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ This is a network library that has:
- cryptopp
- libcurl

### MacOS

Dependencies are expected to be installed via brew.
If this does not work for you, please open an issue.

brew install ninja boost cryptopp curl llvm@16

### Windows

Use vcpkg on windows for these dependencies when building with Visual Studio & cmake.
https://vcpkg.io/en/getting-started.html

Expand Down
1 change: 1 addition & 0 deletions cmake/brew.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(BREW_PREFIX "/opt/homebrew" CACHE STRING "Homebrew install prefix")
1 change: 1 addition & 0 deletions cmake/dependencies/boost.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
find_package(Boost 1.81.0 REQUIRED COMPONENTS system)
25 changes: 25 additions & 0 deletions cmake/dependencies/cryptopp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
if (UNIX)
find_package(PkgConfig REQUIRED)
endif()

add_library(roar-cryptopp INTERFACE)

if (WIN32)
find_package(CryptoPP REQUIRED)
if (${MSVC})
target_link_libraries(roar-cryptopp INTERFACE cryptopp::cryptopp)
else()
target_link_libraries(roar-cryptopp INTERFACE cryptopp-static)
endif()
elseif(APPLE)
find_library(CRYPTOPP_LIB libcryptopp.a HINTS ${BREW_PREFIX}/lib)
target_include_directories(roar-cryptopp INTERFACE ${BREW_PREFIX}/include)
target_link_libraries(roar-cryptopp INTERFACE ${CRYPTOPP_LIB})
elseif(UNIX)
pkg_check_modules(cryptopp IMPORTED_TARGET libcrypto++)
if ("${cryptopp_FOUND}" STREQUAL "1")
else()
pkg_check_modules(cryptopp IMPORTED_TARGET libcryptopp)
endif()
target_link_libraries(roar-cryptopp INTERFACE PkgConfig::cryptopp)
endif()
1 change: 1 addition & 0 deletions cmake/dependencies/curl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
find_package(CURL REQUIRED)
15 changes: 15 additions & 0 deletions cmake/dependencies/nlohmann_json.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
option(ROAR_EXTERNAL_NLOHMANN_JSON "Use an external nlohmann_json library (provide it manually)" OFF)
set(ROAR_NLOHMANN_JSON_GIT_REPOSITORY "https://github.com/nlohmann/json.git" CACHE STRING "The URL from which to clone the nlohmann_json repository")
set(ROAR_NLOHMANN_JSON_GIT_TAG "9dfa7226693012ed5bcf5ab3bc5d8e69d58006ab" CACHE STRING "The git tag or commit hash to checkout from the nlohmann_json repository")

if (ROAR_EXTERNAL_NLOHMANN_JSON)
else()
include(FetchContent)
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY ${ROAR_NLOHMANN_JSON_GIT_REPOSITORY}
GIT_TAG ${ROAR_NLOHMANN_JSON_GIT_TAG}
)

FetchContent_MakeAvailable(nlohmann_json)
endif()
1 change: 1 addition & 0 deletions cmake/dependencies/ssl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
find_package(OpenSSL COMPONENTS SSL Crypto)
22 changes: 22 additions & 0 deletions cmake/dependencies/xhawk18_promise.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set(PROMISE_BUILD_EXAMPLES off CACHE BOOL "Promise build examples" FORCE)
set(PROMISE_MULTITHREAD on CACHE BOOL "Promise multithreading on")

option(ROAR_EXTERNAL_PROMISE "Use an external promise library (provide it manually)" OFF)
set(ROAR_PROMISE_GIT_REPOSITORY "https://github.com/5cript/promise-cpp.git" CACHE STRING "The URL from which to clone the promiselib repository")
set(ROAR_PROMISE_GIT_TAG "affb386031896805c198485f10fd56215b1a4460" CACHE STRING "The git tag or commit hash to checkout from the promiselib repository")

if (ROAR_EXTERNAL_PROMISE)
else()
include(FetchContent)
FetchContent_Declare(
promise
GIT_REPOSITORY ${ROAR_PROMISE_GIT_REPOSITORY}
GIT_TAG ${ROAR_PROMISE_GIT_TAG}
)
FetchContent_MakeAvailable(promise)

if (WIN32)
# MS SOCK
target_link_libraries(promise PUBLIC -lws2_32 -lmswsock -lbcrypt)
endif()
endif()
10 changes: 0 additions & 10 deletions cmake/nlohmann_json.cmake

This file was deleted.

17 changes: 0 additions & 17 deletions cmake/xhawk18_promise.cmake

This file was deleted.

25 changes: 2 additions & 23 deletions src/roar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,39 +33,18 @@ add_library(

include(../../cmake/warnings.cmake)

if (UNIX)
find_package(PkgConfig REQUIRED)
endif()
find_package(CURL REQUIRED)
find_package(Boost 1.81.0 REQUIRED COMPONENTS system)
find_package(OpenSSL COMPONENTS SSL Crypto)

target_compile_features(roar PUBLIC cxx_std_20)
target_include_directories(roar PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include
${CURL_INCLUDE_DIR})
target_link_libraries(
roar
PUBLIC Boost::system
promise
roar-cryptopp
CURL::libcurl
OpenSSL::SSL
OpenSSL::Crypto
)
if (WIN32)
find_package(CryptoPP REQUIRED)
if (${MSVC})
target_link_libraries(roar PUBLIC cryptopp::cryptopp)
else()
target_link_libraries(roar PUBLIC cryptopp-static)
endif()
else()
pkg_check_modules(cryptopp IMPORTED_TARGET libcrypto++)
if ("${cryptopp_FOUND}" STREQUAL "1")
else()
pkg_check_modules(cryptopp IMPORTED_TARGET libcryptopp)
endif()
target_link_libraries(roar PUBLIC PkgConfig::cryptopp)
endif()
target_compile_features(roar PUBLIC cxx_std_20)

set_target_warnings(roar)

Expand Down

0 comments on commit 7886b9a

Please sign in to comment.