Skip to content
Snippets Groups Projects
Commit a6567ecc authored by Sergey Musikhin's avatar Sergey Musikhin
Browse files

fix CMakeLista for correct python import

parent 847b2311
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
######################################################################## ########################################################################
cmake_minimum_required(VERSION 3.8) cmake_minimum_required(VERSION 3.8)
project(gr-bladeRF CXX C) project(gr-bladeRF CXX C)
include(GNUInstallDirs)
enable_testing() enable_testing()
# Install to PyBOMBS target prefix if defined # Install to PyBOMBS target prefix if defined
...@@ -48,6 +49,7 @@ if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR ...@@ -48,6 +49,7 @@ if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
AND NOT WIN32) AND NOT WIN32)
#http://gcc.gnu.org/wiki/Visibility #http://gcc.gnu.org/wiki/Visibility
add_definitions(-fvisibility=hidden) add_definitions(-fvisibility=hidden)
add_definitions(-fvisibility-inlines-hidden)
endif() endif()
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
...@@ -70,6 +72,57 @@ ELSE() ...@@ -70,6 +72,57 @@ ELSE()
message(WARNING "C standard could not be set because compiler is not GNU, Clang or MSVC.") message(WARNING "C standard could not be set because compiler is not GNU, Clang or MSVC.")
ENDIF() ENDIF()
# Misc options
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_definitions(-Wall)
add_definitions(-Wextra)
add_definitions(-Wno-unused-parameter)
add_definitions(-Wsign-compare)
#add_definitions(-Wconversion)
#add_definitions(-pedantic)
#add_definitions(-ansi)
endif()
# SIMD
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64|x86")
set(USE_SIMD "SSE2" CACHE STRING "Use SIMD instructions")
else()
set(USE_SIMD "no" CACHE STRING "Use SIMD instructions")
endif()
set(USE_SIMD_VALUES "no" "SSE2" "AVX")
set_property(CACHE USE_SIMD PROPERTY STRINGS ${USE_SIMD_VALUES})
list(FIND USE_SIMD_VALUES ${USE_SIMD} USE_SIMD_INDEX)
if(${USE_SIMD_INDEX} EQUAL -1)
message(FATAL_ERROR "Option ${USE_SIMD} not supported, valid entries are ${USE_SIMD_VALUES}")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(USE_SIMD MATCHES SSE2)
add_definitions(-msse2)
add_definitions(-DUSE_SSE2)
endif()
if(USE_SIMD MATCHES AVX)
add_definitions(-march=native)
add_definitions(-DUSE_AVX)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(USE_SIMD MATCHES SSE2)
add_definitions(/arch:SSE2)
add_definitions(-DUSE_SSE2)
endif()
if(USE_SIMD MATCHES AVX)
add_definitions(/arch:AVX)
add_definitions(-DUSE_AVX)
endif()
# boost feels like using lib pragmas to link to libs,
# but the boost libs might not even be in the (default) lib search path
add_definitions(-DBOOST_ALL_NO_LIB)
# macro turns std::min into errors...
add_definitions(-DNOMINMAX)
endif()
######################################################################## ########################################################################
# Install directories # Install directories
######################################################################## ########################################################################
...@@ -81,6 +134,9 @@ include(GrVersion) ...@@ -81,6 +134,9 @@ include(GrVersion)
include(GrPlatform) #define LIB_SUFFIX include(GrPlatform) #define LIB_SUFFIX
include(GrComponent)
if(NOT CMAKE_MODULES_DIR) if(NOT CMAKE_MODULES_DIR)
set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake) set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake)
endif(NOT CMAKE_MODULES_DIR) endif(NOT CMAKE_MODULES_DIR)
...@@ -112,6 +168,10 @@ if(APPLE) ...@@ -112,6 +168,10 @@ if(APPLE)
endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
endif(APPLE) endif(APPLE)
########################################################################
# Hardware
########################################################################
find_package(LibbladeRF)
######################################################################## ########################################################################
# Find gnuradio build dependencies # Find gnuradio build dependencies
######################################################################## ########################################################################
......
...@@ -10,16 +10,16 @@ ...@@ -10,16 +10,16 @@
# Setup library # Setup library
######################################################################## ########################################################################
include(GrPlatform) #define LIB_SUFFIX include(GrPlatform) #define LIB_SUFFIX
list(APPEND bladeRF_sources list(APPEND gr_bladerf_srcs
source_impl.cc source_impl.cc
sink_impl.cc sink_impl.cc
) )
set(bladeRF_sources "${bladeRF_sources}" PARENT_SCOPE) #-pthread Adds support for multithreading with the pthreads library.
if(NOT bladeRF_sources) #This option sets flags for both the preprocessor and linker. (man gcc)
MESSAGE(STATUS "No C++ sources... skipping lib/") if(CMAKE_COMPILER_IS_GNUCXX)
return() list(APPEND Boost_LIBRARIES -pthread)
endif(NOT bladeRF_sources) endif()
MACRO (APPEND_LIB_LIST) MACRO (APPEND_LIB_LIST)
SET (gr_bladerf_libs "${gr_bladerf_libs};${ARGN}" CACHE INTERNAL "lib list") SET (gr_bladerf_libs "${gr_bladerf_libs};${ARGN}" CACHE INTERNAL "lib list")
...@@ -27,11 +27,8 @@ ENDMACRO(APPEND_LIB_LIST) ...@@ -27,11 +27,8 @@ ENDMACRO(APPEND_LIB_LIST)
set(gr_bladerf_libs "" CACHE INTERNAL "lib that accumulates link targets") set(gr_bladerf_libs "" CACHE INTERNAL "lib that accumulates link targets")
APPEND_LIB_LIST(gnuradio::gnuradio-runtime) add_library(gnuradio-bladeRF SHARED)
APPEND_LIB_LIST(${Boost_LIBRARIES} gnuradio::gnuradio-runtime)
add_library(gnuradio-bladeRF SHARED ${bladeRF_sources})
target_link_libraries(gnuradio-bladeRF ${gr_bladerf_libs})
target_include_directories(gnuradio-bladeRF target_include_directories(gnuradio-bladeRF
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC ${Boost_INCLUDE_DIRS} PUBLIC ${Boost_INCLUDE_DIRS}
...@@ -46,7 +43,80 @@ if(APPLE) ...@@ -46,7 +43,80 @@ if(APPLE)
) )
endif(APPLE) endif(APPLE)
########################################################################
# Setup defines for high resolution timing
########################################################################
message(STATUS "")
message(STATUS "Configuring high resolution timing...")
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_LIBRARIES -lrt)
CHECK_CXX_SOURCE_COMPILES("
#include <ctime>
int main(){
timespec ts;
return clock_gettime(CLOCK_MONOTONIC, &ts);
}
" HAVE_CLOCK_GETTIME
)
unset(CMAKE_REQUIRED_LIBRARIES)
include(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES("
#include <mach/mach_time.h>
int main(){
mach_timebase_info_data_t info;
mach_timebase_info(&info);
mach_absolute_time();
return 0;
}
" HAVE_MACH_ABSOLUTE_TIME
)
CHECK_CXX_SOURCE_COMPILES("
#include <Windows.h>
int main(){
LARGE_INTEGER value;
QueryPerformanceCounter(&value);
QueryPerformanceFrequency(&value);
return 0;
}
" HAVE_QUERY_PERFORMANCE_COUNTER
)
if(HAVE_CLOCK_GETTIME)
message(STATUS " High resolution timing supported through clock_gettime.")
set(TIME_SPEC_DEFS HAVE_CLOCK_GETTIME)
APPEND_LIB_LIST( "-lrt")
elseif(HAVE_MACH_ABSOLUTE_TIME)
message(STATUS " High resolution timing supported through mach_absolute_time.")
set(TIME_SPEC_DEFS HAVE_MACH_ABSOLUTE_TIME)
elseif(HAVE_QUERY_PERFORMANCE_COUNTER)
message(STATUS " High resolution timing supported through QueryPerformanceCounter.")
set(TIME_SPEC_DEFS HAVE_QUERY_PERFORMANCE_COUNTER)
else()
message(STATUS " High resolution timing supported through microsec_clock.")
set(TIME_SPEC_DEFS HAVE_MICROSEC_CLOCK)
endif()
set_source_files_properties(
time_spec.cc
PROPERTIES COMPILE_DEFINITIONS "${TIME_SPEC_DEFS}"
)
########################################################################
# Setup bladeRF component
########################################################################
GR_REGISTER_COMPONENT("nuand bladeRF" ENABLE_BLADERF LIBBLADERF_FOUND)
if(ENABLE_BLADERF)
add_subdirectory(bladerf) add_subdirectory(bladerf)
endif(ENABLE_BLADERF)
########################################################################
# Finalize target
########################################################################
set_target_properties(gnuradio-bladeRF PROPERTIES SOURCES "${gr_bladerf_srcs}")
target_link_libraries(gnuradio-bladeRF ${gr_bladerf_libs})
######################################################################## ########################################################################
......
...@@ -31,9 +31,9 @@ APPEND_LIB_LIST( ...@@ -31,9 +31,9 @@ APPEND_LIB_LIST(
${Volk_LIBRARIES} ${Volk_LIBRARIES}
) )
list(APPEND bladeRF_sources list(APPEND gr_bladerf_srcs
${CMAKE_CURRENT_SOURCE_DIR}/bladerf_source_c.cc ${CMAKE_CURRENT_SOURCE_DIR}/bladerf_source_c.cc
${CMAKE_CURRENT_SOURCE_DIR}/bladerf_sink_c.cc ${CMAKE_CURRENT_SOURCE_DIR}/bladerf_sink_c.cc
${CMAKE_CURRENT_SOURCE_DIR}/bladerf_common.cc ${CMAKE_CURRENT_SOURCE_DIR}/bladerf_common.cc
) )
set(bladeRF_sources ${bladeRF_sources} PARENT_SCOPE) set(gr_bladerf_srcs ${gr_bladerf_srcs} PARENT_SCOPE)
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
######################################################################## ########################################################################
# Check if there is C++ code at all # Check if there is C++ code at all
######################################################################## ########################################################################
if(NOT bladeRF_sources) if(NOT gr_bladerf_srcs)
MESSAGE(STATUS "No C++ sources... skipping python bindings") MESSAGE(STATUS "No C++ sources... skipping python bindings")
return() return()
endif(NOT bladeRF_sources) endif(NOT gr_bladerf_srcs)
######################################################################## ########################################################################
# Check for pygccxml # Check for pygccxml
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment