conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
945 stars 1.72k forks source link

[package] gtest/1.10.0: does not install cmake package config #2854

Closed sergio-eld closed 3 years ago

sergio-eld commented 4 years ago

Package and Environment Details (include every applicable attribute)

Conan profile (output of conan profile show default or conan profile show <profile> if custom profile is in use)

Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=10
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
CONAN_CMAKE_GENERATOR=Ninja

Steps to reproduce (Include if Applicable)

Run from CMake script:

conan_cmake_run(REQUIRES gtest/1.10.0
        OPTIONS gtest:shared=True
        ENV CONAN_CMAKE_GENERATOR=Ninja
        BASIC_SETUP
        CMAKE_TARGETS
        BUILD missing)

Log shows that CMake config files are installed: -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/cmake/GTest/ But there is actually no lib/cmake folder. The same result with 1.8.1. However, cmake folder is generated if option shared=False.

Logs (Include/Attach if Applicable)

Click to expand log ``` Installing (downloading, building) binaries... Downloading conan_sources.tgz gtest/1.10.0: Configuring sources in C:\Users\Sergey\.conan\data\gtest\1.10.0\_\_\source gtest/1.10.0: Copying sources to build folder gtest/1.10.0: Building your package in C:\Users\Sergey\.conan\data\gtest\1.10.0\_\_\build\2ecd116eebe18800267b91f8d9448c2bcda3e84a gtest/1.10.0: Generator cmake created conanbuildinfo.cmake gtest/1.10.0: Calling build() -- The C compiler identification is GNU 10.1.0 -- The CXX compiler identification is GNU 10.1.0 -- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe -- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: C:/msys64/mingw64/bin/c++.exe -- Check for working CXX compiler: C:/msys64/mingw64/bin/c++.exe - works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Conan: called by CMake conan helper -- Conan: called inside local cache -- Conan: Adjusting output directories -- Conan: Using cmake global configuration -- Conan: Adjusting default RPATHs Conan policies -- Conan: Adjusting language standard -- Conan: Compiler GCC>=5, checking major version 10 -- Conan: Checking correct version: 10 -- Conan: C++ stdlib: libstdc++11 -- Found PythonInterp: C:/msys64/mingw64/bin/python.exe (found version "3.8.3") -- Configuring done -- Generating done CMake Warning: Manually-specified variables were not used by the project: CMAKE_EXPORT_NO_PACKAGE_REGISTRY CUSTOM_DEBUG_POSTFIX -- Build files have been written to: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/build/2ecd116eebe18800267b91f8d9448c2bcda3e84a [1/8] Building CXX object source_subfolder/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.obj [2/8] Building CXX object source_subfolder/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.obj [3/8] Building CXX object source_subfolder/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.obj [4/8] Building CXX object source_subfolder/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj [5/8] Linking CXX shared library bin\libgtestd.dll [6/8] Linking CXX shared library bin\libgtest_maind.dll [7/8] Linking CXX shared library bin\libgmockd.dll [8/8] Linking CXX shared library bin\libgmock_maind.dll gtest/1.10.0: Package '2ecd116eebe18800267b91f8d9448c2bcda3e84a' built gtest/1.10.0: Build folder C:\Users\Sergey\.conan\data\gtest\1.10.0\_\_\build\2ecd116eebe18800267b91f8d9448c2bcda3e84a gtest/1.10.0: Generated conaninfo.txt gtest/1.10.0: Generated conanbuildinfo.txt gtest/1.10.0: Generating the package gtest/1.10.0: Package folder C:\Users\Sergey\.conan\data\gtest\1.10.0\_\_\package\2ecd116eebe18800267b91f8d9448c2bcda3e84a gtest/1.10.0: Calling package() -- Conan: called by CMake conan helper -- Conan: called inside local cache -- Conan: Adjusting output directories -- Conan: Using cmake global configuration -- Conan: Adjusting default RPATHs Conan policies -- Conan: Adjusting language standard -- Conan: Compiler GCC>=5, checking major version 10 -- Conan: Checking correct version: 10 -- Conan: C++ stdlib: libstdc++11 -- Configuring done -- Generating done -- Build files have been written to: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/build/2ecd116eebe18800267b91f8d9448c2bcda3e84a [0/1] Install the project... -- Install configuration: "Debug" -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-actions.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-cardinalities.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-function-mocker.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-generated-actions.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-generated-actions.h.pump -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-generated-function-mockers.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-generated-function-mockers.h.pump -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-generated-matchers.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-generated-matchers.h.pump -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-matchers.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-more-actions.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-more-matchers.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-nice-strict.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock-spec-builders.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/gmock.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/internal -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/internal/custom -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/internal/custom/gmock-generated-actions.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/internal/custom/gmock-generated-actions.h.pump -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/internal/custom/gmock-matchers.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/internal/custom/gmock-port.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/internal/custom/README.md -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/internal/gmock-internal-utils.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/internal/gmock-port.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gmock/internal/gmock-pp.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/libgmockd.dll.a -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/bin/libgmockd.dll -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/libgmock_maind.dll.a -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/bin/libgmock_maind.dll -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/pkgconfig/gmock.pc -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/pkgconfig/gmock_main.pc -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/cmake/GTest/GTestTargets.cmake -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/cmake/GTest/GTestTargets-debug.cmake -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/cmake/GTest/GTestConfigVersion.cmake -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/cmake/GTest/GTestConfig.cmake -- Up-to-date: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/gtest-death-test.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/gtest-matchers.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/gtest-message.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/gtest-param-test.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/gtest-printers.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/gtest-spi.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/gtest-test-part.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/gtest-typed-test.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/gtest.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/gtest_pred_impl.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/gtest_prod.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/custom -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/custom/gtest-port.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/custom/gtest-printers.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/custom/gtest.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/custom/README.md -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/gtest-death-test-internal.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/gtest-filepath.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/gtest-internal.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/gtest-param-util.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/gtest-port-arch.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/gtest-port.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/gtest-string.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/gtest-type-util.h -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/include/gtest/internal/gtest-type-util.h.pump -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/libgtestd.dll.a -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/bin/libgtestd.dll -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/libgtest_maind.dll.a -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/bin/libgtest_maind.dll -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/pkgconfig/gtest.pc -- Installing: C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/pkgconfig/gtest_main.pc gtest/1.10.0 package(): Packaged 4 '.dll' files: libgmockd.dll, libgmock_maind.dll, libgtestd.dll, libgtest_maind.dll gtest/1.10.0 package(): Packaged 40 '.h' files gtest/1.10.0 package(): Packaged 5 '.pump' files gtest/1.10.0 package(): Packaged 2 '.md' files: README.md, README.md gtest/1.10.0 package(): Packaged 4 '.a' files: libgmockd.dll.a, libgmock_maind.dll.a, libgtestd.dll.a, libgtest_maind.dll.a gtest/1.10.0 package(): Packaged 1 file: LICENSE gtest/1.10.0: Package '2ecd116eebe18800267b91f8d9448c2bcda3e84a' created gtest/1.10.0: Created package revision fc4e2ef6267c681a02843109de7b86ee conanfile.txt: Generator cmake created conanbuildinfo.cmake conanfile.txt: Generator txt created conanbuildinfo.txt conanfile.txt: Generated conaninfo.txt conanfile.txt: Generated graphinfo -- Conan: Loading conanbuildinfo.cmake -- Conan: Adjusting output directories -- Conan: Using cmake targets configuration -- Library gtest_maind found C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/libgtest_maind.dll.a -- Library gmock_maind found C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/libgmock_maind.dll.a -- Library gmockd found C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/libgmockd.dll.a -- Library gtestd found C:/Users/Sergey/.conan/data/gtest/1.10.0/_/_/package/2ecd116eebe18800267b91f8d9448c2bcda3e84a/lib/libgtestd.dll.a -- Conan: Adjusting default RPATHs Conan policies -- Conan: Adjusting language standard -- Current conanbuildinfo.cmake directory: C:/dev/builds/example_gtest/Debug-MinGW-w64 -- Conan: Compiler GCC>=5, checking major version 10 -- Conan: Checking correct version: 10 -- Could NOT find GTest (missing: GTest_DIR) -- GTest found: 0 -- Configuring done -- Generating done -- Build files have been written to: C:/dev/builds/example_gtest/Debug-MinGW-w64```
prince-chrismc commented 4 years ago

