diff options
author | Ryan Volz <ryan.volz@gmail.com> | 2021-03-26 13:06:47 -0400 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-04-17 20:04:40 -0400 |
commit | d28d1b13a490e0d7a92fbc5a44fd9abee4720bda (patch) | |
tree | 859033eb2eb4e5c8cadc2d041be467f6d846fccf /gnuradio-runtime/lib | |
parent | c6cf6f99329bed4160f2273563f529852365f799 (diff) |
cmake: Move swath of add_definitions to gnuradio-runtime target.
Besides being a more modern CMake style, this has the benefit of
propagating the public definitions to any consumers of the
gnuradio-runtime library, which includes OOT modules. For example, OOT
modules would previously have to know to define "NOMINMAX" on MSVC, but
now that happens transitively.
Signed-off-by: Ryan Volz <ryan.volz@gmail.com>
Diffstat (limited to 'gnuradio-runtime/lib')
-rw-r--r-- | gnuradio-runtime/lib/CMakeLists.txt | 111 |
1 files changed, 71 insertions, 40 deletions
diff --git a/gnuradio-runtime/lib/CMakeLists.txt b/gnuradio-runtime/lib/CMakeLists.txt index 17c577c934..1256f62761 100644 --- a/gnuradio-runtime/lib/CMakeLists.txt +++ b/gnuradio-runtime/lib/CMakeLists.txt @@ -122,6 +122,47 @@ target_sources(gnuradio-runtime PRIVATE ${MATH_SINE_TABLE_HEADER} ) +target_link_libraries(gnuradio-runtime PUBLIC + gnuradio-pmt + Volk::volk + Boost::program_options + Boost::system + Boost::regex + Boost::thread + Log4Cpp::log4cpp + MPLib::mplib + ${libunwind_LIBRARIES} + # INTERFACE/PRIVATE split so users of the library can choose how to link to Python + # (importantly, extension modules can avoid linking against Python and resolve + # their own Python symbols at runtime through the Python interpreter's linking) + INTERFACE + Python::Module + PRIVATE + Python::Python + ) + +# Address linker issues with std::filesystem on Centos 8 and Debian +target_link_libraries(gnuradio-runtime PUBLIC $<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:stdc++fs>) + +target_include_directories(gnuradio-runtime + PUBLIC + ${PYTHON_NUMPY_INCLUDE_DIR} + ${pybind11_INCLUDE_DIR} + $<INSTALL_INTERFACE:include> + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include> + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include> + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ) + +target_compile_definitions(gnuradio-runtime PUBLIC ${MPLIB_DEFINITIONS}) + +# constants.cc includes boost::dll headers, force them to use std::filesystem +target_compile_definitions(gnuradio-runtime PRIVATE BOOST_DLL_USE_STD_FS) + +######################################################################## +# Add controlport stuff to gnuradio-runtime +######################################################################## # Controlport if(ENABLE_GR_CTRLPORT) @@ -178,6 +219,8 @@ target_link_libraries(gnuradio-runtime PUBLIC Thrift::thrift ) +target_compile_definitions(gnuradio-runtime PUBLIC GR_CTRLPORT) + # Add install rule to move example Thrift configuration file into a # documentation directory install( @@ -188,10 +231,6 @@ install( endif(THRIFT_FOUND) endif(ENABLE_CTRLPORT_THRIFT) -######################################################################## -# Add controlport stuff to gnuradio-runtime -######################################################################## - # Save the number of backends for testing against later set( CTRLPORT_BACKENDS ${CTRLPORT_BACKENDS} @@ -200,46 +239,38 @@ set( endif(ENABLE_GR_CTRLPORT) -target_link_libraries(gnuradio-runtime PUBLIC - gnuradio-pmt - Volk::volk - Boost::program_options - Boost::system - Boost::regex - Boost::thread - Log4Cpp::log4cpp - MPLib::mplib - ${libunwind_LIBRARIES} - # INTERFACE/PRIVATE split so users of the library can choose how to link to Python - # (importantly, extension modules can avoid linking against Python and resolve - # their own Python symbols at runtime through the Python interpreter's linking) - INTERFACE - Python::Module - PRIVATE - Python::Python - ) - -# Address linker issues with std::filesystem on Centos 8 and Debian -target_link_libraries(gnuradio-runtime PUBLIC $<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:stdc++fs>) +######################################################################## +# Add misc conditional includes/definitions to gnuradio-runtime +######################################################################## -target_include_directories(gnuradio-runtime - PUBLIC - ${PYTHON_NUMPY_INCLUDE_DIR} - ${pybind11_INCLUDE_DIR} - $<INSTALL_INTERFACE:include> - $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include> - $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include> - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ) +if(ENABLE_PERFORMANCE_COUNTERS) + target_compile_definitions(gnuradio-runtime PUBLIC -DGR_PERFORMANCE_COUNTERS) +endif() -# constants.cc includes boost::dll headers, force them to use std::filesystem -target_compile_definitions(gnuradio-runtime PRIVATE BOOST_DLL_USE_STD_FS) +if(GR_IS_BIG_ENDIAN) + target_compile_definitions(gnuradio-runtime PUBLIC -DGR_IS_BIG_ENDIAN) +endif(GR_IS_BIG_ENDIAN) - if(ENABLE_GR_CTRLPORT) - target_compile_definitions(gnuradio-runtime PUBLIC GR_CTRLPORT) - endif() +if(MSVC) + target_compile_definitions(gnuradio-runtime PUBLIC + # Minimum version: "Windows Server 2003 with SP1, Windows XP with SP2" + -D_WIN32_WINNT=0x0502 + # disables stupidity and enables std::min and std::max + -DNOMINMAX + # stop all kinds of compatibility warnings + -D_SCL_SECURE_NO_WARNINGS + -D_CRT_SECURE_NO_WARNINGS + -D_CRT_SECURE_NO_DEPRECATE + -D_CRT_NONSTDC_NO_DEPRECATE + ) +endif(MSVC) +if(WIN32) + target_compile_definitions(gnuradio-runtime PUBLIC -D_USE_MATH_DEFINES) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + target_compile_definitions(gnuradio-runtime PUBLIC -DMS_WIN64) + endif(CMAKE_SIZEOF_VOID_P EQUAL 8) +endif(WIN32) if(WIN32) target_compile_definitions(gnuradio-runtime PUBLIC -DWIN32_LEAN_AND_MEAN) |