2019-12-28 20:33:14 +00:00
|
|
|
cmake_minimum_required (VERSION 3.0)
|
|
|
|
|
2020-10-04 20:29:54 +00:00
|
|
|
# To allow linking to static libs from other directories
|
|
|
|
cmake_policy(SET CMP0079 NEW)
|
|
|
|
|
2019-12-28 20:33:14 +00:00
|
|
|
# This is used for code completion in vim
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS=ON)
|
2019-12-08 13:19:10 +00:00
|
|
|
project(LASP)
|
2018-01-29 15:14:50 +00:00
|
|
|
|
|
|
|
# Whether we want to use blas yes or no
|
2018-02-23 19:40:45 +00:00
|
|
|
set(LASP_USE_BLAS TRUE)
|
|
|
|
# set(LASP_USE_BLAS FALSE)
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2018-02-23 19:40:45 +00:00
|
|
|
set(LASP_FLOAT double)
|
|
|
|
# set(LASP_FLOAT float)
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2018-02-23 19:40:45 +00:00
|
|
|
add_definitions(-DLASP_PARALLEL)
|
2020-10-02 08:01:18 +00:00
|
|
|
add_definitions(-DLASP_MAX_NUM_THREADS=30)
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2018-02-23 19:40:45 +00:00
|
|
|
add_definitions(-DLASP_MAX_NUM_CHANNELS=80)
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2018-02-06 11:01:27 +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
|
|
|
|
|
|
|
|
add_definitions(-D_REENTRANT)
|
|
|
|
|
2019-12-29 21:07:27 +00:00
|
|
|
# ############### Choose an fft backend here
|
2020-04-06 19:38:04 +00:00
|
|
|
set(LASP_FFT_BACKEND fftpack)
|
|
|
|
#set(LASP_FFT_BACKEND "fftw")
|
2019-12-29 21:07:27 +00:00
|
|
|
|
|
|
|
if(LASP_FFT_BACKEND STREQUAL "fftw")
|
|
|
|
find_library(FFTW_LIBRARY NAMES fftw3 fftw)
|
|
|
|
set(FFTW_LIBRARIES "${FFTW_LIBRARY}")
|
|
|
|
set(LASP_FFT_LIBRARY "${FFTW_LIBRARIES}")
|
|
|
|
add_definitions(-DLASP_FFT_BACKEND_FFTW)
|
|
|
|
elseif(LASP_FFT_BACKEND STREQUAL "fftpack")
|
|
|
|
add_definitions(-DLASP_FFT_BACKEND_FFTPACK)
|
|
|
|
set(LASP_FFT_LIBRARY "fftpack")
|
|
|
|
endif()
|
|
|
|
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2018-02-23 19:40:45 +00:00
|
|
|
if(LASP_FLOAT STREQUAL "double")
|
2019-12-29 21:07:27 +00:00
|
|
|
add_definitions(-DLASP_FLOAT=64)
|
|
|
|
add_definitions(-DLASP_DOUBLE_PRECISION)
|
2018-01-29 15:14:50 +00:00
|
|
|
else()
|
2019-12-29 21:07:27 +00:00
|
|
|
add_definitions(-DLASP_FLOAT=32)
|
|
|
|
add_definitions(-DLASP_SINGLE_PRECISION)
|
2018-02-23 19:40:45 +00:00
|
|
|
endif(LASP_FLOAT STREQUAL "double")
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2018-02-23 19:40:45 +00:00
|
|
|
if(NOT DEFINED LASP_DEBUG)
|
2019-12-29 21:07:27 +00:00
|
|
|
message(FATAL_ERROR "LASP_DEBUG flag not defined. Please set -DLASP_DEBUG=TRUE
|
|
|
|
or -DLASP_DEBUG=FALSE")
|
2018-02-23 19:40:45 +00:00
|
|
|
endif(NOT DEFINED LASP_DEBUG)
|
2018-01-29 15:14:50 +00:00
|
|
|
|
|
|
|
# ##################### END Cmake variables converted to a macro
|
2020-10-02 08:01:18 +00:00
|
|
|
set(Python_ADDITIONAL_VERSIONS "3.8")
|
2018-01-29 15:14:50 +00:00
|
|
|
# #################### Setting definitions and debug-specific compilation flags
|
|
|
|
|
2020-04-06 19:38:04 +00:00
|
|
|
# General make flags
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -Wno-type-limits \
|
|
|
|
-Werror=implicit-function-declaration \
|
|
|
|
-Werror=return-type")
|
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
set(win32 true)
|
|
|
|
message("Building for Windows")
|
|
|
|
include_directories(
|
|
|
|
..\\rtaudio
|
|
|
|
C:\\mingw\\include\\OpenBLAS
|
|
|
|
)
|
|
|
|
add_definitions(-DMS_WIN64)
|
|
|
|
link_directories(C:\\mingw\\lib)
|
|
|
|
link_directories(C:\\mingw\\bin)
|
|
|
|
link_directories(..\\rtaudio)
|
2020-04-26 12:41:11 +00:00
|
|
|
link_directories(C:\\Users\\User\\Miniconda3)
|
2020-10-04 20:29:54 +00:00
|
|
|
add_definitions(-DHAS_RTAUDIO_WIN_WASAPI_API)
|
2020-04-06 19:38:04 +00:00
|
|
|
else()
|
|
|
|
set(win32 false)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -std=c11 \
|
|
|
|
-Werror=incompatible-pointer-types")
|
2020-08-03 18:17:52 +00:00
|
|
|
include_directories(/usr/local/include/rtaudio)
|
|
|
|
link_directories(/usr/local/lib)
|
2020-04-06 19:38:04 +00:00
|
|
|
|
2020-10-04 20:29:54 +00:00
|
|
|
add_definitions(-DHAS_RTAUDIO)
|
|
|
|
add_definitions(-DHAS_RTAUDIO_PULSEAUDIO_API)
|
|
|
|
add_definitions(-DHAS_RTAUDIO_ALSA_API)
|
|
|
|
# This should become optional later on, and be added to the windows list as
|
|
|
|
# well.
|
|
|
|
add_definitions(-DHAS_ULDAQ)
|
|
|
|
add_definitions(-DHAS_ULDAQ_LINUX_API)
|
|
|
|
|
2020-04-06 19:38:04 +00:00
|
|
|
|
|
|
|
endif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
|
2018-02-23 19:40:45 +00:00
|
|
|
if(LASP_DEBUG)
|
2019-12-29 21:07:27 +00:00
|
|
|
set(TRACERNAME LASPTracer)
|
|
|
|
set(LASP_DEBUG_CYTHON=True)
|
|
|
|
set(CMAKE_BUILD_TYPE Debug)
|
|
|
|
message("Building debug code")
|
|
|
|
set(CMAKE_BUILD_TYPE Debug)
|
|
|
|
add_definitions(-DLASP_DEBUG=1)
|
|
|
|
add_definitions(-DTRACERNAME=${TRACERNAME})
|
|
|
|
add_definitions(-DDEBUG)
|
|
|
|
add_definitions(-DTRACER=1)
|
|
|
|
# This will produce html files
|
|
|
|
set(CYTHON_ANNOTATE ON)
|
|
|
|
# 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(CMAKE_BUILD_TYPE 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")
|
|
|
|
|
|
|
|
add_definitions(-DTRACER=0 -DNDEBUG)
|
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")
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2020-04-06 19:38:04 +00:00
|
|
|
|
2018-01-29 15:14:50 +00:00
|
|
|
|
2020-04-03 09:12:49 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++11 -Wall -Wextra \
|
|
|
|
-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
|
|
|
|
|
|
|
# set(CMAKE_C_FLAGS_RELEASE "-O2 -march=native -mtune=native -fomit-frame-pointer")
|
|
|
|
|
2018-02-23 19:40:45 +00:00
|
|
|
if(LASP_USE_BLAS)
|
2019-12-29 21:07:27 +00:00
|
|
|
add_definitions(-DLASP_USE_BLAS=1)
|
2018-01-29 15:14:50 +00:00
|
|
|
else()
|
2019-12-29 21:07:27 +00:00
|
|
|
add_definitions(-DLASP_USE_BLAS=0)
|
2018-02-23 19:40:45 +00:00
|
|
|
endif(LASP_USE_BLAS)
|
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
|
|
|
|
2018-12-30 15:45:39 +00:00
|
|
|
find_package(PythonLibs REQUIRED )
|
|
|
|
find_package(PythonInterp REQUIRED)
|
|
|
|
|
2018-01-29 15:14:50 +00:00
|
|
|
add_subdirectory(fftpack)
|
|
|
|
include_directories(
|
2019-12-29 21:07:27 +00:00
|
|
|
fftpack
|
|
|
|
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} .)")
|