summaryrefslogtreecommitdiff
path: root/portaudio/doc/src/tutorial/compile_cmake.dox
blob: 8db400e7686cadfb8eaab07e56afbf72ee508c6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/** @page compile_cmake PortAudio on Windows, OS X or Linux via. CMake
@ingroup tutorial

@section cmake_building Building PortAudio stand-alone on Windows, OS X or Linux

CMake can be used to generate Visual Studio solutions on Windows, Makefiles (on Linux and OS X) and build metadata for other build systems for PortAudio. You should obtain a recent version of CMake from [http://www.cmake.org] if you do not have one already. If you are unfamiliar with CMake, this section will provide some information on using CMake to build PortAudio.

On Linux, CMake serves a very similar purpose to an autotools "configure" script - except it can generate build metadata apart from Makefiles. The equivalent of the following on POSIX'y systems:

    build_path> {portaudio path}/configure --prefix=/install_location
    build_path> make
    build_path> make install

Would be:

    build_path> cmake {portaudio path} -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/install_location
    build_path> make
    build_path> make install

The "-G" option specifies the type of build metadata which will be generated. You can obtain a list of supported build metadata formats by invoking (on any platform):

    cmake -G

"make install" should install the same set of files that are installed using the usual configure script included with PortAudio along with a few extra files (similar to pkg-config metadata files) which make it easier for other CMake projects to use the installed libraries.

On Windows, you can use CMake to generate Visual Studio project files which can be used to create the PortAudio libraries. The following serves as an example (and should be done from a directory outside the PortAudio tree) which will create Visual Studio 2015 project files targeting a 64-bit build:

    C:\PABUILD> cmake {portaudio path} -G "Visual Studio 14 2015 Win64"

After executing the above, you can either open the generated solution with Visual Studio or use CMake to invoke the build process. The following shows an example of how to build a release configuration (assuming the above command was executed previously in the same directory):

    C:\PABUILD> cmake --build . --config Release

If you want ASIO support you need to obtain the ASIO2 SDK from Steinberg and place it according to \ref compile_windows_asio_msvc. Both ASIO and the DirectX SDK are automatically searched for by the CMake script - if they are found, they will be enabled by default.

@section cmake_using Using PortAudio in your CMake project

PortAudio defines the following CMake targets:

 - "portaudio_static" for a static library and
 - "portaudio" for a dynamic library

If you installed PortAudio as described above in \ref cmake_building and the install prefix you used (CMAKE_INSTALL_PREFIX) is in your system PATH or CMAKE_MODULE_PATH CMake variable, you should be able to use:

    find_package(portaudio)

To define the "portaudio_static" and "portaudio" targets in your CMake project.

If you do not want to install portaudio into your system but would rather just have it get built as part of your own project (which may be particularly convenient on Windows), you may also use:

    add_subdirectory("path to PortAudio location" "some binary directory" EXCLUDE_FROM_ALL)

EXCLUDE_FROM_ALL is not strictly necessary, but will ensure that targets which you don't use in your project won't get built.

Back to \ref tutorial_start

*/