Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More cmake work based on jcelerier's pull request. #8

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.cm*
# *.cm* # This line is broken it matches all files.
*.dat
*.gz
*.la
Expand Down Expand Up @@ -28,6 +28,7 @@ aclocal.m4
autom4te.cache
compile
config.*
!/config.h.in
configure
depcomp
doc/ChangeLog
Expand All @@ -49,3 +50,5 @@ stamp-h1
tests/*_test
tests/benchmark
tests/src-evaluate

build/
109 changes: 109 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
cmake_minimum_required(VERSION 3.1)
project(LibSamplerate LANGUAGES C)


set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)

set(SAMPLERATE_SRC
${PROJECT_SOURCE_DIR}/src/samplerate.c
${PROJECT_SOURCE_DIR}/src/src_linear.c
${PROJECT_SOURCE_DIR}/src/src_sinc.c
${PROJECT_SOURCE_DIR}/src/src_zoh.c)

if(WIN32)
set(SAMPLERATE_SRC
${SAMPLERATE_SRC}
${PROJECT_SOURCE_DIR}/Win32/libsamplerate-0.def)
endif()

include(TestBigEndian)
test_big_endian(IS_BIG_ENDIAN)
if(IS_BIG_ENDIAN)
set(CPU_IS_BIG_ENDIAN 1)
set(CPU_IS_LITTLE_ENDIAN 0)
else()
set(CPU_IS_BIG_ENDIAN 0)
set(CPU_IS_LITTLE_ENDIAN 1)
endif()

include(CheckFunctionExists)
check_function_exists(alarm IS_ALARM)
if(IS_ALARM)
set(HAVE_ALARM 1)
else()
set(HAVE_ALARM 0)
endif()

check_function_exists(lrint IS_LRINT)
if(IS_LRINT)
set(HAVE_LRINT 1)
else()
set(HAVE_LRINT 0)
endif()

check_function_exists(lrintf IS_LRINTF)
if(IS_LRINTF)
set(HAVE_LRINTF 1)
else()
set(HAVE_LRINTF 0)
endif()

check_function_exists(signal IS_SIGNAL)
if(IS_SIGNAL)
set(HAVE_SIGNAL 1)
else()
set(HAVE_SIGNAL 0)
endif()

include(CheckIncludeFiles)
check_include_files(stdint.h IS_STDINT)
if(IS_STDINT)
set(HAVE_STDINT_H 1)
else()
set(HAVE_STDINT_H 0)
endif()

check_include_files(sys/times.h IS_SYS_TIMES)
if(IS_SYS_TIMES)
set(HAVE_SYS_TIMES_H 1)
else()
set(HAVE_SYS_TIMES_H 0)
endif()

check_include_files(alsa/asoundlib.h IS_ALSA_ASOUNDLIB)
if(IS_ALSA_ASOUNDLIB)
set(HAVE_ALSA_ASOUNDLIB_H 1)
else()
set(HAVE_ALSA_ASOUNDLIB_H 0)
endif()

include(CheckTypeSize)
check_type_size("double" SIZEOF_DOUBLE)
check_type_size("float" SIZEOF_FLOAT)
check_type_size("int" SIZEOF_INT)
check_type_size("long" SIZEOF_LONG)


set(ENV{SNDFILE_ROOT} "${PROJECT_SOURCE_DIR}/extern/yaml-cpp")

find_package(Sndfile)

if(SNDFILE_FOUND)
set(HAVE_SNDFILE 1)
else()
set(HAVE_SNDFILE 0)
endif()

configure_file(${PROJECT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)

add_library(samplerate ${SAMPLERATE_SRC})

if(WIN32)
target_compile_definitions(samplerate PRIVATE "WIN32" "_USRDLL")
target_include_directories(samplerate PUBLIC ${PROJECT_SOURCE_DIR}/Win32)
endif()

target_include_directories(samplerate PUBLIC
${PROJECT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR})

197 changes: 0 additions & 197 deletions Win32/config.h

This file was deleted.

18 changes: 18 additions & 0 deletions cmake/FindSndfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Variables defined:
# SNDFILE_FOUND
# SNDFILE_INCLUDE_DIR
# SNDFILE_LIBRARY
#
# Environment variables used:
# SNDFILE_ROOT

find_path(SNDFILE_INCLUDE_DIR sndfile.h
HINTS $ENV{SNDFILE_ROOT}/include)

find_library(SNDFILE_LIBRARY NAMES sndfile
HINTS $ENV{SNDFILE_ROOT}/lib)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SNDFILE DEFAULT_MSG SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)

mark_as_advanced(SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)
Loading