diff --git a/CMakeLists.txt b/CMakeLists.txt index a6b01a1..3ae2967 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,20 +21,20 @@ cmake_minimum_required(VERSION 3.8) project(gr-ieee802-11 CXX C) enable_testing() -#install to PyBOMBS target prefix if defined +# Install to PyBOMBS target prefix if defined if(DEFINED ENV{PYBOMBS_PREFIX}) set(CMAKE_INSTALL_PREFIX $ENV{PYBOMBS_PREFIX}) message(STATUS "PyBOMBS installed GNU Radio. Setting CMAKE_INSTALL_PREFIX to $ENV{PYBOMBS_PREFIX}") endif() -#select the release build type by default to get optimization flags +# Select the release build type by default to get optimization flags if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") message(STATUS "Build type not specified: defaulting to release.") endif(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") -#make sure our local CMake Modules path comes first +# Make sure our local CMake Modules path comes first list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules) # Set the version information here @@ -45,6 +45,9 @@ set(VERSION_INFO_MAINT_VERSION 0) cmake_policy(SET CMP0011 NEW) +# Enable generation of compile_commands.json for code completion engines +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + ######################################################################## # Compiler specific setup ######################################################################## @@ -55,10 +58,30 @@ if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR add_definitions(-fvisibility=hidden) endif() +IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + SET(CMAKE_CXX_STANDARD 11) +ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(CMAKE_CXX_STANDARD 11) +ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + SET(CMAKE_CXX_STANDARD 11) +ELSE() + message(WARNING "C++ standard could not be set because compiler is not GNU, Clang or MSVC.") +ENDIF() + +IF(CMAKE_C_COMPILER_ID STREQUAL "GNU") + SET(CMAKE_C_STANDARD 11) +ELSEIF(CMAKE_C_COMPILER_ID MATCHES "Clang") + SET(CMAKE_C_STANDARD 11) +ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + SET(CMAKE_C_STANDARD 11) +ELSE() + message(WARNING "C standard could not be set because compiler is not GNU, Clang or MSVC.") +ENDIF() + ######################################################################## # Install directories ######################################################################## -find_package(Gnuradio "3.8" REQUIRED COMPONENTS RUNTIME FILTER FFT PMT DIGITAL) +find_package(Gnuradio "3.8" REQUIRED COMPONENTS filter fft digital analog blocks) include(GrVersion) include(GrPlatform) #define LIB_SUFFIX diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index 160940b..5b44980 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -1,3 +1,31 @@ -file(GLOB xml_files "*.block.yml") +# Copyright 2011 Free Software Foundation, Inc. +# +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-ieee802_11 +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. -install(FILES ${xml_files} DESTINATION share/gnuradio/grc/blocks ) +install(FILES + ieee802_11_chunks_to_symbols.block.yml + ieee802_11_decode_mac.block.yml + ieee802_11_ether_encap.block.yml + ieee802_11_frame_equalizer.block.yml + ieee802_11_mac.block.yml + ieee802_11_mapper.block.yml + ieee802_11_parse_mac.block.yml + ieee802_11_sync_long.block.yml + ieee802_11_sync_short.block.yml DESTINATION share/gnuradio/grc/blocks +) diff --git a/include/ieee802-11/CMakeLists.txt b/include/ieee802-11/CMakeLists.txt index 85d5978..07d853f 100644 --- a/include/ieee802-11/CMakeLists.txt +++ b/include/ieee802-11/CMakeLists.txt @@ -35,7 +35,7 @@ list(APPEND include_sources ) install( - FILES ${include_sources} - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/ieee802_11 - COMPONENT "ieee802_11_devel" + FILES ${include_sources} + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/ieee802_11 + COMPONENT "ieee802_11_devel" ) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 92f36df..08f217d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -30,7 +30,7 @@ endif(SSE2_SUPPORTED) ######################################################################## # Setup library ######################################################################## -list(APPEND gr_ieee802_11_sources +list(APPEND ieee802_11_sources chunks_to_symbols_impl.cc constellations_impl.cc decode_mac.cc @@ -53,29 +53,60 @@ list(APPEND gr_ieee802_11_sources # use SSE2 optimized viterbi implementation if SSE2 is enabled if(SSE2_SUPPORTED) - list(APPEND gr_ieee802_11_sources + list(APPEND ieee802_11_sources viterbi_decoder/viterbi_decoder_x86.cc ) else() - list(APPEND gr_ieee802_11_sources + list(APPEND ieee802_11_sources viterbi_decoder/viterbi_decoder_generic.cc ) endif(SSE2_SUPPORTED) -list(APPEND gr_ieee802_11_libs - ${Boost_LIBRARIES} - ${GNURADIO_ALL_LIBRARIES} -) +set(ieee802_11_sources "${ieee802_11_sources}" PARENT_SCOPE) +if(NOT ieee802_11_sources) + MESSAGE(STATUS "No C++ sources... skipping lib/") + return() +endif(NOT ieee802_11_sources) -add_library(gnuradio-ieee802_11 SHARED ${gr_ieee802_11_sources}) -target_link_libraries(gnuradio-ieee802_11 ${gr_ieee802_11_libs}) +add_library(gnuradio-ieee802_11 SHARED ${ieee802_11_sources}) +target_link_libraries(gnuradio-ieee802_11 + gnuradio::gnuradio-runtime + gnuradio::gnuradio-filter + gnuradio::gnuradio-blocks + gnuradio::gnuradio-analog + gnuradio::gnuradio-fft + gnuradio::gnuradio-digital) +target_include_directories(gnuradio-ieee802_11 + PUBLIC $ + PUBLIC $ + ) set_target_properties(gnuradio-ieee802_11 PROPERTIES DEFINE_SYMBOL "gnuradio_ieee802_11_EXPORTS") +if(APPLE) + set_target_properties(gnuradio-ieee802_11 PROPERTIES + INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" + ) +endif(APPLE) + ######################################################################## # Install built library files ######################################################################## -install(TARGETS gnuradio-ieee802_11 - LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file - ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file - RUNTIME DESTINATION bin # .dll file +include(GrMiscUtils) +GR_LIBRARY_FOO(gnuradio-ieee802_11) + +######################################################################## +# Print summary +######################################################################## +message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}") +message(STATUS "Building for version: ${VERSION} / ${LIBVER}") + +######################################################################## +# Build and register unit test +######################################################################## +include(GrTest) + +# If your unit tests require special include paths, add them here +#include_directories() +# List all files that contain Boost.UTF unit tests here +list(APPEND test_ieee802_11_sources ) diff --git a/lib/viterbi_decoder/base.h b/lib/viterbi_decoder/base.h index 4a98ef0..d99fe2a 100644 --- a/lib/viterbi_decoder/base.h +++ b/lib/viterbi_decoder/base.h @@ -17,7 +17,7 @@ #ifndef INCLUDED_IEEE802_11_VITERBI_DECODER_BASE_H #define INCLUDED_IEEE802_11_VITERBI_DECODER_BASE_H -#include "utils.h" +#include "../utils.h" namespace gr { namespace ieee802_11 { diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt index 1c0b154..6ce25c2 100644 --- a/swig/CMakeLists.txt +++ b/swig/CMakeLists.txt @@ -15,31 +15,35 @@ # along with this program. If not, see . # +######################################################################## +# Check if there is C++ code at all +######################################################################## +if(NOT ieee802_11_sources) + MESSAGE(STATUS "No C++ sources... skipping swig/") + return() +endif(NOT ieee802_11_sources) + ######################################################################## # Include swig generation macros ######################################################################## find_package(SWIG) -include(GrPython) +find_package(PythonLibs) +if(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) + return() +endif() include(GrSwig) - -set(GR_SWIG_INCLUDE_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/../include/ - ${CMAKE_CURRENT_BINARY_DIR}/../include/ -) +include(GrPython) ######################################################################## # Setup swig generation ######################################################################## -foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig) -endforeach(incdir) +set(GR_SWIG_INCLUDE_DIRS $) +set(GR_SWIG_TARGET_DEPS gnuradio::runtime_swig) set(GR_SWIG_LIBRARIES gnuradio-ieee802_11) + set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/ieee802_11_swig_doc.i) -set(GR_SWIG_DOC_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/../include/ieee802-11/ - ${CMAKE_CURRENT_BINARY_DIR}/../include/ieee802-11/ -) +set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include) GR_SWIG_MAKE(ieee802_11_swig ieee802_11_swig.i)