diff options
author | Andrej Rode <mail@andrejro.de> | 2019-03-02 19:59:00 +0100 |
---|---|---|
committer | Marcus Müller <marcus.mueller@ettus.com> | 2019-03-04 22:30:37 +0100 |
commit | ab2fb35677e38a384df3f9503d1f45f64bbc0374 (patch) | |
tree | c59965a71d4951e9bcae9efcf9a6005df2f340a1 /gr-fec | |
parent | 4e777f1c0ee28011255e3b6b703463cef0f207e0 (diff) |
cmake: Update to modern CMake usage
This includes using target based setting of includes
and link libraries. This will transitively add the includes
and linking flags to dependent targets.
This is still a work in progress since only the dynamic
libraries have been touched and not all of include_directories
directives are gone yet.
cmake: remove GR_INCLUDE_SUBDIRECTORY macro
Previously this macro was used to inject subdirectories in the
current CMake namespace. This is generally undesired and pollutes the
current context.
previously GNU Radio CMake had a non-default option ENABLE_STATIC_LIBS
to build both, shared libraries and static libraries.
This seems to be a construction taken over from autotools and serves
no purpuose in CMake and complicates the library building.
cmake: remove GR_LIBTOOL and la generation support
This looks like it was primarily used to support projects using
autotools, but comments state that the generated .la files aren't
compatible with autotools anyway.
cmake: Bump required CMake version to 3.8
UseSWIG cmake uses syntax which requires at least CMake 3.8 and is non-trivial
to change
Diffstat (limited to 'gr-fec')
-rw-r--r-- | gr-fec/CMakeLists.txt | 8 | ||||
-rw-r--r-- | gr-fec/apps/CMakeLists.txt | 40 | ||||
-rw-r--r-- | gr-fec/lib/CMakeLists.txt | 87 | ||||
-rw-r--r-- | gr-fec/lib/reed-solomon/CMakeLists.txt | 27 | ||||
-rw-r--r-- | gr-fec/lib/viterbi/CMakeLists.txt | 50 | ||||
-rw-r--r-- | gr-fec/lib/viterbi/metrics.cc (renamed from gr-fec/lib/viterbi/metrics.c) | 0 | ||||
-rw-r--r-- | gr-fec/lib/viterbi/tab.cc (renamed from gr-fec/lib/viterbi/tab.c) | 0 | ||||
-rw-r--r-- | gr-fec/lib/viterbi/viterbi.cc (renamed from gr-fec/lib/viterbi/viterbi.c) | 0 | ||||
-rw-r--r-- | gr-fec/swig/CMakeLists.txt | 14 |
9 files changed, 38 insertions, 188 deletions
diff --git a/gr-fec/CMakeLists.txt b/gr-fec/CMakeLists.txt index be554db7ef..2b562da5fb 100644 --- a/gr-fec/CMakeLists.txt +++ b/gr-fec/CMakeLists.txt @@ -36,13 +36,6 @@ GR_REGISTER_COMPONENT("gr-fec" ENABLE_GR_FEC ENABLE_GR_BLOCKS ) -GR_SET_GLOBAL(GR_FEC_INCLUDE_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/lib - ${CMAKE_CURRENT_SOURCE_DIR}/lib/viterbi - ${CMAKE_CURRENT_SOURCE_DIR}/lib/reed-solomon - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - SET(GR_PKG_FEC_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/fec) ######################################################################## @@ -66,7 +59,6 @@ endif(ENABLE_GRC) add_subdirectory(examples) add_subdirectory(docs) add_subdirectory(ldpc_alist) -add_subdirectory(apps) ######################################################################## # Create Pkg Config File diff --git a/gr-fec/apps/CMakeLists.txt b/gr-fec/apps/CMakeLists.txt deleted file mode 100644 index 41c6e4e2fc..0000000000 --- a/gr-fec/apps/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2015 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# 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. - -#include_directories( -# ${GR_FEC_INCLUDE_DIRS} -# ${GNURADIO_RUNTIME_INCLUDE_DIRS} -# ${GSL_INCLUDE_DIRS} -# ${Boost_INCLUDE_DIRS} -#) -# -#list(APPEND libs -# ${GSL_LIBRARIES} -# ${Boost_LIBRARIES} -# gnuradio-fec gnuradio-runtime -#) -# -#INSTALL(TARGETS -# DESTINATION ${GR_RUNTIME_DIR} -#) -# -#GR_PYTHON_INSTALL( -# PROGRAMS -# DESTINATION ${GR_RUNTIME_DIR} -#) diff --git a/gr-fec/lib/CMakeLists.txt b/gr-fec/lib/CMakeLists.txt index 7f07314768..cbcfb62861 100644 --- a/gr-fec/lib/CMakeLists.txt +++ b/gr-fec/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012-2014 Free Software Foundation, Inc. +# Copyright 2012-2014,2019 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -19,34 +19,11 @@ # These are convenience libraries of 3rd party code. # Change to test for distro provided packages -GR_INCLUDE_SUBDIRECTORY(reed-solomon) -GR_INCLUDE_SUBDIRECTORY(viterbi) - -######################################################################## -# Setup the include and linker paths -######################################################################## -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${GR_FEC_INCLUDE_DIRS} - ${GR_BLOCKS_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} -) - -if(ENABLE_GR_CTRLPORT) - ADD_DEFINITIONS(-DGR_CTRLPORT) -endif(ENABLE_GR_CTRLPORT) - -link_directories( - ${Boost_LIBRARY_DIRS} -) ######################################################################## # Setup library ######################################################################## -list(APPEND gnuradio_fec_sources +add_library(gnuradio-fec generic_decoder.cc generic_encoder.cc decoder_impl.cc @@ -87,7 +64,20 @@ list(APPEND gnuradio_fec_sources scl_list.cc polar_encoder_systematic.cc polar_decoder_sc_systematic.cc -) + ) +target_include_directories(gnuradio-fec + PUBLIC + $<INSTALL_INTERFACE:include> + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include> + ) + +add_subdirectory(reed-solomon) + +target_sources(gnuradio-fec PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/viterbi/metrics.cc + ${CMAKE_CURRENT_SOURCE_DIR}/viterbi/tab.cc + ${CMAKE_CURRENT_SOURCE_DIR}/viterbi/viterbi.cc + ) #Add Windows DLL resource file if using MSVC if(MSVC) @@ -98,25 +88,20 @@ if(MSVC) ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fec.rc @ONLY) - list(APPEND gnuradio_fec_sources + target_sources(gnuradio-fec PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fec.rc ) endif(MSVC) -list(APPEND gnuradio_fec_libs - gnuradio-blocks +target_link_libraries(gnuradio-fec PUBLIC gnuradio-runtime - ${VOLK_LIBRARIES} - ${Boost_LIBRARIES} + gnuradio-blocks ) # Only include the LDPC work if we have GSL installed if(GSL_FOUND) - include_directories(${GSL_INCLUDE_DIRS}) - link_directories(${GSL_LIBRARY_DIRS}) - list(APPEND gnuradio_fec_libs ${GSL_LDFLAGS}) - - list(APPEND gnuradio_fec_sources + target_link_libraries(gnuradio-fec PUBLIC gsl::gsl) + target_sources(gnuradio-fec PRIVATE ldpc_bit_flip_decoder_impl.cc ldpc_par_mtrx_encoder_impl.cc ldpc_gen_mtrx_encoder_impl.cc @@ -126,30 +111,6 @@ if(GSL_FOUND) ) endif(GSL_FOUND) -add_library(gnuradio-fec SHARED ${gnuradio_fec_sources}) -target_link_libraries(gnuradio-fec ${gnuradio_fec_libs}) -GR_LIBRARY_FOO(gnuradio-fec) - -if(ENABLE_STATIC_LIBS) - if(ENABLE_GR_CTRLPORT) - # Remove GR_CTRLPORT set this target's definitions. - # Makes sure we don't try to use ControlPort stuff in source files - GET_DIRECTORY_PROPERTY(STATIC_DEFS COMPILE_DEFINITIONS) - list(REMOVE_ITEM STATIC_DEFS "GR_CTRLPORT") - SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS "${STATIC_DEFS}") - - # readd it to the target since we removed it from the directory-wide list. - SET_PROPERTY(TARGET gnuradio-fec APPEND PROPERTY COMPILE_DEFINITIONS "GR_CTRLPORT") - endif(ENABLE_GR_CTRLPORT) - - add_library(gnuradio-fec_static STATIC ${gnuradio_fec_sources}) - - if(NOT WIN32) - set_target_properties(gnuradio-fec_static - PROPERTIES OUTPUT_NAME gnuradio-fec) - endif(NOT WIN32) - - install(TARGETS gnuradio-fec_static - ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file - ) -endif(ENABLE_STATIC_LIBS) +if(BUILD_SHARED_LIBS) + GR_LIBRARY_FOO(gnuradio-fec) +endif() diff --git a/gr-fec/lib/reed-solomon/CMakeLists.txt b/gr-fec/lib/reed-solomon/CMakeLists.txt index 2d26b3eeff..2c96921bf7 100644 --- a/gr-fec/lib/reed-solomon/CMakeLists.txt +++ b/gr-fec/lib/reed-solomon/CMakeLists.txt @@ -32,36 +32,31 @@ if(MSVC) ) endif(MSVC) -set(gr_fec_rs_sources +add_library(gr_fec_rs OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/encode_rs.c ${CMAKE_CURRENT_SOURCE_DIR}/decode_rs.c ${CMAKE_CURRENT_SOURCE_DIR}/init_rs.c -) -add_library(gr_fec_rs OBJECT ${gr_fec_rs_sources}) + ) target_include_directories(gr_fec_rs PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include> PRIVATE $<TARGET_PROPERTY:gnuradio-runtime,INCLUDE_DIRECTORIES> ) set_target_properties(gr_fec_rs PROPERTIES POSITION_INDEPENDENT_CODE ON) -######################################################################## -# Setup sources and includes -######################################################################## -list(APPEND gnuradio_fec_sources ${gr_fec_rs_sources}) - -#install( -# FILES ${CMAKE_CURRENT_SOURCE_DIR}/rs.h -# DESTINATION ${GR_INCLUDE_DIR}/gnuradio/fec -#) +target_sources(gnuradio-fec PRIVATE $<TARGET_OBJECTS:gr_fec_rs>) ######################################################################## # Register unit tests ######################################################################## if(ENABLE_TESTING) add_executable(gr_fec_rstest - ${gr_fec_rs_sources} - ${CMAKE_CURRENT_SOURCE_DIR}/rstest.c ${CMAKE_CURRENT_SOURCE_DIR}/exercise.c -) -add_test(gr-fec-reed-solomon-test gr_fec_rstest) + ${CMAKE_CURRENT_SOURCE_DIR}/rstest.c + $<TARGET_OBJECTS:gr_fec_rs> + ) + target_link_libraries(gr_fec_rstest gnuradio-runtime) + target_include_directories(gr_fec_rstest + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include + ) +add_test(test_rs gr_fec_rstest) endif(ENABLE_TESTING) diff --git a/gr-fec/lib/viterbi/CMakeLists.txt b/gr-fec/lib/viterbi/CMakeLists.txt deleted file mode 100644 index c13d500f7f..0000000000 --- a/gr-fec/lib/viterbi/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# 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. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## - -set(viterbi_sources - ${CMAKE_CURRENT_SOURCE_DIR}/metrics.c - ${CMAKE_CURRENT_SOURCE_DIR}/tab.c - ${CMAKE_CURRENT_SOURCE_DIR}/viterbi.c -) - -######################################################################## -# Append gnuradio-runtime library sources -######################################################################## -SET_SOURCE_FILES_PROPERTIES( ${viterbi_sources} PROPERTIES LANGUAGE CXX ) -list(APPEND gnuradio_fec_sources ${viterbi_sources}) - -######################################################################## -# Install runtime headers -######################################################################## -#install( -# FILES ${CMAKE_CURRENT_SOURCE_DIR}/viterbi.h -# DESTINATION ${GR_INCLUDE_DIR}/gnuradio/fec -#) - -######################################################################## -# Create some text executables (not registered tests) -# Its not much to build so the sources are just re-listed, -# rather than create a new library just for these two apps. -######################################################################## -#ADD_EXECUTABLE(viterbi_encode ${CMAKE_CURRENT_SOURCE_DIR}/encode.cc ${viterbi_sources}) -#ADD_EXECUTABLE(viterbi_decode ${CMAKE_CURRENT_SOURCE_DIR}/decode.cc ${viterbi_sources}) diff --git a/gr-fec/lib/viterbi/metrics.c b/gr-fec/lib/viterbi/metrics.cc index c94133be15..c94133be15 100644 --- a/gr-fec/lib/viterbi/metrics.c +++ b/gr-fec/lib/viterbi/metrics.cc diff --git a/gr-fec/lib/viterbi/tab.c b/gr-fec/lib/viterbi/tab.cc index 1c135acfee..1c135acfee 100644 --- a/gr-fec/lib/viterbi/tab.c +++ b/gr-fec/lib/viterbi/tab.cc diff --git a/gr-fec/lib/viterbi/viterbi.c b/gr-fec/lib/viterbi/viterbi.cc index 11b9f79b9a..11b9f79b9a 100644 --- a/gr-fec/lib/viterbi/viterbi.c +++ b/gr-fec/lib/viterbi/viterbi.cc diff --git a/gr-fec/swig/CMakeLists.txt b/gr-fec/swig/CMakeLists.txt index 5eaa5de748..9fb98fe5d3 100644 --- a/gr-fec/swig/CMakeLists.txt +++ b/gr-fec/swig/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012,2019 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,16 +23,8 @@ include(GrPython) include(GrSwig) -set(GR_SWIG_INCLUDE_DIRS - ${CMAKE_CURRENT_BINARY_DIR}/../include - ${GR_FEC_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_SWIG_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} -) - -if(ENABLE_GR_CTRLPORT) - list(APPEND GR_SWIG_FLAGS "-DGR_CTRLPORT") -endif(ENABLE_GR_CTRLPORT) +set(GR_SWIG_INCLUDE_DIRS $<TARGET_PROPERTY:runtime_swig,INCLUDE_DIRECTORIES>) +set(GR_SWIG_TARGET_DEPS runtime_swig) if(GSL_FOUND) list(APPEND GR_SWIG_FLAGS "-DGSL_FOUND") |