Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: build python deps conditionally #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/make-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,28 @@ jobs:
su -c ldconfig
- name: Test Python3
run: python3 -c "import gnuradio.blocks; print(gnuradio.blocks.complex_to_float())"
no-python:
# All of these shall depend on the formatting check (needs: check-formatting)
needs: [check-formatting, check-python-formatting]
runs-on: ubuntu-latest
# The GH default is 360 minutes (it's also the max as of Feb-2021). However
# we should fail sooner. The only reason to exceed this time is if a test
# hangs.
timeout-minutes: 120
name: C++ Only Build (Ubuntu 20.04)
container:
image: 'gnuradio/ci:ubuntu-20.04-3.9'
volumes:
- build_data:/build
options: --cpus 2
steps:
- uses: actions/checkout@v2
name: Checkout Project
- name: CMake
env:
CXXFLAGS: -Werror -Wno-error=invalid-pch
run: 'cd /build && cmake ${GITHUB_WORKSPACE} -DENABLE_DOXYGEN=OFF -DENABLE_PYTHON=OFF'
- name: Make
run: 'cd /build && make -j2 -k'
- name: Make Test
run: 'cd /build && ctest --output-on-failure'
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,12 @@ if(NOT PYGCCXML_FOUND)
message(STATUS "******************************************************************")
endif()

find_package(pybind11 REQUIRED)
find_package(pybind11)
IF(pybind11_FOUND)
IF(${pybind11_VERSION} VERSION_LESS ${PYBIND11_MIN_VERSION})
message(FATAL_ERROR "pybind11 version ${pybind11_VERSION} < ${PYBIND11_MIN_VERSION}")
message(WARNING "pybind11 version ${pybind11_VERSION} < ${PYBIND11_MIN_VERSION}")
set(pybind11_FOUND False)
ENDIF()
ENDIF()

include(GrComponent)
Expand Down Expand Up @@ -372,7 +375,6 @@ GR_REGISTER_COMPONENT("post-install" ENABLE_POSTINSTALL)
########################################################################
add_subdirectory(docs)
add_subdirectory(gnuradio-runtime)
add_subdirectory(grc)
add_subdirectory(gr-blocks)
add_subdirectory(gr-fec)
add_subdirectory(gr-fft)
Expand All @@ -387,13 +389,16 @@ add_subdirectory(gr-iio)
add_subdirectory(gr-qtgui)
add_subdirectory(gr-trellis)
add_subdirectory(gr-uhd)
add_subdirectory(gr-utils)
add_subdirectory(gr-video-sdl)
add_subdirectory(gr-vocoder)
add_subdirectory(gr-wavelet)
add_subdirectory(gr-zeromq)
add_subdirectory(gr-network)
add_subdirectory(gr-soapy)
if (ENABLE_PYTHON)
add_subdirectory(grc)
add_subdirectory(gr-utils)
endif()

# Defining GR_CTRLPORT for gnuradio/config.h
if(ENABLE_GR_CTRLPORT)
Expand Down
9 changes: 9 additions & 0 deletions gnuradio-runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,22 @@ find_package(spdlog CONFIG)
# Register component
########################################################################
include(GrComponent)
if (ENABLE_PYTHON)
GR_REGISTER_COMPONENT("gnuradio-runtime" ENABLE_GNURADIO_RUNTIME
Boost_FOUND
PYTHONINTERP_FOUND
MPLIB_FOUND
spdlog_FOUND
pybind11_FOUND
)
else()
GR_REGISTER_COMPONENT("gnuradio-runtime" ENABLE_GNURADIO_RUNTIME
Boost_FOUND
PYTHONINTERP_FOUND
MPLIB_FOUND
spdlog_FOUND
)
endif()

get_filename_component(GNURADIO_RUNTIME_PYTHONPATH
${CMAKE_SOURCE_DIR}/python ABSOLUTE
Expand Down
23 changes: 17 additions & 6 deletions gnuradio-runtime/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ add_library(gnuradio-runtime
block.cc
block_detail.cc
block_executor.cc
block_gateway_impl.cc
block_registry.cc
buffer.cc
buffer_double_mapped.cc
Expand Down Expand Up @@ -99,6 +98,12 @@ add_library(gnuradio-runtime
vmcircbuf_sysv_shm.cc
)

if (ENABLE_PYTHON)
target_sources(gnuradio-runtime PRIVATE
block_gateway_impl.cc
)
endif()

# Messages
target_sources(gnuradio-runtime PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/messages/msg_accepter.cc
Expand Down Expand Up @@ -135,14 +140,20 @@ target_link_libraries(gnuradio-runtime PUBLIC
# 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
libunwind::libunwind
pybind11::pybind11
libunwind::libunwind
)

if (ENABLE_PYTHON)
target_link_libraries(gnuradio-runtime
INTERFACE
Python::Module
PRIVATE
Python::Python
pybind11::pybind11
)
endif()

# 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>)

Expand Down