lasp/CMakeLists.txt
J.A. de Jong - Redu-Sone B.V., ASCEE V.O.F 6b337df2a9
All checks were successful
Building, testing and releasing LASP if it has a tag / Build-Test-Ubuntu (push) Successful in 3m2s
Building, testing and releasing LASP if it has a tag / Release-Ubuntu (push) Has been skipped
Bugfix in channel counter for getHighestEnabledOutChannel, added Api -subapis for Portaudio backend. Switch to defaulting Portaudio as audio backend. Added PulseAudio as extra sub-api to default compile in portaudio
2024-01-25 15:31:53 +01:00

128 lines
4.1 KiB
CMake

cmake_minimum_required (VERSION 3.16)
project(LASP LANGUAGES C CXX VERSION 1.1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED)
option(LASP_DOUBLE_PRECISION "Compile as double precision floating point" ON)
# Setting defaults for PortAudio and RtAudio backend, depending on Linux /
# Windows.
if(WIN32)
set(DEFAULT_RTAUDIO OFF)
set(DEFAULT_PORTAUDIO ON)
set(DEFAULT_ULDAQ OFF)
else()
set(DEFAULT_RTAUDIO OFF)
set(DEFAULT_PORTAUDIO ON)
set(DEFAULT_ULDAQ ON)
endif()
option(LASP_HAS_RTAUDIO "Compile with RtAudio Daq backend" ${DEFAULT_RTAUDIO})
option(LASP_HAS_PORTAUDIO "Compile with PortAudio Daq backend" ${DEFAULT_PORTAUDIO})
if(LASP_HAS_PORTAUDIO AND LASP_HAS_RTAUDIO)
message(FATAL_ERROR "Either PortAudio or RtAudio can be selected as audio backend")
endif()
option(LASP_HAS_ULDAQ "Compile with UlDaq backend" ${DEFAULT_ULDAQ})
option(LASP_BUILD_TUNED "Tune build for current machine (Experimental / untested)" OFF)
option(LASP_WITH_OPENMP "Use OpenMP parallelization (Experimental: crashes SHOULD BE EXPECTED)" OFF)
set(LASP_MAX_NFFT "33554432" CACHE STRING "Max FFT size")
option(LASP_BUILD_CPP_TESTS "Build CPP test code" OFF)
# Use ccache if available
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}")
endif()
# To allow linking to static libs from other directories
cmake_policy(SET CMP0079 NEW)
# This is used for code completion in vim
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
include_directories(/usr/include/python3.8)
include("BuildType")
include("QueryPythonForPybind11")
# Find the pybind11 package
find_pybind11_python_first()
find_package(OpenMP REQUIRED COMPONENTS CXX)
set(LASP_FFT_BACKEND "FFTW" CACHE STRING "FFT Library backend")
set_property(CACHE LASP_FFT_BACKEND PROPERTY STRINGS "FFTW" "Armadillo")
set(PY_FULL_VERSION ${PROJECT_VERSION}${PY_VERSION_SUFFIX})
# Required for PYBIND11
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(LASP_DEBUG True)
# This does not work nicely with RtAudio if it is precompiled (undefined
# symbols). However, if we compile it
# ourselves as a third_party ref, this works nicely together.
# This flag gives "floating point exception: core dumped"
# add_definitions(-D_GLIBCXX_DEBUG)
# add_definitions(ARMA_EXTRA_DEBUG)
else()
set(LASP_DEBUG False)
add_definitions(-DARMA_NO_DEBUG)
endif()
# Tune for current machine
if(LASP_BUILD_TUNED)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(FATAL_ERROR
"Cannot build optimized and tuned code when debug is switched on")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -mtune=native")
endif()
# ###################################### Find and link to OpenBLAS
set(BLA_VENDOR OpenBLAS)
find_package(BLAS REQUIRED)
# ###################################### Find and link to FFTW
if(LASP_FFT_BACKEND STREQUAL "FFTW")
find_library(fftw3 REQUIRED NAMES fftw fftw3)
set(LASP_FFT_LIBS "fftw3")
elseif(LASP_FFT_BACKEND STREQUAL "Armadillo")
endif()
# ###################################### OpenMP related
if(LASP_WITH_OPENMP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
endif()
# ###################################### Compilation flags
set(CMAKE_C_FLAGS_RELEASE "-O3 -flto -mfpmath=sse -march=x86-64 -mtune=native \
-fdata-sections -ffunction-sections -fomit-frame-pointer -finline-functions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-type-limits -Werror=return-type")
# ############################# End compilation flags
include_directories(/usr/lib/python3.10/site-packages/numpy/core/include)
# ####################################### End of user-adjustable variables section
include(OSSpecific)
include(rtaudio)
include(portaudio)
include(uldaq)
#
add_definitions(-Dgsl_CONFIG_DEFAULTS_VERSION=1)
add_subdirectory(cpp_src)
if(LASP_BUILD_CPP_TESTS)
add_subdirectory(test)
endif()