cmake_minimum_required (VERSION 3.16) # To allow linking to static libs from other directories cmake_policy(SET CMP0079 NEW) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/lasp/cmake") include("BuildType") # This is used for code completion in vim set(CMAKE_EXPORT_COMPILE_COMMANDS ON) project(LASP LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED) set(CMAKE_C_STANDARD 11) option(LASP_DOUBLE_PRECISION "Compile as double precision floating point" ON) option(LASP_HAS_RTAUDIO "Compile with RtAudio Daq backend" ON) option(LASP_HAS_ULDAQ "Compile with UlDaq backend" ON) 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") find_package(Python3 COMPONENTS Interpreter Development REQUIRED) include_directories(${Python3_INCLUDE_DIRS}) find_package(pybind11 CONFIG REQUIRED) # Required for PYBIND11 set(POSITION_INDEPENDENT_CODE True) if(CMAKE_BUILD_TYPE STREQUAL Debug) set(LASP_DEBUG True) else() set(LASP_DEBUG False) endif() if(LASP_PARALLEL) add_definitions(-D_REENTRANT) set(LASP_THREADING_LIBRARIES pthread) else() set(LASP_THREADING_LIBRARIES "") endif() # link openblas set(BLA_VENDOR OpenBLAS) find_package(BLAS REQUIRED) # Armadillo include_directories(SYSTEM armadillo-code/include) # 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 if(LASP_FFT_BACKEND STREQUAL "FFTW") find_library(FFTW_LIBRARY NAMES fftw3 fftw) set(FFT_LIBRARIES "${FFTW_LIBRARY}") elseif(LASP_FFT_BACKEND STREQUAL "FFTPack") include_directories(fftpack) set(FFT_LIBRARIES fftpack) add_subdirectory(fftpack) endif() # General make flags set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-type-limits \ -Werror=implicit-function-declaration -Wno-unused-parameter \ -Werror=return-type -Wfatal-errors") if(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(win32 true) 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) add_definitions(-DHAS_RTAUDIO_WIN_WASAPI_API) else() # Linux compile set(win32 false) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=incompatible-pointer-types") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wfatal-errors") include_directories(/usr/local/include/rtaudio) include_directories(/usr/include/rtaudio) link_directories(/usr/local/lib) # This should become optional later on, and be added to the windows list as # well. endif() # The last argument here takes care of calling SIGABRT when an integer overflow # occures. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-type-limits") set(CMAKE_C_FLAGS_RELEASE "-O2 -mfpmath=sse -march=x86-64 -mtune=native \ -fdata-sections -ffunction-sections -fomit-frame-pointer -finline-functions") # ############################# End compilation flags # Add FFTpack dir if used as FFT backend if(LASP_FFTPACK_BACKEND) add_subdirectory(fftpack) include_directories( fftpack ) endif() include_directories(STL-Threadsafe/include) include_directories(gsl-lite/include) include_directories(DebugTrace-cpp/include) add_subdirectory(lasp) add_subdirectory(gsl-lite) 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_device_lib") ) # 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} .)")