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-fft | |
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-fft')
-rw-r--r-- | gr-fft/CMakeLists.txt | 7 | ||||
-rw-r--r-- | gr-fft/lib/CMakeLists.txt | 77 | ||||
-rw-r--r-- | gr-fft/swig/CMakeLists.txt | 14 |
3 files changed, 21 insertions, 77 deletions
diff --git a/gr-fft/CMakeLists.txt b/gr-fft/CMakeLists.txt index 4bf8263965..1da483f407 100644 --- a/gr-fft/CMakeLists.txt +++ b/gr-fft/CMakeLists.txt @@ -34,12 +34,7 @@ GR_REGISTER_COMPONENT("gr-fft" ENABLE_GR_FFT Boost_FOUND ENABLE_GNURADIO_RUNTIME ENABLE_GR_BLOCKS - FFTW3F_FOUND -) - -GR_SET_GLOBAL(GR_FFT_INCLUDE_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/lib - ${CMAKE_CURRENT_SOURCE_DIR}/include + FFTW3f_FOUND ) ######################################################################## diff --git a/gr-fft/lib/CMakeLists.txt b/gr-fft/lib/CMakeLists.txt index 9777d243df..7b8207665e 100644 --- a/gr-fft/lib/CMakeLists.txt +++ b/gr-fft/lib/CMakeLists.txt @@ -18,29 +18,9 @@ # Boston, MA 02110-1301, USA. ######################################################################## -# Setup the include and linker paths -######################################################################## -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${GR_FFT_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${VOLK_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${FFTW3F_INCLUDE_DIRS} -) - -link_directories(${Boost_LIBRARY_DIRS}) -link_directories(${FFTW3F_LIBRARY_DIRS}) - -if(ENABLE_GR_CTRLPORT) - ADD_DEFINITIONS(-DGR_CTRLPORT) -endif(ENABLE_GR_CTRLPORT) - -######################################################################## # Setup library ######################################################################## -list(APPEND fft_sources +add_library(gnuradio-fft fft.cc fft_vcc_fftw.cc fft_vfc_fftw.cc @@ -49,18 +29,24 @@ list(APPEND fft_sources window.cc ) +target_link_libraries(gnuradio-fft PUBLIC + gnuradio-runtime + fftw3f::fftw3f + ${GR_VOLK_LIB} +) + +target_include_directories(gnuradio-fft + PUBLIC + $<INSTALL_INTERFACE:include> + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include> + ) + if(ENABLE_GR_CTRLPORT) -list(APPEND fft_sources +target_sources(gnuradio-fft PRIVATE ctrlport_probe_psd_impl.cc ) endif(ENABLE_GR_CTRLPORT) -list(APPEND fft_libs - gnuradio-runtime - ${VOLK_LIBRARIES} - ${Boost_LIBRARIES} - ${FFTW3F_LIBRARIES} -) #Add Windows DLL resource file if using MSVC if(MSVC) @@ -71,40 +57,11 @@ if(MSVC) ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fft.rc @ONLY) - list(APPEND fft_sources + target_sources(gnuradio-fft PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fft.rc ) endif(MSVC) -if(FFTW3F_THREADS_LIBRARIES) - list(APPEND fft_libs ${FFTW3F_THREADS_LIBRARIES}) - add_definitions("-DFFTW3F_THREADS") +if(BUILD_SHARED_LIBS) + GR_LIBRARY_FOO(gnuradio-fft FFTW3f) endif() - -add_library(gnuradio-fft SHARED ${fft_sources}) -target_link_libraries(gnuradio-fft ${fft_libs}) -GR_LIBRARY_FOO(gnuradio-fft) - -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-fft APPEND PROPERTY COMPILE_DEFINITIONS "GR_CTRLPORT") - endif(ENABLE_GR_CTRLPORT) - - add_library(gnuradio-fft_static STATIC ${fft_sources}) - - if(NOT WIN32) - set_target_properties(gnuradio-fft_static - PROPERTIES OUTPUT_NAME gnuradio-fft) - endif(NOT WIN32) - - install(TARGETS gnuradio-fft_static - ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file - ) -endif(ENABLE_STATIC_LIBS) diff --git a/gr-fft/swig/CMakeLists.txt b/gr-fft/swig/CMakeLists.txt index 67e34bbba8..e0e780a282 100644 --- a/gr-fft/swig/CMakeLists.txt +++ b/gr-fft/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 - ${GR_FFT_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_SWIG_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${FFTW3F_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) set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/fft_swig_doc.i) set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include/gnuradio/fft) |