Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing dependencies for exported CMake targets in installed configuration file #6692

Open
gnaggnoyil opened this issue Apr 13, 2020 · 1 comment

Comments

@gnaggnoyil
Copy link

gnaggnoyil commented Apr 13, 2020

Steps to reproduce the behavior

  • Prepare an environment with required dependencies installed. (I was using Archlinux with dependencies installed using sudo pacman -Syu bzip2 gcc-libs gflags jemalloc lz4 snappy zlib zstd)

  • Build RocksDB from current master HEAD with the following commands:

    cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=<rocksdb_install_dir> -DWITH_BZ2=ON -DWITH_LZ4=ON -DWITH_SNAPPY=ON -DWITH_ZLIB=ON -DWITH_ZSTD=ON -DUSE_RTTI=ON -DWITH_JEMALLOC=ON -DFAIL_ON_WARNINGS=OFF -DPORTABLE=ON -DWITH_BENCHMARK_TOOLS=OFF <rocksdb_src_dir>
    cmake --build . --config Release
    cmake --install . --config Release
    
  • Write a test project with a CMakeLists.txt of the following content:

    cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
    
    cmake_policy(SET CMP0074 NEW)
    
    project(test_proj1)
    
    find_package(RocksDB CONFIG REQUIRED)
    
    add_executable(test1 test1.cpp)
    target_link_libraries(test1 RocksDB::rocksdb-shared)
    
  • Configure the test project with the following command:

    cmake -DRocksDB_ROOT=<rocksdb_install_dir> -DCMAKE_BUILD_TYPE=Release <test_proj_src_dir>
    

Expected behavior

The test project should be configured successfully without errors

Actual behavior

CMake reports dependency missing error when configuring the test project:

CMake Error at CMakeLists.txt:9 (add_executable):
  Target "test1" links to target "JeMalloc::JeMalloc" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?


CMake Error at CMakeLists.txt:9 (add_executable):
  Target "test1" links to target "gflags::gflags" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?


CMake Error at CMakeLists.txt:9 (add_executable):
  Target "test1" links to target "snappy::snappy" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?


CMake Error at CMakeLists.txt:9 (add_executable):
  Target "test1" links to target "ZLIB::ZLIB" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?


CMake Error at CMakeLists.txt:9 (add_executable):
  Target "test1" links to target "lz4::lz4" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?


CMake Error at CMakeLists.txt:9 (add_executable):
  Target "test1" links to target "zstd::zstd" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?


-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

Additional Info

The root cause seems to be those dependency targets being exported as interface link libraries of rocksdb, as shown in lib/cmake/rocksdb/RocksDBTargets.cmake, yet there's no steps in the configuration files to acutallly find those dependencies. I'm not sure about the original intention why the configuration files are designed like so, but I do want to mention that it is intended in CMake that package configuration file should handle dependencies on its own, if package providers want to encapsule package together with its dependencies.

@bachp
Copy link

bachp commented Oct 12, 2020

I think the proper solution would be to call find_dependency for them in the RocksDBConfig.cmake file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants