TileDB icon indicating copy to clipboard operation
TileDB copied to clipboard

changes to aid building against tiledb static (after libmagic additions)

Open dhoke4tdb opened this issue 2 years ago • 3 comments

add pcre2* libs assoc'd with file-windows libmagic build needed for linking with static tiledb

TYPE: BUG DESC: changes to aid building against tiledb static (after libmagic additions)

dhoke4tdb avatar May 24 '22 16:05 dhoke4tdb

It looks like these should be added as INTERFACE libraries in the libmagic target, rather than hard-coding them here.

If I'm following they are already part of the libmagic INTERFACE_LINK_LIBRARIES,

  libmagic INTERFACE_LINK_LIBRARIES = pcre2-posix;pcre2-8;shlwapi

However, adding libmagic alone to TILEDB_CORE_OBJECTS_ILIB does not get those dependencies carried over into the INTERFACE_LINK_LIBRARIES for TILEDB_CORE_OBJECTS_ILIB -unless- they are specifically added to that.

  TILEDB_CORE_OBJECTS_ILIB INTERFACE_LINK_LIBRARIES = Bzip2::Bzip2;LZ4::LZ4;spdlog::spdlog;Zlib::Zlib;Zstd::Zstd;libmagic

and it is the TILEDB_CORE_OBJECTS_ILIB INTERFACE_LINK_LIBRARIES that is expressed in the installed TileDBTargets.cmake,

set_target_properties(TileDB::TILEDB_CORE_OBJECTS_ILIB PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "Bzip2::Bzip2;LZ4::LZ4;spdlog::spdlog;Zlib::Zlib;Zstd::Zstd;libmagic;C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/um/x64/ShLwApi.Lib;C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/um/x64/RpcRT4.Lib;C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/um/x64/bcrypt.lib"
)

and not being there results in the undefined symbol failures when TileDB-Java is built, or at least, if they are there as below, the symbols are resolved...

  TILEDB_CORE_OBJECTS_ILIB INTERFACE_LINK_LIBRARIES = Bzip2::Bzip2;LZ4::LZ4;spdlog::spdlog;Zlib::Zlib;Zstd::Zstd;libmagic;pcre2-8;pcre2-posix
...
set_target_properties(TileDB::TILEDB_CORE_OBJECTS_ILIB PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "Bzip2::Bzip2;LZ4::LZ4;spdlog::spdlog;Zlib::Zlib;Zstd::Zstd;libmagic;pcre2-8;pcre2-posix;C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/um/x64/ShLwApi.Lib;C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/um/x64/RpcRT4.Lib;C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/um/x64/bcrypt.lib"
)

Not sure if there's some other better approach to solve the issue...

In the build tree, I also see that there are the various lib/cmake//.cmake items for libmagic, pcre, zlib, spdlog that are not carried into the tiledb 'dist' installation, A) not sure how they would be gotten there, and B) even if present (manually copied) that alone is not enough....

dhoke4tdb avatar May 26 '22 11:05 dhoke4tdb

If I'm following they are already part of the libmagic INTERFACE_LINK_LIBRARIES

That looks right. As far as I can tell, it should then be added to TileDBConfig.cmake by the call to append_dep_lib(libmagic). I can't test it locally ATM, but something like this might let you debug:

diff --git a/tiledb/CMakeLists.txt b/tiledb/CMakeLists.txt
index acdc5f3b4..3eb54763e 100644
--- a/tiledb/CMakeLists.txt
+++ b/tiledb/CMakeLists.txt
@@ -813,6 +813,10 @@ if (TILEDB_STATIC)

   # Helper to generate CMake code
   macro(append_dep_lib APPEND_LIB)
+    message(STATUS "append_dep_lib: '${APPEND_LIB}'")
+    if (NOT TARGET ${APPEND_LIB})
+      message(STATUS "NOT TARGET append_dep_lib: '${APPEND_LIB}'")
+    endif()
     if (TARGET ${APPEND_LIB})
       get_installed_location(TARGET_LOC ${APPEND_LIB})
       cmake_path(GET TARGET_LOC FILENAME TARGET_LOC_FILENAME)

ihnorton avatar May 26 '22 14:05 ihnorton

macro(append_dep_lib APPEND_LIB)

The items added by that code are appearing just fine in /lib/cmake/TileDB/TileDBConfig.cmake. But the following INTERFACE_LINK_LIBRARIES IN /lib/cmake/TileDB/TileDBTargets.cmake

set_target_properties(TileDB::TILEDB_CORE_OBJECTS_ILIB PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "Bzip2::Bzip2;LZ4::LZ4;spdlog::spdlog;Zlib::Zlib;Zstd::Zstd;libmagic;pcre2-8;pcre2-posix;C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/um/x64/ShLwApi.Lib;C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/um/x64/RpcRT4.Lib;C:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/um/x64/bcrypt.lib"
)

is -not- being affected by that add, and this is apparently what is needed for (static library) linking symbol resolution with 'other things' as they are.

Should 'macro add_dep_lib()' also be trying to add things to the TILEDB_CORE_OBJECTS_ILIB INTERFACE_LINK_LIBRARIES property which affects that item in TileDBTargets.cmake? Or the cmake code being gen'd by add_dep_lib() be modified to add on 'that side' for clients building against an installation?

result from modified version of your suggested diagnostics:

  -- append_dep_lib: 'pcre2-8'
  pcre2-8 BINARY_DIR = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/bld.vs19.A/tiledb/tiledb
  pcre2-8 IMPORTED = TRUE
  pcre2-8 IMPORTED_CONFIGURATIONS = RELEASE
  pcre2-8 INTERFACE_INCLUDE_DIRECTORIES = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/bld.vs19.A/externals/install/include
  pcre2-8 LOCATION = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/bld.vs19.A/externals/install/lib/pcre2-8.lib
  pcre2-8 LOCATION_Release = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/bld.vs19.A/externals/install/lib/pcre2-8.lib
  pcre2-8 MACOSX_PACKAGE_LOCATION = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/bld.vs19.A/externals/install/lib/pcre2-8.lib
  pcre2-8 NAME = pcre2-8
  pcre2-8 SOURCE_DIR = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/tiledb
  pcre2-8 TYPE = STATIC_LIBRARY
  pcre2-8 VS_DEPLOYMENT_LOCATION = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/bld.vs19.A/externals/install/lib/pcre2-8.lib
  -- append_dep_lib: 'pcre2-posix'
  pcre2-posix BINARY_DIR = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/bld.vs19.A/tiledb/tiledb
  pcre2-posix IMPORTED = TRUE
  pcre2-posix IMPORTED_CONFIGURATIONS = RELEASE
  pcre2-posix INTERFACE_INCLUDE_DIRECTORIES = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/bld.vs19.A/externals/install/include
  pcre2-posix LOCATION = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/bld.vs19.A/externals/install/lib/pcre2-posix.lib
  pcre2-posix LOCATION_Release = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/bld.vs19.A/externals/install/lib/pcre2-posix.lib
  pcre2-posix MACOSX_PACKAGE_LOCATION = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/bld.vs19.A/externals/install/lib/pcre2-posix.lib
  pcre2-posix NAME = pcre2-posix
  pcre2-posix SOURCE_DIR = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/tiledb
  pcre2-posix TYPE = STATIC_LIBRARY
  pcre2-posix VS_DEPLOYMENT_LOCATION = D:/dev/tiledb/gh.sc18075-win-libmagic-static-build.git/bld.vs19.A/externals/install/lib/pcre2-posix.lib

possibly related, but not quite the same, issues, one 6yo, one recent... https://cmake.cmake.narkive.com/wbKfRtOK/private-dependencies-of-static-libraries-exported-as-targets https://discourse.cmake.org/t/how-to-export-target-which-depends-on-other-target-which-is-in-multiple-export-sets/3007/2

dhoke4tdb avatar May 27 '22 13:05 dhoke4tdb