Skip to content

Commit 0aea9e0

Browse files
committed
Replace autotools build system with CMake.
1 parent 22557d4 commit 0aea9e0

21 files changed

+323
-658
lines changed

.gitignore

-68
This file was deleted.

.travis.yml

+21-10
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ before_install:
4848
fi
4949
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
5050
if [ ! -z "$HOST" ]; then
51-
sudo apt-get install -qq mingw-w64 g++-mingw-w64 binutils-mingw-w64;
52-
wget http://mirrors.kernel.org/ubuntu/pool/universe/m/mingw-w64/mingw-w64-tools_3.1.0-1_amd64.deb;
53-
sudo dpkg -i mingw-w64-tools_3.1.0-1_amd64.deb;
51+
sudo apt-get install -qq mingw-w64 mingw-w64-tools g++-mingw-w64 binutils-mingw-w64;
5452
fi
5553
fi
56-
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew uninstall libtool && brew install libtool; fi
54+
- if [[ $TRAVIS_OS_NAME = "osx" ]]; then
55+
brew update;
56+
brew uninstall libtool && brew install libtool;
57+
brew uninstall cmake && brew install cmake;
58+
fi
5759
before_script:
60+
- cmake --version
5861
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
5962
if [ ! -z "$HOST" ]; then
6063
unset CC;
@@ -67,15 +70,23 @@ before_script:
6770
export CXX=$COMPILER_CXX;
6871
fi
6972
fi
70-
- autoreconf -i
71-
- $SCAN_BUILD_PATH ./configure --host=$HOST
73+
- mkdir build
74+
- cd build
75+
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
76+
if [ ! -z "$HOST" ]; then
77+
$SCAN_BUILD_PATH cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-cross-mingw.cmake ..;
78+
else
79+
$SCAN_BUILD_PATH cmake ..;
80+
fi
81+
else
82+
$SCAN_BUILD_PATH cmake ..;
83+
fi
7284
script:
7385
- echo $SCAN_BUILD_PATH
7486
- $SCAN_BUILD_PATH make
75-
- if [ -z "$HOST" ]; then
76-
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
77-
make check;
78-
cat test/*.log;
87+
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
88+
if [ -z "$HOST" ]; then
89+
make test ARGS=-V;
7990
fi
8091
fi
8192
addons:

CMakeLists.txt

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# TODO
2+
# - backend selection via command line, rather than simply detecting headers.
3+
4+
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
5+
project(cubeb
6+
VERSION 0.0.0)
7+
8+
if(POLICY CMP0063)
9+
cmake_policy(SET CMP0063 NEW)
10+
endif()
11+
set(CMAKE_C_STANDARD 99)
12+
set(CMAKE_CXX_STANDARD 11)
13+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
14+
15+
set(CMAKE_C_VISIBILITY_PRESET hidden)
16+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
17+
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
18+
19+
add_library(cubeb
20+
src/cubeb.c
21+
src/cubeb_resampler.cpp
22+
src/cubeb_panner.cpp
23+
$<TARGET_OBJECTS:speex>)
24+
target_include_directories(cubeb PUBLIC include)
25+
target_include_directories(cubeb PRIVATE src)
26+
target_compile_definitions(cubeb PRIVATE OUTSIDE_SPEEX)
27+
target_compile_definitions(cubeb PRIVATE FLOATING_POINT)
28+
target_compile_definitions(cubeb PRIVATE EXPORT=)
29+
target_compile_definitions(cubeb PRIVATE RANDOM_PREFIX=speex)
30+
31+
include(GenerateExportHeader)
32+
generate_export_header(cubeb EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/exports/cubeb_export.h)
33+
target_include_directories(cubeb PUBLIC ${CMAKE_BINARY_DIR}/exports)
34+
35+
add_library(speex OBJECT
36+
src/speex/resample.c)
37+
set_target_properties(speex PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
38+
target_compile_definitions(speex PRIVATE OUTSIDE_SPEEX)
39+
target_compile_definitions(speex PRIVATE FLOATING_POINT)
40+
target_compile_definitions(speex PRIVATE EXPORT=)
41+
target_compile_definitions(speex PRIVATE RANDOM_PREFIX=speex)
42+
43+
include(CheckIncludeFiles)
44+
45+
check_include_files(AudioUnit/AudioUnit.h USE_AUDIOUNIT)
46+
if(USE_AUDIOUNIT)
47+
target_sources(cubeb PRIVATE
48+
src/cubeb_audiounit.cpp
49+
src/cubeb_osx_run_loop.c)
50+
target_compile_definitions(cubeb PRIVATE USE_AUDIOUNIT)
51+
target_link_libraries(cubeb PRIVATE "-framework AudioUnit" "-framework CoreAudio" "-framework CoreServices")
52+
endif()
53+
54+
check_include_files(pulse/pulseaudio.h USE_PULSE)
55+
if(USE_PULSE)
56+
target_sources(cubeb PRIVATE
57+
src/cubeb_pulse.c)
58+
target_compile_definitions(cubeb PRIVATE USE_PULSE)
59+
target_link_libraries(cubeb PRIVATE pulse)
60+
endif()
61+
62+
check_include_files(alsa/asoundlib.h USE_ALSA)
63+
if(USE_ALSA)
64+
target_sources(cubeb PRIVATE
65+
src/cubeb_alsa.c)
66+
target_compile_definitions(cubeb PRIVATE USE_ALSA)
67+
target_link_libraries(cubeb PRIVATE asound dl pthread)
68+
endif()
69+
70+
check_include_files(jack/jack.h USE_JACK)
71+
if(USE_JACK)
72+
target_sources(cubeb PRIVATE
73+
src/cubeb_jack.cpp)
74+
target_compile_definitions(cubeb PRIVATE USE_JACK)
75+
target_link_libraries(cubeb PRIVATE jack dl pthread)
76+
endif()
77+
78+
check_include_files(audioclient.h USE_WASAPI)
79+
if(USE_WASAPI)
80+
target_sources(cubeb PRIVATE
81+
src/cubeb_wasapi.cpp)
82+
target_compile_definitions(cubeb PRIVATE USE_WASAPI)
83+
endif()
84+
85+
check_include_files("windows.h;mmsystem.h" USE_WINMM)
86+
if(USE_WINMM)
87+
target_sources(cubeb PRIVATE
88+
src/cubeb_winmm.c)
89+
target_compile_definitions(cubeb PRIVATE USE_WINMM)
90+
target_link_libraries(cubeb PRIVATE winmm)
91+
endif()
92+
93+
check_include_files(SLES/OpenSLES.h USE_OPENSL)
94+
if(USE_OPENSL)
95+
target_sources(cubeb PRIVATE
96+
src/cubeb_opensl.c)
97+
target_compile_definitions(cubeb PRIVATE USE_OPENSL)
98+
target_link_libraries(cubeb PRIVATE OpenSLES)
99+
endif()
100+
101+
check_include_files(android/log.h USE_AUDIOTRACK)
102+
if(USE_AUDIOTRACK)
103+
target_sources(cubeb PRIVATE
104+
src/cubeb_audiotrack.c)
105+
target_compile_definitions(cubeb PRIVATE USE_AUDIOTRACK)
106+
endif()
107+
108+
check_include_files(sndio.h USE_SNDIO)
109+
if(USE_SNDIO)
110+
target_sources(cubeb PRIVATE
111+
src/cubeb_sndio.c)
112+
target_compile_definitions(cubeb PRIVATE USE_SNDIO)
113+
target_link_libraries(cubeb PRIVATE sndio)
114+
endif()
115+
116+
check_include_files(kai.h USE_KAI)
117+
if(USE_KAI)
118+
target_sources(cubeb PRIVATE
119+
src/cubeb_kai.c)
120+
target_compile_definitions(cubeb PRIVATE USE_KAI)
121+
target_link_libraries(cubeb PRIVATE kai)
122+
endif()
123+
124+
find_package(Doxygen)
125+
if(DOXYGEN_FOUND)
126+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile @ONLY)
127+
add_custom_target(doc ALL
128+
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile
129+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs
130+
COMMENT "Generating API documentation with Doxygen" VERBATIM)
131+
endif()
132+
133+
enable_testing()
134+
135+
add_executable(test_sanity test/test_sanity.cpp)
136+
target_link_libraries(test_sanity PRIVATE cubeb)
137+
add_test(sanity test_sanity)
138+
139+
add_executable(test_tone test/test_tone.cpp)
140+
target_link_libraries(test_tone PRIVATE cubeb)
141+
add_test(tone test_tone)
142+
143+
add_executable(test_audio test/test_audio.cpp)
144+
target_link_libraries(test_audio PRIVATE cubeb)
145+
add_test(audio test_audio)
146+
147+
add_executable(test_record test/test_record.cpp)
148+
target_link_libraries(test_record PRIVATE cubeb)
149+
add_test(record test_record)
150+
151+
add_executable(test_devices test/test_devices.c)
152+
target_link_libraries(test_devices PRIVATE cubeb)
153+
add_test(devices test_devices)
154+
155+
add_executable(test_resampler test/test_resampler.cpp src/cubeb_resampler.cpp $<TARGET_OBJECTS:speex>)
156+
target_include_directories(test_resampler PRIVATE src)
157+
target_compile_definitions(test_resampler PRIVATE OUTSIDE_SPEEX)
158+
target_compile_definitions(test_resampler PRIVATE FLOATING_POINT)
159+
target_compile_definitions(test_resampler PRIVATE EXPORT=)
160+
target_compile_definitions(test_resampler PRIVATE RANDOM_PREFIX=speex)
161+
target_link_libraries(test_resampler PRIVATE cubeb)
162+
add_test(resampler test_resampler)
163+
164+
add_executable(test_duplex test/test_duplex.cpp)
165+
target_link_libraries(test_duplex PRIVATE cubeb)
166+
add_test(duplex test_duplex)
167+
168+
add_executable(test_latency test/test_latency.cpp)
169+
target_link_libraries(test_latency PRIVATE cubeb)
170+
add_test(latency test_latency)
171+
172+
add_executable(test_ring_array test/test_ring_array.cpp)
173+
target_include_directories(test_ring_array PRIVATE src)
174+
target_link_libraries(test_ring_array PRIVATE cubeb)
175+
add_test(ring_array test_ring_array)
176+
177+
add_executable(test_utils test/test_utils.cpp)
178+
target_include_directories(test_utils PRIVATE src)
179+
target_link_libraries(test_utils PRIVATE cubeb)
180+
add_test(utils test_utils)

INSTALL.md

+21-33
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,24 @@
11
# Build instructions for libcubeb
22

3-
Note Also:Cubeb does not currently build under Cygwin, but this is being worked on.
4-
5-
0. Change directory into the source directory.
6-
1. Run |autoreconf --install| to generate configure.
7-
2. Run |./configure| to configure the build.
8-
3. Run |make| to build.
9-
4. Run |make check| to run the test suite.
10-
11-
# Debugging
12-
13-
Debugging tests can be done like so:
14-
15-
```libtool --mode=execute gdb test/test_tone```
16-
17-
# Windows build prerequisite, using `msys2`
18-
19-
Cubeb for Windows uses win32 threads
20-
21-
- Download and install `msys2` 32-bits from <https://msys2.github.io>. Let it
22-
install in `C:\msys32`.
23-
- Download and install `7z` from <http://www.7-zip.org/>.
24-
- Run `msys2` (a shortcut has been added to the start menu, or use the `.bat`
25-
script: `C:\msys32\mingw32_shell.bat`), and issue the following commands to
26-
install the dependencies:
27-
```
28-
pacman -S git automake autoconf libtool m4 make pkg-config gdb
29-
```
30-
- Download a `mingw` compiler with the WIN32 thread model [here](http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/sjlj/i686-4.9.2-release-win32-sjlj-rt_v3-rev0.7z/download). `msys2` does not have `mingw` builds with win32 threads,
31-
so we have to install another compiler.
32-
- Unzip the compiler, and copy all folders in `C:\msys32\opt`
33-
- Exit the `msys2` shell, and run `C:\msys32\autorebase.bat` (double clicking
34-
works).
35-
- Open an `msys2` shell and follow the build instructions.
3+
You must have CMake v3.1 or later installed.
4+
5+
1. `git clone https://github.com/kinetiknz/cubeb.git`
6+
2. `mkdir cubeb-build`
7+
3. `cd cubeb-build`
8+
3. `cmake ../cubeb`
9+
4. `cmake --build .`
10+
5. `ctest`
11+
12+
# Windows build notes
13+
14+
Windows builds can use Microsoft Visual Studio 2015 (the default) or MinGW-w64
15+
with Win32 threads (by passing `cmake -G` to generate the appropriate build
16+
configuration). To build with MinGW-w64, install the following items:
17+
18+
- Download and install MinGW-w64 with Win32 threads.
19+
- Download and install CMake.
20+
- Run MinGW-w64 Terminal from the Start Menu.
21+
- Follow the build steps above, but at step 3 run:
22+
`cmake -G "MinGW Makefiles" ..`
23+
- Continue the build steps above.
3624

0 commit comments

Comments
 (0)