202 lines
5.9 KiB
CMake
202 lines
5.9 KiB
CMake
cmake_minimum_required (VERSION 3.0)
|
|
|
|
# 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)
|
|
project(LASP LANGUAGES C CXX)
|
|
|
|
# Whether we want to use blas yes or no
|
|
set(LASP_USE_BLAS TRUE)
|
|
# set(LASP_USE_BLAS FALSE)
|
|
|
|
set(LASP_FLOAT double)
|
|
# set(LASP_FLOAT float)
|
|
|
|
option(LASP_PARALLEL "Parallel processing" ON)
|
|
option(LASP_RTAUDIO "Compile with RtAudio Daq backend" ON)
|
|
option(LASP_ULDAQ "Compile with UlDaq backend" ON)
|
|
option(LASP_DEBUG "Compile in debug mode" ON)
|
|
option(LASP_FFTW_BACKEND "Compile with FFTW fft backend" ON)
|
|
option(LAS_FFTPACK_BACKEND "Compile with Fftpack fft backend" OFF)
|
|
|
|
if(LASP_PARALLEL)
|
|
add_definitions(-DLASP_MAX_NUM_THREADS=30)
|
|
add_definitions(-D_REENTRANT)
|
|
endif()
|
|
|
|
if(LASP_RTAUDIO)
|
|
add_definitions(-DHAS_RTAUDIO_API)
|
|
endif()
|
|
if(LASP_ULDAQ)
|
|
add_definitions(-DHAS_ULDAQ_API)
|
|
endif()
|
|
|
|
add_definitions(-DLASP_MAX_NUM_CHANNELS=80)
|
|
|
|
# Reasonable maximum to the nfft size, at 48kHz this is 700s of data...
|
|
add_definitions(-DLASP_MAX_NFFT=33554432) # 2**25
|
|
|
|
# ####################################### End of user-adjustable variables section
|
|
|
|
|
|
# ############### Choose an fft backend here
|
|
if(LASP_FFTW_BACKEND AND LASP_FFTPACK_BACKEND)
|
|
message(FATAL_ERROR "Either FFTW or Fftpack backend should be chosen. Please disable one of them")
|
|
endif()
|
|
|
|
if(LASP_FFTW_BACKEND)
|
|
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_FFTPACK_BACKEND)
|
|
add_definitions(-DLASP_FFT_BACKEND_FFTPACK)
|
|
set(LASP_FFT_LIBRARY "fftpack")
|
|
endif()
|
|
|
|
|
|
if(LASP_FLOAT STREQUAL "double")
|
|
add_definitions(-DLASP_FLOAT=64)
|
|
add_definitions(-DLASP_DOUBLE_PRECISION)
|
|
else()
|
|
add_definitions(-DLASP_FLOAT=32)
|
|
add_definitions(-DLASP_SINGLE_PRECISION)
|
|
endif(LASP_FLOAT STREQUAL "double")
|
|
|
|
|
|
# ##################### END Cmake variables converted to a macro
|
|
set(Python_ADDITIONAL_VERSIONS "3.8")
|
|
# #################### Setting definitions and debug-specific compilation flags
|
|
|
|
# General make flags
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -Wextra -Wno-type-limits \
|
|
-Werror=implicit-function-declaration -Wno-unused-parameter \
|
|
-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)
|
|
link_directories(C:\\Users\\User\\Miniconda3)
|
|
add_definitions(-DHAS_RTAUDIO_WIN_WASAPI_API)
|
|
else()
|
|
set(win32 false)
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -std=c11 \
|
|
-Werror=incompatible-pointer-types")
|
|
include_directories(/usr/local/include/rtaudio)
|
|
link_directories(/usr/local/lib)
|
|
|
|
# This should become optional later on, and be added to the windows list as
|
|
# well.
|
|
|
|
endif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
|
|
set(CYTHON_FLAGS "--fast-fail")
|
|
if(LASP_DEBUG)
|
|
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 $<))\"'")
|
|
else()
|
|
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)
|
|
endif(LASP_DEBUG)
|
|
|
|
# The last argument here takes care of calling SIGABRT when an integer overflow
|
|
# occures.
|
|
############################## General compilation flags (independent of debug mode, windows or linux)
|
|
set(CYTHON_EXTRA_C_FLAGS "-Wno-sign-compare -Wno-cpp -Wno-implicit-fallthrough -Wno-incompatible-pointer-types -Wno-strict-aliasing")
|
|
set(CYTHON_EXTRA_CXX_FLAGS "-Wno-sign-compare -Wno-cpp -Wno-implicit-fallthrough -Wno-strict-aliasing")
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++11 -Wall -Wextra \
|
|
-Wno-type-limits")
|
|
|
|
# Debug make flags
|
|
set(CMAKE_C_FLAGS_DEBUG "-g" )
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "-O2 -mfpmath=sse -march=x86-64 -mtune=native \
|
|
-fdata-sections -ffunction-sections -fomit-frame-pointer -finline-functions")
|
|
|
|
# set(CMAKE_C_FLAGS_RELEASE "-O2 -march=native -mtune=native -fomit-frame-pointer")
|
|
|
|
if(LASP_USE_BLAS)
|
|
add_definitions(-DLASP_USE_BLAS=1)
|
|
else()
|
|
add_definitions(-DLASP_USE_BLAS=0)
|
|
endif(LASP_USE_BLAS)
|
|
|
|
# ############################# End compilation flags
|
|
|
|
|
|
|
|
find_package(PythonLibs REQUIRED )
|
|
find_package(PythonInterp REQUIRED)
|
|
|
|
if(LASP_FFTPACK_BACKEND)
|
|
add_subdirectory(fftpack)
|
|
include_directories(
|
|
fftpack
|
|
)
|
|
endif()
|
|
|
|
include_directories(
|
|
lasp/c
|
|
)
|
|
|
|
add_subdirectory(lasp)
|
|
add_subdirectory(test)
|
|
|
|
# set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in")
|
|
set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
|
|
|
|
set(DEPS "${CMAKE_CURRENT_SOURCE_DIR}/*.py"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/lasp/*.py"
|
|
"wrappers"
|
|
"lasp_daq")
|
|
|
|
set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp")
|
|
|
|
# configure_file(${SETUP_PY_IN} ${SETUP_PY})
|
|
add_custom_command(OUTPUT ${OUTPUT}
|
|
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} build
|
|
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
|
|
DEPENDS ${DEPS})
|
|
|
|
add_custom_target(target ALL DEPENDS ${OUTPUT})
|
|
|
|
if(DEFINED INSTALL_DEBUG)
|
|
set(EXTRA_SETUP_ARG --user -e)
|
|
else()
|
|
set(EXTRA_SETUP_ARG "")
|
|
endif()
|
|
|
|
|
|
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install ${EXTRA_SETUP_ARG} .)")
|