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 | |
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>
-rw-r--r-- | CMakeLists.txt | 22 | ||||
-rw-r--r-- | gnuradio-runtime/lib/CMakeLists.txt | 111 |
2 files changed, 71 insertions, 62 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cd5ea10ee..549c0e1bc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,9 +167,6 @@ include(GrMiscUtils) #compiler flag check include(TestBigEndian) TEST_BIG_ENDIAN(GR_IS_BIG_ENDIAN) -if(GR_IS_BIG_ENDIAN) - add_definitions(-DGR_IS_BIG_ENDIAN) -endif(GR_IS_BIG_ENDIAN) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") @@ -185,26 +182,10 @@ endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR if(MSVC) include_directories(${CMAKE_SOURCE_DIR}/cmake/msvc) #missing headers - add_definitions(-D_USE_MATH_DEFINES) #enables math constants on all supported versions of MSVC - add_definitions(-D_WIN32_WINNT=0x0502) #Minimum version: "Windows Server 2003 with SP1, Windows XP with SP2" - add_definitions(-DNOMINMAX) #disables stupidity and enables std::min and std::max - add_definitions( #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 - ) add_compile_options(/MP) #build with multiple processors add_compile_options(/bigobj) #allow for larger object files endif(MSVC) -if(WIN32) - add_definitions(-D_USE_MATH_DEFINES) - if (CMAKE_SIZEOF_VOID_P EQUAL 8) - add_definitions(-DMS_WIN64) - endif(CMAKE_SIZEOF_VOID_P EQUAL 8) -endif(WIN32) - # Record Compiler Info for record STRING(TOUPPER ${CMAKE_BUILD_TYPE} GRCBTU) SET(COMPILER_INFO "") @@ -276,7 +257,6 @@ OPTION(ENABLE_PERFORMANCE_COUNTERS "Enable block performance counters" ON) if(ENABLE_PERFORMANCE_COUNTERS) message(STATUS "ADDING PERF COUNTERS") SET(GR_PERFORMANCE_COUNTERS True) - add_definitions(-DGR_PERFORMANCE_COUNTERS) else(ENABLE_PERFORMANCE_COUNTERS) SET(GR_PERFORMANCE_COUNTERS False) message(STATUS "NO PERF COUNTERS") @@ -458,7 +438,6 @@ list(APPEND GR_TEST_PYTHON_DIRS # multiprecision arithmetic library header to include include(FindPkgConfig) find_package(MPLIB) -add_definitions(${MPLIB_DEFINITIONS}) ######################################################################## # Post-Install tasks are tasks that are usually not executed during @@ -495,7 +474,6 @@ add_subdirectory(gr-network) # Defining GR_CTRLPORT for gnuradio/config.h if(ENABLE_GR_CTRLPORT) SET(GR_CTRLPORT True) - add_definitions(-DGR_CTRLPORT) if(CTRLPORT_BACKENDS GREATER 0) SET(GR_RPCSERVER_ENABLED True) 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) |