Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use vcpkg for dependency management #92

Draft
wants to merge 34 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e928d3f
add vcpkg
acarabott Aug 14, 2022
2df9bcc
use vcpkg for libsndfile and libsoundio
acarabott Aug 14, 2022
c50a102
add vcpkg manifest file
acarabott Aug 14, 2022
6f3b200
use vcpkg for json11
acarabott Aug 14, 2022
6cf233e
use vcpkg for pybind11
acarabott Aug 14, 2022
0b4078b
add python3 to vcpkg
acarabott Aug 14, 2022
6824804
add fftw to vcpkg
acarabott Aug 14, 2022
00f0106
Merge branch 'master' into vcpkg
acarabott Aug 14, 2022
b54e85b
remove unneeded include directories
acarabott Aug 14, 2022
8458723
add vamp as feature dependency
acarabott Aug 14, 2022
b710f58
remove vcpkg handled dependencies from readme
acarabott Aug 14, 2022
3ff3937
Revert "enable building on intel mac"
acarabott Aug 20, 2022
ff17d45
build works, split up this commit
acarabott Aug 21, 2022
7ff5ec1
use vcpkg to manage all dependencies
acarabott Aug 21, 2022
2c3ce59
remove /usr include directory
acarabott Aug 23, 2022
93927b0
make python into a cmake option
acarabott Aug 23, 2022
38b5a1e
Make libsoundio an optional feature
acarabott Aug 23, 2022
0605448
print message if no features enabled
acarabott Aug 23, 2022
76ef07a
make libsndfile an option
acarabott Aug 23, 2022
c9f5657
add warnings if can't find libsndfile/libsoundio
acarabott Aug 29, 2022
0d8a463
put dependent code inside ifdefs
acarabott Aug 29, 2022
bdacd67
fix json include
acarabott Sep 5, 2022
d926a8b
fix missing symbols
acarabott Sep 6, 2022
86ec873
add if def guard to audio in example
acarabott Sep 6, 2022
a8c16d8
add description and homepage to vcpkg
acarabott Sep 6, 2022
5b74073
add ifdefs to all necessary examples
acarabott Sep 6, 2022
3616fba
remove install commands
acarabott Sep 10, 2022
9c90ce0
Revert "remove install commands"
acarabott Sep 10, 2022
2a92934
Remove CMAKE_BUILD_TYPE default
acarabott Sep 10, 2022
2c9b527
fix typo in spooky-wobble example
acarabott Oct 11, 2022
b7c7590
add option to make examples optional
acarabott Oct 11, 2022
f93c206
print message when building examples
acarabott Oct 11, 2022
e2ff794
fix vcpkg
acarabott Oct 11, 2022
914f9ce
fix examples option
acarabott Oct 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vcpkg"]
path = vcpkg
url = [email protected]:microsoft/vcpkg.git
186 changes: 116 additions & 70 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,67 @@
cmake_minimum_required(VERSION 3.12.0)
project(SignalFlow C CXX)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Develop)
endif()

#-------------------------------------------------------------------------------
# Use C++11
#-------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_MACOSX_RPATH 1)

#-------------------------------------------------------------------------------
# By default, build a universal library on Apple.
# For a faster build, select a single architecture by defining the
# environmental variable CMAKE_OSX_ARCHITECTURES.
# Must be set prior to `project()`
#-------------------------------------------------------------------------------
if (NOT CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES "${ARCHS_STANDARD}")
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
endif()

#-------------------------------------------------------------------------------
# Build features
#-------------------------------------------------------------------------------
option(CMAKE_BUILD_SOUNDIO "Audio Hardware I/O support" ON)
if (CMAKE_BUILD_SOUNDIO)
list(APPEND VCPKG_MANIFEST_FEATURES "soundio")
endif ()

option(CMAKE_BUILD_FILEIO "Audio File I/O support" ON)
if (CMAKE_BUILD_FILEIO)
list(APPEND VCPKG_MANIFEST_FEATURES "fileio")
endif ()

option(CMAKE_BUILD_PYTHON "Build Python bindings" OFF)
if (CMAKE_BUILD_PYTHON)
list(APPEND VCPKG_MANIFEST_FEATURES "python")
endif ()

option(CMAKE_BUILD_VAMP "Vamp plugin support" OFF)
if (CMAKE_BUILD_VAMP)
list(APPEND VCPKG_MANIFEST_FEATURES "vamp")
endif ()

option(BUILD_EXAMPLES "Build examples" OFF)
if (BUILD_EXAMPLES)
list(APPEND VCPKG_MANIFEST_FEATURES "examples")
endif ()


if (VCPKG_MANIFEST_FEATURES)
message("Building with features:")
foreach (feature IN LISTS VCPKG_MANIFEST_FEATURES)
message(" - ${feature}")
endforeach ()
else ()
message("Building without any extra features")
endif ()

set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")

#-------------------------------------------------------------------------------
# Project
#-------------------------------------------------------------------------------
project(SignalFlow C CXX)

#-------------------------------------------------------------------------------
# Use C++11
#-------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_MACOSX_RPATH 1)

