Skip to content

Commit

Permalink
Fix linking pybindings on Mac
Browse files Browse the repository at this point in the history
Mac has different linker defaults than linux, and by default it
does not allow undefined symbols to be left in resulting pybinding
library.
To allow it, we specifically pass linker argument when linking final
pybinding object.

This is done to avoid linking excessively to libpythonX.Y since at the
time pybinding is loaded into Python process, all libpython symbols
would be immediately available.
  • Loading branch information
vicpopov committed Sep 30, 2020
1 parent 5b94691 commit 4122b00
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 2 deletions.
4 changes: 4 additions & 0 deletions generator/mwm_diff/pymwm_diff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ omim_link_libraries(
${LIBZ}
)

if (PLATFORM_MAC)
omim_link_libraries(${PROJECT_NAME} "-Wl,-undefined,dynamic_lookup")
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
4 changes: 4 additions & 0 deletions generator/pygen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ omim_link_libraries(
link_qt5_core(${PROJECT_NAME})
link_qt5_network(${PROJECT_NAME})

if (PLATFORM_MAC)
omim_link_libraries(${PROJECT_NAME} "-Wl,-undefined,dynamic_lookup")
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
2 changes: 1 addition & 1 deletion kml/pykmlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ omim_link_libraries(
link_qt5_core(${PROJECT_NAME})

if (PLATFORM_MAC)
omim_link_libraries(${PROJECT_NAME} ${LIBZ})
omim_link_libraries(${PROJECT_NAME} "-Wl,-undefined,dynamic_lookup")
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
4 changes: 4 additions & 0 deletions local_ads/pylocal_ads/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ omim_link_libraries(
base
)

if (PLATFORM_MAC)
omim_link_libraries(${PROJECT_NAME} "-Wl,-undefined,dynamic_lookup")
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
4 changes: 4 additions & 0 deletions search/pysearch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ omim_link_libraries(
link_qt5_core(${PROJECT_NAME})
link_qt5_network(${PROJECT_NAME})

if (PLATFORM_MAC)
omim_link_libraries(${PROJECT_NAME} "-Wl,-undefined,dynamic_lookup")
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
14 changes: 13 additions & 1 deletion tracking/pytracking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,17 @@ include_directories(${CMAKE_BINARY_DIR})

omim_add_library(${PROJECT_NAME} MODULE ${SRC})

omim_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES} tracking coding geometry base)
omim_link_libraries(
${PROJECT_NAME}
${Boost_LIBRARIES}
tracking
coding
geometry
base
)

if (PLATFORM_MAC)
omim_link_libraries(${PROJECT_NAME} "-Wl,-undefined,dynamic_lookup")
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
1 change: 1 addition & 0 deletions traffic/pytraffic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ if (PLATFORM_MAC)
${PROJECT_NAME}
${Qt5Widgets_LIBRARIES}
"-framework QuartzCore"
"-Wl,-undefined,dynamic_lookup"
)
endif()

Expand Down

0 comments on commit 4122b00

Please sign in to comment.