Skip to content

Commit 85d6d11

Browse files
skrahinsertinterestingnamehere
authored andcommitted
Link dynd.ndt against libdyndt only.
1 parent 7c20718 commit 85d6d11

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,41 @@ postprocess_cython( postprocess.py dynd.ndt.type_postprocess dynd.ndt.type_pyx d
241241
postprocess_cython( postprocess.py dynd.nd.array_postprocess dynd.nd.array_pyx dynd.nd.array)
242242
postprocess_cython( postprocess.py dynd.nd.callable_postprocess dynd.nd.callable_pyx dynd.nd.callable)
243243

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