Might be worth reading https://github.com/conan-io/conan-center-index/blob/master/docs/faqs.md#why-are-cmake-findconfig-files-and-pkg-config-files-not-packaged

sergio-eld commented 4 years ago

Might be worth reading https://github.com/conan-io/conan-center-index/blob/master/docs/faqs.md#why-are-cmake-findconfig-files-and-pkg-config-files-not-packaged

If I want to copy dependent libraries in CMake-way, I use (imported) target properties that are generated with CMake config files. This way I am able to collect all transitive dependent dlls and copy them to the location of a specific executable. I have a script deploy_dlls(TARGET) that does just that. Dlls are collected using a modified version of this answer. Notice that set_target_property is a better and more consistent approach than just defining <PKG-NAME>_LIBS, because importing libraries and dlls' paths are embedded to a particular target as properties. Hence you can target_link_libraries using normal CMake targets that are defined during the package installation.

Moreover, I want my CMake script to be flexible, i.e. using conan only after it has failed to find a package in the system (using <PackageName>_DIR). And maybe after searching in installed packages with apt-get.

prince-chrismc commented 4 years ago

:thinking: way more then I was expecting.

Is it fair to summarize the problem as "the Conan generated CMake targets does not correctly set target properties to find the shared libraries"? because I am not clear on what issue you are having. The files are not supposed to be packaged. I just want to make sure, are you expecting the original cmake files form GTest to be present?

