Skip to content

Commit

Permalink
Merge pull request openhome#4 from KGrzeg/conan-deps
Browse files Browse the repository at this point in the history
Fetch dependencies from conan if that is possible
  • Loading branch information
DoomHammer authored Nov 29, 2022
2 parents 58c8c2b + f4c0cce commit 0af14e9
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 270 deletions.
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ project(ohNet LANGUAGES CXX C)

set(platform Posix)

list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")
find_package(libb64 CONFIG REQUIRED)

if(WIN32)
set(platform Windows)
set(CMAKE_SYSTEM_NAME Windows)
Expand Down Expand Up @@ -31,8 +34,6 @@ set(SourcesMain
OpenHome/Net/Device/Bonjour/Bonjour.cpp
OpenHome/Buffer.cpp
OpenHome/Converter.cpp
thirdparty/libb64/cencode.c
thirdparty/libb64/cdecode.c
OpenHome/Net/Discovery.cpp
OpenHome/Debug.cpp
OpenHome/Net/ControlPoint/CpDeviceCore.cpp
Expand Down Expand Up @@ -246,6 +247,10 @@ header_copy(header31 IncludeBase IncludeCopy ${CMAKE_SOURCE_DIR}/${mDNSdir}/mDNS

message("Creating files in " ${CMAKE_CURRENT_BINARY_DIR}/Temp/OpenHome)
target_include_directories(ohNet SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/Temp)

target_include_directories(
ohNet PUBLIC $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
set(GENERATED_INCLUDES ${CMAKE_CURRENT_BINARY_DIR}/Temp PARENT_SCOPE)

set(ENDIANNESS DEFINE_LITTLE_ENDIAN)
Expand All @@ -256,6 +261,7 @@ endif(DEBUG_LOG)

target_compile_definitions(ohNet PUBLIC ${ENDIANNESS})
add_dependencies(ohNet IncludeCopy)
target_link_libraries(ohNet PUBLIC libb64::libb64)

# tests

Expand Down Expand Up @@ -300,4 +306,3 @@ if(${COMPILE_FOR_RPI})
find_package(Threads REQUIRED)
target_link_libraries(finder PRIVATE Threads::Threads)
endif()

4 changes: 2 additions & 2 deletions OpenHome/Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

extern "C"
{
#include "../thirdparty/libb64/cencode.h"
#include "../thirdparty/libb64/cdecode.h"
#include <b64/cencode.h>
#include <b64/cdecode.h>
}

using namespace OpenHome;
Expand Down
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
# Prerequisites
## Install dependencies
Install the latest [conan](https://pypi.org/project/conan/) via pip (at least version 1.54.0)


If [libb64]((https://conan.io/center/libb64)) is available on [conan center](https://conan.io/center/), you can skip this step.
If not, then you need to build the package locally.
```sh
🐧 git clone [email protected]:KGrzeg/libb64-conan.git # clone the repo
🐧 cd libb64-conan
🐧 direnv allow # or manually setup cmake and gcc
🐧 git checkout 1.2.1-conanfile # switch to proper tag
🐧 conan create . libb64/1.2.1@ # install package to conan's cache

# verify that package is successfully installed
🐧λ conan search libb64
Existing package recipes:

libb64/1.2.1

# if everything is ok, you can delete the directory
🐧 cd ..
🐧 rm -rf libb64-conan
```


# Build and compile (Windows, Linux, MacOS)
```sh
🐧 mkdir build
🐧 cd build
🐧 cmake ..
🐧 conan install .. --build missing
🐧 cmake .. -DCMAKE_BUILD_TYPE=Release
#optionally "🐧 cmake .. -DCMAKE_BUILD_TYPE=Release -GNinja" for quicker builds
🐧 cmake --build . -v
```

Expand Down
5 changes: 5 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[requires]
libb64/1.2.1

[generators]
CMakeDeps
12 changes: 12 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,24 @@

with pkgs;

let
python-with-my-packages = python3.withPackages (p: with p; [
virtualenv
]);
in
mkShell {
buildInputs = [
cmake
gdb
gcc
gnumake
ninja
python-with-my-packages
];

shellHook = ''
[ ! -d venv ] && python -m virtualenv venv
source venv/bin/activate
pip install conan==1.54.0
'';
}
88 changes: 0 additions & 88 deletions thirdparty/libb64/cdecode.c

This file was deleted.

37 changes: 0 additions & 37 deletions thirdparty/libb64/cdecode.h

This file was deleted.

101 changes: 0 additions & 101 deletions thirdparty/libb64/cencode.c

This file was deleted.

38 changes: 0 additions & 38 deletions thirdparty/libb64/cencode.h

This file was deleted.

0 comments on commit 0af14e9

Please sign in to comment.