Skip to content

Commit 750ce75

Browse files
committed
BUILD: Replace build system with cmake
1 parent 4fcd0b1 commit 750ce75

File tree

9 files changed

+122
-662
lines changed

9 files changed

+122
-662
lines changed

.gitlab-ci.yml

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,6 @@ lint_commit_messages:
2626
when: always
2727
- when: never
2828

29-
test_build:
30-
image: ubuntu:latest
31-
stage: build
32-
before_script:
33-
- apt-get -y update
34-
- apt-get -y install build-essential autoconf libtool
35-
script:
36-
- echo "Build renamenoise"
37-
- ./autogen.sh
38-
- ./configure
39-
- make
40-
- echo "Apply noise suppression to test sample"
41-
- ./examples/renamenoise_demo ./sample/babble_15dB.pcm ./sample/renamenoise_babble_15dB.pcm
42-
- sha1sum -c --strict ./sample/CHECKSUMS
43-
- echo "Check exported symbols"
44-
- FAILED=""
45-
- EXPORTED_SYMBOLS=$(nm ./.libs/librenamenoise.a | awk '/ T / {print $3}' | sort)
46-
- "SYMBOL_REGEX='^_?renamenoise.*$'"
47-
- "while IFS= read -r line; do if [[ \"$line\" =~ $SYMBOL_REGEX ]]; then echo \"passed '$line'\"; else echo \"failed '$line'\"; FAILED=\"$FAILED,$line\"; fi; done <<< \"$EXPORTED_SYMBOLS\""
48-
- "if [[ -n \"$FAILED\" ]]; then echo \"$FAILED\"; exit 1; fi;"
49-
5029
lint_clang_format:
5130
image: xianpengshen/clang-tools:16
5231
stage: lint
@@ -70,18 +49,17 @@ test_build:
7049
stage: build
7150
before_script:
7251
- apt-get -y update
73-
- apt-get -y install build-essential autoconf libtool
52+
- apt-get -y install build-essential cmake
7453
script:
7554
- echo "Build renamenoise"
76-
- ./autogen.sh
77-
- ./configure
55+
- cmake .
7856
- make
7957
- echo "Apply noise suppression to test sample"
8058
- ./examples/renamenoise_demo ./sample/babble_15dB.pcm ./sample/renamenoise_babble_15dB.pcm
8159
- sha1sum -c --strict ./sample/CHECKSUMS
8260
- echo "Check exported symbols"
8361
- FAILED=""
84-
- EXPORTED_SYMBOLS=$(nm ./.libs/librenamenoise.a | awk '/ T / {print $3}' | sort)
62+
- EXPORTED_SYMBOLS=$(nm ./librenamenoise.a | awk '/ T / {print $3}' | sort)
8563
- "SYMBOL_REGEX='^_?renamenoise.*$'"
8664
- "while IFS= read -r line; do if [[ \"$line\" =~ $SYMBOL_REGEX ]]; then echo \"passed '$line'\"; else echo \"failed '$line'\"; FAILED=\"$FAILED,$line\"; fi; done <<< \"$EXPORTED_SYMBOLS\""
8765
- "if [[ -n \"$FAILED\" ]]; then echo \"$FAILED\"; exit 1; fi;"
@@ -91,12 +69,11 @@ test_build_no_vla:
9169
stage: build
9270
before_script:
9371
- apt-get -y update
94-
- apt-get -y install build-essential autoconf libtool
72+
- apt-get -y install build-essential cmake
9573
script:
9674
- echo "Build renamenoise"
9775
- export CFLAGS="-DRENAMENOISE_NO_VLA=1 -Werror=vla"
98-
- ./autogen.sh
99-
- ./configure
76+
- cmake .
10077
- make
10178
- echo "Apply noise suppression to test sample"
10279
- ./examples/renamenoise_demo ./sample/babble_15dB.pcm ./sample/renamenoise_babble_15dB.pcm

CMakeLists.txt

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
3+
project(renamenoise LANGUAGES C)
4+
5+
if(NOT CMAKE_BUILD_TYPE)
6+
set(CMAKE_BUILD_TYPE Release)
7+
endif()
8+
9+
if(NOT DEFINED RENAMENOISE_DEMO_EXECUTABLE)
10+
set(RENAMENOISE_DEMO_EXECUTABLE ON)
11+
endif()
12+
13+
if (MSVC)
14+
add_compile_options(/W4)
15+
16+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
17+
add_compile_options(/Zi)
18+
else()
19+
add_compile_options(/Od)
20+
endif()
21+
else()
22+
add_compile_options(-Wall -Wextra -Wpedantic)
23+
24+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
25+
add_compile_options(-g)
26+
else()
27+
add_compile_options(-O3)
28+
endif()
29+
endif()
30+
31+
if(WIN32)
32+
add_library(renamenoise SHARED)
33+
set_target_properties(renamenoise PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
34+
if(MINGW)
35+
# Remove "lib" prefix.
36+
set_target_properties(renamenoise PROPERTIES PREFIX "")
37+
endif()
38+
target_compile_definitions(renamenoise
39+
PRIVATE
40+
"WIN32"
41+
"DLL_EXPORT"
42+
)
43+
else()
44+
add_library(renamenoise STATIC)
45+
endif()
46+
47+
target_compile_definitions(renamenoise PRIVATE "RENAMENOISE_BUILD")
48+
target_compile_definitions(renamenoise PRIVATE "ENABLE_ASSERTIONS")
49+
50+
target_include_directories(renamenoise
51+
PRIVATE SYSTEM
52+
${CMAKE_CURRENT_SOURCE_DIR}
53+
PUBLIC SYSTEM
54+
"include"
55+
)
56+
57+
target_sources(renamenoise PRIVATE
58+
"src/rnn_data.c"
59+
"src/rnn.c"
60+
"src/pitch.c"
61+
"src/renamenoise_fft.c"
62+
"src/denoise.c"
63+
"src/renamenoise_lpc.c"
64+
)
65+
66+
if(RENAMENOISE_DEMO_EXECUTABLE)
67+
add_executable(renamenoise_demo examples/renamenoise_demo.c)
68+
69+
target_compile_definitions(renamenoise_demo PRIVATE "RENAMENOISE_BUILD")
70+
target_compile_definitions(renamenoise_demo PRIVATE "ENABLE_ASSERTIONS")
71+
72+
target_include_directories(renamenoise_demo
73+
PRIVATE SYSTEM
74+
${CMAKE_CURRENT_SOURCE_DIR}
75+
PUBLIC SYSTEM
76+
"include"
77+
)
78+
79+
target_sources(renamenoise_demo PRIVATE
80+
"src/rnn_data.c"
81+
"src/rnn.c"
82+
"src/pitch.c"
83+
"src/renamenoise_fft.c"
84+
"src/denoise.c"
85+
"src/renamenoise_lpc.c"
86+
)
87+
88+
target_link_libraries(renamenoise_demo PRIVATE m)
89+
set_target_properties(renamenoise_demo PROPERTIES RUNTIME_OUTPUT_DIRECTORY "examples")
90+
endif()
91+
92+
message(STATUS "===")
93+
message(STATUS " Building ReNameNoise ${CMAKE_BUILD_TYPE}")
94+
message(STATUS " RENAMENOISE_DEMO_EXECUTABLE is ${RENAMENOISE_DEMO_EXECUTABLE}")
95+
get_target_property(RENAMENOISE_CFLAGS renamenoise COMPILE_OPTIONS)
96+
message(STATUS " CLFAGS = '${RENAMENOISE_CFLAGS}'")
97+
message(STATUS "===")
98+
99+
# target_disable_warnings(renamenoise)

Makefile.am

Lines changed: 0 additions & 130 deletions
This file was deleted.

README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,33 @@ An interactive demo is available at: https://jmvalin.ca/demo/rnnoise/
1818
To build the library with the existing, pre-trained network data you will need to install the following packages:
1919

2020
* build-essential
21-
* autoconf
22-
* libtool
21+
* cmake
2322

2423
## Build
2524

26-
To compile, just type:
25+
To compile, open a terminal in the repository root directory and type:
2726

2827
```bash
29-
./autogen.sh
30-
./configure
28+
cmake .
3129
make
3230
```
3331

34-
Optionally:
32+
To compile the library only, without the demo executable:
3533

36-
``make install``
34+
```bash
35+
cmake -DRENAMENOISE_DEMO_EXECUTABLE=OFF .
36+
make
37+
```
38+
39+
## Usage
40+
41+
While it is meant to be used as a library, a simple command-line tool is
42+
provided as an example. It operates on RAW 16-bit (machine endian) mono
43+
PCM files sampled at 48 kHz. It can be used as:
44+
45+
``./examples/renamenoise_demo <noisy speech> <output denoised>``
46+
47+
The output is also a 16-bit raw PCM file.d
3748

3849
## Training
3950

@@ -54,13 +65,3 @@ cd training ; ./bin2hdf5.py ../src/training.f32 500000 87 training.h5
5465

5566
./dump_rnn.py weights.hdf5 ../src/rnn_data.c ../src/rnn_data.h
5667
```
57-
58-
## Usage
59-
60-
While it is meant to be used as a library, a simple command-line tool is
61-
provided as an example. It operates on RAW 16-bit (machine endian) mono
62-
PCM files sampled at 48 kHz. It can be used as:
63-
64-
``./examples/renamenoise_demo <noisy speech> <output denoised>``
65-
66-
The output is also a 16-bit raw PCM file.d

autogen.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)