Skip to content

Commit

Permalink
Vendor the PortAudio dependency as a submodule with ExternalProject.
Browse files Browse the repository at this point in the history
This commits adds a submodule pointing to the portaudio
pa_stable_v190600_20161030 (same as latest FlexASIO release bundle)
and extends the FlexASIO CMake superbuild to build the PortAudio
dependency. This ensures that FlexASIO is built against a
well-defined PortAudio library, and will make it easy to migrate
to a different PortAudio revision in the future. It also gets rid of
the dependency on vcpkg.

Closes #37.
  • Loading branch information
dechamps committed Dec 24, 2018
1 parent e670307 commit 989d7a1
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "src/tinytoml"]
path = src/tinytoml
url = https://github.com/mayah/tinytoml.git
[submodule "src/portaudio"]
path = src/portaudio
url = https://git.assembla.com/portaudio.git
24 changes: 23 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,36 @@ ExternalProject_Add(
EXCLUDE_FROM_ALL
)

find_path(DXSDK_INCLUDE_DIR dsound.h)
find_library(DXSDK_DSOUND_LIBRARY dsound.lib)
ExternalProject_Add(
portaudio
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/portaudio"
INSTALL_DIR "${INTERNAL_INSTALL_PREFIX}"
BUILD_ALWAYS TRUE USES_TERMINAL_BUILD TRUE
# In the version we're currently using, PortAudio doesn't have an install target.
CMAKE_ARGS ${CMAKE_ARGS}
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${INTERNAL_INSTALL_PREFIX}/bin"
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${INTERNAL_INSTALL_PREFIX}/bin"
"-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${INTERNAL_INSTALL_PREFIX}/lib"
-DPA_ENABLE_DEBUG_OUTPUT=ON
"-DCMAKE_C_FLAGS=-DPA_GIT_REVISION=396fe4b6699ae929d3a685b3ef8a7e97396139a4-FlexASIO" # TODO: stop hardcoding this
# Work around https://lists.columbia.edu/pipermail/portaudio/2017-January/001001.html
-DMSVS=ON
# Work around lack of https://app.assembla.com/spaces/portaudio/git/commits/0baa1e2e31f37bac2883ea59e50b76037271426d
"-DDXSDK_ROOT_DIR=${DXSDK_INCLUDE_DIR}/.." "-DDXSDK_INCLUDE_DIR=${DXSDK_INCLUDE_DIR}" "-DDXSDK_DSOUND_LIBRARY=${DXSDK_DSOUND_LIBRARY}"
INSTALL_COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_LIST_DIR}/portaudio/include" "${INTERNAL_INSTALL_PREFIX}/include"
EXCLUDE_FROM_ALL
)

ExternalProject_Add(
FlexASIO
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/flexasio"
USES_TERMINAL_CONFIGURE TRUE
BUILD_ALWAYS TRUE USES_TERMINAL_BUILD TRUE
INSTALL_DIR "${INTERNAL_INSTALL_PREFIX}"
CMAKE_ARGS ${CMAKE_ARGS}
DEPENDS tinytoml
DEPENDS tinytoml portaudio
)

install(DIRECTORY "${INTERNAL_INSTALL_PREFIX}/" DESTINATION "${CMAKE_INSTALL_PREFIX}")
Expand Down
31 changes: 11 additions & 20 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,29 @@
FlexASIO is designed to be built using CMake within the Microsoft Visual C++
2017 toolchain native CMake support.

For the build to work you will need to provide the [PortAudio][] dependency. The
easiest way is to use [vcpkg][]:
FlexASIO uses a CMake "superbuild" system (in `/src`) to automatically build the
[tinytoml][] and [PortAudio][] dependencies before building FlexASIO itself.
These dependencies are pulled in as git submodules; make sure to run
`git submodule update --init`.

```
vcpkg install portaudio:x64-windows portaudio:x86-windows
```

Note that vcpkg needs to be integrated with CMake for the build to work. You
can use the method described in the vcpkg documentation, or you might find it
easier to simply set the `VCPKG_DIR` environment variable to your vcpkg
directory.

The FlexASIO CMake build system will download the [ASIO SDK][] for you
automatically at configure time.
If you want to handle the dependencies yourself, you can build FlexASIO in
isolation from `/src/flexasio`.

The [tinytoml][] dependency is pulled in as a git submodule. Make sure to
run `git submodule update --init`.
In any case, the FlexASIO CMake build system will download the [ASIO SDK][] for
you automatically at configure time.

## Packaging

The following command will do a clean build and generate a FlexASIO installer
package for you:
The following command will do a clean superbuild and generate a FlexASIO
installer package for you:

```
cmake -P installer.cmake
```

Note that for this command to work, you need to have [Inno Setup][] installed,
and the `VCPKG_DIR` environment variable must be set.
Note that for this command to work, you need to have [Inno Setup][] installed.

[ASIO SDK]: http://www.steinberg.net/en/company/developer.html
[Inno Setup]: http://www.jrsoftware.org/isdl.php
[PortAudio]: http://www.portaudio.com/
[tinytoml]: https://github.com/mayah/tinytoml
[vcpkg]: https://github.com/Microsoft/vcpkg
4 changes: 0 additions & 4 deletions src/flexasio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
cmake_minimum_required(VERSION 3.11)
project(FlexASIO DESCRIPTION "FlexASIO Universal ASIO Driver")

if(DEFINED ENV{VCPKG_DIR})
include("$ENV{VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake")
endif()

if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(FLEXASIO_PLATFORM x86)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
Expand Down
3 changes: 1 addition & 2 deletions src/flexasio/CMakeModules/Findportaudio.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
find_path(portaudio_INCLUDE_DIR NAMES portaudio.h)
find_library(portaudio_LIBRARY NAMES portaudio)
find_library(portaudio_LIBRARY NAMES "portaudio_${FLEXASIO_PLATFORM}")
mark_as_advanced(portaudio_INCLUDE_DIR portaudio_LIBRARY)

include(FindPackageHandleStandardArgs)
Expand All @@ -11,5 +11,4 @@ if(portaudio_FOUND AND NOT TARGET portaudio::portaudio)
IMPORTED_LOCATION "${portaudio_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${portaudio_INCLUDE_DIR}"
)
install(FILES "${portaudio_LIBRARY}/../../bin/portaudio_${FLEXASIO_PLATFORM}.dll" DESTINATION bin)
endif()
1 change: 1 addition & 0 deletions src/portaudio
Submodule portaudio added at 396fe4

0 comments on commit 989d7a1

Please sign in to comment.