forked from hbe72/cdsp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
158 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,61 @@ | ||
# dsp | ||
# CDSP - Compositional DSP Library for C++ | ||
|
||
CDSP is a header only DSP library written with [CNL](https://github.com/johnmcfarlane/cnl) | ||
aiming for floating point and fixed-point implementation of typical DSP kernels. | ||
|
||
## Requirements are the same as with [CNL](https://github.com/johnmcfarlane/cnl) | ||
### Linux | ||
Requires: | ||
* GCC 5.1 / Clang 3.5 | ||
* [Cmake](https://cmake.org/) 3.2.2 | ||
|
||
Optional: | ||
* [Boost](https://www.boost.org/) - for multiprecision support with [CNL](https://github.com/johnmcfarlane/cnl) | ||
* [Doxygen](https://www.doxygen.org/) - generates documentation in the doc/gh-pages directory | ||
|
||
### Mac | ||
See the instructions for Linux. Works similarly. | ||
For missing packages please use [Homebrew](https://brew.sh/). | ||
|
||
### Windows | ||
* MSBuild 15.0 (VS 2017) | ||
* [Cmake](https://cmake.org/) 3.8.0 | ||
|
||
## Instructions | ||
In an empty workspace folder, run the following script: | ||
|
||
```sh | ||
#!/bin/bash | ||
|
||
# clone the repositories | ||
git clone git@github.com:johnmcfarlane/cnl --branch develop | ||
git clone git@github.com:google/googletest --branch master | ||
git clone git@github.com:hbe72/dsp | ||
|
||
# create an env directory (for include, lib etc.) | ||
ENV="$(pwd)/env" | ||
mkdir -p $ENV | ||
|
||
# configure, build and install CNL in env/ | ||
mkdir -p build/cnl | ||
pushd build/cnl | ||
cmake -DCMAKE_INSTALL_PREFIX=$ENV ../../cnl | ||
cmake --build . -- -j 8 install | ||
popd | ||
|
||
# configure, build and install Google Test in env/ | ||
mkdir -p build/googletest | ||
pushd build/googletest | ||
cmake -DCMAKE_INSTALL_PREFIX=$ENV ../../googletest | ||
cmake --build . -- -j 8 install | ||
popd | ||
|
||
# configure, build and test DSP | ||
mkdir -p build/dsp | ||
pushd build/dspcd | ||
cmake -DCMAKE_INSTALL_PREFIX=$ENV -DCMAKE_PREFIX_PATH=$ENV ../../dsp | ||
cmake --build . -- -j 8 install | ||
ctest | ||
popd | ||
### Download | ||
The library is hosted on [GitHub](https://github.com/hbe72/dsp) | ||
``` | ||
cd /some/directory | ||
git clone https://github.com/hbe72/dsp.git | ||
``` | ||
|
||
###Build | ||
1. Generate the build system | ||
``` | ||
mkdir build | ||
cd build | ||
cmake /some/directory/dsp -DCMAKE_INSTALL_PREFIX=/directory/to/install | ||
``` | ||
2. Build tests: | ||
* Linux and Mac parallel with 8 cores | ||
``` | ||
cmake --build . --target Tests -- j 8 | ||
``` | ||
* Windows | ||
``` | ||
cmake --build . --target Tests | ||
``` | ||
3. Run the tests | ||
``` | ||
ctest | ||
``` | ||
4. Install | ||
If you want to install the CDSP and CNL libraries to location specified by | ||
CMAKE_INSTALL_PREFIX. | ||
``` | ||
cmake --build . --target install | ||
``` | ||
By default CDSP and CNL install to /usr/local. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
include("../cmake/common.cmake") | ||
|
||
###################################################################### | ||
# add_cnl_dependency | ||
function(add_cnl_dependency target) | ||
ExternalProject_Get_Property(Cnl source_dir) | ||
target_include_directories("${target}" SYSTEM PRIVATE "${source_dir}/include") | ||
add_dependencies("${target}" Cnl) | ||
endfunction(add_cnl_dependency) | ||
|
||
# Google Test | ||
ExternalProject_Add( | ||
GoogleTest | ||
PREFIX ${CMAKE_BINARY_DIR}/GoogleTest | ||
URL "https://github.com/google/googletest/archive/3a4cf1a02ef4adc28fccb7eef2b573b14cd59009.zip" | ||
URL_MD5 "06ac495303fbe94b198026e3c196425e" | ||
UPDATE_COMMAND "" | ||
INSTALL_COMMAND "" | ||
CMAKE_ARGS -Dgtest_force_shared_crt=ON | ||
) | ||
|
||
###################################################################### | ||
# add_gtest_dependency | ||
function(add_gtest_dependency target) | ||
# gtest | ||
ExternalProject_Get_Property(GoogleTest binary_dir) | ||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) | ||
target_link_libraries("${target}" | ||
debug ${binary_dir}/googlemock/gtest/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}gtestd${CMAKE_FIND_LIBRARY_SUFFIXES} | ||
debug ${binary_dir}/googlemock/gtest/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_maind${CMAKE_FIND_LIBRARY_SUFFIXES} | ||
optimized ${binary_dir}/googlemock/gtest/Release/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_FIND_LIBRARY_SUFFIXES} | ||
optimized ${binary_dir}/googlemock/gtest/Release/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_FIND_LIBRARY_SUFFIXES} | ||
) | ||
else () | ||
target_link_libraries( | ||
"${target}" | ||
general "${binary_dir}/googlemock/gtest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a" | ||
general "${binary_dir}/googlemock/gtest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a" | ||
general pthread | ||
) | ||
endif () | ||
|
||
ExternalProject_Get_Property(GoogleTest source_dir) | ||
target_include_directories("${target}" SYSTEM PRIVATE "${source_dir}/googletest/include") | ||
|
||
add_dependencies("${target}" GoogleTest) | ||
endfunction(add_gtest_dependency) | ||
|
||
|
||
# DSP tests | ||
set(sample_cdsp_sources | ||
basic_math.cpp | ||
biquad.cpp | ||
biquad_cascade.cpp | ||
complex.cpp | ||
complex_vector.cpp | ||
fft.cpp | ||
stft.cpp | ||
trig.cpp | ||
virtual_float.cpp) | ||
|
||
include(CTest) | ||
add_custom_target(Tests) | ||
|
||
foreach(source ${sample_cdsp_sources}) | ||
string(REPLACE "\." "_" target "${source}") | ||
string(REPLACE "/" "-" target "${target}") | ||
add_executable(${target} ${source}) | ||
add_test("${target}" "${target}") | ||
|
||
add_gtest_dependency("${target}") | ||
add_cnl_dependency("${target}") | ||
|
||
target_include_directories( | ||
${target} PRIVATE | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include>) | ||
add_dependencies(Tests "${target}") | ||
endforeach(source) |