Moreover, I want my CMake script to be flexible, i.e. using conan only after it has failed to find a package in the system (using <PackageName>_DIR). And maybe after searching in installed packages with apt-get.

this is something that CMake has support for, you may want to read https://cmake.org/cmake/help/v3.18/command/find_package.html#id5 and see how you can figure it to search in that other

sergio-eld commented 4 years ago

@prince-chrismc my basic issue is about misleading logs that say about installation of generated via installation cmake config files. If the repo's script does not generate installed cmake scripts for some reason, it should not say in logs that it does. It leads to a huge frustration.

As for the pipeline in general, I expect to have a cmake config file after installation in case the package provides an installation routine via cmake. Perhaps, at least an option to enable that should be provided by conan package. If there is a discussion on that issue, I'd like to know the link where to find it.

sergio-eld commented 4 years ago

@prince-chrismc more over, the issue is not about "the Conan generated CMake targets does not correctly set target properties to find the shared libraries". It would be logical to avoid using conan generated targets, but use those that are documented in the library. Take for instance Qt. Everybody expect to use targets (components) provided by documentation. Using the conan generated targets would force users to define their dependencies in a completely different way.

Croydon commented 4 years ago

If the repo's script does not generate installed cmake scripts for some reason, it should not say in logs that it does. It leads to a huge frustration.

You got this one wrong. The packages don't include any CMake find scripts (or find scripts for other build systems) per default. You need to explicitly use the Conan generators as stated in the FAQ.

Please have a look: https://docs.conan.io/en/latest/integrations/build_system/cmake/cmake_find_package_generator.html

You can also have a look at the test_package of gtest for an concrete example:

https://github.com/conan-io/conan-center-index/blob/83709600dc900be39d0dcdbf4d866b30649d9d37/recipes/gtest/all/test_package/CMakeLists.txt#L16

https://github.com/conan-io/conan-center-index/blob/83709600dc900be39d0dcdbf4d866b30649d9d37/recipes/gtest/all/test_package/conanfile.py#L9

It is Conan's goal to integrate seemingless with (potentially) any build systems, hence the generators in the first place. You can read more about them here: https://docs.conan.io/en/latest/reference/generators.html

prince-chrismc commented 4 years ago

This topic was bit of a learning curve for myself.

What you see in the logs, is the project GTest cmake install be ran, not that of Conan. The CCI rules (to provide the most seamless integration with many systems) it to remove them after the fact.

As Croydon, is pointing out the Conan generator you are using does not generate the cmake targets you are expecting, it does however support ninja. To have the cmake targets you expect to find in the you need to use the cmake_find_package or cmake_find_package_multi. The links above should be a great place to start.

sergio-eld commented 4 years ago

@prince-chrismc 1) Does cmake_find_package generator generate the targets provided via CMake installation script (that are explicitly deleted according to CCI rules)?

