summaryrefslogtreecommitdiff
path: root/cmake/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/Modules')
-rw-r--r--cmake/Modules/Findlibunwind.cmake12
-rw-r--r--cmake/Modules/GrPybind.cmake20
-rw-r--r--cmake/Modules/GrPython.cmake20
3 files changed, 40 insertions, 12 deletions
diff --git a/cmake/Modules/Findlibunwind.cmake b/cmake/Modules/Findlibunwind.cmake
index 4875c1a7d6..07d5621b69 100644
--- a/cmake/Modules/Findlibunwind.cmake
+++ b/cmake/Modules/Findlibunwind.cmake
@@ -4,6 +4,7 @@
# libunwind_FOUND - system has libunwind
# libunwind_INCLUDE_DIRS - the libunwind include directories
# libunwind_LIBRARIES - link these to use libunwind
+# libunwind::libunwind target
include(LibFindMacros)
@@ -27,3 +28,14 @@ find_library(libunwind_LIBRARY
set(libunwind_PROCESS_INCLUDES ${libunwind_INCLUDE_DIR})
set(libunwind_PROCESS_LIBS libunwind_LIBRARY)
libfind_process(libunwind)
+
+add_library(libunwind::libunwind INTERFACE IMPORTED)
+# Only add properties if libunwind was found, so target can be used even
+# when libunwind was not found
+if(libunwind_FOUND)
+ set_target_properties(libunwind::libunwind PROPERTIES
+ INTERFACE_COMPILE_DEFINITIONS HAVE_LIBUNWIND
+ INTERFACE_INCLUDE_DIRECTORIES "${libunwind_INCLUDE_DIRS}"
+ INTERFACE_LINK_LIBRARIES "${libunwind_LIBRARIES}"
+ )
+endif()
diff --git a/cmake/Modules/GrPybind.cmake b/cmake/Modules/GrPybind.cmake
index d90cbf6c2e..7da4e36a56 100644
--- a/cmake/Modules/GrPybind.cmake
+++ b/cmake/Modules/GrPybind.cmake
@@ -1,5 +1,7 @@
include(GrPython)
+find_package(pybind11 REQUIRED)
+
macro(GR_PYBIND_MAKE name updir filter files)
configure_file(${CMAKE_SOURCE_DIR}/docs/doxygen/pydoc_macros.h ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
@@ -32,14 +34,12 @@ else(ENABLE_DOXYGEN)
add_custom_target(${name}_docstrings ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/docstring_status)
endif(ENABLE_DOXYGEN)
-target_include_directories(${name}_python PUBLIC
+target_include_directories(${name}_python PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
- ${PYTHON_NUMPY_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/${updir}/lib
${CMAKE_CURRENT_SOURCE_DIR}/${updir}/include
- ${pybind11_INCLUDE_DIR}
)
-target_link_libraries(${name}_python PUBLIC ${Boost_LIBRARIES} Python::Module gnuradio-${MODULE_NAME})
+target_link_libraries(${name}_python PRIVATE ${Boost_LIBRARIES} pybind11::pybind11 Python::Module Python::NumPy gnuradio-${MODULE_NAME})
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${name}_python PRIVATE -Wno-unused-variable) # disable warnings for docstring templates
@@ -149,14 +149,12 @@ else(ENABLE_DOXYGEN)
add_custom_target(${name}_docstrings ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/docstring_status)
endif(ENABLE_DOXYGEN)
-target_include_directories(${name}_python PUBLIC
+target_include_directories(${name}_python PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
- ${PYTHON_NUMPY_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/${updir}/lib
${CMAKE_CURRENT_SOURCE_DIR}/${updir}/include
- ${pybind11_INCLUDE_DIR}
)
-target_link_libraries(${name}_python PUBLIC ${Boost_LIBRARIES} Python::Module gnuradio-${MODULE_NAME})
+target_link_libraries(${name}_python PRIVATE ${Boost_LIBRARIES} pybind11::pybind11 Python::Module Python::NumPy gnuradio-${MODULE_NAME})
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${name}_python PRIVATE -Wno-unused-variable) # disable warnings for docstring templates
@@ -282,14 +280,12 @@ else(ENABLE_DOXYGEN)
add_custom_target(${name}_docstrings ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/docstring_status)
endif(ENABLE_DOXYGEN)
-target_include_directories(${name}_python PUBLIC
+target_include_directories(${name}_python PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
- ${PYTHON_NUMPY_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/${updir}/lib
${CMAKE_CURRENT_SOURCE_DIR}/${updir}/include
- ${pybind11_INCLUDE_DIR}
)
-target_link_libraries(${name}_python PUBLIC ${Boost_LIBRARIES} Python::Module gnuradio-${MODULE_NAME})
+target_link_libraries(${name}_python PRIVATE ${Boost_LIBRARIES} pybind11::pybind11 Python::Module Python::NumPy gnuradio-${MODULE_NAME})
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${name}_python PRIVATE -Wno-unused-variable) # disable warnings for docstring templates
diff --git a/cmake/Modules/GrPython.cmake b/cmake/Modules/GrPython.cmake
index 8149cb5cbe..e2da0d8170 100644
--- a/cmake/Modules/GrPython.cmake
+++ b/cmake/Modules/GrPython.cmake
@@ -80,6 +80,26 @@ else()
endif(APPLE)
endif(WIN32)
+# Find NumPy but duplicate behavior/variable names of FindPython in CMake 3.14+
+# (to facilitate a future transition)
+execute_process(
+ COMMAND "${PYTHON_EXECUTABLE}" -c
+ "try:\n import numpy\n import os\n inc_path = numpy.get_include()\n if os.path.exists(os.path.join(inc_path, 'numpy', 'arrayobject.h')):\n print(inc_path, end='')\nexcept:\n pass"
+ OUTPUT_VARIABLE NUMPY_INCLUDE_DIR
+)
+# advanced cache variable that the user should set to override the numpy include dir
+set(Python_NumPy_INCLUDE_DIR ${NUMPY_INCLUDE_DIR} CACHE FILEPATH "NumPy include directory")
+mark_as_advanced(Python_NumPy_INCLUDE_DIR)
+# output used by modern FindPython, duplicate the behavior
+set(Python_NumPy_INCLUDE_DIRS ${Python_NumPy_INCLUDE_DIR})
+
+# target for building with NumPy
+add_library(Python::NumPy INTERFACE IMPORTED)
+set_target_properties(Python::NumPy PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${Python_NumPy_INCLUDE_DIRS}"
+)
+target_link_libraries(Python::NumPy INTERFACE Python::Module)
+
########################################################################
# Check for the existence of a python module: