cmake: Go back CMake min ver. 3.8 by removing need for CMP0079

CMake 3.13 is not present in older (~2 years old)
Linux distributions and GNU Radio requires min CMake
version 3.8.

All that is needed in order to avoid bumping CMake version
is to not use 'target_link_libraries' in subdirectories.
Here this is done by creating a list of needed
libraries and adding them for linking at the end (like
it was done in gr-osmosdr before porting to GNU Radio 3.8).

One thing that is lost here is 'PRIVATE' statement in case
of FCD libraries linking.

Signed-off-by: Eric Wild <ewild@sysmocom.de>
This commit is contained in:
Piotr Krysik 2020-02-17 08:11:25 +02:00 committed by Eric Wild
parent af2fda22b3
commit 8cf6840da1
17 changed files with 22 additions and 21 deletions

View File

@ -20,14 +20,13 @@
######################################################################## ########################################################################
# Project setup # Project setup
######################################################################## ########################################################################
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.8)
include(GNUInstallDirs) include(GNUInstallDirs)
project(gr-osmosdr CXX C) project(gr-osmosdr CXX C)
enable_testing() enable_testing()
#policy setup #policy setup
cmake_policy(SET CMP0011 NEW) cmake_policy(SET CMP0011 NEW)
cmake_policy(SET CMP0079 NEW)
#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) if(NOT CMAKE_BUILD_TYPE)

View File

@ -41,7 +41,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif() endif()
add_library(gnuradio-osmosdr SHARED) add_library(gnuradio-osmosdr SHARED)
target_link_libraries(gnuradio-osmosdr ${Boost_LIBRARIES} gnuradio::gnuradio-runtime) list(APPEND gr_osmosdr_libs ${Boost_LIBRARIES} gnuradio::gnuradio-runtime)
target_include_directories(gnuradio-osmosdr target_include_directories(gnuradio-osmosdr
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC ${Boost_INCLUDE_DIRS} PUBLIC ${Boost_INCLUDE_DIRS}
@ -100,7 +100,7 @@ CHECK_CXX_SOURCE_COMPILES("
if(HAVE_CLOCK_GETTIME) if(HAVE_CLOCK_GETTIME)
message(STATUS " High resolution timing supported through clock_gettime.") message(STATUS " High resolution timing supported through clock_gettime.")
set(TIME_SPEC_DEFS HAVE_CLOCK_GETTIME) set(TIME_SPEC_DEFS HAVE_CLOCK_GETTIME)
target_link_libraries(gnuradio-osmosdr "-lrt") list(APPEND gr_osmosdr_libs "-lrt")
elseif(HAVE_MACH_ABSOLUTE_TIME) elseif(HAVE_MACH_ABSOLUTE_TIME)
message(STATUS " High resolution timing supported through mach_absolute_time.") message(STATUS " High resolution timing supported through mach_absolute_time.")
set(TIME_SPEC_DEFS HAVE_MACH_ABSOLUTE_TIME) set(TIME_SPEC_DEFS HAVE_MACH_ABSOLUTE_TIME)
@ -124,7 +124,7 @@ GR_REGISTER_COMPONENT("Osmocom IQ Imbalance Correction" ENABLE_IQBALANCE gnuradi
if(ENABLE_IQBALANCE) if(ENABLE_IQBALANCE)
add_definitions(-DHAVE_IQBALANCE=1) add_definitions(-DHAVE_IQBALANCE=1)
target_include_directories(gnuradio-osmosdr PRIVATE ${gnuradio-iqbalance_INCLUDE_DIRS}) target_include_directories(gnuradio-osmosdr PRIVATE ${gnuradio-iqbalance_INCLUDE_DIRS})
target_link_libraries(gnuradio-osmosdr gnuradio::gnuradio-iqbalance) list(APPEND gr_osmosdr_libs gnuradio::gnuradio-iqbalance)
endif(ENABLE_IQBALANCE) endif(ENABLE_IQBALANCE)
######################################################################## ########################################################################
@ -263,6 +263,7 @@ configure_file(
# Finalize target # Finalize target
######################################################################## ########################################################################
set_target_properties(gnuradio-osmosdr PROPERTIES SOURCES "${gr_osmosdr_srcs}") set_target_properties(gnuradio-osmosdr PROPERTIES SOURCES "${gr_osmosdr_srcs}")
target_link_libraries(gnuradio-osmosdr ${gr_osmosdr_libs})
######################################################################## ########################################################################
# Install built library files # Install built library files

View File

@ -26,7 +26,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${LIBAIRSPY_INCLUDE_DIRS} ${LIBAIRSPY_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
gnuradio::gnuradio-filter gnuradio::gnuradio-filter
${Gnuradio-blocks_LIBRARIES} ${Gnuradio-blocks_LIBRARIES}
${LIBAIRSPY_LIBRARIES} ${LIBAIRSPY_LIBRARIES}

View File

@ -26,7 +26,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${LIBAIRSPYHF_INCLUDE_DIRS} ${LIBAIRSPYHF_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
${Gnuradio-blocks_LIBRARIES} ${Gnuradio-blocks_LIBRARIES}
${LIBAIRSPYHF_LIBRARIES} ${LIBAIRSPYHF_LIBRARIES}
) )

View File

@ -27,7 +27,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${Volk_INCLUDE_DIRS} ${Volk_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
${LIBBLADERF_LIBRARIES} ${LIBBLADERF_LIBRARIES}
${Volk_LIBRARIES} ${Volk_LIBRARIES}
) )

View File

@ -29,7 +29,8 @@ if(ENABLE_FCD)
target_include_directories(gnuradio-osmosdr PRIVATE target_include_directories(gnuradio-osmosdr PRIVATE
${Gnuradio-fcd_INCLUDE_DIRS} ${Gnuradio-fcd_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr PRIVATE
list(APPEND gr_osmosdr_libs
${Gnuradio-fcd_LIBRARIES} ${Gnuradio-fcd_LIBRARIES}
) )
endif(ENABLE_FCD) endif(ENABLE_FCD)
@ -38,7 +39,7 @@ if(ENABLE_FCDPP)
target_include_directories(gnuradio-osmosdr PRIVATE target_include_directories(gnuradio-osmosdr PRIVATE
${Gnuradio-fcdpp_INCLUDE_DIRS} ${Gnuradio-fcdpp_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr PRIVATE list(APPEND gr_osmosdr_libs
${Gnuradio-fcdpp_LIBRARIES} ${Gnuradio-fcdpp_LIBRARIES}
) )
endif(ENABLE_FCDPP) endif(ENABLE_FCDPP)

View File

@ -25,7 +25,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
gnuradio::gnuradio-blocks gnuradio::gnuradio-blocks
) )
message(STATUS ${gnuradio-blocks_LIBRARIES}) message(STATUS ${gnuradio-blocks_LIBRARIES})

View File

@ -26,7 +26,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${LIBFREESRP_INCLUDE_DIRS} ${LIBFREESRP_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
${LIBFREESRP_LIBRARIES} ${LIBFREESRP_LIBRARIES}
) )

View File

@ -26,7 +26,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${LIBHACKRF_INCLUDE_DIRS} ${LIBHACKRF_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
${LIBHACKRF_LIBRARIES} ${LIBHACKRF_LIBRARIES}
) )

View File

@ -26,7 +26,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${LIBMIRISDR_INCLUDE_DIRS} ${LIBMIRISDR_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
${LIBMIRISDR_LIBRARIES} ${LIBMIRISDR_LIBRARIES}
) )

View File

@ -26,7 +26,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${LIBOSMOSDR_INCLUDE_DIRS} ${LIBOSMOSDR_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
${LIBOSMOSDR_LIBRARIES} ${LIBOSMOSDR_LIBRARIES}
) )

View File

@ -25,7 +25,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
${Gnuradio-blocks_LIBRARIES} ${Gnuradio-blocks_LIBRARIES}
) )

View File

@ -26,7 +26,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${LIBRTLSDR_INCLUDE_DIRS} ${LIBRTLSDR_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
${LIBRTLSDR_LIBRARIES} ${LIBRTLSDR_LIBRARIES}
) )

View File

@ -25,7 +25,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
${Gnuradio-blocks_LIBRARIES} ${Gnuradio-blocks_LIBRARIES}
) )

View File

@ -26,7 +26,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${LIBSDRPLAY_INCLUDE_DIRS} ${LIBSDRPLAY_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
${LIBSDRPLAY_LIBRARIES} ${LIBSDRPLAY_LIBRARIES}
) )

View File

@ -26,7 +26,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${SoapySDR_INCLUDE_DIRS} ${SoapySDR_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
${SoapySDR_LIBRARIES} ${SoapySDR_LIBRARIES}
) )

View File

@ -27,7 +27,7 @@ target_include_directories(gnuradio-osmosdr PRIVATE
${UHD_INCLUDE_DIRS} ${UHD_INCLUDE_DIRS}
) )
target_link_libraries(gnuradio-osmosdr list(APPEND gr_osmosdr_libs
gnuradio::gnuradio-uhd gnuradio::gnuradio-uhd
${UHD_LIBRARIES} ${UHD_LIBRARIES}
) )