Skip to content

Commit b5b9e87

Browse files
authored
Remove sip dependencies for macOS (#268)
Signed-off-by: Rhys Mainwaring <[email protected]>
1 parent cabbbc7 commit b5b9e87

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

qt_gui_cpp/CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,17 @@ if(WIN32)
1818
return()
1919
endif()
2020

21+
# FindPythonLibs deprecated since 3.12
22+
# https://cmake.org/cmake/help/latest/module/FindPythonLibs.html
23+
# Use FindPython to set the cache variables.
24+
find_package(Python 3 REQUIRED
25+
COMPONENTS Interpreter Development
26+
)
27+
set(PYTHON_LIBRARY ${Python_LIBRARY_DIRS})
28+
set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS})
29+
2130
find_package(pluginlib REQUIRED)
22-
find_package(Qt5 REQUIRED COMPONENTS Widgets)
31+
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets)
2332
find_package(rcpputils REQUIRED)
2433
find_package(tinyxml2_vendor REQUIRED)
2534
find_package(TinyXML2 REQUIRED)
@@ -60,7 +69,9 @@ target_link_libraries(${PROJECT_NAME}
6069
tinyxml2::tinyxml2)
6170

6271
add_subdirectory(src/qt_gui_cpp_shiboken)
63-
add_subdirectory(src/qt_gui_cpp_sip)
72+
if (NOT APPLE)
73+
add_subdirectory(src/qt_gui_cpp_sip)
74+
endif()
6475

6576
message(STATUS "Python binding generators: ${qt_gui_cpp_BINDINGS}")
6677
if(NOT qt_gui_cpp_BINDINGS)

qt_gui_cpp/src/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ add_subdirectory(qt_gui_cpp)
33
set(qt_gui_cpp_BINDINGS "")
44

55
add_subdirectory(qt_gui_cpp_shiboken)
6-
add_subdirectory(qt_gui_cpp_sip)
6+
if (NOT APPLE)
7+
add_subdirectory(qt_gui_cpp_sip)
8+
endif()
79

810
message(STATUS "Python binding generators: ${qt_gui_cpp_BINDINGS}")
911
if(NOT qt_gui_cpp_BINDINGS)

qt_gui_cpp/src/qt_gui_cpp_shiboken/CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,37 @@ if(shiboken_helper_FOUND)
5050
list(APPEND qt_gui_cpp_BINDINGS "shiboken")
5151
set(qt_gui_cpp_BINDINGS "${qt_gui_cpp_BINDINGS}" PARENT_SCOPE)
5252

53+
if (APPLE)
54+
# The shiboken_generator fails without these includes.
55+
# TODO: resolve why these cannot be set using the component variables
56+
# Qt5Core_INCLUDE_DIRS etc.
57+
list(APPEND qt_gui_cpp_INCLUDE_PATH "${Qt5_DIR}/../../../include")
58+
list(APPEND qt_gui_cpp_INCLUDE_PATH "${Qt5_DIR}/../../../include/QtCore")
59+
list(APPEND qt_gui_cpp_INCLUDE_PATH "${Qt5_DIR}/../../../include/QtWidgets")
60+
endif()
61+
5362
set(QT_INCLUDE_DIR "${Qt5Widgets_INCLUDE_DIRS}")
5463
shiboken_generator(libqt_gui_cpp global.h typesystem.xml ${PROJECT_SOURCE_DIR}/src/qt_gui_cpp_shiboken "${qt_gui_cpp_shiboken_SRCS}" "${qt_gui_cpp_HDRS}" "${qt_gui_cpp_INCLUDE_PATH}" "${CMAKE_CURRENT_BINARY_DIR}")
5564

5665
shiboken_include_directories(qt_gui_cpp_shiboken "${qt_gui_cpp_shiboken_QT_COMPONENTS}")
5766

5867
add_library(qt_gui_cpp_shiboken SHARED ${qt_gui_cpp_shiboken_SRCS})
5968
target_include_directories(qt_gui_cpp_shiboken PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
60-
target_link_libraries(qt_gui_cpp_shiboken ${PROJECT_NAME})
69+
target_link_libraries(qt_gui_cpp_shiboken
70+
${PROJECT_NAME}
71+
Qt5::Core
72+
Qt5::Gui
73+
Qt5::Widgets
74+
)
6175
ament_target_dependencies(qt_gui_cpp_shiboken pluginlib TinyXML2)
6276
shiboken_target_link_libraries(qt_gui_cpp_shiboken "${qt_gui_cpp_shiboken_QT_COMPONENTS}")
6377

78+
if (APPLE)
79+
# the brew installed version of cmake (>3.24) supports Python3_SOABI
80+
find_package(Python3 COMPONENTS Development)
81+
set_target_properties(qt_gui_cpp_shiboken PROPERTIES SUFFIX ".${Python3_SOABI}.so")
82+
endif()
83+
6484
install(TARGETS qt_gui_cpp_shiboken
6585
DESTINATION ${PYTHON_INSTALL_DIR}/${PROJECT_NAME})
6686
endif()

0 commit comments

Comments
 (0)