Skip to content

Commit 661e867

Browse files
committed
Merge pull request #691 from insertinterestingnamehere/libdyndt
Stop linking type modules against libdynd
2 parents 7c20718 + 8088596 commit 661e867

2 files changed

Lines changed: 52 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,15 @@ cython_add_module(dynd.ndt.type dynd.ndt.type_pyx True
218218
dynd/src/type_deduction.cpp
219219
)
220220

221-
foreach(module dynd.ndt.json dynd.nd.callable dynd.nd.functional dynd.nd.registry)
221+
cython_add_module(dynd.ndt.json dynd.ndt.json_pyx True dynd/src/type_conversions.cpp)
222+
223+
foreach(module dynd.nd.callable dynd.nd.functional dynd.nd.registry)
222224
cython_add_module(${module} ${module}_pyx True
223225
# Additional C++ source files:
224226
dynd/src/type_conversions.cpp
225227
dynd/src/array_conversions.cpp)
226228
endforeach(module)
229+
227230
if (DYND_PYTHON_INPLACE_BUILD)
228231
set_target_library_output_dir(dynd.config "${PROJECT_SOURCE_DIR}/dynd")
229232
set_target_library_output_dir(dynd.nd.array "${PROJECT_SOURCE_DIR}/dynd/nd")
@@ -241,7 +244,41 @@ postprocess_cython( postprocess.py dynd.ndt.type_postprocess dynd.ndt.type_pyx d
241244
postprocess_cython( postprocess.py dynd.nd.array_postprocess dynd.nd.array_pyx dynd.nd.array)
242245
postprocess_cython( postprocess.py dynd.nd.callable_postprocess dynd.nd.callable_pyx dynd.nd.callable)
243246

244-
foreach(module dynd.config dynd.ndt.type dynd.ndt.json dynd.nd.array dynd.nd.callable dynd.nd.functional dynd.nd.registry)
247+
# Linker commands for the dynd.ndt module.
248+
foreach(module dynd.ndt.type dynd.ndt.json)
249+
# Temporarily continue to define PYDYND_EXPORT to avoid inconsistent linkage warnings.
250+
# This should be removed once the macros have been refactored to hide all symbols
251+
# other than module initialization routines.
252+
set_property(
253+
TARGET ${module}
254+
PROPERTY COMPILE_DEFINITIONS PYDYND_EXPORT
255+
)
256+
if(DYND_INSTALL_LIB)
257+
target_link_libraries(${module} "${LIBDYNDT_LIBRARY}")
258+
else()
259+
target_link_libraries(${module} libdyndt)
260+
if(UNIX)
261+
# Make sure libdyndt is on the rpath.
262+
# On Windows, the dll is loaded dynamically via the logic in
263+
# dynd/__init__.py
264+
if(APPLE)
265+
set(module_install_rpath "@loader_path")
266+
else()
267+
set(module_install_rpath "$ORIGIN")
268+
endif()
269+
string(REPLACE "." ";" module_directories "${module}")
270+
list(LENGTH module_directories i)
271+
while(${i} GREATER 2)
272+
set(module_install_rpath "${module_install_rpath}/..")
273+
math(EXPR i "${i} - 1" )
274+
endwhile(${i} GREATER 2)
275+
set_target_properties(${module} PROPERTIES INSTALL_RPATH ${module_install_rpath})
276+
endif()
277+
endif()
278+
endforeach(module)
279+
280+
# Linker commands for the dynd.nd module.
281+
foreach(module dynd.config dynd.nd.array dynd.nd.callable dynd.nd.functional dynd.nd.registry)
245282
# Temporarily continue to define PYDYND_EXPORT to avoid inconsistent linkage warnings.
246283
# This should be removed once the macros have been refactored to hide all symbols
247284
# other than module initialization routines.

cmake/FindLibDyND.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ if("${_LIBDYND_CONFIG}" STREQUAL "")
5959

6060
else()
6161

62+
# Get the ndt library to link against.
63+
execute_process(COMMAND "${_LIBDYND_CONFIG}" "-libdyndtname"
64+
RESULT_VARIABLE _DYND_SEARCH_SUCCESS
65+
OUTPUT_VARIABLE LIBDYNDT_NAME
66+
ERROR_VARIABLE _DYND_ERROR_VALUE
67+
OUTPUT_STRIP_TRAILING_WHITESPACE)
68+
if(NOT _DYND_SEARCH_SUCCESS MATCHES 0)
69+
message(FATAL_ERROR "Error getting ndt library name:\n${_DYND_ERROR_VALUE}")
70+
endif()
71+
6272
# Get the libraries to link against.
6373
execute_process(COMMAND "${_LIBDYND_CONFIG}" "-libnames"
6474
RESULT_VARIABLE _DYND_SEARCH_SUCCESS
@@ -82,6 +92,9 @@ else()
8292
if(WIN32)
8393
string(REPLACE "\\" "/" LIBDYND_LIBRARY_DIR ${LIBDYND_LIBRARY_DIR})
8494
endif()
95+
96+
set(LIBDYNDT_LIBRARY "${LIBDYND_LIBRARY_DIR}/${LIBDYNDT_NAME}")
97+
8598
set(LIBDYND_LIBRARIES "")
8699
foreach(_lib ${LIBDYND_LIBRARY_NAMES})
87100
LIST(APPEND LIBDYND_LIBRARIES "${LIBDYND_LIBRARY_DIR}/${_lib}")

0 commit comments

Comments
 (0)