Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-10661

Specify IMPORTED_IMPLIB for builtin compressors on Windows

    • Type: Icon: Build Failure Build Failure
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • WT11.2.0, 7.0.0-rc0
    • Affects Version/s: WT11.0.0, WT11.1.0
    • Component/s: None
    • Labels:
    • Environment:
      OS: Windows 10
      Build tool: CMake3.24.2 + VS2019/MSBUILD
      Package manager: vcpkg
      _MSC_VER: 1922

      Following the reproduce steps:

      vcpkg install lz4:x64-windows
      cd <wiredtiger-11.0.0>
      mkdir build
      cd build
      cmake -DCMAKE_TOOLCHAIN_FILE=<vcpkg_root>/scripts/buildsystems/vcpkg.cmake -DHAVE_BUILTIN_EXTENSION_LZ4=1 -DENABLE_STATIC=1 -DENABLE_PYTHON=0 ..

      I got:

      CMake Warning (dev) in CMakeLists.txt:
        Policy CMP0111 is not set: An imported target missing its location property
        fails during generation.  Run "cmake --help-policy CMP0111" for policy
        details.  Use the cmake_policy command to set the policy and suppress this
        warning.  IMPORTED_IMPLIB not set for imported target "wt::lz4" configuration
        "Release". 

      then continue with:

      msbuild ALL_BUILD.vcxproj 

      got:

      LINK : fatal error LNK1104: cannot open file"wt::lz4-NOTFOUND.obj"

       
      I check the add_library, it said:

      • For a SHARED library on Windows, the IMPORTED_IMPLIB target property (or its per-configuration variant IMPORTED_IMPLIB_<CONFIG>) specifies the location of the DLL import library file (.lib or .dll.a) on disk, and the IMPORTED_LOCATION is the location of the .dll runtime library (and is optional, but needed by the TARGET_RUNTIME_DLLS generator expression).

      So I modified cmake/third_party/lz4.cmake:

      --- a/cmake/third_party/lz4.cmake
      +++ b/cmake/third_party/lz4.cmake@@ -13,7 +13,7 @@ endif()
       # with an IMPORTED target (which allows CMake to issue a diagnostic message if the library wasn't found).
       add_library(wt::lz4 SHARED IMPORTED GLOBAL)
       set_target_properties(wt::lz4 PROPERTIES
      -    IMPORTED_LOCATION ${HAVE_LIBLZ4}
      +    IMPORTED_IMPLIB ${HAVE_LIBLZ4}
       ) 

       
      And the build succeeded.

      The same for other builtin compressors: snappy, zstd, zlib.

      I made a vcpkg port of wiredtiger including two patches to solve the building problems on windows, I don't know if this makes sense:

      patch1

      patch2

            Assignee:
            luke.chen@mongodb.com Luke Chen
            Reporter:
            yuchengye2013@outlook.com yu chengye
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: