direwolf/cmake/modules/FindPortaudio.cmake

65 lines
1.7 KiB
CMake
Raw Normal View History

cmake: new build tool this step unify the builing system for all platforms (windows, linux, osx and *BSD) * Requirements: - gcc/clang (C/C++ compiler) (in debian build-essential) - cmake (in debian cmake) - git if you build from source (in debian git) - posix threads ** Requirements on *BSD/macOS: - portaudio ** Optional Requirements: - gpsd (in debian libgps-dev) - libhamlib (in debian libhamlib-dev) ** Optional Requirements in Linux - udev (in debian libudev-dev) - alsa (in debian libasound2-dev) * Main changes: - version is now set only on CMakeLists.txt and automatically used on the code - cpu flags are auto-discovered in the default build and it works on gcc/clang/msvc on x86/x86_64/arm; you can force cpu flags with -DFORCE_SSE=1 for example (see CMakeLists.txt on root) - use a more "complex" tag on generic.conf to facilitate parsing by cmake (not more platform dependent). Now it is %C% or %R% for example - target `tocalls-symbols` is now called `data-update` - created debian/ directory to contains files to use debuild * Example to build: mkdir build && cd build cmake .. make make install make install-conf then you have the binary files on src/ and in the system directory * CMake options (see the head of CMakeLists.txt) - FORCE_SSE force sse instruction - FORCE_SSSE3 force ssse3 instruction - FORCE_SSE41 force ssse4.1 instruction - OPTIONAL_TEST compile optional test (might be broken) - BUILD_TESTING enable tests (ctest framework) - CMAKE_INSTALL_PREFIX if you want to change your install path prefix for example: cmake .. -DOPTIONAL_TEST=ON
2019-08-15 06:30:42 +00:00
# - Try to find Portaudio
# Once done this will define
#
# PORTAUDIO_FOUND - system has Portaudio
# PORTAUDIO_INCLUDE_DIRS - the Portaudio include directory
# PORTAUDIO_LIBRARIES - Link these to use Portaudio
set(PORTAUDIO_ROOT_DIR
"${PORTAUDIO_ROOT_DIR}"
CACHE
PATH
"Directory to search for portaudio")
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_PORTAUDIO portaudio-2.0)
endif()
find_path(PORTAUDIO_INCLUDE_DIRS
NAMES
portaudio.h
PATHS
/usr/local/include
/usr/include
/opt/local/include
HINTS
${PC_PORTAUDIO_INCLUDEDIR}
${PORTAUDIO_ROOT_DIR}
)
find_library(PORTAUDIO_LIBRARIES
NAMES
portaudio
PATHS
/usr/local/lib
/usr/lib
/usr/lib64
/opt/local/lib
HINTS
${PC_PORTAUDIO_LIBDIR}
${PORTAUDIO_ROOT_DIR}
)
mark_as_advanced(PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARIES)
# Found PORTAUDIO, but it may be version 18 which is not acceptable.
if(EXISTS ${PORTAUDIO_INCLUDE_DIRS}/portaudio.h)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES_SAVED ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_INCLUDES ${PORTAUDIO_INCLUDE_DIRS})
CHECK_CXX_SOURCE_COMPILES(
"#include <portaudio.h>\nPaDeviceIndex pa_find_device_by_name(const char *name); int main () {return 0;}"
PORTAUDIO2_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVED})
unset(CMAKE_REQUIRED_INCLUDES_SAVED)
if(PORTAUDIO2_FOUND)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PORTAUDIO DEFAULT_MSG PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARIES)
else(PORTAUDIO2_FOUND)
message(STATUS
" portaudio.h not compatible (requires API 2.0)")
set(PORTAUDIO_FOUND FALSE)
endif(PORTAUDIO2_FOUND)
endif()