conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.3k stars 985 forks source link

[bug] $<TARGET_RUNTIME_DLLS:tgt> doesn't work with GLFW: 'Cannot locate shared library: glfw3dll' #14604

Open Erlkoenig90 opened 1 year ago

Erlkoenig90 commented 1 year ago

Environment details

Steps to reproduce

Create a simple project with conanfile.txt as follows:

[requires]
glfw/3.3.8
libusb/1.0.26

[generators]
CMakeDeps
CMakeToolchain

[options]
glfw/*:shared=True
libusb/*:shared=True

CMakeLists.txt:

cmake_minimum_required(VERSION 3.22)

set(CMAKE_CXX_STANDARD 20 CACHE STRING "C++ standard")
set(CMAKE_CXX_STANDARD_REQUIRED on)

project(Conantest VERSION 1.0 DESCRIPTION "Conantest")

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

find_package(glfw3 CONFIG REQUIRED)
find_package(libusb CONFIG REQUIRED)

add_executable(Conantest
    "app.cpp"
)

set_target_properties(Conantest PROPERTIES OUTPUT_NAME "Conantest")

target_link_libraries(Conantest glfw libusb::libusb)

install(TARGETS Conantest DESTINATION "Conantest")
install(FILES $<TARGET_RUNTIME_DLLS:Conantest> DESTINATION "Conantest")

Build it:

conan install . --output-folder=build --build=missing -s build_type=Release
cd build
cmake .. -G "Visual Studio 17 2022" --debug-output --preset conan-default
cmake --build . --target ALL_BUILD --config Release
cmake --install . --prefix install

CMake outputs a warning:

-- Cannot locate shared library: glfw3dll
   Called from: [5]     .../build/cmakedeps_macros.cmake
                [4]     .../build/glfw3-Target-release.cmake
                [3]     .../build/glfw3Targets.cmake
                [2]     .../build/glfw3-config.cmake
                [1]     .../CMakeLists.txt

The generated build/cmake_install.cmake will also not contain any mention of the glfw3.dll file, but it will contain an installation command for libusb-1.0.dll. The installation directory contains the libusb DLL, but not the glfw one, even though it is available in ~/.conan2.

I guess this is because the glfw DLL is called glfw3.dll while the import library is called glfw3dll.lib. The glfw recipe defines one glfw3dll library in cpp_info.

Logs

No response

memsharded commented 1 year ago

Hi @Erlkoenig90

Thanks for reporting. I think this is a known issue, would be a duplicated of https://github.com/conan-io/conan/issues/12654. I'd recommended closing this issue as duplicated and centralized discussion in the other one.

In short: this is a limitation of the available information in the cpp_info of the dependencies, for shared libraries, as well as the CMakeDeps target creation. There is pending a new model and CMakeDeps implementation for the 2.X roadmap.