2021-11-01 10:47:12 +00:00
|
|
|
cmake_minimum_required (VERSION 3.12)
|
2019-12-28 20:33:14 +00:00
|
|
|
|
2020-10-04 20:29:54 +00:00
|
|
|
# To allow linking to static libs from other directories
|
|
|
|
cmake_policy(SET CMP0079 NEW)
|
2021-09-14 18:05:42 +00:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/lasp/cmake")
|
|
|
|
include("BuildType")
|
|
|
|
|
2020-10-04 20:29:54 +00:00
|
|
|
|
2019-12-28 20:33:14 +00:00
|
|
|
# This is used for code completion in vim
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS=ON)
|
2020-10-14 07:42:19 +00:00
|
|
|
project(LASP LANGUAGES C CXX)
|
2018-01-29 15:14:50 +00:00
|
|
|
|
|
|
|
# Whether we want to use blas yes or no
|
2021-09-14 18:05:42 +00:00
|
|
|
option(LASP_USE_BLAS "Use external blas library for math" ON)
|
|
|
|
option(LASP_ARM "Compile subset of code for ARM real time (Bela board)" OFF)
|
|
|
|
option(LASP_DOUBLE_PRECISION "Compile as double precision floating point" ON)
|
2020-10-14 07:42:19 +00:00
|
|
|
option(LASP_PARALLEL "Parallel processing" ON)
|
2021-09-14 18:05:42 +00:00
|
|
|
option(LASP_HAS_RTAUDIO "Compile with RtAudio Daq backend" ON)
|
|
|
|
option(LASP_HAS_ULDAQ "Compile with UlDaq backend" ON)
|
|
|
|
set(LASP_MAX_NUM_CHANNELS 16 CACHE STRING "Maximum number of audio channels that is compiled in in code")
|
|
|
|
set(LASP_MAX_NUM_THREADS 30 CACHE STRING "The maximum number of simultaneous threads in parallel processing")
|
|
|
|
set(LASP_TRACERNAME "defaulttracer" CACHE STRING "Name of tracer variable containing level")
|
|
|
|
set(LASP_FFT_BACKEND "FFTW" CACHE STRING "FFT Library backend")
|
|
|
|
set_property(CACHE LASP_FFT_BACKEND PROPERTY STRINGS "FFTW" "FFTPack" "None")
|
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
|
|
|
set(LASP_DEBUG True)
|
|
|
|
else()
|
|
|
|
set(LASP_DEBUG False)
|
|
|
|
endif()
|
2020-10-14 07:42:19 +00:00
|
|
|
|
|
|
|
if(LASP_PARALLEL)
|
2021-09-14 18:05:42 +00:00
|
|
|
add_definitions(-D_REENTRANT)
|
|
|
|
set(LASP_THREADING_LIBRARIES pthread)
|
|
|
|
else()
|
|
|
|
set(LASP_THREADING_LIBRARIES "")
|
2020-10-14 07:42:19 +00:00
|
|
|
endif()
|
|
|
|
|
2021-09-14 18:05:42 +00:00
|
|
|
if(LASP_USE_BLAS)
|
2021-10-19 09:30:39 +00:00
|
|
|
# link openblas
|
|
|
|
set(BLA_VENDOR OpenBLAS)
|
2021-09-14 18:05:42 +00:00
|
|
|
find_package(BLAS REQUIRED)
|
2020-10-14 07:42:19 +00:00
|
|
|
endif()
|
2018-01-29 15:14:50 +00:00
|
|
|
|
|
|
|
|
2020-10-14 07:42:19 +00:00
|
|
|
# Reasonable maximum to the nfft size, at 48kHz this is 700s of data...
|
2018-02-23 19:40:45 +00:00
|
|
|
add_definitions(-DLASP_MAX_NFFT=33554432) # 2**25
|
2018-02-06 11:01:27 +00:00
|
|
|
|
2018-01-29 15:14:50 +00:00
|
|
|
# ####################################### End of user-adjustable variables section
|
2021-05-23 20:53:48 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2021-09-14 18:05:42 +00:00
|
|
|
if(LASP_FFT_BACKEND STREQUAL "FFTW")
|
2019-12-29 21:07:27 +00:00
|
|
|
find_library(FFTW_LIBRARY NAMES fftw3 fftw)
|
2021-09-14 18:05:42 +00:00
|
|
|
set(FFT_LIBRARIES "${FFTW_LIBRARY}")
|
|
|
|
elseif(LASP_FFT_BACKEND STREQUAL "FFTPack")
|
|
|
|
include_directories(fftpack)
|
|
|
|
set(FFT_LIBRARIES fftpack)
|
|
|
|
add_subdirectory(fftpack)
|
2019-12-29 21:07:27 +00:00
|
|
|
endif()
|
|
|
|
|
2020-04-06 19:38:04 +00:00
|
|
|
# General make flags
|
2021-10-04 13:53:22 +00:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
2021-09-14 18:05:42 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-type-limits \
|
2020-10-16 18:37:02 +00:00
|
|
|
-Werror=implicit-function-declaration -Wno-unused-parameter \
|
2020-04-06 19:38:04 +00:00
|
|
|
-Werror=return-type")
|
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
set(win32 true)
|
2021-09-14 18:05:42 +00:00
|
|
|
set(home $ENV{USERPROFILE})
|
|
|
|
# set(miniconda_dir ${home}\\Miniconda3)
|
|
|
|
|
|
|
|
message("Building for Windows")
|
|
|
|
include_directories(
|
|
|
|
..\\rtaudio
|
|
|
|
C:\\mingw\\mingw64\\include\\OpenBLAS
|
|
|
|
link_directories(${home}\\miniconda3\\Library\\include)
|
|
|
|
)
|
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH} $miniconda_dir\\Lib\\cmake")
|
|
|
|
# include(
|
|
|
|
add_definitions(-DMS_WIN64)
|
|
|
|
link_directories(C:\\mingw\\mingw64\\lib)
|
|
|
|
link_directories(C:\\mingw\\mingw64\\bin)
|
|
|
|
link_directories(..\\rtaudio)
|
|
|
|
link_directories(${home}\\Miniconda3)
|
2020-10-04 20:29:54 +00:00
|
|
|
add_definitions(-DHAS_RTAUDIO_WIN_WASAPI_API)
|
2021-05-23 14:38:41 +00:00
|
|
|
else() # Linux compile
|
2020-04-06 19:38:04 +00:00
|
|
|
set(win32 false)
|
2021-09-14 18:05:42 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Werror=incompatible-pointer-types")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
2020-08-03 18:17:52 +00:00
|
|
|
include_directories(/usr/local/include/rtaudio)
|
2021-05-07 09:22:28 +00:00
|
|
|
include_directories(/usr/include/rtaudio)
|
2020-08-03 18:17:52 +00:00
|
|
|
link_directories(/usr/local/lib)
|
2020-04-06 19:38:04 +00:00
|
|
|
|
2020-10-04 20:29:54 +00:00
|
|
|
# This should become optional later on, and be added to the windows list as
|
|
|
|
# well.
|
2021-09-14 18:05:42 +00:00
|
|
|
|
2021-10-04 13:53:22 +00:00
|
|
|
endif()
|
2020-04-06 19:38:04 +00:00
|
|
|
|
2020-11-19 10:11:38 +00:00
|
|
|
set(CYTHON_FLAGS "--fast-fail")
|
2018-02-23 19:40:45 +00:00
|
|
|
if(LASP_DEBUG)
|
2019-12-29 21:07:27 +00:00
|
|
|
set(LASP_DEBUG_CYTHON=True)
|
|
|
|
message("Building debug code")
|
|
|
|
# This will produce html files
|
2020-11-19 10:11:38 +00:00
|
|
|
# set(CYTHON_ANNOTATE ON)
|
2019-12-29 21:07:27 +00:00
|
|
|
# Add the __FILENAME__ macro
|
|
|
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
|
2018-01-29 15:14:50 +00:00
|
|
|
else()
|
2019-12-29 21:07:27 +00:00
|
|
|
message("Building LASP for release")
|
|
|
|
set(LASP_DEBUG_CYTHON=False)
|
|
|
|
set(CYTHON_ANNOTATE OFF)
|
|
|
|
set(CYTHON_NO_DOCSTRINGS ON)
|
|
|
|
# Strip unnecessary symbols
|
|
|
|
# set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--gc-sections")
|
|
|
|
# set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--gc-sections")
|
2018-02-23 19:40:45 +00:00
|
|
|
endif(LASP_DEBUG)
|
2018-01-29 15:14:50 +00:00
|
|
|
|
|
|
|
# The last argument here takes care of calling SIGABRT when an integer overflow
|
|
|
|
# occures.
|
|
|
|
############################## General compilation flags (independent of debug mode, windows or linux)
|
2019-12-29 21:07:27 +00:00
|
|
|
set(CYTHON_EXTRA_C_FLAGS "-Wno-sign-compare -Wno-cpp -Wno-implicit-fallthrough -Wno-incompatible-pointer-types -Wno-strict-aliasing")
|
2020-10-16 18:37:02 +00:00
|
|
|
set(CYTHON_EXTRA_CXX_FLAGS "-Wno-sign-compare -Wno-cpp -Wno-implicit-fallthrough -Wno-strict-aliasing")
|
2020-04-06 19:38:04 +00:00
|
|
|
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2021-05-23 20:53:48 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra \
|
2020-04-03 09:12:49 +00:00
|
|
|
-Wno-type-limits")
|
|
|
|
|
2018-01-29 15:14:50 +00:00
|
|
|
# Debug make flags
|
|
|
|
set(CMAKE_C_FLAGS_DEBUG "-g" )
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "-O2 -mfpmath=sse -march=x86-64 -mtune=native \
|
2019-12-29 21:07:27 +00:00
|
|
|
-fdata-sections -ffunction-sections -fomit-frame-pointer -finline-functions")
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2018-04-01 08:27:27 +00:00
|
|
|
# ############################# End compilation flags
|
|
|
|
|
2020-04-06 19:38:04 +00:00
|
|
|
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2021-10-04 18:54:36 +00:00
|
|
|
# Python searching.
|
|
|
|
set(Python_ADDITIONAL_VERSIONS "3.8")
|
|
|
|
set(python_version_windll "38")
|
2018-12-30 15:45:39 +00:00
|
|
|
find_package(PythonLibs REQUIRED )
|
|
|
|
find_package(PythonInterp REQUIRED)
|
|
|
|
|
2021-10-04 18:54:36 +00:00
|
|
|
# Add FFTpack dir if used as FFT backend
|
2020-10-14 07:42:19 +00:00
|
|
|
if(LASP_FFTPACK_BACKEND)
|
2021-09-14 18:05:42 +00:00
|
|
|
add_subdirectory(fftpack)
|
|
|
|
include_directories(
|
|
|
|
fftpack
|
|
|
|
)
|
2020-10-14 07:42:19 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
include_directories(
|
2019-12-29 21:07:27 +00:00
|
|
|
lasp/c
|
|
|
|
)
|
2018-12-30 15:45:39 +00:00
|
|
|
|
2018-02-23 19:40:45 +00:00
|
|
|
add_subdirectory(lasp)
|
2018-01-29 15:14:50 +00:00
|
|
|
add_subdirectory(test)
|
|
|
|
|
2018-12-30 15:45:39 +00:00
|
|
|
# set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in")
|
|
|
|
set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
|
2019-01-05 11:16:03 +00:00
|
|
|
|
|
|
|
set(DEPS "${CMAKE_CURRENT_SOURCE_DIR}/*.py"
|
2019-12-29 21:07:27 +00:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/lasp/*.py"
|
|
|
|
"wrappers"
|
2020-10-06 19:29:02 +00:00
|
|
|
"lasp_daq")
|
2019-01-05 11:16:03 +00:00
|
|
|
|
2018-12-30 15:45:39 +00:00
|
|
|
set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp")
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2018-12-30 15:45:39 +00:00
|
|
|
# configure_file(${SETUP_PY_IN} ${SETUP_PY})
|
|
|
|
add_custom_command(OUTPUT ${OUTPUT}
|
2019-12-29 21:07:27 +00:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} build
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
|
|
|
|
DEPENDS ${DEPS})
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2018-12-30 15:45:39 +00:00
|
|
|
add_custom_target(target ALL DEPENDS ${OUTPUT})
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2018-12-30 19:16:01 +00:00
|
|
|
if(DEFINED INSTALL_DEBUG)
|
|
|
|
set(EXTRA_SETUP_ARG --user -e)
|
|
|
|
else()
|
|
|
|
set(EXTRA_SETUP_ARG "")
|
2019-12-29 21:07:27 +00:00
|
|
|
endif()
|
2018-12-30 19:16:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install ${EXTRA_SETUP_ARG} .)")
|