#-------------------------------------------------------------------------------
# Shared compiler flags.
#-------------------------------------------------------------------------------
Expand All @@ -41,10 +84,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
endif()

include_directories(
/usr/local/include
source/include
source/lib
source/lib/pybind11/include
)

if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
Expand All @@ -64,7 +104,14 @@ endif()
#-------------------------------------------------------------------------------
set(SRC)
add_subdirectory("source/src")
set(SRC ${SRC} source/lib/json11/json11.cpp)

#-------------------------------------------------------------------------------
# Build C++ examples
#-------------------------------------------------------------------------------
if(BUILD_EXAMPLES)
message("Building signalflow examples")
add_subdirectory("examples/cpp")
endif(BUILD_EXAMPLES)

#-------------------------------------------------------------------------------
# For builds of the Python bindings, add Python dependencies and flags
Expand All @@ -90,42 +137,25 @@ add_library(signalflow SHARED ${SRC})
# Dependencies
#-------------------------------------------------------------------------------

set(SOUNDIO_BUILD_DIR "" CACHE PATH "Path to built SoundIO library (will use find_library if blank)")
if (SOUNDIO_BUILD_DIR)
set(SOUNDIO_INCLUDE_DIR "${SOUNDIO_BUILD_DIR}/.." CACHE PATH "Path to SoundIO include directory (ignored if SOUNDIO_BUILD_DIR is blank")
add_definitions(-DHAVE_SOUNDIO)
target_link_libraries(signalflow "${SOUNDIO_BUILD_DIR}/$<CONFIG>/soundio.lib")
include_directories(signalflow "${SOUNDIO_BUILD_DIR}/$<CONFIG>/")
include_directories(signalflow "${SOUNDIO_INCLUDE_DIR}/")
else()
find_library(SOUNDIO soundio)
if (SOUNDIO)
message("Found libsoundio")
if (CMAKE_BUILD_SOUNDIO)
find_package(libsoundio CONFIG REQUIRED)
if (libsoundio_FOUND)
add_definitions(-DHAVE_SOUNDIO)
target_link_libraries(signalflow ${SOUNDIO})
else()
message(SEND_ERROR "Couldn't find libsoundio")
endif()
endif()


set(SNDFILE_BUILD_DIR "" CACHE PATH "Path to build sndfile library (will use find_library if blank)")
if (SNDFILE_BUILD_DIR)
set(SNDFILE_INCLUDE_DIR "${SNDFILE_BUILD_DIR}/../include" CACHE PATH "Path to sndfile include directory (ignored if SNDFILE_BUILD_DIR is blank")
add_definitions(-DHAVE_SNDFILE)
target_link_libraries(signalflow "${SNDFILE_BUILD_DIR}/$<CONFIG>/sndfile.lib")
include_directories(signalflow "${SNDFILE_BUILD_DIR}/include/")
include_directories(signalflow "${SNDFILE_INCLUDE_DIR}/")
else()
find_library(SNDFILE sndfile)
if (SNDFILE)
message("Found sndfile")
target_link_libraries(signalflow libsoundio::libsoundio libsoundio::libsoundio_static)
else ()
message(WARNING "could not find libsoundio")
endif ()
endif ()

if (CMAKE_BUILD_FILEIO)
find_package(SndFile CONFIG REQUIRED)
if (SndFile_FOUND)
add_definitions(-DHAVE_SNDFILE)
target_link_libraries(signalflow ${SNDFILE})
else()
message(SEND_ERROR "Couldn't find libsndfile")
endif()
endif()
target_link_libraries(signalflow SndFile::sndfile)
else ()
message(WARNING "could not find libsndfile")
endif ()
endif ()