If it does not and just generates targets for small libraries like ZLIB::ZLIB, it is of not much use (but convenient in case you don't have a find module file). Again, take the Qt example: In the CMake script many targets would be linked like:

add_executable(Foo ...)
target_link_libraries(Foo PRIVATE Qt5::Core)

add_executable(Bar ...)
target_link_libraries(Bar PRIVATE Qt5::Network)

This targets would be accessible after calling find_package(Qt5 COMPONENTS Core Network REQUIRED) and will contain properties with the full paths to binaries. The components` names are specified in the documentation. User would expect them.

2) Moreover, the key thing for packaged via cmake installation script targets have embedded properties, containing full path to the binaries, that can be queried with $<TARGET_FILE:TARGET_NAME>. Therefore they can be copied to any desired place. Does cmake_find_package define this properties for the imported target?

To sum up: when a library specifies installation script that exports target names, user would expect to use those targets. To search this info in a Conan package would be wrong and inconsistent. Therefore Conan scripts must either generate imported targets with the same names and properties as in installation scripts, or have an option to not delete generated config files.

prince-chrismc commented 4 years ago
  1. Does cmake_find_package generator generate the targets provided via CMake installation script (that are explicitly deleted according to CCI rules)?

Yes!

Its the best advantage of life. If it's published by CCI there is a very good change the targets are exactly the same. (disclaimer there's a lot of open PRs fixing the some discrpencies)

What I am not sure about, (i've just never tried) is the "find components syntax" is find_package(Qt5 COMPONENTS Core Network REQUIRED) if there's a issue, please share, it might be better for the main conan repo.

What you can do is just find the package and the targets would be there,

  1. Moreover, the key thing for packaged via cmake installation script targets have embedded properties, containing full path to the binaries, that can be queried with $<TARGET_FILE:TARGET_NAME>. Therefore they can be copied to any desired place. Does cmake_find_package define this properties for the imported target?

Directly copying the cmake from the conan generated find package... you will see the information you are looking for in present

This is only a snippet of the entire file

if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0")
    # Target approach
    if(NOT TARGET tl-expected::expected)
        add_library(tl-expected::expected INTERFACE IMPORTED)
        set_target_properties(tl-expected::expected PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
                              "${tl-expected_expected_INCLUDE_DIRS}")
        set_target_properties(tl-expected::expected PROPERTIES INTERFACE_LINK_DIRECTORIES
                              "${tl-expected_expected_LIB_DIRS}")
        set_target_properties(tl-expected::expected PROPERTIES INTERFACE_LINK_LIBRARIES
                              "${tl-expected_expected_LINK_LIBS};${tl-expected_expected_LINKER_FLAGS_LIST}")
        set_target_properties(tl-expected::expected PROPERTIES INTERFACE_COMPILE_DEFINITIONS
                              "${tl-expected_expected_COMPILE_DEFINITIONS}")
        set_target_properties(tl-expected::expected PROPERTIES INTERFACE_COMPILE_OPTIONS
                              "${tl-expected_expected_COMPILE_OPTIONS_LIST}")
    endif()
endif()

########## GLOBAL TARGET ####################################################################

if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0")
    if(NOT TARGET tl-expected::tl-expected)
        add_library(tl-expected::tl-expected INTERFACE IMPORTED)
        set_target_properties(tl-expected::tl-expected PROPERTIES INTERFACE_LINK_LIBRARIES
                              "${tl-expected_COMPONENTS}")
    endif()
endif()
sergio-eld commented 4 years ago

@prince-chrismc Well, I've tried out cmake_find_package generator and here is what I've got to say. 1) Long story short, the main difference between conan-generated FindGTest.cmake and authentic cmake .config files (generated via cmake installation script) is the targets' types. Conan generates targets as INTERFACE IMPORTED, but originally they are generated as SHARED IMPORTED. Take a closer look at a FindGTest.cmake generated by Conan.

...
foreach(_CONAN_ACTUAL_TARGET ${_CONAN_ACTUAL_TARGETS})
            set_property(TARGET ${_CONAN_ACTUAL_TARGET} PROPERTY INTERFACE_LINK_LIBRARIES "${_CONAN_FOUND_SYSTEM_LIBS};${deps_list}")
endforeach()
...
########## COMPONENT gtest TARGET #################################################

if(NOT ${CMAKE_VERSION} VERSION_LESS "3.0")
    # Target approach
    if(NOT TARGET GTest::gtest)
        add_library(GTest::gtest INTERFACE IMPORTED)
        set_target_properties(GTest::gtest PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
                              "${GTest_gtest_INCLUDE_DIRS}")
        set_target_properties(GTest::gtest PROPERTIES INTERFACE_LINK_DIRECTORIES
                              "${GTest_gtest_LIB_DIRS}")
        set_target_properties(GTest::gtest PROPERTIES INTERFACE_LINK_LIBRARIES
                              "${GTest_gtest_LINK_LIBS};${GTest_gtest_LINKER_FLAGS_LIST}")
        set_target_properties(GTest::gtest PROPERTIES INTERFACE_COMPILE_DEFINITIONS
                              "${GTest_gtest_COMPILE_DEFINITIONS}")
        set_target_properties(GTest::gtest PROPERTIES INTERFACE_COMPILE_OPTIONS
                              "${GTest_gtest_COMPILE_OPTIONS_LIST}")
    endif()
endif()

It sets all the properties as INTERFACE and does not set a property for a full path to the binary (if a target has one). Unlike Conan, CMake installation script consistently provides the comprehensive info about the targets. GTestTargets.cmake file:

set_target_properties(GTest::gtest PROPERTIES
  INTERFACE_COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1"
  INTERFACE_COMPILE_FEATURES "cxx_std_11"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
)

GTestTargets-debug.cmake file:

# Import target "GTest::gtest" for configuration "Debug"
set_property(TARGET GTest::gtest APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(GTest::gtest PROPERTIES
  IMPORTED_IMPLIB_DEBUG "${_IMPORT_PREFIX}/lib/libgtestd.dll.a"
  IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/bin/libgtestd.dll"
  )

Notice that it does provide a full path to the binary in case it has one (this is generated implicitly by CMake).

By utilizing Conan-generated find script I am able to link against the dependent libraries, BUT it is impossible to find the binaries to copy them. Therefore Conan integration with CMake is far from seamless.

2)

The CCI rules (to provide the most seamless integration with many systems) it to remove them after the fact.

There is some inconsistency here. What does integration with many systems has to do with cutting of the package's native CMake support? You first remove it just to replenish it later with your FindXXX.cmake generator. It does not make sense. CMake implicitly generates comprehensive info on installation. Providing a valid CMake installation script is a responsibility of a package developer. Another responsibility is to write a Conan recipe which is in some way just a convenient wrapper. They should not be mixed. Mimicking package targets names is a very error prone and difficult process. You have to constantly keep track of any changes in packages. You will never have enough resources to accomplish this.

3) cmake_find_generator is useful, given it generates targets with paths to binaries (when they present). But is incompatible with the CMake find_package in CONFIG mode.

uilianries commented 4 years ago

@ElDesalmado if you are looking for GTestConfig.cmake, you have to use cmake_find_package_multi generator. As mentioned before, the cmake files are not copied to the package folder. The only exception is when the project offers cmake file with important function (e.g. protobuf).

tjwrona commented 3 years ago

I was previously using GTest 1.8.1 with the cmake_paths generator and was able to use find_package to find the GTest library just fine. Is there any particular reason this does not work with the GTest 1.10.0 Conan package?

I would think you would want both cmake_find_package to work and also cmake_paths.

prince-chrismc commented 3 years ago

Can you check the recipe revisions you are using for 1.8.1 and 1.10? Recently #2267 was merged and it changed the file names which may explain the problem.

tjwrona commented 3 years ago

@prince-chrismc I think I was using the bincrafters GTest 1.8.1 package which might be different from the one on conan-center

But I also would really like for cmake_paths to work for gtest. Mainly because I have many libraries I wrote myself that pass a lot of transitive dependencies through cmake targets such as compile definitions or flags. Because of this I need to use the cmake_paths generator for consuming my own packages and a different generator for gtest.

It would be nice to be able to use cmake_paths to keep things more consistent and not need to worry about using different generators for different libraries.

prince-chrismc commented 3 years ago

I first hand had to go through some learning pain understanding exactly this issue. It may seem counter-intuitive but using multiple generators is the best (most practical) approach to having seamless integration. There are an infinite number of possibilities that Conan (CCI in particular) needs to accommodate. This is by design of the Conan team. https://github.com/conan-io/conan-center-index/issues/2854#issuecomment-688832754 has a great link to the why .

As a consumer, I have projects using many build systems and rely on the generic component generation... you can fully mix and match CCI generated and in-house built FindPackage.cmake pr even Package.pc. To date I have not had an issue with that.

@tjwrona1992, In case you did not follow the original conversation, your best bet is to use...

    generators = "cmake_paths", "cmake_find_package"

if not you can follow the original solution posted above.

tjwrona commented 3 years ago

Thanks Chris!

I actually ended up switching test libraries to Catch2 and find it much easier to work with in general, but this is still good to know!

On Sun, Nov 15, 2020 at 11:43 AM Chris Mc notifications@github.com wrote:

I first hand had to go through some learning pain understanding exactly this issue. It may seem counter-intuitive but using multiple generators is the best (most practical) approach to having seamless integration. There are an infinite number of possibilities that Conan (CCI in particular) needs to accommodate. This is by design of the Conan team. #2854 (comment) https://github.com/conan-io/conan-center-index/issues/2854#issuecomment-688832754 has a great link to the why .

As a consumer, I have projects using many build systems and rely on the generic component generation... you can fully mix and match CCI generated and in-house built FindPackage.cmake pr even Package.pc. To date I have not had an issue with that.

@tjwrona1992 https://github.com/tjwrona1992, In case you did not follow the original conversation, your best bet is to use...

generators = "cmake_paths", "cmake_find_package"

if not you can follow the original solution posted above.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/conan-io/conan-center-index/issues/2854#issuecomment-727599425, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKWHUJ3LTW3KBM44VEWHHOLSQAAMNANCNFSM4Q737DVA .

Croydon commented 3 years ago

I think this issue can be closed