conan-io / examples2

Conan 2.x examples
MIT License
87 stars 48 forks source link

Conan 2.x and CLion #116

Closed andreubernadserra closed 12 months ago

andreubernadserra commented 1 year ago

Hi!

I'm having trouble trying to reproduce the Conan 2.x - CLion example produced here. I'm using a Windows machine with CLion 2023.2.1.

I'm getting the following error when trying to install the two required packages, upon reloading the CMake project.

======== Installing packages ========
ERROR: There are invalid packages:
libtool/2.4.7: Invalid: 'settings.compiler' value not defined
CMake Error at conan_provider.cmake:250 (message):
  Conan install failed='6'
Call Stack (most recent call first):
  conan_provider.cmake:317 (conan_install)
  CMakeLists.txt:6 (find_package)

Could it be that Conan is using the default profile instead of the one from the project? My suspicion is based on the following part of the CMake output. If so, how can I force CMake to use the host profile instead of the build one?

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Debug
compiler=gcc
compiler.cppstd=17
compiler.version=13
os=Windows
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

Profile build:
[settings]
arch=x86_64
build_type=Release
os=Windows

Thanks in advance!

PS. The full output from CMake is the following:

"C:\Program Files\JetBrains\CLion 2023.2.1\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2023.2.1/bin/ninja/win/x64/ninja.exe" -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=C:\Users\USERNAME\CLionProjects\conan-test\conan_provider.cmake -G Ninja -S C:\Users\USERNAME\CLionProjects\conan-test -B C:\Users\USERNAME\CLionProjects\conan-test\cmake-build-debug
-- The C compiler identification is GNU 13.1.0
-- The CXX compiler identification is GNU 13.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/JetBrains/CLion 2023.2.1/bin/mingw/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/JetBrains/CLion 2023.2.1/bin/mingw/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMake-Conan: first find_package() found. Installing dependencies with Conan
-- CMake-Conan: Checking if a default profile exists
C:\Users\USERNAME\.conan2\profiles\default
-- CMake-Conan: cmake_system_name=Windows
-- CMake-Conan: cmake_system_processor=x86_64
-- CMake-Conan: CMake compiler=GNU
-- CMake-Conan: CMake compiler version=13.1.0
-- CMake-Conan: [settings] compiler=gcc
-- CMake-Conan: [settings] compiler.version=13
-- CMake-Conan: Creating profile C:/Users/USERNAME/CLionProjects/conan-test/cmake-build-debug/conan_host_profile
-- CMake-Conan: Profile: 
include(default)
[settings]
arch=x86_64
os=Windows
compiler=gcc
compiler.version=13
compiler.cppstd=17
build_type=Debug
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

-- CMake-Conan: Installing single configuration Debug
-- CMake-Conan: conan install C:/Users/USERNAME/CLionProjects/conan-test -of=C:/Users/USERNAME/CLionProjects/conan-test/cmake-build-debug/conan -pr;C:/Users/USERNAME/CLionProjects/conan-test/cmake-build-debug/conan_host_profile;--build=missing;-g;CMakeDeps

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Debug
compiler=gcc
compiler.cppstd=17
compiler.version=13
os=Windows
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

Profile build:
[settings]
arch=x86_64
build_type=Release
os=Windows

======== Computing dependency graph ========
Graph root
    conanfile.py: C:/Users/USERNAME/CLionProjects/conan-test\conanfile.py
Requirements
    libcurl/8.2.1#8f62ba7135f5445e5fe6c4bd85143b53 - Cache
    openssl/3.1.2#ef79f25fe0968d69538feca6a6b3bc7f - Cache
    stb/cci.20220909#1c47474f095ef8cd9e4959558525b827 - Cache
    zlib/1.2.13#e377bee636333ae348d51ca90874e353 - Cache
Build requirements
    autoconf/2.71#ce232afdcd21d1269419c355375731e6 - Cache
    automake/1.16.5#058bda3e21c36c9aa8425daf3c1faf50 - Cache
    gnu-config/cci.20210814#15c3bf7dfdb743977b84d0321534ad90 - Cache
    libtool/2.4.7#d55a3c2435c19e830fa77aa5c6c19350 - Cache
    m4/1.4.19#c1c4b1ee919e34630bb9b50046253d3c - Cache
    meson/1.0.0#15586c0ac6f682805875ef903dbe7ee2 - Cache
    msys2/cci.latest#567331f1604f3c584f04feade960f06e - Cache
    nasm/2.15.05#ca1c14c2060af0ec151048b54ced9262 - Cache
    ninja/1.11.1#77587f8c8318662ac8e5a7867eb4be21 - Cache
    pkgconf/1.9.3#5da3944c3226f5764374e4b8b4e1d055 - Cache
    strawberryperl/5.32.1.1#8f83d05a60363a422f9033e52d106b47 - Cache
Resolved version ranges
    openssl/[>=1.1 <4]: openssl/3.1.2

======== Computing necessary packages ========
Requirements
    libcurl/8.2.1#8f62ba7135f5445e5fe6c4bd85143b53:d42fb32943d83549e1d07e9e25f61449fbbd4e93 - Build
    openssl/3.1.2#ef79f25fe0968d69538feca6a6b3bc7f:2799bd3a510a9427d114f466c75d5e79345ea39a - Build
    stb/cci.20220909#1c47474f095ef8cd9e4959558525b827:da39a3ee5e6b4b0d3255bfef95601890afd80709#cab2e5cf0f4391f87945a304034a4e5d - Download (conancenter)
    zlib/1.2.13#e377bee636333ae348d51ca90874e353:f60e50a74ab05a616895712be87aa8c9377863ad - Build
Build requirements
    autoconf/2.71#ce232afdcd21d1269419c355375731e6:da39a3ee5e6b4b0d3255bfef95601890afd80709#f23fbd87879937e4deeda004f0c87d46 - Download (conancenter)
    automake/1.16.5#058bda3e21c36c9aa8425daf3c1faf50:ebec3dc6d7f6b907b3ada0c3d3cdc83613a2b715#07094da42a0b39fd4b34760c5f1f3e7d - Download (conancenter)
    libtool/2.4.7#d55a3c2435c19e830fa77aa5c6c19350:bcc931be595773e81271f8be3ca987adef1a37fc - Invalid
    m4/1.4.19#c1c4b1ee919e34630bb9b50046253d3c:723257509aee8a72faf021920c2874abc738e029#0b5e50355c3e4e4e9e3434f96167ed09 - Download (conancenter)
    msys2/cci.latest#567331f1604f3c584f04feade960f06e:956a88975bda9dfcc485e2861d71e74bd7e2b9a5#ce3addef73068ed1ad9ca9976b2d50c1 - Download (conancenter)
    nasm/2.15.05#ca1c14c2060af0ec151048b54ced9262:723257509aee8a72faf021920c2874abc738e029#88d82c8b5a0298a070ca691f347e6c05 - Download (conancenter)
    pkgconf/1.9.3#5da3944c3226f5764374e4b8b4e1d055:43771b8671ac44479c188dd72670e2eb2d7918a6#d099cffb928baadbda4a55828258c3f8 - Download (conancenter)
Skipped binaries
    gnu-config/cci.20210814, meson/1.0.0, ninja/1.11.1, strawberryperl/5.32.1.1

======== Installing packages ========
ERROR: There are invalid packages:
libtool/2.4.7: Invalid: 'settings.compiler' value not defined
CMake Error at conan_provider.cmake:250 (message):
  Conan install failed='6'
Call Stack (most recent call first):
  conan_provider.cmake:317 (conan_install)
  CMakeLists.txt:6 (find_package)

-- Configuring incomplete, errors occurred!

[Finished]
memsharded commented 1 year ago

Hi @andreubernadserra

Thanks for your feedback

Yes, it seems the lack of compiler in profile "build" is the root cause. There are missing binaries for your configuration (ConanCenter does not build gcc binaries in Windows), and when trying to build the tool_requires applying the "build" profile, it didn't define enough inputs.

Some clarifications:

I'd try:

Finally, it is very possible that for building with gcc in Windows some extra configuration is needed, that is not detected or configured yet by cmake-conan integration. If that is the case, we will move this ticket to the cmake-conan repo.

andreubernadserra commented 1 year ago

Hi @memsharded , thanks for your prompt reply!

I did create my own default profile with a separate command window, independently from CLion. Additionally, I was using the bundled toolkit from the IDE (gcc).

I managed to solve my issue, as suggested, by:

  1. Deleting the default profile.
  2. Changing the toolchain of the IDE to MSVS.

This allowed me to use conan as a package manager seamlessly with CLion.

Unfortunately, the original code did not run on Windows. The response_string returned by function download_image seems to be empty. I've tried another project with different dependencies and this worked fine.

Thanks once again! A

memsharded commented 1 year ago

This allowed me to use conan as a package manager seamlessly with CLion.

Great, happy that you made it work

Unfortunately, the original code did not run on Windows. The response_string returned by function download_image seems to be empty. I've tried another project with different dependencies and this worked fine.

Thanks for the feedback, this is worth checking, it should run in Windows as well, even if it seems this issue would be responded and could be closed, let's investigate it.

Cheers!

memsharded commented 1 year ago

Just double checked, the example test code is running in CI in Windows too in: https://ci.conan.io/blue/organizations/jenkins/Examples2.0/detail/PR-111/6/pipeline, but using MSVC. It could be some side issue of using gcc.

andreubernadserra commented 12 months ago

Thanks once again for your support! I'll triple check by creating a new project and starting from scratch.

Have a nice day :)