if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(FFTW_BUILD_DIR "" CACHE PATH "Path to prebuilt FFTW library (will use find_library if blank)")
Expand All @@ -138,27 +168,48 @@ if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
"${FFTW_BUILD_DIR}/libfftw3l-3.lib"
)
else()
find_library(FFTW3F fftw3f)
if (FFTW3F)
message("Found fftw3f")
target_link_libraries(signalflow ${FFTW3F})
find_package(FFTW3f CONFIG REQUIRED)
target_link_libraries(signalflow PRIVATE FFTW3::fftw3f)
if (FFTW3f_FOUND)
add_definitions(-DFFT_FFTW)
else()
# if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(FATAL_ERROR "Couldn't find fftw3f")
# endif()
endif()
endif ()
endif()
endif(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")

find_library(VAMP vamp-hostsdk)
if (VAMP)
message("Found vamp")
add_definitions(-DHAVE_VAMP)
target_link_libraries(signalflow ${VAMP})
if (CMAKE_BUILD_VAMP)
find_library(VAMP vamp-hostsdk)
if (VAMP)
message("Found vamp")
add_definitions(-DHAVE_VAMP)
target_link_libraries(signalflow ${VAMP})
else ()
message(WARNING "Couldn't find vamp")
endif ()
endif ()

find_package(JSON11 CONFIG REQUIRED)
if (JSON11_FOUND)
target_link_libraries(signalflow ${JSON11_LIBRARIES})
target_include_directories(signalflow PRIVATE ${JSON11_INCLUDE_DIRS})
else()
message(WARNING "Couldn't find vamp")
endif()
message(WARNING "Couldn't find json11")
endif ()

if (CMAKE_BUILD_PYTHON)
find_package(Python3 COMPONENTS Development REQUIRED)
if (python3_FOUND)
target_link_libraries(signalflow Python3::Python)
else()
message(WARNING "Couldn't find python3")
endif ()

find_package(pybind11 CONFIG REQUIRED)
if (pybind11_FOUND)
target_link_libraries(signalflow pybind11::lto pybind11::embed pybind11::module)
else()
message(WARNING "Couldn't find pybind11")
endif ()
endif ()


#-------------------------------------------------------------------------------
Expand All @@ -173,11 +224,6 @@ endif()

if (CMAKE_BUILD_PYTHON)
target_link_libraries(signalflow ${PYTHON_LIBRARY})
else()
#-------------------------------------------------------------------------------
# Build examples
#-------------------------------------------------------------------------------
add_subdirectory("examples/cpp")
endif()

#-------------------------------------------------------------------------------
Expand Down
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,31 @@ graph.wait()
### macOS

To install the Python library on macOS, install dependencies with homebrew:
```
brew install cmake python libsndfile libsoundio
```sh
brew install cmake python
```

Clone this repository, then build and install with `pip`:
```
```sh
pip3 install .
```


### Linux, Raspberry Pi

To install the Python library on Linux, install dependencies with apt:
```
```sh
apt-get install git cmake g++ python3-pip libasound2-dev libsndfile1-dev libsoundio-dev fftw3-dev
```

If you experience an error on Raspberry Pi `libf77blas.so.3: cannot open shared object file`:

```
```sh
sudo apt-get install libatlas-base-dev
```

Clone this repository, then build and install with `pip`:
```
```sh
pip3 install .
```

Expand All @@ -91,7 +91,22 @@ As of 2021-03-03, only the signalflow project has been ported to build correctly

## Build (C++)

To build and install the C++ core without the Python binding layer:
### Dependencies

Ensure the vcpkg submodule is checked out

```sh
git submodule init
git submodule update
```

Run the vcpkg bootstrap script (you can leave out `-disableMetrics` if you want to send usage data to Microsoft)
```sh
cd vcpkg
./bootstrap-vcpkg.sh -disableMetrics
```

Build and install the C++ core without the Python binding layer:
```
mkdir build
cd build
Expand Down
5 changes: 5 additions & 0 deletions examples/cpp/audio-in-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using namespace signalflow;

int main()
{
#ifdef HAVE_SOUNDIO
/*------------------------------------------------------------------------
* Instantiate a global processing graph.
*-----------------------------------------------------------------------*/
Expand Down Expand Up @@ -51,4 +52,8 @@ int main()
}

graph->wait();
#else
std::cerr << "signalflow was not built with libsoundio" << std::endl;
return 0;
#endif
}
6 changes: 6 additions & 0 deletions examples/cpp/buffer-save-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using namespace signalflow;

int main()
{
#if defined(HAVE_SOUNDIO) && defined(HAVE_SNDFILE)
/*------------------------------------------------------------------------
* Instantiate the global processing graph.
*-----------------------------------------------------------------------*/
Expand Down Expand Up @@ -49,4 +50,9 @@ int main()
std::cout << "Finished recording." << std::endl;

buffer->save("out.wav");

#else
std::cerr << "signalflow was not built with libsoundio and/or libsndfile" << std::endl;
return 0;
#endif
}
9 changes: 8 additions & 1 deletion examples/cpp/granulator-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ using namespace signalflow;

int main()
{
#ifdef HAVE_SNDFILE

/*------------------------------------------------------------------------
* Instantiate a single AudioGraph object for all global audio processing.
*-----------------------------------------------------------------------*/
Expand All @@ -25,7 +27,7 @@ int main()
BufferRef buffer = new Buffer("audio/gliss.aif");

/*------------------------------------------------------------------------
* RandomImpulse creates an impulse train with randomised interval, at a
* RandomImpulse creates an impulse train with randomised interval, at a
* given mean frequency. This is used to trigger grains.
*-----------------------------------------------------------------------*/
NodeRef dust = new RandomImpulse(100.0);
Expand Down Expand Up @@ -57,4 +59,9 @@ int main()
* Loop forever.
*-----------------------------------------------------------------------*/
graph->wait();

#else
std::cerr << "signalflow was not built with libsndfile" << std::endl;
return 0;
#endif
}
6 changes: 6 additions & 0 deletions examples/cpp/mouse-control-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ using namespace signalflow;

int main()
{
#ifdef HAVE_SNDFILE
/*------------------------------------------------------------------------
* Instantiate a global processing graph.
*-----------------------------------------------------------------------*/
Expand Down Expand Up @@ -48,4 +49,9 @@ int main()
granulator->set_input("max_grains", 50);
graph->play(granulator * 0.2);
graph->wait();

#else
std::cerr << "signalflow was not built with libsndfile" << std::endl;
return 0;
#endif
}
Loading