2022-06-29 10:25:32 +00:00
|
|
|
cmake_minimum_required (VERSION 3.16)
|
2023-12-18 11:37:46 +00:00
|
|
|
project(LASP LANGUAGES C CXX VERSION 1.1)
|
2019-12-28 20:33:14 +00:00
|
|
|
|
2022-09-03 18:59:14 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED)
|
|
|
|
|
|
|
|
option(LASP_DOUBLE_PRECISION "Compile as double precision floating point" ON)
|
2023-06-15 07:57:06 +00:00
|
|
|
|
|
|
|
# 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()
|
2024-01-25 14:31:53 +00:00
|
|
|
set(DEFAULT_RTAUDIO OFF)
|
|
|
|
set(DEFAULT_PORTAUDIO ON)
|
2023-06-15 07:57:06 +00:00
|
|
|
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})
|
2023-06-14 19:23:53 +00:00
|
|
|
if(LASP_HAS_PORTAUDIO AND LASP_HAS_RTAUDIO)
|
|
|
|
message(FATAL_ERROR "Either PortAudio or RtAudio can be selected as audio backend")
|
|
|
|
endif()
|
2023-06-15 07:57:06 +00:00
|
|
|
option(LASP_HAS_ULDAQ "Compile with UlDaq backend" ${DEFAULT_ULDAQ})
|
2022-10-12 13:02:42 +00:00
|
|
|
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)
|
2022-10-05 09:27:46 +00:00
|
|
|
set(LASP_MAX_NFFT "33554432" CACHE STRING "Max FFT size")
|
2022-10-12 13:02:42 +00:00
|
|
|
option(LASP_BUILD_CPP_TESTS "Build CPP test code" OFF)
|
2022-09-03 18:59:14 +00:00
|
|
|
|
|
|
|
# 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()
|
2022-07-20 12:58:48 +00:00
|
|
|
|
2020-10-04 20:29:54 +00:00
|
|
|
# To allow linking to static libs from other directories
|
|
|
|
cmake_policy(SET CMP0079 NEW)
|
2022-07-20 12:58:48 +00:00
|
|
|
|
2022-09-03 18:59:14 +00:00
|
|
|
# This is used for code completion in vim
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2022-07-20 12:58:48 +00:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
|
2022-10-07 07:34:32 +00:00
|
|
|
include_directories(/usr/include/python3.8)
|
2021-09-14 18:05:42 +00:00
|
|
|
include("BuildType")
|
2022-07-20 12:58:48 +00:00
|
|
|
include("QueryPythonForPybind11")
|
|
|
|
|
|
|
|
# Find the pybind11 package
|
|
|
|
find_pybind11_python_first()
|
2021-09-14 18:05:42 +00:00
|
|
|
|
2022-09-03 18:59:14 +00:00
|
|
|
find_package(OpenMP REQUIRED COMPONENTS CXX)
|
2021-12-27 11:08:53 +00:00
|
|
|
|
2021-09-14 18:05:42 +00:00
|
|
|
set(LASP_FFT_BACKEND "FFTW" CACHE STRING "FFT Library backend")
|
2022-08-07 19:13:45 +00:00
|
|
|
set_property(CACHE LASP_FFT_BACKEND PROPERTY STRINGS "FFTW" "Armadillo")
|
2021-09-14 18:05:42 +00:00
|
|
|
|
2022-07-20 12:58:48 +00:00
|
|
|
set(PY_FULL_VERSION ${PROJECT_VERSION}${PY_VERSION_SUFFIX})
|
2022-06-29 10:25:32 +00:00
|
|
|
|
2022-05-23 15:26:29 +00:00
|
|
|
# Required for PYBIND11
|
2022-07-20 12:58:48 +00:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
2022-05-23 15:26:29 +00:00
|
|
|
|
2022-09-03 18:59:14 +00:00
|
|
|
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
2021-09-14 18:05:42 +00:00
|
|
|
set(LASP_DEBUG True)
|
2022-10-10 17:17:38 +00:00
|
|
|
# This does not work nicely with RtAudio if it is precompiled (undefined
|
|
|
|
# symbols). However, if we compile it
|
2022-10-05 09:27:46 +00:00
|
|
|
# ourselves as a third_party ref, this works nicely together.
|
2022-10-10 17:17:38 +00:00
|
|
|
|
|
|
|
# This flag gives "floating point exception: core dumped"
|
|
|
|
# add_definitions(-D_GLIBCXX_DEBUG)
|
|
|
|
|
|
|
|
# add_definitions(ARMA_EXTRA_DEBUG)
|
2022-10-05 09:27:46 +00:00
|
|
|
|
2021-09-14 18:05:42 +00:00
|
|
|
else()
|
|
|
|
set(LASP_DEBUG False)
|
2022-10-18 20:31:25 +00:00
|
|
|
add_definitions(-DARMA_NO_DEBUG)
|
2021-09-14 18:05:42 +00:00
|
|
|
endif()
|
2020-10-14 07:42:19 +00:00
|
|
|
|
2022-09-03 18:59:14 +00:00
|
|
|
# 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()
|
|
|
|
|
2022-10-05 09:27:46 +00:00
|
|
|
# ###################################### Find and link to OpenBLAS
|
2022-06-29 10:25:32 +00:00
|
|
|
set(BLA_VENDOR OpenBLAS)
|
|
|
|
find_package(BLAS REQUIRED)
|
|
|
|
|
2022-10-05 09:27:46 +00:00
|
|
|
# ###################################### 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()
|
2022-09-22 19:02:41 +00:00
|
|
|
|
2022-10-05 09:27:46 +00:00
|
|
|
# ###################################### OpenMP related
|
2022-09-22 19:02:41 +00:00
|
|
|
if(LASP_WITH_OPENMP)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
2022-10-05 11:39:45 +00:00
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
|
2022-09-22 19:02:41 +00:00
|
|
|
endif()
|
2020-04-03 09:12:49 +00:00
|
|
|
|
2022-10-05 09:27:46 +00:00
|
|
|
# ###################################### Compilation flags
|
2022-08-07 19:13:45 +00:00
|
|
|
set(CMAKE_C_FLAGS_RELEASE "-O3 -flto -mfpmath=sse -march=x86-64 -mtune=native \
|
2019-12-29 21:07:27 +00:00
|
|
|
-fdata-sections -ffunction-sections -fomit-frame-pointer -finline-functions")
|
2023-06-14 19:24:29 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-type-limits -Werror=return-type")
|
2022-10-05 09:27:46 +00:00
|
|
|
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2018-04-01 08:27:27 +00:00
|
|
|
# ############################# End compilation flags
|
2022-09-03 18:59:14 +00:00
|
|
|
include_directories(/usr/lib/python3.10/site-packages/numpy/core/include)
|
2018-04-01 08:27:27 +00:00
|
|
|
|
2022-10-05 09:27:46 +00:00
|
|
|
# ####################################### End of user-adjustable variables section
|
|
|
|
include(OSSpecific)
|
|
|
|
include(rtaudio)
|
2023-06-14 19:23:53 +00:00
|
|
|
include(portaudio)
|
2022-10-05 09:27:46 +00:00
|
|
|
include(uldaq)
|
|
|
|
#
|
2023-06-14 19:23:53 +00:00
|
|
|
add_definitions(-Dgsl_CONFIG_DEFAULTS_VERSION=1)
|
2023-07-14 14:40:57 +00:00
|
|
|
add_subdirectory(cpp_src)
|
2022-10-12 13:02:42 +00:00
|
|
|
if(LASP_BUILD_CPP_TESTS)
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
2022-08-07 19:13:45 +00:00
|
|
|
|